From: Dr. Stephen Henson Date: Wed, 28 Oct 2009 13:52:19 +0000 (+0000) Subject: PR: 2078 X-Git-Tag: OpenSSL_0_9_8m-beta1~78 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d916f92d6f53118c5233dd0adaeb75e3fe15f054;p=oweals%2Fopenssl.git PR: 2078 Submitted by: Dale Anderson Approved by: steve@openssl.org Corrections to bn_internal documentation. --- diff --git a/doc/crypto/bn_internal.pod b/doc/crypto/bn_internal.pod index 891914678c..d39ce90939 100644 --- a/doc/crypto/bn_internal.pod +++ b/doc/crypto/bn_internal.pod @@ -70,24 +70,34 @@ applications. =head2 The BIGNUM structure - typedef struct bignum_st + typedef struct bignum_st BIGNUM; + + struct bignum_st { - int top; /* number of words used in d */ - BN_ULONG *d; /* pointer to an array containing the integer value */ - int max; /* size of the d array */ - int neg; /* sign */ - } BIGNUM; + 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; + }; + The integer value is stored in B, a malloc()ed array of words (B), least significant word first. A B can be either 16, 32 or 64 bits in size, depending on the 'number of bits' (B) specified in C. -B is the size of the B array that has been allocated. B +B is the size of the B array that has been allocated. B is the number of words being used, so for a value of 4, bn.d[0]=4 and bn.top=1. B is 1 if the number is negative. When a B is B<0>, the B field can be B and B == B<0>. +B is a bit field of flags which are defined in C. The +flags begin with B. The macros BN_set_flags(b,n) and +BN_get_flags(b,n) exist to enable or fetch flag(s) B from B +structure B. + Various routines in this library require the use of temporary B variables during their execution. Since dynamic memory allocation to create Bs is rather expensive when used in @@ -207,12 +217,12 @@ significant non-zero word plus one when B has shrunk. =head2 Debugging bn_check_top() verifies that C<((a)-Etop E= 0 && (a)-Etop -E= (a)-Emax)>. A violation will cause the program to abort. +E= (a)-Edmax)>. A violation will cause the program to abort. bn_print() prints B to stderr. bn_dump() prints B words at B (in reverse order, i.e. most significant word first) to stderr. -bn_set_max() makes B a static number with a B of its current size. +bn_set_max() makes B a static number with a B of its current size. This is used by bn_set_low() and bn_set_high() to make B a read-only B that contains the B low or high words of B.