将BIGNUM转换为原始二进制文件

时间:2019-12-23 00:27:29

标签: c ssl openssl bignum

我想使用BIGNUM的BN_bn2bin函数将此十六进制字符串转换为原始二进制文件

.graphql

但是为什么只将“ 30 31 30 0D 06 09 60 86 48 01 65 03 04 02 01 05”输出到文件中?

1 个答案:

答案 0 :(得分:0)

感谢修正密码

BN_hex2bn(&asn1hash, "3031300D060960864801650304020105000420BC5F9353CBB9DCAE86B9F8F68C1C95856DB836ACA2E00C9319716CDF4DD0F5BA");

    int num_bytes = BN_num_bytes(asn1hash);
    char *buf = (unsigned char *)malloc(num_bytes);

    BN_bn2bin(asn1hash, buf);
    FILE *fp;
    fp = fopen("ASn1Hash","wb+");

        fwrite(buf, 1, num_bytes, fp);
        fclose(fp);