[openssl-dev] Consistent way of making a const bignum

黄勤瑾 huangqinjin at gmail.com
Wed Apr 20 18:36:06 UTC 2016


I'd submitted a pull request to openssl, changing the use of BN_bin2bin()
to static const bignums in bn_const.c . I defined macro bn_pack2 :

#if BN_BITS2 == 64
#    define bn_pack2(a1,a2) ((0x##a1##ULL<<32)|0x##a2##ULL)
#elif BN_BITS2 == 32
#    define bn_pack2(a1,a2) 0x##a2##UL, 0x##a1##UL
#else
#    error "unsupported BN_BITS2"
#endif

Use bn_pack2 to define BN_ULONG arrays:
static const BN_ULONG num[] = {
    bn_pack2(FFFFFFFF, FFFFFFFF),  bn_pack2(F44C42E9, A63A3620)
};

bn_const.c , bn_dh.c , bn_nist.c , bn_srp.c make const bignums
respectively.
<https://github.com/openssl/openssl/pull/982#issuecomment-212528822> *
richsalz <https://github.com/richsalz>* wants to make them consistent. So
if the marco bn_pack2 works well on all platforms, or the best way to do
that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-dev/attachments/20160421/74a479f0/attachment-0001.html>


More information about the openssl-dev mailing list