Fix with ASN1 encapsulation for keypair generation. It only affects RSA 4096 bits.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -994,15 +994,19 @@ static int cmd_keypair_gen() {
|
|||||||
|
|
||||||
res_APDU[0] = 0x67;
|
res_APDU[0] = 0x67;
|
||||||
int outer_len = strlen(cvc.outer_car)+2+2+1+4;
|
int outer_len = strlen(cvc.outer_car)+2+2+1+4;
|
||||||
int bytes_length = (cvclen+outer_len)/256;
|
int bytes_length = 0;
|
||||||
if (cvclen%256 > 0)
|
if (cvclen+outer_len < 128)
|
||||||
bytes_length++;
|
|
||||||
if (cvclen < 128)
|
|
||||||
res_APDU[1] = cvclen+outer_len;
|
res_APDU[1] = cvclen+outer_len;
|
||||||
|
else if (cvclen+outer_len < 256) {
|
||||||
|
res_APDU[1] = 0x81;
|
||||||
|
res_APDU[2] = cvclen+outer_len;
|
||||||
|
bytes_length = 1;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
res_APDU[1] = 0x80|bytes_length;
|
res_APDU[1] = 0x82;
|
||||||
for (int b = 1; b <= bytes_length; b++)
|
res_APDU[2] = (cvclen+outer_len) >> 8;
|
||||||
res_APDU[1+b] = ((cvclen+outer_len)>>((bytes_length-b)*8))&0xff;
|
res_APDU[3] = (cvclen+outer_len) & 0xff;
|
||||||
|
bytes_length = 2;
|
||||||
}
|
}
|
||||||
memcpy(res_APDU+bytes_length+2, cvcbin, cvclen);
|
memcpy(res_APDU+bytes_length+2, cvcbin, cvclen);
|
||||||
res_APDU[bytes_length+2+cvclen] = 0x42;
|
res_APDU[bytes_length+2+cvclen] = 0x42;
|
||||||
|
|||||||
Reference in New Issue
Block a user