Lines Matching refs:key
113 static isc_result_t opensslrsa_todns(const dst_key_t *key, isc_buffer_t *data);
116 opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) {
122 UNUSED(key);
123 REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 ||
124 dctx->key->key_alg == DST_ALG_RSASHA1 ||
125 dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 ||
126 dctx->key->key_alg == DST_ALG_RSASHA256 ||
127 dctx->key->key_alg == DST_ALG_RSASHA512);
134 switch (dctx->key->key_alg) {
164 switch (dctx->key->key_alg) {
226 REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 ||
227 dctx->key->key_alg == DST_ALG_RSASHA1 ||
228 dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 ||
229 dctx->key->key_alg == DST_ALG_RSASHA256 ||
230 dctx->key->key_alg == DST_ALG_RSASHA512);
238 switch (dctx->key->key_alg) {
300 REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 ||
301 dctx->key->key_alg == DST_ALG_RSASHA1 ||
302 dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 ||
303 dctx->key->key_alg == DST_ALG_RSASHA256 ||
304 dctx->key->key_alg == DST_ALG_RSASHA512);
313 switch (dctx->key->key_alg) {
367 dst_key_t *key = dctx->key;
372 EVP_PKEY *pkey = key->keydata.pkey;
374 RSA *rsa = key->keydata.rsa;
386 REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 ||
387 dctx->key->key_alg == DST_ALG_RSASHA1 ||
388 dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 ||
389 dctx->key->key_alg == DST_ALG_RSASHA256 ||
390 dctx->key->key_alg == DST_ALG_RSASHA512);
407 switch (dctx->key->key_alg) {
460 switch (dctx->key->key_alg) {
506 dst_key_t *key = dctx->key;
510 EVP_PKEY *pkey = key->keydata.pkey;
516 RSA *rsa = key->keydata.rsa;
523 REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 ||
524 dctx->key->key_alg == DST_ALG_RSASHA1 ||
525 dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 ||
526 dctx->key->key_alg == DST_ALG_RSASHA256 ||
527 dctx->key->key_alg == DST_ALG_RSASHA512);
542 switch (dctx->key->key_alg) {
598 switch (dctx->key->key_alg) {
720 opensslrsa_generate(dst_key_t *key, int exp) {
751 if (RSA_generate_key_ex(rsa, key->key_size, e, &cb)) {
755 key->keydata.pkey = pkey;
759 key->keydata.rsa = rsa;
790 rsa = RSA_generate_key(key->key_size, e, NULL, NULL);
805 key->keydata.pkey = pkey;
808 key->keydata.rsa = rsa;
816 opensslrsa_isprivate(const dst_key_t *key) {
818 RSA *rsa = EVP_PKEY_get1_RSA(key->keydata.pkey);
821 /* key->keydata.pkey still has a reference so rsa is still valid. */
823 RSA *rsa = key->keydata.rsa;
831 opensslrsa_destroy(dst_key_t *key) {
833 EVP_PKEY *pkey = key->keydata.pkey;
835 key->keydata.pkey = NULL;
837 RSA *rsa = key->keydata.rsa;
839 key->keydata.rsa = NULL;
845 opensslrsa_todns(const dst_key_t *key, isc_buffer_t *data) {
856 REQUIRE(key->keydata.pkey != NULL);
858 REQUIRE(key->keydata.rsa != NULL);
862 pkey = key->keydata.pkey;
867 rsa = key->keydata.rsa;
875 if (e_bytes < 256) { /*%< key exponent is <= 2040 bits */
907 opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
951 key->key_size = BN_num_bits(rsa->n);
966 key->keydata.pkey = pkey;
969 key->keydata.rsa = rsa;
976 opensslrsa_tofile(const dst_key_t *key, const char *directory) {
984 if (key->keydata.pkey == NULL)
986 rsa = EVP_PKEY_get1_RSA(key->keydata.pkey);
990 if (key->keydata.rsa == NULL)
992 rsa = key->keydata.rsa;
997 bufs[i] = isc_mem_get(key->mctx, BN_num_bytes(rsa->n));
1066 if (key->engine != NULL) {
1068 priv.elements[i].length = strlen(key->engine) + 1;
1069 priv.elements[i].data = (unsigned char *)key->engine;
1073 if (key->label != NULL) {
1075 priv.elements[i].length = strlen(key->label) + 1;
1076 priv.elements[i].data = (unsigned char *)key->label;
1081 result = dst__privstruct_writefile(key, &priv, directory);
1089 isc_mem_put(key->mctx, bufs[i], BN_num_bytes(rsa->n));
1095 opensslrsa_parse(dst_key_t *key, isc_lex_t *lexer) {
1103 isc_mem_t *mctx = key->mctx;
1109 /* read private key file */
1110 ret = dst__privstruct_parse(key, DST_ALG_RSA, lexer, mctx, &priv);
1127 * Is this key is stored in a HSM?
1142 key->engine = isc_mem_strdup(key->mctx, name);
1143 if (key->engine == NULL)
1145 key->label = isc_mem_strdup(key->mctx, label);
1146 if (key->label == NULL)
1148 key->key_size = EVP_PKEY_bits(pkey);
1150 key->keydata.pkey = pkey;
1152 key->keydata.rsa = EVP_PKEY_get1_RSA(pkey);
1176 key->keydata.pkey = pkey;
1178 key->keydata.rsa = rsa;
1226 key->key_size = BN_num_bits(rsa->n);
1240 opensslrsa_destroy(key);
1247 opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
1264 key->engine = isc_mem_strdup(key->mctx, label);
1265 if (key->engine == NULL)
1267 key->label = isc_mem_strdup(key->mctx, label);
1268 if (key->label == NULL)
1270 key->key_size = EVP_PKEY_bits(pkey);
1272 key->keydata.pkey = pkey;
1274 key->keydata.rsa = EVP_PKEY_get1_RSA(pkey);
1276 if (key->keydata.rsa == NULL)
1286 UNUSED(key);