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;
171 memcpy(bufin,bufout,lout);
206 memcpy(bufin,bufout,lout);
250static const char *
gHEX=
"0123456789ABCDEF";
251static const char *
ghex=
"0123456789abcdef";
269 for ( i=1; i<16; i++)
278#if rsa_MAXINT == ( (1 << rsa_MAXBIT) - 1 )
285 ab = 4 - (bi + 3) % 4 -1;
286 p = &
n->n_part[
n->n_len -1];
288 if ( (bi+3) / 4 >=
l )
294 b |= (
unsigned long)*p--;
299 b &= ( 1L << (ab - 4)) -1L;
315 int i,
b,p,len,low,high;
325 for (;
q.n_len && len > 1; len --) {
327 for (p=8,
b=0, i=3; i >= 0; i--, p /= 2) {
359 for (j=0, np=n_print; *np ; np++, j++) {
376#if rsa_MAXINT == ( (1 << rsa_MAXBIT) - 1 )
386 p = &
n->n_part[ i -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) )
458 while ( (
c=getc(
f)) != EOF && ( isxdigit(
c) || isspace(
c)) ) {
480 if ( (
l=
c1->n_len) !=
c2->n_len)
481 return(
l -
c2->n_len);
495 memcpy(
d->n_part,
s->n_part,
sizeof(
rsa_INT)*
l);
static constexpr double s
int a_cmp(rsa_NUMBER *, rsa_NUMBER *)
int n_bitlen(rsa_NUMBER *)
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
int p_prim(rsa_NUMBER *, int)
void a_sub(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
void a_ggt(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
int n_cmp(rsa_INT *, rsa_INT *, int)
void a_assign(rsa_NUMBER *, rsa_NUMBER *)
void do_crypt(char *, char *, int, rsa_NUMBER *)
void m_init(rsa_NUMBER *, rsa_NUMBER *)
void a_mult(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
void gen_number(int, rsa_NUMBER *)
void a_add(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)
int rsa_num_fget(rsa_NUMBER *n, FILE *f)
int rsa_num_sput(rsa_NUMBER *n, char *s, int l)
int rsa_decode(char *bufin, int lin, rsa_NUMBER n, rsa_NUMBER e)
int rsa_cmp(rsa_NUMBER *c1, rsa_NUMBER *c2)
int rsa_num_fput(rsa_NUMBER *n, FILE *f)
void rsa_assign(rsa_NUMBER *d, rsa_NUMBER *s)
int rsa_encode_size(rsa_NUMBER n)
static rsa_NUMBER gbits[9]
int rsa_num_sget(rsa_NUMBER *n, char *s)
int rsa_encode(char *bufin, int lin, rsa_NUMBER n, rsa_NUMBER e)
static rsa_NUMBER gint16[16]
rsa_NUMBER rsa_genprim(int len, int prob)