Lines Matching defs:rsa
49 #include <openssl/rsa.h>
79 #define SET_FLAGS(rsa) \
81 (rsa)->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE); \
82 (rsa)->flags |= RSA_FLAG_BLINDING; \
85 #define SET_FLAGS(rsa) \
87 (rsa)->flags |= RSA_FLAG_BLINDING; \
93 #define SET_FLAGS(rsa) \
95 (rsa)->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE); \
96 (rsa)->flags &= ~RSA_FLAG_BLINDING; \
99 #define SET_FLAGS(rsa) \
101 (rsa)->flags &= ~RSA_FLAG_BLINDING; \
102 (rsa)->flags |= RSA_FLAG_NO_BLINDING; \
105 #define SET_FLAGS(rsa) \
107 (rsa)->flags &= ~RSA_FLAG_BLINDING; \
374 RSA *rsa = key->keydata.rsa;
404 if (r.length < (unsigned int) RSA_size(rsa))
466 &siglen, rsa);
478 digest, r.base, rsa,
491 status = RSA_sign(type, digest, digestlen, r.base, &siglen, rsa);
516 RSA *rsa = key->keydata.rsa;
594 if (sig->length != (unsigned int) RSA_size(rsa))
604 RSA_size(rsa), rsa);
619 if (RSA_size(rsa) > (int)sizeof(original))
623 original, rsa,
646 RSA_size(rsa), rsa);
678 rsa1 = key1->keydata.rsa;
679 rsa2 = key2->keydata.rsa;
724 RSA *rsa = RSA_new();
730 if (rsa == NULL || e == NULL)
735 if (!EVP_PKEY_set1_RSA(pkey, rsa))
751 if (RSA_generate_key_ex(rsa, key->key_size, e, &cb)) {
753 SET_FLAGS(rsa);
757 RSA_free(rsa);
759 key->keydata.rsa = rsa;
773 if (rsa != NULL)
774 RSA_free(rsa);
777 RSA *rsa;
790 rsa = RSA_generate_key(key->key_size, e, NULL, NULL);
791 if (rsa == NULL) {
798 SET_FLAGS(rsa);
800 if (!EVP_PKEY_set1_RSA(pkey, rsa)) {
802 RSA_free(rsa);
806 RSA_free(rsa);
808 key->keydata.rsa = rsa;
818 RSA *rsa = EVP_PKEY_get1_RSA(key->keydata.pkey);
819 INSIST(rsa != NULL);
820 RSA_free(rsa);
821 /* key->keydata.pkey still has a reference so rsa is still valid. */
823 RSA *rsa = key->keydata.rsa;
825 if (rsa != NULL && (rsa->flags & RSA_FLAG_EXT_PKEY) != 0)
827 return (ISC_TF(rsa != NULL && rsa->d != NULL));
837 RSA *rsa = key->keydata.rsa;
838 RSA_free(rsa);
839 key->keydata.rsa = NULL;
850 RSA *rsa;
858 REQUIRE(key->keydata.rsa != NULL);
863 rsa = EVP_PKEY_get1_RSA(pkey);
864 if (rsa == NULL)
867 rsa = key->keydata.rsa;
872 e_bytes = BN_num_bytes(rsa->e);
873 mod_bytes = BN_num_bytes(rsa->n);
891 BN_bn2bin(rsa->e, r.base);
893 BN_bn2bin(rsa->n, r.base);
900 if (rsa != NULL)
901 RSA_free(rsa);
908 RSA *rsa;
919 rsa = RSA_new();
920 if (rsa == NULL)
922 SET_FLAGS(rsa);
925 RSA_free(rsa);
933 RSA_free(rsa);
942 RSA_free(rsa);
945 rsa->e = BN_bin2bn(r.base, e_bytes, NULL);
949 rsa->n = BN_bin2bn(r.base, r.length, NULL);
951 key->key_size = BN_num_bits(rsa->n);
958 RSA_free(rsa);
961 if (!EVP_PKEY_set1_RSA(pkey, rsa)) {
963 RSA_free(rsa);
967 RSA_free(rsa);
969 key->keydata.rsa = rsa;
978 RSA *rsa;
986 rsa = EVP_PKEY_get1_RSA(key->keydata.pkey);
987 if (rsa == NULL)
990 if (key->keydata.rsa == NULL)
992 rsa = key->keydata.rsa;
997 bufs[i] = isc_mem_get(key->mctx, BN_num_bytes(rsa->n));
1007 priv.elements[i].length = BN_num_bytes(rsa->n);
1008 BN_bn2bin(rsa->n, bufs[i]);
1013 priv.elements[i].length = BN_num_bytes(rsa->e);
1014 BN_bn2bin(rsa->e, bufs[i]);
1018 if (rsa->d != NULL) {
1020 priv.elements[i].length = BN_num_bytes(rsa->d);
1021 BN_bn2bin(rsa->d, bufs[i]);
1026 if (rsa->p != NULL) {
1028 priv.elements[i].length = BN_num_bytes(rsa->p);
1029 BN_bn2bin(rsa->p, bufs[i]);
1034 if (rsa->q != NULL) {
1036 priv.elements[i].length = BN_num_bytes(rsa->q);
1037 BN_bn2bin(rsa->q, bufs[i]);
1042 if (rsa->dmp1 != NULL) {
1044 priv.elements[i].length = BN_num_bytes(rsa->dmp1);
1045 BN_bn2bin(rsa->dmp1, bufs[i]);
1050 if (rsa->dmq1 != NULL) {
1052 priv.elements[i].length = BN_num_bytes(rsa->dmq1);
1053 BN_bn2bin(rsa->dmq1, bufs[i]);
1058 if (rsa->iqmp != NULL) {
1060 priv.elements[i].length = BN_num_bytes(rsa->iqmp);
1061 BN_bn2bin(rsa->iqmp, bufs[i]);
1084 RSA_free(rsa);
1089 isc_mem_put(key->mctx, bufs[i], BN_num_bytes(rsa->n));
1099 RSA *rsa = NULL;
1152 key->keydata.rsa = EVP_PKEY_get1_RSA(pkey);
1153 if (rsa == NULL)
1164 rsa = RSA_new();
1165 if (rsa == NULL)
1167 SET_FLAGS(rsa);
1173 if (!EVP_PKEY_set1_RSA(pkey, rsa)) {
1178 key->keydata.rsa = rsa;
1199 rsa->n = bn;
1202 rsa->e = bn;
1205 rsa->d = bn;
1208 rsa->p = bn;
1211 rsa->q = bn;
1214 rsa->dmp1 = bn;
1217 rsa->dmq1 = bn;
1220 rsa->iqmp = bn;
1226 key->key_size = BN_num_bits(rsa->n);
1228 RSA_free(rsa);
1238 if (rsa != NULL)
1239 RSA_free(rsa);
1274 key->keydata.rsa = EVP_PKEY_get1_RSA(pkey);
1276 if (key->keydata.rsa == NULL)