Skip to content

Commit

Permalink
Merge pull request #14 from divegeek/Javacard_KeyMint_100_master
Browse files Browse the repository at this point in the history
Javacard key mint 100 master
  • Loading branch information
subrahmanyaman authored Dec 9, 2021
2 parents bc5f358 + 9bc640c commit 8f09b88
Show file tree
Hide file tree
Showing 75 changed files with 9,224 additions and 248 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright(C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" (short)0IS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.javacard.seprovider;

import org.globalplatform.upgrade.Element;

import javacard.security.AESKey;

public class KMAESKey implements KMMasterKey {

private AESKey aesKey;

public KMAESKey(AESKey key) {
aesKey = key;
}

public void setKey(byte[] keyData, short kOff) {
aesKey.setKey(keyData, kOff);
}

public byte getKey(byte[] keyData, short kOff) {
return aesKey.getKey(keyData, kOff);
}

public short getKeySizeBits() {
return aesKey.getSize();
}

public static void onSave(Element element, KMAESKey kmKey) {
element.write(kmKey.aesKey);
}

public static KMAESKey onRestore(Element element) {
AESKey aesKey = (AESKey) element.readObject();
KMAESKey kmKey = new KMAESKey(aesKey);
return kmKey;
}

public static short getBackupPrimitiveByteCount() {
return (short) 0;
}

public static short getBackupObjectCount() {
return (short) 1;
}

}
Loading

0 comments on commit 8f09b88

Please sign in to comment.