check length of private key components before setting
the card functions only accepts key components of correct size so here we add 0 before if they're shorter (usually one byte shorter) thus fixing the issue where the card returned 6f00
This commit is contained in:
+12
@@ -203,3 +203,15 @@ int get_object_id(enum enum_slot slot) {
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
bool set_component_with_len(unsigned char **in_ptr, const BIGNUM *bn, int element_len) {
|
||||
int real_len = BN_num_bytes(bn);
|
||||
*in_ptr += set_length(*in_ptr, element_len);
|
||||
if(real_len > element_len) {
|
||||
return false;
|
||||
}
|
||||
memset(*in_ptr, 0, (size_t)(element_len - real_len));
|
||||
*in_ptr += element_len - real_len;
|
||||
*in_ptr += BN_bn2bin(bn, *in_ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user