opensslecdsa_link.c revision 3249da26fc28297265d444a1f3647f1e6700a2a0
/*
* Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id$ */
#include <config.h>
#ifdef 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
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
isc_region_t r;
unsigned char digest[EVP_MAX_MD_SIZE];
return (ISC_R_FAILURE);
else
"EVP_DigestFinal",
"ECDSA_do_sign",
ret = ISC_R_SUCCESS;
err:
return (ret);
}
static isc_result_t
int status;
unsigned char digest[EVP_MAX_MD_SIZE];
return (ISC_R_FAILURE);
else
return (DST_R_VERIFYFAILURE);
"EVP_DigestFinal_ex",
ecdsasig = ECDSA_SIG_new();
/* 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();
}
ret = ISC_R_SUCCESS;
err:
return (ret);
}
static dst_func_t opensslecdsa_functions = {
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 */