Commit 7d4f5d78 authored by Josh Ji's avatar Josh Ji

generateHMAC(byte[], short)->generateHMAC()

parent 8da66024
...@@ -445,7 +445,7 @@ public class CTAP2 extends Applet implements ExtendedLength { ...@@ -445,7 +445,7 @@ public class CTAP2 extends Applet implements ExtendedLength {
cborEncoder.encodeByteString(idSecret.encryptedCx, (short) 0, (short) idSecret.encryptedCx.length); cborEncoder.encodeByteString(idSecret.encryptedCx, (short) 0, (short) idSecret.encryptedCx.length);
// generate HMAC // generate HMAC
idSecret.generateHMAC(scratch, (short) 0); idSecret.generateHMAC();
apdu.setOutgoing(); apdu.setOutgoing();
apdu.setOutgoingLength(cborEncoder.getCurrentOffset()); apdu.setOutgoingLength(cborEncoder.getCurrentOffset());
......
...@@ -88,7 +88,7 @@ public class IDSecret { ...@@ -88,7 +88,7 @@ public class IDSecret {
/** /**
* AES(aesRawKey, SHA256(IDx||Cx)) * AES(aesRawKey, SHA256(IDx||Cx))
*/ */
public void generateHMAC(byte[] outputBuffer, short outputOffset){ public void generateHMAC(){
Util.arrayCopy(IDx.str, (short)0, scratch, (short)0, (short)IDx.str.length); Util.arrayCopy(IDx.str, (short)0, scratch, (short)0, (short)IDx.str.length);
Util.arrayCopy(Cx, (short)0, scratch, (short)IDx.str.length, (short)Cx.length); Util.arrayCopy(Cx, (short)0, scratch, (short)IDx.str.length, (short)Cx.length);
short scratchLength = (short)(IDx.str.length + Cx.length); short scratchLength = (short)(IDx.str.length + Cx.length);
...@@ -101,17 +101,15 @@ public class IDSecret { ...@@ -101,17 +101,15 @@ public class IDSecret {
sha256.doFinal(scratch, updateOffset, scratchLength, scratch, (short)0); sha256.doFinal(scratch, updateOffset, scratchLength, scratch, (short)0);
// pkcs#7 padding // pkcs#7 padding
Util.arrayFill(scratch, (short)32, (short)16, (byte)0x10); Util.arrayFill(scratch, (short)32, (short)16, (byte)0x10);
aesEncrypt.update(scratch, (short)0, (short)16, outputBuffer, outputOffset); aesEncrypt.update(scratch, (short)0, (short)16, hmac, (short)0);
aesEncrypt.update(scratch, (short)16, (short)16 , outputBuffer, (short)(outputOffset+16) ); aesEncrypt.update(scratch, (short)16, (short)16 , hmac, (short)16 );
aesEncrypt.doFinal(scratch, (short)32, (short)16, outputBuffer, (short)(outputOffset+32) ); aesEncrypt.doFinal(scratch, (short)32, (short)16, hmac, (short)32 );
Util.arrayCopy(outputBuffer, (short)0, hmac, (short)0, (short)hmac.length );
} }
public void next(){ public void next(){
plusOne(Cx); plusOne(Cx);
encryptCx(); encryptCx();
generateHMAC(tempBuffer, (short)0); generateHMAC();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment