opensslrsa_link.c revision 25c18fded02c5df8391a333e90ea776b52bff079
/*
* Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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.
*/
/*
* Principal Author: Brian Wellington
* $Id: opensslrsa_link.c,v 1.6 2006/03/01 02:31:40 marka Exp $
*/
#ifdef OPENSSL
#include <config.h>
#include "dst_internal.h"
#include "dst_openssl.h"
#include "dst_parse.h"
/*
* XXXMPA Temporarially disable RSA_BLINDING as it requires
* good quality random data that cannot currently be guarenteed.
* XXXMPA Find which versions of openssl use pseudo random data
* and set RSA_FLAG_BLINDING for those.
*/
#if 0
#if OPENSSL_VERSION_NUMBER < 0x0090601fL
do { \
} while (0)
#else
do { \
} while (0)
#endif
#endif
#if OPENSSL_VERSION_NUMBER < 0x0090601fL
do { \
} while (0)
#elif defined(RSA_FLAG_NO_BLINDING)
do { \
} while (0)
#else
do { \
} while (0)
#endif
static isc_result_t
return (ISC_R_NOMEMORY);
} else {
return (ISC_R_NOMEMORY);
}
return (ISC_R_SUCCESS);
}
static void
}
} else {
}
}
}
static isc_result_t
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
isc_region_t r;
/* note: ISC_SHA1_DIGESTLENGTH > ISC_MD5_DIGESTLENGTH */
unsigned char digest[ISC_SHA1_DIGESTLENGTH];
unsigned int siglen = 0;
int status;
int type;
unsigned int digestlen;
char *message;
unsigned long err;
const char* file;
int line;
return (ISC_R_NOSPACE);
} else {
}
if (status == 0) {
if (err != 0U) {
}
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
}
return (ISC_R_SUCCESS);
}
static isc_result_t
/* note: ISC_SHA1_DIGESTLENGTH > ISC_MD5_DIGESTLENGTH */
unsigned char digest[ISC_SHA1_DIGESTLENGTH];
int status = 0;
int type;
unsigned int digestlen;
} else {
}
return (DST_R_VERIFYFAILURE);
if (status == 0)
return (dst__openssl_toresult(DST_R_VERIFYFAILURE));
return (ISC_R_SUCCESS);
}
static isc_boolean_t
int status;
return (ISC_TRUE);
return (ISC_FALSE);
if (status != 0)
return (ISC_FALSE);
return (ISC_FALSE);
if (status != 0)
return (ISC_FALSE);
}
return (ISC_TRUE);
}
#ifndef HAVE_RSA_GENERATE_KEY
/* ====================================================================
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
static RSA *
{
size_t i;
goto err;
/* The problem is when building with 8, 16, or 32 BN_ULONG,
* unsigned long can be larger */
for (i = 0; i < sizeof(unsigned long) * 8; i++) {
if ((e_value & (1UL<<i)) != 0)
BN_set_bit(e, i);
}
BN_free(e);
return (rsa);
}
err:
if (e != NULL)
BN_free(e);
return (NULL);
}
#endif
static isc_result_t
unsigned long e;
if (exp == 0)
e = RSA_3;
else
e = RSA_F4;
return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
return (ISC_R_SUCCESS);
}
static isc_boolean_t
}
static void
}
static isc_result_t
isc_region_t r;
unsigned int e_bytes;
unsigned int mod_bytes;
if (r.length < 1)
return (ISC_R_NOSPACE);
} else {
if (r.length < 3)
return (ISC_R_NOSPACE);
isc_buffer_putuint8(data, 0);
}
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
isc_region_t r;
unsigned int e_bytes;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (dst__openssl_toresult(ISC_R_NOMEMORY));
if (r.length < 1) {
return (DST_R_INVALIDPUBLICKEY);
}
r.length--;
if (e_bytes == 0) {
if (r.length < 2) {
return (DST_R_INVALIDPUBLICKEY);
}
r.length -= 2;
}
return (DST_R_INVALIDPUBLICKEY);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int i;
unsigned char *bufs[8];
return (DST_R_NULLKEY);
for (i = 0; i < 8; i++) {
goto fail;
}
}
i = 0;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
fail:
for (i = 0; i < 8; i++) {
break;
}
return (result);
}
static isc_result_t
int i;
/* read private key file */
if (ret != ISC_R_SUCCESS)
return (ret);
case TAG_RSA_MODULUS:
break;
case TAG_RSA_PUBLICEXPONENT:
break;
case TAG_RSA_PRIVATEEXPONENT:
break;
case TAG_RSA_PRIME1:
break;
case TAG_RSA_PRIME2:
break;
case TAG_RSA_EXPONENT1:
break;
case TAG_RSA_EXPONENT2:
break;
case TAG_RSA_COEFFICIENT:
break;
}
}
return (ISC_R_SUCCESS);
err:
return (ret);
}
static dst_func_t opensslrsa_functions = {
NULL, /*%< computesecret */
NULL, /*%< paramcompare */
NULL, /*%< cleanup */
};
return (ISC_R_SUCCESS);
}
#else /* OPENSSL */
#endif /* OPENSSL */
/*! \file */