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

Lines Matching refs:rsa

1 /* crypto/rsa/rsa_gen.c */
64 #include <openssl/rsa.h>
69 static int fips_check_rsa(RSA *rsa)
80 n=RSA_public_encrypt(sizeof(original_ptext)-1,original_ptext,ctext,rsa,
92 n=RSA_private_decrypt(n,ctext,ptext,rsa,RSA_PKCS1_OAEP_PADDING);
110 RSA *rsa=NULL;
134 rsa=RSA_new();
135 if (rsa == NULL) goto err;
138 rsa->e=BN_new();
139 if (rsa->e == NULL) goto err;
147 BN_set_bit(rsa->e,i);
150 if (!BN_set_word(rsa->e,e_value)) goto err;
156 rsa->p=BN_generate_prime(NULL,bitsp,0,NULL,NULL,callback,cb_arg);
157 if (rsa->p == NULL) goto err;
158 if (!BN_sub(r2,rsa->p,BN_value_one())) goto err;
159 if (!BN_gcd(r1,r2,rsa->e,ctx)) goto err;
162 BN_free(rsa->p);
167 rsa->q=BN_generate_prime(NULL,bitsq,0,NULL,NULL,callback,cb_arg);
168 if (rsa->q == NULL) goto err;
169 if (!BN_sub(r2,rsa->q,BN_value_one())) goto err;
170 if (!BN_gcd(r1,r2,rsa->e,ctx)) goto err;
171 if (BN_is_one(r1) && (BN_cmp(rsa->p,rsa->q) != 0))
174 BN_free(rsa->q);
177 if (BN_cmp(rsa->p,rsa->q) < 0)
179 tmp=rsa->p;
180 rsa->p=rsa->q;
181 rsa->q=tmp;
185 rsa->n=BN_new();
186 if (rsa->n == NULL) goto err;
187 if (!BN_mul(rsa->n,rsa->p,rsa->q,ctx)) goto err;
190 if (!BN_sub(r1,rsa->p,BN_value_one())) goto err; /* p-1 */
191 if (!BN_sub(r2,rsa->q,BN_value_one())) goto err; /* q-1 */
197 if (!BN_gcd(r3,r0,rsa->e,ctx)) goto err;
202 if (!BN_add_word(rsa->e,2L)) goto err;
209 rsa->d=BN_mod_inverse(NULL,rsa->e,r0,ctx2); /* d */
210 if (rsa->d == NULL) goto err;
213 rsa->dmp1=BN_new();
214 if (rsa->dmp1 == NULL) goto err;
215 if (!BN_mod(rsa->dmp1,rsa->d,r1,ctx)) goto err;
218 rsa->dmq1=BN_new();
219 if (rsa->dmq1 == NULL) goto err;
220 if (!BN_mod(rsa->dmq1,rsa->d,r2,ctx)) goto err;
223 rsa->iqmp=BN_mod_inverse(NULL,rsa->q,rsa->p,ctx2);
224 if (rsa->iqmp == NULL) goto err;
226 if(!fips_check_rsa(rsa))
242 if (rsa != NULL) RSA_free(rsa);
246 return(rsa);