Lines Matching refs:rsa

24 int ossl_rsa_check_crt_components(const RSA *rsa, BN_CTX *ctx)  in ossl_rsa_check_crt_components()  argument
30 if (rsa->dmp1 == NULL || rsa->dmq1 == NULL || rsa->iqmp == NULL) { in ossl_rsa_check_crt_components()
31 if (rsa->dmp1 != NULL || rsa->dmq1 != NULL || rsa->iqmp != NULL) in ossl_rsa_check_crt_components()
50 && (BN_copy(p1, rsa->p) != NULL) in ossl_rsa_check_crt_components()
53 && (BN_copy(q1, rsa->q) != NULL) in ossl_rsa_check_crt_components()
56 && (BN_cmp(rsa->dmp1, BN_value_one()) > 0) in ossl_rsa_check_crt_components()
57 && (BN_cmp(rsa->dmp1, p1) < 0) in ossl_rsa_check_crt_components()
59 && (BN_cmp(rsa->dmq1, BN_value_one()) > 0) in ossl_rsa_check_crt_components()
60 && (BN_cmp(rsa->dmq1, q1) < 0) in ossl_rsa_check_crt_components()
62 && (BN_cmp(rsa->iqmp, BN_value_one()) > 0) in ossl_rsa_check_crt_components()
63 && (BN_cmp(rsa->iqmp, rsa->p) < 0) in ossl_rsa_check_crt_components()
65 && BN_mod_mul(r, rsa->dmp1, rsa->e, p1, ctx) in ossl_rsa_check_crt_components()
68 && BN_mod_mul(r, rsa->dmq1, rsa->e, q1, ctx) in ossl_rsa_check_crt_components()
71 && BN_mod_mul(r, rsa->iqmp, rsa->q, rsa->p, ctx) in ossl_rsa_check_crt_components()
175 int ossl_rsa_check_private_exponent(const RSA *rsa, int nbits, BN_CTX *ctx) in ossl_rsa_check_private_exponent() argument
181 if (BN_num_bits(rsa->d) <= (nbits >> 1)) in ossl_rsa_check_private_exponent()
204 && (ossl_rsa_get_lcm(ctx, rsa->p, rsa->q, lcm, gcd, p1, q1, in ossl_rsa_check_private_exponent()
207 && (BN_cmp(rsa->d, lcm) < 0) in ossl_rsa_check_private_exponent()
209 && BN_mod_mul(r, rsa->e, rsa->d, lcm, ctx) in ossl_rsa_check_private_exponent()
281 int ossl_rsa_sp800_56b_check_public(const RSA *rsa) argument
288 if (rsa->n == NULL || rsa->e == NULL)
291 nbits = BN_num_bits(rsa->n);
307 if (!BN_is_odd(rsa->n)) {
312 if (!ossl_rsa_check_public_exponent(rsa->e)) {
317 ctx = BN_CTX_new_ex(rsa->libctx);
326 if (!BN_gcd(gcd, rsa->n, ossl_bn_get0_small_factors(), ctx)
333 ret = ossl_bn_miller_rabin_is_prime(rsa->n, 5, ctx, NULL, 1, &status);
356 int ossl_rsa_sp800_56b_check_private(const RSA *rsa) argument
358 if (rsa->d == NULL || rsa->n == NULL)
360 return BN_cmp(rsa->d, BN_value_one()) >= 0 && BN_cmp(rsa->d, rsa->n) < 0;
374 int ossl_rsa_sp800_56b_check_keypair(const RSA *rsa, const BIGNUM *efixed, argument
381 if (rsa->p == NULL
382 || rsa->q == NULL
383 || rsa->e == NULL
384 || rsa->d == NULL
385 || rsa->n == NULL) {
396 if (BN_cmp(efixed, rsa->e) != 0) {
402 if (!ossl_rsa_check_public_exponent(rsa->e)) {
408 if (nbits != BN_num_bits(rsa->n)) {
418 ctx = BN_CTX_new_ex(rsa->libctx);
424 if (r == NULL || !BN_mul(r, rsa->p, rsa->q, ctx))
427 if (BN_cmp(rsa->n, r) != 0) {
433 ret = ossl_rsa_check_prime_factor(rsa->p, rsa->e, nbits, ctx)
434 && ossl_rsa_check_prime_factor(rsa->q, rsa->e, nbits, ctx)
435 && (ossl_rsa_check_pminusq_diff(r, rsa->p, rsa->q, nbits) > 0)
437 && ossl_rsa_check_private_exponent(rsa, nbits, ctx)
439 && ossl_rsa_check_crt_components(rsa, ctx);