/*
* Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <config.h>
#if defined(OPENSSL) && defined(HAVE_OPENSSL_ECDSA)
#if !defined(HAVE_EVP_SHA256) || !defined(HAVE_EVP_SHA384)
#error "ECDSA without EVP for SHA2?"
#endif
#include <dns/keyvalues.h>
#include "dst_internal.h"
#include "dst_openssl.h"
#include "dst_parse.h"
#ifndef NID_X9_62_prime256v1
#error "P-256 group is not known (NID_X9_62_prime256v1)"
#endif
#ifndef NID_secp384r1
#error "P-384 group is not known (NID_secp384r1)"
#endif
/* From OpenSSL 1.1 */
static void
}
static int
return 0;
BN_clear_free(sig->r);
BN_clear_free(sig->s);
sig->r = r;
sig->s = s;
return 1;
}
#endif
isc_buffer_t *data);
static isc_result_t
if (evp_md_ctx == NULL)
return (ISC_R_NOMEMORY);
type = EVP_sha256();
else
type = EVP_sha384();
"EVP_DigestInit_ex",
}
return (ISC_R_SUCCESS);
}
static void
if (evp_md_ctx != NULL) {
}
}
static isc_result_t
"EVP_DigestUpdate",
return (ISC_R_SUCCESS);
}
static int
while (bytes-- > 0)
*buf++ = 0;
return (size);
}
static isc_result_t
const BIGNUM *r, *s;
return (ISC_R_FAILURE);
else
"EVP_DigestFinal",
"ECDSA_do_sign",
ECDSA_SIG_get0(ecdsasig, &r, &s);
ret = ISC_R_SUCCESS;
err:
return (ret);
}
static isc_result_t
int status;
return (ISC_R_FAILURE);
else
return (DST_R_VERIFYFAILURE);
"EVP_DigestFinal_ex",
ecdsasig = ECDSA_SIG_new();
ECDSA_SIG_set0(ecdsasig, r, s);
/* cp += siglen / 2; */
switch (status) {
case 1:
ret = ISC_R_SUCCESS;
break;
case 0:
break;
default:
"ECDSA_do_verify",
break;
}
err:
return (ret);
}
static isc_boolean_t
int status;
return (ISC_TRUE);
return (ISC_FALSE);
if (status != 1)
}
err:
return (ret);
}
static isc_result_t
int group_nid;
} else {
}
return (dst__openssl_toresult2("EC_KEY_new_by_curve_name",
pkey = EVP_PKEY_new();
}
ret = ISC_R_SUCCESS;
err:
return (ret);
}
static isc_boolean_t
return (ret);
}
static void
}
static isc_result_t
isc_region_t r;
int len;
unsigned char *cp;
return (dst__openssl_toresult(ISC_R_FAILURE));
/* skip form */
len--;
ret = ISC_R_SUCCESS;
err:
return (ret);
}
static isc_result_t
isc_region_t r;
int group_nid;
unsigned int len;
const unsigned char *cp;
} else {
}
if (r.length == 0)
return (ISC_R_SUCCESS);
return (DST_R_INVALIDPUBLICKEY);
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
if (o2i_ECPublicKey(&eckey,
(const unsigned char **) &cp,
pkey = EVP_PKEY_new();
}
ret = ISC_R_SUCCESS;
err:
return (ret);
}
static isc_result_t
return (DST_R_NULLKEY);
}
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
err:
return (ret);
}
static isc_result_t
{
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
err:
return (ret);
}
static isc_result_t
int group_nid;
/* read private key file */
if (ret != ISC_R_SUCCESS)
goto err;
return (ISC_R_SUCCESS);
}
else
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
pkey = EVP_PKEY_new();
}
else
ret = ISC_R_SUCCESS;
err:
return (ret);
}
NULL, /*%< createctx2 */
NULL, /*%< verify2 */
NULL, /*%< computesecret */
NULL, /*%< paramcompare */
NULL, /*%< cleanup */
NULL, /*%< fromlabel */
NULL, /*%< dump */
NULL, /*%< restore */
};
return (ISC_R_SUCCESS);
}
#else /* HAVE_OPENSSL_ECDSA */
#endif /* HAVE_OPENSSL_ECDSA */
/*! \file */