15 #include <openssl/ssl.h> 16 #include <openssl/evp.h> 17 #include <openssl/rand.h> 18 #include <openssl/err.h> 19 #include <openssl/md5.h> 131 # ifdef HAVE_EVP_DSS1
165 EVP_get_digestbyname(
"md_gost94"));
183 case LDNS_SIGN_ED25519:
191 case LDNS_SIGN_ED448:
206 printf(
"unknown algorithm, ");
207 printf(
"is the one used available on this system?\n");
335 unsigned char *sha1_hash;
349 sha1_hash = SHA1((
unsigned char*)ldns_buffer_begin(to_sign),
350 ldns_buffer_position(to_sign), NULL);
356 sig = DSA_do_sign(sha1_hash, SHA_DIGEST_LENGTH, key);
362 data =
LDNS_XMALLOC(uint8_t, 1 + 2 * SHA_DIGEST_LENGTH);
370 # ifdef HAVE_DSA_SIG_GET0 371 DSA_SIG_get0(sig, &R, &S);
376 pad = 20 - (size_t) BN_num_bytes(R);
378 memset(data + 1, 0, pad);
380 BN_bn2bin(R, (
unsigned char *) (data + 1) + pad);
382 pad = 20 - (size_t) BN_num_bytes(S);
384 memset(data + 1 + SHA_DIGEST_LENGTH, 0, pad);
386 BN_bn2bin(S, (
unsigned char *) (data + 1 + SHA_DIGEST_LENGTH + pad));
389 1 + 2 * SHA_DIGEST_LENGTH,
398 (void)to_sign; (void)key;
407 ldns_pkey_is_ecdsa(EVP_PKEY* pkey)
411 #ifdef HAVE_EVP_PKEY_BASE_ID 412 if(EVP_PKEY_base_id(pkey) != EVP_PKEY_EC)
415 if(EVP_PKEY_type(key->type) != EVP_PKEY_EC)
418 ec = EVP_PKEY_get1_EC_KEY(pkey);
419 g = EC_KEY_get0_group(ec);
424 if(EC_GROUP_get_curve_name(g) == NID_X9_62_prime256v1) {
428 if(EC_GROUP_get_curve_name(g) == NID_secp384r1) {
442 const EVP_MD *digest_type)
448 const EVP_MD *md_type;
458 md_type = digest_type;
465 #ifdef HAVE_EVP_MD_CTX_NEW 466 ctx = EVP_MD_CTX_new();
468 ctx = (EVP_MD_CTX*)malloc(
sizeof(*ctx));
469 if(ctx) EVP_MD_CTX_init(ctx);
476 r = EVP_SignInit(ctx, md_type);
478 r = EVP_SignUpdate(ctx, (
unsigned char*)
479 ldns_buffer_begin(to_sign),
480 ldns_buffer_position(to_sign));
483 EVP_MD_CTX_destroy(ctx);
487 r = EVP_SignFinal(ctx, (
unsigned char*)
488 ldns_buffer_begin(b64sig), &siglen, key);
491 EVP_MD_CTX_destroy(ctx);