Commit 313e68ad authored by Josh Ji's avatar Josh Ji

code review

getPuKxCx
parent 8906f0a4
...@@ -415,8 +415,12 @@ public class CTAP2 extends Applet implements ExtendedLength { ...@@ -415,8 +415,12 @@ public class CTAP2 extends Applet implements ExtendedLength {
cborDecoder.init(dataBuffer, (short) 1, dataLength); cborDecoder.init(dataBuffer, (short) 1, dataLength);
try { try {
cborDecoder.readMajorType(CBORBase.TYPE_ARRAY); cborDecoder.readMajorType(CBORBase.TYPE_ARRAY);
// read IDx
short length = cborDecoder.readTextString(scratch, (short) 0); short length = cborDecoder.readTextString(scratch, (short) 0);
idSecret.IDx = new DomString(scratch, length); idSecret.IDx = new DomString(scratch, length);
// read PuKp
cborDecoder.readByteString(scratch, (short) 0); cborDecoder.readByteString(scratch, (short) 0);
Util.arrayCopy(scratch, (short) 8, idSecret.PuKp, (short) 1, (short) 64); Util.arrayCopy(scratch, (short) 8, idSecret.PuKp, (short) 1, (short) 64);
} catch (UserException e) { } catch (UserException e) {
...@@ -429,14 +433,19 @@ public class CTAP2 extends Applet implements ExtendedLength { ...@@ -429,14 +433,19 @@ public class CTAP2 extends Applet implements ExtendedLength {
idSecret.initAesKey(); idSecret.initAesKey();
idSecret.encryptCx(); idSecret.encryptCx();
// make output cbor
cborEncoder.init(dataBuffer, (short) 0, (short) 1200); cborEncoder.init(dataBuffer, (short) 0, (short) 1200);
cborEncoder.startArray((short) 2); cborEncoder.startArray((short) 2);
// put PuKx
short length = attestationKeyPair.getPubkey(scratch, (short) 0); short length = attestationKeyPair.getPubkey(scratch, (short) 0);
cborEncoder.encodeByteString(scratch, (short) 0, length); cborEncoder.encodeByteString(scratch, (short) 0, length);
// put encryptedCx
cborEncoder.encodeByteString(idSecret.encryptedCx, (short) 0, (short) idSecret.encryptedCx.length); cborEncoder.encodeByteString(idSecret.encryptedCx, (short) 0, (short) idSecret.encryptedCx.length);
//for test //for test
idSecret.getHMAC(scratch, (short) 0); // idSecret.getHMAC(scratch, (short) 0);
apdu.setOutgoing(); apdu.setOutgoing();
apdu.setOutgoingLength(cborEncoder.getCurrentOffset()); apdu.setOutgoingLength(cborEncoder.getCurrentOffset());
......
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