【发布时间】: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_bn2bin 或 BN_mask_bits。
有什么方法可以在不额外复制的情况下访问最低字节?
【问题讨论】: