bsafe_link.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
/*
* Portions Copyright (C) 1999, 2000 Internet Software Consortium.
* Portions Copyright (C) 1995-2000 by Network Associates, Inc.
*
* 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 INTERNET SOFTWARE CONSORTIUM AND
* NETWORK ASSOCIATES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE CONSORTIUM OR NETWORK
* ASSOCIATES 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: bsafe_link.c,v 1.33 2000/08/01 01:27:44 tale Exp $
*/
#if defined(DNSSAFE)
#include <config.h>
#include <dns/keyvalues.h>
#include "dst_internal.h"
#include "dst_parse.h"
#include <global.h>
#include <bsafe2.h>
typedef struct dnssafekey {
} RSA_Key;
#define MAX_RSA_MODULUS_BITS 2048
static B_ALGORITHM_METHOD *CHOOSER[] =
{
&AM_MD5,
};
static unsigned char pkcs1[] =
{
0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,
0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
};
static isc_result_t
return (ISC_R_SUCCESS);
}
static void
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char digest[ISC_MD5_DIGESTLENGTH];
unsigned int written = 0;
return (ISC_R_NOSPACE);
if (!dnssafersa_isprivate(key))
return (DST_R_NOTPRIVATEKEY);
if (B_CreateAlgorithmObject(&rsaEncryptor) != 0)
return (ISC_R_NOMEMORY);
!= 0)
goto finalfail;
NULL_SURRENDER) != 0)
goto finalfail;
written = 0;
NULL_PTR, NULL_SURRENDER) != 0)
goto finalfail;
if (written > 0) {
written = 0;
}
NULL_PTR, NULL_SURRENDER) != 0)
goto finalfail;
if (written > 0) {
written = 0;
}
NULL_SURRENDER) != 0)
goto finalfail;
return (ISC_R_SUCCESS);
return (DST_R_SIGNFAILURE);
}
static isc_result_t
unsigned char digest[ISC_MD5_DIGESTLENGTH];
unsigned int written = 0;
if (B_CreateAlgorithmObject(&rsaEncryptor) != 0)
return (ISC_R_NOMEMORY);
goto finalfail;
CHOOSER, NULL_SURRENDER) != 0)
goto finalfail;
NULL_PTR, NULL_SURRENDER) != 0)
goto finalfail;
if (written > 0) {
written = 0;
}
NULL_SURRENDER) != 0)
goto finalfail;
if (written > 0)
/*
* Skip PKCS#1 header in output from Decrypt function.
*/
sizeof(digest)) == 0)
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_FALSE);
else
return (ISC_TRUE);
}
static isc_boolean_t
int status;
return (ISC_TRUE);
return (ISC_FALSE);
if (rkey1->rk_Public_Key)
if (rkey2->rk_Public_Key)
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
}
return (ISC_TRUE);
}
static isc_result_t
char exponent[4];
int exponent_len = 0;
unsigned char randomSeed[256];
int entropylen;
isc_buffer_t b;
return (ISC_R_NOMEMORY);
if (B_CreateAlgorithmObject(&keypairGenerator) != 0)
/*
* exp = 0 or 1 are special (mean 3 or F4).
*/
if (exp == 0)
exp = 3;
else if (exp == 1)
exp = 65537;
/*
* Now encode the exponent and its length.
*/
if (exp < 256) {
exponent_len = 1;
exponent_len = 2;
exponent_len = 3;
} else {
exponent_len = 4;
}
(POINTER)&keygenParams) != 0)
if (B_CreateKeyObject(&public) != 0)
if (B_CreateKeyObject(&private) != 0)
if (B_CreateAlgorithmObject(&randomAlgorithm) != 0)
NULL_PTR) != 0)
if (ret != ISC_R_SUCCESS)
goto fail;
NULL_SURRENDER) != 0)
randomAlgorithm, NULL_SURRENDER) != 0)
/*
* Fill in the footprint in generate key.
*/
isc_buffer_add(&b, 2);
return (ISC_R_SUCCESS);
fail:
}
}
if (keypairGenerator != NULL)
if (randomAlgorithm != NULL)
return (ret);
}
static isc_boolean_t
}
static void
}
static isc_result_t
isc_region_t r;
return (DST_R_INVALIDPUBLICKEY);
return (ISC_R_NOSPACE);
} else { /* key exponent is > 2040 bits */
return (ISC_R_NOSPACE);
isc_buffer_putuint8(data, 0);
}
return (ISC_R_SUCCESS);
}
static int
else
}
static isc_result_t
unsigned int bytes;
isc_region_t r;
isc_buffer_t b;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
}
/*
* Length of exponent in bytes.
*/
if (bytes == 0) /* special case for long exponents */
if (bytes > MAX_RSA_MODULUS_LEN) {
return (DST_R_INVALIDPUBLICKEY);
}
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
}
return (ISC_R_NOMEMORY);
}
if (r.length > MAX_RSA_MODULUS_LEN) {
return (ISC_R_NOMEMORY);
}
return (ISC_R_NOMEMORY);
}
!= 0)
return (DST_R_INVALIDPUBLICKEY);
isc_buffer_add(&b, 2);
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
return (DST_R_NULLKEY);
}
static isc_result_t
const char *filename) {
isc_buffer_t b;
int i;
/*
* Read private key file.
*/
if (ret != ISC_R_SUCCESS)
return (ret);
/*
* Allocate key.
*/
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;
}
}
isc_buffer_add(&b, 2);
!= 0)
err:
}
}
}
return (ret);
}
static dst_func_t dnssafersa_functions = {
NULL, /* computesecret */
NULL, /* paramcompare */
};
return (ISC_R_SUCCESS);
}
void
dst__dnssafersa_destroy(void) {
}
/*
* define memory functions for dnssafe that use the isc_mem functions and a
* static context.
*/
void
}
return (dst__mem_alloc(len));
}
int
}
void
}
void
}
void
}
}
#endif /* DNSSAFE */