X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=doc%2Fcrypto%2Fbn_internal.pod;h=6b01e2570b48f0ee7633a885077e2eab44b45d01;hb=8a4af56fc6ef29c938d0e181bf39533f941decb3;hp=588874f5244723f0bb544ca483cbc48627d43268;hpb=775c63fc023cbe1f2f6c2f512482a52986f55753;p=oweals%2Fopenssl.git diff --git a/doc/crypto/bn_internal.pod b/doc/crypto/bn_internal.pod index 588874f524..6b01e2570b 100644 --- a/doc/crypto/bn_internal.pod +++ b/doc/crypto/bn_internal.pod @@ -2,10 +2,19 @@ =head1 NAME -bn_internal - BIGNUM library internal functions +bn_mul_words, bn_mul_add_words, bn_sqr_words, bn_div_words, +bn_add_words, bn_sub_words, bn_mul_comba4, bn_mul_comba8, +bn_sqr_comba4, bn_sqr_comba8, bn_cmp_words, bn_mul_normal, +bn_mul_low_normal, bn_mul_recursive, bn_mul_part_recursive, +bn_mul_low_recursive, bn_mul_high, bn_sqr_normal, bn_sqr_recursive, +bn_expand, bn_wexpand, bn_expand2, bn_fix_top, bn_check_top, +bn_print, bn_dump, bn_set_max, bn_set_high, bn_set_low - BIGNUM +library internal functions =head1 SYNOPSIS + #include + BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); @@ -27,9 +36,9 @@ bn_internal - BIGNUM library internal functions int nb); void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n); void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, - BN_ULONG *tmp); + int dna,int dnb,BN_ULONG *tmp); void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, - int tn, int n, BN_ULONG *tmp); + int n, int tna,int tnb, BN_ULONG *tmp); void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, BN_ULONG *tmp); void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, @@ -65,19 +74,19 @@ applications. typedef struct bignum_st { - int top; /* index of last used d (most significant word) */ - BN_ULONG *d; /* pointer to an array of 'BITS2' bit chunks */ + 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; -The big number is stored in B, a malloc()ed array of Bs, -least significant first. A B can be either 16, 32 or 64 bits -in size (B), depending on the 'number of bits' specified in +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 -is the 'last' entry being used, so for a value of 4, bn.d[0]=4 and +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>. @@ -85,18 +94,8 @@ 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 conjunction with repeated subroutine calls, the B structure is -used. This structure contains B Bs. -B is the maximum number of temporary Bs any -publicly exported function will use. - - #define BN_CTX_NUM 12 - typedef struct bignum_ctx - { - int tos; /* top of stack */ - BIGNUM *bn[BN_CTX_NUM]; /* The variables */ - } BN_CTX; - -B is the index of the first unused B in the B array. +used. This structure contains B Bs, see +L. =head2 Low-level arithmetic operations @@ -152,17 +151,18 @@ word array B, the B word array B and the B+B word array B. It computes B*B and places the result in B. bn_mul_low_normal(B, B, B, B) operates on the B word -arrays B, B und B. It computes the B low words of +arrays B, B and B. It computes the B low words of B*B and places the result in B. -bn_mul_recursive(B, B, B, B, B) operates on the B -word arrays B and B and the 2*B word arrays B and B. -B must be a power of 2. It computes B*B and places the -result in B. +bn_mul_recursive(B, B, B, B, B, B, B) operates +on the word arrays B and B of length B+B and B+B +(B and B are currently allowed to be 0 or negative) and the 2*B +word arrays B and B. B must be a power of 2. It computes +B*B and places the result in B. -bn_mul_part_recursive(B, B, B, B, B, B) operates -on the B+B word arrays B and B and the 4*B word arrays -B and B. +bn_mul_part_recursive(B, B, B, B, B, B, B) +operates on the word arrays B and B of length B+B and +B+B and the 4*B word arrays B and B. bn_mul_low_recursive(B, B, B, B, B) operates on the B word arrays B and B and the B/2 word arrays B @@ -203,12 +203,12 @@ B word number. If the number has to be expanded, both macros call bn_expand2(), which allocates a new B array and copies the data. They return B on error, B otherwise. -The bn_fix_top() macro reduces Btop> to most significant -non-zero word when B has shrunk. +The bn_fix_top() macro reduces Btop> to point to the most +significant non-zero word plus one when B has shrunk. =head2 Debugging -bn_check_top() verifies that C<((a)->top E= 0 && (a)-Etop +bn_check_top() verifies that C<((a)-Etop E= 0 && (a)-Etop E= (a)-Emax)>. A violation will cause the program to abort. bn_print() prints B to stderr. bn_dump() prints B words at B @@ -216,7 +216,7 @@ bn_print() prints B to stderr. bn_dump() prints B words at B 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 lower or higher words of B. +B that contains the B low or high words of B. If B is not defined, bn_check_top(), bn_print(), bn_dump() and bn_set_max() are defined as empty macros.