【问题标题】:Access BIGNUM bits in OpenSSL 1.1?在 OpenSSL 1.1 中访问 BIGNUM 位?
【发布时间】:2017-08-01 07:46:32
【问题描述】:

之前 1.1 版本的 OpenSSL API 我可以通过 struct bignum_st 中的“d”字段访问 BIGNUM 类型的原始表示:

   struct bignum_st
           {
           BN_ULONG *d;    /* Pointer to an array of 'BN_BITS2' bit chunks. */
           int top;        /* Index of last used d +1. */
           /* The next are internal book keeping for bn_expand. */
           int dmax;       /* Size of the d array. */
           int neg;        /* one if the number is negative */
           int flags;
           };

在我的程序中,我需要经过一些计算后从 BIGNUM 中获取最低字节 - 这很容易 - 就像:

(bn->d[0] & 0xff)

使用 OpenSSL 1.1 版的 API,许多 BN 内部都变得不透明 - 我无法直接访问 BIGNUM 的表示。我仍然可以获得原始表示,但需要额外复制 - BN_bn2binBN_mask_bits

有什么方法可以在不额外复制的情况下访问最低字节?

【问题讨论】:

    标签: api openssl bignum


    【解决方案1】:

    有什么方法可以在不额外复制的情况下访问最低字节?

    是的,不是的。如果BIGNUM 小于0xffffffff,则使用BN_get_word(bn) & 0xff;

    如果您的BIGNUM 大于0xffffffff,则使用BN_bn2binpad 复制出一个字节范围。

    另请参阅 OpenSSL 错误跟踪器中的 Issue 2001, Please provide BIGNUM And, Or and Xor ops

    【讨论】:

      猜你喜欢
      • 2018-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多