c - char * to ASN1_INTEGER -
for pki certificate generation , , setting serial number , used rand_bytes
20 bytes of random serial number, wanted char *
set serial number of certificate , seems of type asn1_integer *
tried asn1_type_set_octetstring(asn1_type *, unsigned char *, len)
since takes asn1_type *
, not asn1_integer*
gave crash
how convert between unsigned char * asn1_integer
?
thanks,
i'm sure you're looking for, wrong. if want have 20-byte asn1_integer 1 way sending through bignum library first:
unsigned char data[20] = {0}; rand_bytes(data, sizeof(data)); data[0] &= 0x7f; // build big number our bytes bignum* bn = bn_new(); bn_bin2bn(data, sizeof(data), bn); // build asn1_integer our bignum asn1_integer* asnint = asn1_integer_new(); bn_to_asn1_integer(bn, asnint); // todo: use asn1_integer // cleanup asn1_integer_free(asnint); bn_free(bn);
Comments
Post a Comment