以前版本的bignum_st可以通过结构OpenSSL中的"d“字段访问bignum_st类型的原始表示:
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。
有没有办法访问最低字节,而不需要额外的复制?
发布于 2017-08-02 01:32:29
有没有办法访问最低字节,而不需要额外的复制?
是也不是。如果BIGNUM比0xffffffff小,那么使用BN_get_word(bn) & 0xff;。
如果您的BIGNUM大于0xffffffff,则使用BN_bn2binpad复制一个字节范围。
还可以在第2001期,请提供BIGNUM和或或和Xor ops bug跟踪器中看到OpenSSL。
https://stackoverflow.com/questions/45431879
复制相似问题