63 }
while ( !prim.
n_len );
66 a_mult( &prim, &a_three, &prim );
74 a_add( &prim, &a_four, &prim );
88 if ( !
a_cmp( &p1, &p2) )
return 1;
90 if (
a_cmp( &p1, &p2) > 0)
102 len = ( len + 3) / 4;
118 }
while (((
a_cmp( d, max_p) <= 0 ||
a_cmp( d, &p1) >= 0)) && jj <
kMAXT);
171 memcpy(bufin,bufout,lout);
206 memcpy(bufin,bufout,lout);
250 static const char *
gHEX=
"0123456789ABCDEF";
251 static const char *
ghex=
"0123456789abcdef";
266 a_add( &gbits[i-1], &gbits[i-1], &gbits[i] );
269 for ( i=1; i<16; i++)
278 #if rsa_MAXINT == ( (1 << rsa_MAXBIT) - 1 ) 285 ab = 4 - (bi + 3) % 4 -1;
288 if ( (bi+3) / 4 >=
l )
294 b |= (
unsigned long)*p--;
299 b &= ( 1
L << (ab - 4)) -1
L;
315 int i,
b,p,len,low,high;
325 for (; q.
n_len && len > 1; len --) {
326 a_div( &q, &gbits[4], &q, &r );
327 for (p=8, b=0, i=3; i >= 0; i--, p /= 2) {
328 if (
a_cmp( &r, &gbits[i]) >= 0) {
329 a_sub( &r, &gbits[i], &r );
356 if (
rsa_num_sput( n, n_print,
sizeof( n_print) ) == EOF )
359 for (j=0, np=n_print; *np ; np++, j++) {
376 #if rsa_MAXINT == ( (1 << rsa_MAXBIT) - 1 ) 394 if ( (hp = strchr(
gHEX, *s )) )
396 else if ((hp = strchr(
ghex, *s )) )
403 b |= (
unsigned long)i;
433 while ( (c = *s++ & 0xFF)) {
434 if ( p= strchr(
gHEX, c) )
436 else if ( p= strchr(
ghex, c) )
441 a_mult( n, &gbits[4], n );
443 a_add( n, &gint16[i-1], n );
458 while ( (c=getc(f)) != EOF && ( isxdigit(c) || isspace(c)) ) {
481 return( l - c2->
n_len);
rsa_NUMBER rsa_genprim(int len, int prob)
int p_prim(rsa_NUMBER *, int)
int rsa_num_fput(rsa_NUMBER *n, FILE *f)
int rsa_decode(char *bufin, int lin, rsa_NUMBER n, rsa_NUMBER e)
static rsa_NUMBER gbits[9]
void a_assign(rsa_NUMBER *, rsa_NUMBER *)
void do_crypt(char *, char *, int, rsa_NUMBER *)
void a_ggt(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
void a_div(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
int rsa_genrsa(rsa_NUMBER p1, rsa_NUMBER p2, rsa_NUMBER *n, rsa_NUMBER *e, rsa_NUMBER *d)
static double p2(double t, double a, double b, double c)
static constexpr double L
static rsa_NUMBER gint16[16]
void a_add(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
rsa_INT n_part[rsa_MAXLEN]
int rsa_encode(char *bufin, int lin, rsa_NUMBER n, rsa_NUMBER e)
int rsa_num_fget(rsa_NUMBER *n, FILE *f)
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
void a_sub(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
static double p1(double t, double a, double b)
void m_init(rsa_NUMBER *, rsa_NUMBER *)
int rsa_num_sget(rsa_NUMBER *n, char *s)
static constexpr double s
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
int rsa_encode_size(rsa_NUMBER n)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
void gen_number(int, rsa_NUMBER *)
int rsa_cmp(rsa_NUMBER *c1, rsa_NUMBER *c2)
int rsa_num_sput(rsa_NUMBER *n, char *s, int l)
void rsa_assign(rsa_NUMBER *d, rsa_NUMBER *s)
int n_bitlen(rsa_NUMBER *)
int n_cmp(rsa_INT *, rsa_INT *, int)
int a_cmp(rsa_NUMBER *, rsa_NUMBER *)
void a_mult(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)