Lines Matching refs:bkey

374 rsa_genkey_pair(RSAbytekey *bkey)
405 if (bkey == NULL)
409 if (bkey->modulus_bits == 0)
413 if (bkey->pubexpo_bytes == 0 || bkey->pubexpo == NULL)
417 modulus_bytes = CRYPTO_BITS2BYTES(bkey->modulus_bits);
435 CHARLEN2BIGNUMLEN(bkey->pubexpo_bytes)) != BIG_OK) {
439 bytestring2bignum(&public_exponent, bkey->pubexpo, bkey->pubexpo_bytes);
444 bkey->rfunc)) != CKR_OK) {
451 bignum2bytestring(bkey->modulus, &(rsakey.n), modulus_bytes);
453 bkey->privexpo_bytes = rsakey.d.len * (int)sizeof (BIG_CHUNK_TYPE);
454 bignum2bytestring(bkey->privexpo, &(rsakey.d), bkey->privexpo_bytes);
456 bkey->pubexpo_bytes = rsakey.e.len * (int)sizeof (BIG_CHUNK_TYPE);
457 bignum2bytestring(bkey->pubexpo, &(rsakey.e), bkey->pubexpo_bytes);
459 bkey->prime1_bytes = rsakey.q.len * (int)sizeof (BIG_CHUNK_TYPE);
460 bignum2bytestring(bkey->prime1, &(rsakey.q), bkey->prime1_bytes);
462 bkey->prime2_bytes = rsakey.p.len * (int)sizeof (BIG_CHUNK_TYPE);
463 bignum2bytestring(bkey->prime2, &(rsakey.p), bkey->prime2_bytes);
465 bkey->expo1_bytes =
467 bignum2bytestring(bkey->expo1, &(rsakey.dmodqminus1),
468 bkey->expo1_bytes);
470 bkey->expo2_bytes =
472 bignum2bytestring(bkey->expo2,
473 &(rsakey.dmodpminus1), bkey->expo2_bytes);
475 bkey->coeff_bytes =
477 bignum2bytestring(bkey->coeff, &(rsakey.pinvmodq), bkey->coeff_bytes);
489 rsa_encrypt(RSAbytekey *bkey, uchar_t *in, uint32_t in_len, uchar_t *out)
497 if (bkey == NULL)
501 if (bkey->modulus_bits == 0 || bkey->modulus == NULL ||
502 bkey->pubexpo_bytes == 0 || bkey->pubexpo == NULL)
506 modulus_bytes = CRYPTO_BITS2BYTES(bkey->modulus_bits);
508 if (bkey->pubexpo_bytes > modulus_bytes) {
526 bytestring2bignum(&(rsakey.e), bkey->pubexpo, bkey->pubexpo_bytes);
527 bytestring2bignum(&(rsakey.n), bkey->modulus, modulus_bytes);
556 rsa_decrypt(RSAbytekey *bkey, uchar_t *in, uint32_t in_len, uchar_t *out)
564 if (bkey == NULL)
568 if (bkey->modulus_bits == 0 || bkey->modulus == NULL ||
569 bkey->prime1_bytes == 0 || bkey->prime1 == NULL ||
570 bkey->prime2_bytes == 0 || bkey->prime2 == NULL ||
571 bkey->expo1_bytes == 0 || bkey->expo1 == NULL ||
572 bkey->expo2_bytes == 0 || bkey->expo2 == NULL ||
573 bkey->coeff_bytes == 0 || bkey->coeff == NULL)
577 modulus_bytes = CRYPTO_BITS2BYTES(bkey->modulus_bits);
580 if (RSA_key_init(&rsakey, CRYPTO_BYTES2BITS(bkey->prime2_bytes),
581 CRYPTO_BYTES2BITS(bkey->prime1_bytes)) != BIG_OK) {
594 bytestring2bignum(&(rsakey.n), bkey->modulus, modulus_bytes);
602 bytestring2bignum(&(rsakey.q), bkey->prime1, bkey->prime1_bytes);
603 bytestring2bignum(&(rsakey.p), bkey->prime2, bkey->prime2_bytes);
605 bkey->expo1, bkey->expo1_bytes);
607 bkey->expo2, bkey->expo2_bytes);
609 bkey->coeff, bkey->coeff_bytes);