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

Brian Smith brian at briansmith.org
Wed Apr 20 19:08:27 UTC 2016


Feel free to take the patch at
https://boringssl.googlesource.com/boringssl/+/7af36e1e38f54051559e2a40e6461a0c3b23b3fc%5E%21/#F0
if it helps you.

In particular, crypto/ec (ecp_nistz256, at least) also needs this, and in
fact this is already defined there.

Cheers,
Brian

On Wed, Apr 20, 2016 at 8:36 AM, 黄勤瑾 <huangqinjin at gmail.com> wrote:

> 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?
>
> --
> openssl-dev mailing list
> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
>
>


-- 
https://briansmith.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-dev/attachments/20160420/b4194a77/attachment.html>


More information about the openssl-dev mailing list