asn1IntegerToHex method
Converts ASN1_INTEGER to hexadecimal string via BIGNUM.
Implementation
String asn1IntegerToHex(Pointer<ASN1_INTEGER> value) {
final bn = bindings.ASN1_INTEGER_to_BN(value, nullptr);
if (bn == nullptr) {
throw OpenSslException('ASN1_INTEGER_to_BN failed');
}
try {
final hexPtr = bindings.BN_bn2hex(bn);
if (hexPtr == nullptr) {
throw OpenSslException('BN_bn2hex failed');
}
try {
return hexPtr.cast<Utf8>().toDartString();
} finally {
bindings.CRYPTO_free(hexPtr.cast(), nullptr, 0);
}
} finally {
bindings.BN_free(bn);
}
}