openssldsa_link.c revision 8bb630c7513ecfe224622a3923f0de477c44f2a9
/*
* Portions Copyright (C) 2004-2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1999-2002 Internet Software Consortium.
*
* 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 AND NETWORK ASSOCIATES 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.
*
* Portions Copyright (C) 1995-2000 by Network Associates, Inc.
*
* 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 AND NETWORK ASSOCIATES 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$ */
#ifdef OPENSSL
#ifndef USE_EVP
#define USE_EVP 1
#endif
#include <config.h>
#include <string.h>
#include "dst_internal.h"
#include "dst_openssl.h"
#include "dst_parse.h"
static isc_result_t
#if USE_EVP
if (evp_md_ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
#else
return (ISC_R_SUCCESS);
#endif
}
static void
#if USE_EVP
if (evp_md_ctx != NULL) {
}
#else
}
#endif
}
static isc_result_t
#if USE_EVP
return (ISC_R_FAILURE);
}
#else
#endif
return (ISC_R_SUCCESS);
}
static int
while (bytes-- > 0)
*buf++ = 0;
return (size);
}
static isc_result_t
isc_region_t r;
#if USE_EVP
unsigned char *sigbuf;
const unsigned char *sb;
unsigned int siglen;
#else
unsigned char digest[ISC_SHA1_DIGESTLENGTH];
#endif
return (ISC_R_NOSPACE);
#if USE_EVP
pkey = EVP_PKEY_new();
return (ISC_R_NOMEMORY);
return (ISC_R_FAILURE);
}
return (ISC_R_NOMEMORY);
}
"EVP_SignFinal",
}
/* Convert from Dss-Sig-Value (RFC2459). */
dsasig = DSA_SIG_new();
return (ISC_R_NOMEMORY);
}
"d2i_DSA_SIG",
}
#elif 0
/* Only use EVP for the Digest */
"EVP_DigestFinal_ex",
}
"DSA_do_sign",
#else
"DSA_do_sign",
#endif
r.base += ISC_SHA1_DIGESTLENGTH;
r.base += ISC_SHA1_DIGESTLENGTH;
return (ISC_R_SUCCESS);
}
static isc_result_t
int status = 0;
#if USE_EVP
#if 0
unsigned char *sigbuf;
#endif
unsigned int siglen;
#else
#endif
unsigned char digest[ISC_SHA1_DIGESTLENGTH];
#if USE_EVP
#if 1
/* Only use EVP for the digest */
return (ISC_R_FAILURE);
}
#endif
#else
#endif
return (DST_R_VERIFYFAILURE);
}
cp++; /*%< Skip T */
dsasig = DSA_SIG_new();
return (ISC_R_NOMEMORY);
#if 0
pkey = EVP_PKEY_new();
return (ISC_R_NOMEMORY);
return (ISC_R_FAILURE);
}
/* Convert to Dss-Sig-Value (RFC2459). */
return (ISC_R_NOMEMORY);
}
#else
#endif
switch (status) {
case 1:
return (ISC_R_SUCCESS);
case 0:
return (dst__openssl_toresult(DST_R_VERIFYFAILURE));
default:
"DSA_do_verify",
}
}
static isc_boolean_t
int status;
return (ISC_TRUE);
return (ISC_FALSE);
if (status != 0)
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
}
return (ISC_TRUE);
}
#if OPENSSL_VERSION_NUMBER > 0x00908000L
static int
{
union {
void *dptr;
void (*fptr)(int);
} u;
UNUSED(n);
u.fptr(p);
return (1);
}
#endif
static isc_result_t
unsigned char rand_array[ISC_SHA1_DIGESTLENGTH];
#if OPENSSL_VERSION_NUMBER > 0x00908000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#endif
union {
void *dptr;
void (*fptr)(int);
} u;
#else
#endif
if (result != ISC_R_SUCCESS)
return (result);
#if OPENSSL_VERSION_NUMBER > 0x00908000L
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
cb = BN_GENCB_new();
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
}
} else {
}
cb))
{
return (dst__openssl_toresult2("DSA_generate_parameters_ex",
}
#else
return (dst__openssl_toresult2("DSA_generate_parameters",
#endif
if (DSA_generate_key(dsa) == 0) {
return (dst__openssl_toresult2("DSA_generate_key",
}
return (ISC_R_SUCCESS);
}
static isc_boolean_t
}
static void
}
static isc_result_t
isc_region_t r;
int dnslen;
unsigned int t, p_bytes;
if (t > 8)
return (DST_R_INVALIDPUBLICKEY);
return (ISC_R_NOSPACE);
*r.base++ = t;
r.base += ISC_SHA1_DIGESTLENGTH;
return (ISC_R_SUCCESS);
}
static isc_result_t
isc_region_t r;
unsigned int t, p_bytes;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
t = (unsigned int) *r.base++;
if (t > 8) {
return (DST_R_INVALIDPUBLICKEY);
}
return (DST_R_INVALIDPUBLICKEY);
}
r.base += ISC_SHA1_DIGESTLENGTH;
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
return (DST_R_NULLKEY);
}
cnt++;
cnt++;
cnt++;
cnt++;
cnt++;
}
static isc_result_t
int i;
/* read private key file */
if (ret != ISC_R_SUCCESS)
return (ret);
return (ISC_R_SUCCESS);
}
case TAG_DSA_PRIME:
break;
case TAG_DSA_SUBPRIME:
break;
case TAG_DSA_BASE:
break;
case TAG_DSA_PRIVATE:
break;
case TAG_DSA_PUBLIC:
break;
}
}
return (ISC_R_SUCCESS);
err:
return (ret);
}
static dst_func_t openssldsa_functions = {
NULL, /*%< createctx2 */
NULL, /*%< verify2 */
NULL, /*%< computesecret */
NULL, /*%< paramcompare */
NULL, /*%< cleanup */
NULL, /*%< fromlabel */
NULL, /*%< dump */
NULL, /*%< restore */
};
return (ISC_R_SUCCESS);
}
#else /* OPENSSL */
#endif /* OPENSSL */
/*! \file */