NAME
asn1_long_half
asn1_long_add
asn1_long_sub
asn1_long_mul
asn1_long_div
asn1_long_modulo
asn1_long_mod_small
asn1_long_power_modulo
asn1_long_2powN
asn1_long_gcd
- multiple precision integer arithmetic
SYNOPSIS
#include asn1.h
void asn1_long_half(li)
asn1_long *li;
void asn1_long_add(li1, li2, li3)
asn1_long *li1, *li2, *li3;
void asn1_long_sub(li1, li2, li3)
asn1_long *li1, *li2, *li3;
void asn1_long_mul(li1, li2, li3)
asn1_long *li1, *li2, *li3;
void asn1_long_div(li1, li2, li3)
asn1_long *li1, *li2, *li3;
void asn1_long_modulo(r, n, i, po)
asn1_long *r, *n, *i;
int po;
ASN1_LONG_ITEM asn1_long_mod_small(li, l)
asn1_long *li;
ASN1_LONG_ITEM l;
void asn1_long_power_modulo(X, Y, N, r)
asn1_long *X, *Y, *N, *r;
void asn1_long_2powN(li, n)
asn1_long *li;
int n;
int asn1_long_gcd(A, B, GCD, I)
asn1_long *A, *B, *GCD, *I;
DESCRIPTION
The ASN.1 library routines allow C programmers to describe arbitrary
data structures in a machine-independent fashion.
All ASN.1 routines require the header
"asn1.h"
to be included.
These routines perform arithmetic on integers of arbitrary length.
The integers are stored using the defined type
asn1_long
(see asn1_long(9x)) :
-
asn1_long_half()
divides a long integer by two.
-
asn1_long_add(),
asn1_long_sub()
and
asn1_long_mult()
assign to their third arguments the sum, difference, and product,
respectively, of their first two arguments.
The firth argument should be freed.
-
asn1_long_div()
assigns the quotient and remainder,respectively, to its third and
fourth arguments.
-
asn1_long_modulo()
reduces
r
to its value modulo
n.
i
is an auxiliary number, such that : n*i - 2**p + r, where r < n.
po
is the expression of the exponent
p
divided by the number of bits in a long integer.
-
asn1_long_mod_small()
computes
li
modulo
n,
where
n
is a "small" integer.
-
asn1_long_power_modulo()
computes
X
power
Y
modulo
N,
returning it in
r.
-
asn1_long_2powN()
computes two power
n,
returning it in the first argument.
-
asn1_long_gcd()
computes the greatest common divisor of the first two arguments,
returning it in the third argument.
The first two arguments are nonnegative long integers, with
A
greatest or equal than
B.
If
GCD
is equal to one, i.e the first two numbers are prime, the its
also returns
I
such as :
"B*I - 1 mod A."
This routine returns 1 if the numbers are prime, 0 otherwise.
"SEE ALSO"
mavcod (9x),
mavros (9x),
mavros-output (9x),
asn1_time (9x),
asn1_malloc (9x),
asn1_long (9x),
asn1_longio (9x),
asn1_longrand (9x)
asn1_longprime (9x),
C. Huitema,
"General Presentation of the MAVROS Compiler",INRIA, 1990