Hello,

I'm playing with BN_GF2m_* functions. Unfortunately, I found no
documentation for it.
I tried to figure out how it works, but I found it quite difficult.
Please help me understand behaviour described below.

I'm trying to add two polynomials:
a(t) = t^3 + t^2 + t^1  + t^0
b(t) = t^2 + t^0

I encode them as two int arrays, according to description in "bn.h":
int ai[] = {3,2,1,0};
int bi[] = {2,0};

Btw, here comes a little question: how should I write such arrays if I
won't have the 0'th coefficient, eg. for polynomial like:
c(t) = t^3 + t^2 + t^1

Back to my addition. I convert ai and bi to two BIGNUMs using
BN_GF2m_arr2poly:

BN_GF2m_arr2poly(ai, bn_a);
BN_GF2m_arr2poly(bi, bn_b);

Then I try to sum them:

BN_GF2m_add(bn_r,bn_a,bn_b);

As far as I understand polynomial representation, it stores coefficients
as bits in BIGNUM object (and it can be read with BN_is_bit_set(), for
example BN_is_bit_set(bn,0) will check if in given polynomial bn 0th
coefficient exists).

Notice that addition above  clears the 0th coefficient (it's simple XOR
of two polynomials). Unfortunately, in bn_gf2m.c, function
BN_GF2m_poly2arr() we can read:

if (! BN_is_bit_set(a,0)) return 0;


BN_GF2m_poly2arr is used widely in BN_GF2m code, so many operations will
fail when performed on result of polynomial addition.



Regards,

-- 
Lukasz Klimek <[EMAIL PROTECTED]>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to