@@ -918,7 +918,7 @@ private void makeCredential(APDU apdu, short lc, byte[] buffer) {
918918 // ... but it might not match the user ID we're requesting...
919919 if (userIdLen == residentKeys [i ].getUserIdLength ()) {
920920 // DECRYPT the encrypted user ID we stored for this RK, so we can compare
921- AESKey key = getAESKeyForRK ( i , residentKeys [ i ]. getCredProtectLevel () );
921+ AESKey key = getAESKeyForExistingRK ( i );
922922 residentKeys [i ].unpackUserID (key , symmetricUnwrapper , scratchUserIdBuffer , scratchUserIdOffset );
923923
924924 if (Util .arrayCompare (
@@ -988,7 +988,7 @@ private void makeCredential(APDU apdu, short lc, byte[] buffer) {
988988 effectiveCredBlobLen = 0 ;
989989 }
990990
991- AESKey key = getAESKeyForRK ( targetRKSlot , effectiveCPLevel );
991+ AESKey key = getAESKeyForCreatingWithCredProtectLevel ( effectiveCPLevel );
992992 residentKeys [targetRKSlot ] = new ResidentKeyData (
993993 random , key , symmetricWrapper ,
994994 counter ,
@@ -2443,7 +2443,7 @@ private void getAssertion(final APDU apdu, final short lc, final byte[] buffer,
24432443 outputBuffer [outputIdx ++] = 0x07 ; // map key: largeBlobKey
24442444 outputIdx = encodeIntLenTo (outputBuffer , outputIdx , (byte ) 32 , true );
24452445 residentKeys [rkMatch ].emitLargeBlobKey (
2446- getAESKeyForRK (rkMatch , residentKeys [ rkMatch ]. getCredProtectLevel () ), symmetricWrapper ,
2446+ getAESKeyForExistingRK (rkMatch ), symmetricWrapper ,
24472447 outputBuffer , outputIdx );
24482448 outputIdx += 32 ;
24492449 }
@@ -5260,13 +5260,25 @@ private void handleEnumerateRPs(APDU apdu, short startOffset) {
52605260 sendNoCopy (apdu , writeOffset );
52615261 }
52625262
5263- private AESKey getAESKeyForRK (short rkIndex , byte credProt ) {
5263+ /**
5264+ * Gets the AES key to use when creating a new resident key
5265+ *
5266+ * @param credProt The cred protect level of the new key
5267+ * @return An AES key object to pass to ResidentKeyData methods
5268+ */
5269+ private AESKey getAESKeyForCreatingWithCredProtectLevel (byte credProt ) {
52645270 final boolean highSec = !LOW_SECURITY_MAXIMUM_COMPLIANCE && (!USE_LOW_SECURITY_FOR_SOME_RKS || credProt > 2 );
52655271 return highSec ? highSecurityWrappingKey : lowSecurityWrappingKey ;
52665272 }
52675273
5274+ /**
5275+ * Gets the AES key used for the data associated with the given RK
5276+ *
5277+ * @param rkIndex Index of the RK in the store
5278+ * @return An AES key object to pass to ResidentKeyData methods
5279+ */
52685280 private AESKey getAESKeyForExistingRK (short rkIndex ) {
5269- return getAESKeyForRK ( rkIndex , residentKeys [rkIndex ].getCredProtectLevel ());
5281+ return getAESKeyForCreatingWithCredProtectLevel ( residentKeys [rkIndex ].getCredProtectLevel ());
52705282 }
52715283
52725284 /**
0 commit comments