Skip to content

Conversation

@subrahmanyaman
Copy link
Contributor

No description provided.

if (version == 0) {
// Old KeyBlobs have 5 elements.
keyBlob = KMArray.instance((short) 5);
KMArray.cast(keyBlob).add((short) 0, keyBlobExp);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's think about these magic numbers.

KMArray.cast(keyBlob).add(KMKeymasterApplet.KEY_BLOB_NONCE, KMByteBlob.exp());
private short createKeyBlobExp(short version) {
short keyBlob = KMType.INVALID_VALUE;
short keyBlobExp = KMByteBlob.exp();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change the name to keyByteBlobExp

protected static final short MAX_CERT_SIZE = 2048;
// Keyblob version goes into keyblob and will affect all
// the keyblobs if it is changed.
public static final short KEYBLOB_VERSION = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it KEYBLOB_CURRENT_VERSION. Also, add the comment saying, please increment this version number whenever you change anything related to keyblob (structure, encryption algorithm etc).

if (rot == KMType.INVALID_VALUE) {
KMException.throwIt(KMError.UNKNOWN_ERROR);
}
private short readKeyBlobVersion(short keyBlob) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be removed as we will be relying on encrypted version only.

// Check if the KeyBlob is compatible. If there is any change in the KeyBlob, the version
// Parameter in the KeyBlob should be updated to the next version.
short version = readKeyBlobVersion(keyBlob);
if (version < KEYBLOB_VERSION) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this after parsing.

@mdwivedi mdwivedi merged commit 99b0869 into divegeek:Javacard_KeyMint_100_master Apr 11, 2022
subrahmanyaman referenced this pull request in subrahmanyaman/JavaCardKeymaster Apr 11, 2022
Merge pull request #110 from subrahmanyaman/keyblob_version
@subrahmanyaman subrahmanyaman deleted the keyblob_version branch April 13, 2022 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants