Sortix main manual
This manual documents Sortix main. You can instead view this document in the latest official manual.
NAME
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, mul, mul_add, sqr — BIGNUM library internal functionsSYNOPSIS
#include <openssl/bn.h>bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp, int num);
bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp, int num);
bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a);
bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a);
bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n);
bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, int dna, int dnb, BN_ULONG *tmp);
bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, int tnb, BN_ULONG *tmp);
bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, BN_ULONG *tmp);
bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2, BN_ULONG *tmp);
bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);
bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *tmp);
mul(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c);
mul_add(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c);
sqr(BN_ULONG r0, BN_ULONG r1, BN_ULONG a);
bn_expand(BIGNUM *a, int bits);
bn_wexpand(BIGNUM *a, int n);
bn_expand2(BIGNUM *a, int n);
bn_fix_top(BIGNUM *a);
bn_check_top(BIGNUM *a);
bn_print(BIGNUM *a);
bn_dump(BN_ULONG *d, int n);
bn_set_max(BIGNUM *a);
bn_set_high(BIGNUM *r, BIGNUM *a, int n);
bn_set_low(BIGNUM *r, BIGNUM *a, int n);
DESCRIPTION
This page documents the internal functions used by the OpenSSL BIGNUM implementation. They are described here to facilitate debugging and extending the library. They are not to be used by applications.The BIGNUM structure
typedef struct bignum_st 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; };
Low level arithmetic operations
These functions are implemented in C and for several platforms in assembly language:Size changes
bn_expand() ensures that b has enough space for a bits bit number. bn_wexpand() ensures that b has enough space for an n word number. If the number has to be expanded, both macros call bn_expand2(), which allocates a new d array and copies the data. They return NULL on error, b otherwise.Debugging
bn_check_top() verifies that ‘((a)-⟩top ⟩= 0 && (a)-⟩top ⟨= (a)-⟩dmax)
’. A violation will cause the program to abort.