• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/openssl/crypto/rsa/

Lines Matching refs:rsa

1 /* crypto/rsa/rsa_eay.c */
62 #include <openssl/rsa.h>
68 unsigned char *to, RSA *rsa,int padding);
70 unsigned char *to, RSA *rsa,int padding);
72 unsigned char *to, RSA *rsa,int padding);
74 unsigned char *to, RSA *rsa,int padding);
75 static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa);
76 static int RSA_eay_init(RSA *rsa);
77 static int RSA_eay_finish(RSA *rsa);
100 unsigned char *to, RSA *rsa, int padding)
110 num=BN_num_bytes(rsa->n);
141 if (BN_ucmp(&f, rsa->n) >= 0)
148 if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
153 if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->n,ctx))
158 if (rsa->_method_mod_n == NULL) /* other thread may have finished first */
161 if (rsa->_method_mod_n == NULL)
163 rsa->_method_mod_n = bn_mont_ctx;
172 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx,
173 rsa->_method_mod_n)) goto err;
195 static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx)
200 if(rsa->blinding == NULL)
201 ret = RSA_blinding_on(rsa, ctx);
206 #define BLINDING_HELPER(rsa, ctx, err_instr) \
208 if((!((rsa)->flags & RSA_FLAG_NO_BLINDING)) && \
209 ((rsa)->blinding == NULL) && \
210 !rsa_eay_blinding(rsa, ctx)) \
214 static BN_BLINDING *setup_blinding(RSA *rsa, BN_CTX *ctx)
227 if ((RAND_status() == 0) && rsa->d != NULL && rsa->d->d != NULL)
230 RAND_add(rsa->d->d, rsa->d->dmax * sizeof rsa->d->d[0], 0);
231 if (!BN_pseudo_rand_range(A,rsa->n)) goto err;
235 if (!BN_rand_range(A,rsa->n)) goto err;
237 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
239 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
241 ret = BN_BLINDING_new(A,Ai,rsa->n);
250 unsigned char *to, RSA *rsa, int padding)
263 num=BN_num_bytes(rsa->n);
287 if (BN_ucmp(&f, rsa->n) >= 0)
294 BLINDING_HELPER(rsa, ctx, goto err;);
295 blinding = rsa->blinding;
303 if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
318 blinding = setup_blinding(rsa, ctx);
328 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
329 ((rsa->p != NULL) &&
330 (rsa->q != NULL) &&
331 (rsa->dmp1 != NULL) &&
332 (rsa->dmq1 != NULL) &&
333 (rsa->iqmp != NULL)) )
334 { if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; }
337 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err;
366 unsigned char *to, RSA *rsa, int padding)
381 num=BN_num_bytes(rsa->n);
400 if (BN_ucmp(&f, rsa->n) >= 0)
406 BLINDING_HELPER(rsa, ctx, goto err;);
407 blinding = rsa->blinding;
415 if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
430 blinding = setup_blinding(rsa, ctx);
441 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
442 ((rsa->p != NULL) &&
443 (rsa->q != NULL) &&
444 (rsa->dmp1 != NULL) &&
445 (rsa->dmq1 != NULL) &&
446 (rsa->iqmp != NULL)) )
447 { if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; }
450 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL))
499 unsigned char *to, RSA *rsa, int padding)
512 num=BN_num_bytes(rsa->n);
530 if (BN_ucmp(&f, rsa->n) >= 0)
537 if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
542 if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->n,ctx))
547 if (rsa->_method_mod_n == NULL) /* other thread may have finished first */
550 if (rsa->_method_mod_n == NULL)
552 rsa->_method_mod_n = bn_mont_ctx;
561 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx,
562 rsa->_method_mod_n)) goto err;
594 static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
605 if (rsa->flags & RSA_FLAG_CACHE_PRIVATE)
607 if (rsa->_method_mod_p == NULL)
612 if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->p,ctx))
617 if (rsa->_method_mod_p == NULL) /* other thread may have finished first */
620 if (rsa->_method_mod_p == NULL)
622 rsa->_method_mod_p = bn_mont_ctx;
631 if (rsa->_method_mod_q == NULL)
636 if (!BN_MONT_CTX_set(bn_mont_ctx,rsa->q,ctx))
641 if (rsa->_method_mod_q == NULL) /* other thread may have finished first */
644 if (rsa->_method_mod_q == NULL)
646 rsa->_method_mod_q = bn_mont_ctx;
656 if (!BN_mod(&r1,I,rsa->q,ctx)) goto err;
657 if (!rsa->meth->bn_mod_exp(&m1,&r1,rsa->dmq1,rsa->q,ctx,
658 rsa->_method_mod_q)) goto err;
660 if (!BN_mod(&r1,I,rsa->p,ctx)) goto err;
661 if (!rsa->meth->bn_mod_exp(r0,&r1,rsa->dmp1,rsa->p,ctx,
662 rsa->_method_mod_p)) goto err;
668 if (!BN_add(r0,r0,rsa->p)) goto err;
670 if (!BN_mul(&r1,r0,rsa->iqmp,ctx)) goto err;
671 if (!BN_mod(r0,&r1,rsa->p,ctx)) goto err;
680 if (!BN_add(r0,r0,rsa->p)) goto err;
681 if (!BN_mul(&r1,r0,rsa->q,ctx)) goto err;
684 if (rsa->e && rsa->n)
686 if (!rsa->meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err;
687 /* If 'I' was greater than (or equal to) rsa->n, the operation
692 if (!BN_mod(&vrfy, &vrfy, rsa->n, ctx)) goto err;
694 if (!BN_add(&vrfy, &vrfy, rsa->n)) goto err;
699 if (!rsa->meth->bn_mod_exp(r0,I,rsa->d,rsa->n,ctx,NULL)) goto err;
710 static int RSA_eay_init(RSA *rsa)
712 rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE;
716 static int RSA_eay_finish(RSA *rsa)
718 if (rsa->_method_mod_n != NULL)
719 BN_MONT_CTX_free(rsa->_method_mod_n);
720 if (rsa->_method_mod_p != NULL)
721 BN_MONT_CTX_free(rsa->_method_mod_p);
722 if (rsa->_method_mod_q != NULL)
723 BN_MONT_CTX_free(rsa->_method_mod_q);