/*
* Portions Copyright (C) 2004-2012 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.
*/
/*%
* Principal Author: Brian Wellington
* $Id$
*/
#include <config.h>
#include <isc/fsaccess.h>
#include "dst_internal.h"
#include "dst_parse.h"
struct parse_map {
const int value;
const char *tag;
};
{TAG_RSA_MODULUS, "Modulus:"},
{TAG_RSA_PUBLICEXPONENT, "PublicExponent:"},
{TAG_RSA_PRIVATEEXPONENT, "PrivateExponent:"},
{TAG_RSA_PRIME1, "Prime1:"},
{TAG_RSA_PRIME2, "Prime2:"},
{TAG_RSA_EXPONENT1, "Exponent1:"},
{TAG_RSA_EXPONENT2, "Exponent2:"},
{TAG_RSA_COEFFICIENT, "Coefficient:"},
{TAG_RSA_ENGINE, "Engine:" },
{TAG_RSA_LABEL, "Label:" },
{TAG_RSA_PIN, "PIN:" },
{TAG_DH_PRIME, "Prime(p):"},
{TAG_DH_GENERATOR, "Generator(g):"},
{TAG_DH_PRIVATE, "Private_value(x):"},
{TAG_DH_PUBLIC, "Public_value(y):"},
{TAG_DSA_PRIME, "Prime(p):"},
{TAG_DSA_SUBPRIME, "Subprime(q):"},
{TAG_DSA_BASE, "Base(g):"},
{TAG_DSA_PRIVATE, "Private_value(x):"},
{TAG_DSA_PUBLIC, "Public_value(y):"},
{TAG_HMACMD5_KEY, "Key:"},
{TAG_HMACMD5_BITS, "Bits:"},
{TAG_HMACSHA1_KEY, "Key:"},
{TAG_HMACSHA1_BITS, "Bits:"},
{TAG_HMACSHA224_KEY, "Key:"},
{TAG_HMACSHA224_BITS, "Bits:"},
{TAG_HMACSHA256_KEY, "Key:"},
{TAG_HMACSHA256_BITS, "Bits:"},
{TAG_HMACSHA384_KEY, "Key:"},
{TAG_HMACSHA384_BITS, "Bits:"},
{TAG_HMACSHA512_KEY, "Key:"},
{TAG_HMACSHA512_BITS, "Bits:"},
{0, NULL}
};
static int
int i;
for (i = 0; ; i++) {
return (-1);
}
}
static const char *
int i;
for (i = 0; ; i++) {
return (NULL);
}
}
static int
int i, j;
unsigned int mask;
for (i = 0; i < RSA_NTAGS; i++)
for (i = 0; i < RSA_NTAGS; i++)
break;
if (i == RSA_NTAGS)
return (-1);
}
mask = ~0;
else
return (ok ? 0 : -1 );
}
static int
int i, j;
return (-1);
for (i = 0; i < DH_NTAGS; i++) {
break;
return (-1);
}
return (0);
}
static int
int i, j;
return (-1);
for (i = 0; i < DSA_NTAGS; i++) {
break;
return (-1);
}
return (0);
}
static int
int i, j;
/*
* If this is a good old format and we are accepting
* the old format return success.
*/
return (0);
return (-1);
}
/*
* We must be new format at this point.
*/
for (i = 0; i < HMACMD5_NTAGS; i++) {
break;
return (-1);
}
return (0);
}
static int
unsigned int alg)
{
unsigned int i, j;
return (-1);
for (i = 0; i < ntags; i++) {
break;
return (-1);
}
return (0);
}
static int
{
/* XXXVIX this switch statement is too sparse to gen a jump table. */
switch (alg) {
case DST_ALG_RSAMD5:
case DST_ALG_RSASHA1:
case DST_ALG_NSEC3RSASHA1:
case DST_ALG_RSASHA256:
case DST_ALG_RSASHA512:
case DST_ALG_DH:
case DST_ALG_DSA:
case DST_ALG_NSEC3DSA:
case DST_ALG_HMACMD5:
case DST_ALG_HMACSHA1:
case DST_ALG_HMACSHA224:
case DST_ALG_HMACSHA256:
case DST_ALG_HMACSHA384:
case DST_ALG_HMACSHA512:
default:
return (DST_R_UNSUPPORTEDALG);
}
}
void
int i;
return;
continue;
}
}
int
{
isc_buffer_t b;
do { \
if (ret != ISC_R_SUCCESS) \
goto fail; \
} while (0)
do { \
break; \
else if (ret != ISC_R_SUCCESS) \
goto fail; \
/*
* Read the description line.
*/
{
goto fail;
}
{
goto fail;
}
{
goto fail;
}
if (major > MAJOR_VERSION ||
{
goto fail;
}
/*
* Read the algorithm line.
*/
{
goto fail;
}
{
goto fail;
}
/*
* Read the key data.
*/
for (n = 0; n < MAXFIELDS; n++) {
int tag;
isc_region_t r;
do {
goto done;
if (ret != ISC_R_SUCCESS)
goto fail;
goto fail;
}
goto fail;
}
goto fail;
if (ret != ISC_R_SUCCESS)
goto fail;
isc_buffer_usedregion(&b, &r);
}
done:
if (check < 0) {
goto fail;
} else if (check != ISC_R_SUCCESS) {
goto fail;
}
return (ISC_R_SUCCESS);
fail:
return (ret);
}
int
const char *directory)
{
int ret, i;
isc_buffer_t b;
if (ret < 0)
return (DST_R_INVALIDPRIVATEKEY);
else if (ret != ISC_R_SUCCESS)
return (ret);
if (result != ISC_R_SUCCESS)
return (result);
return (DST_R_WRITEERROR);
access = 0;
&access);
/* XXXDCL return value should be checked for full filesystem */
/* XXXVIX this switch statement is too sparse to gen a jump table. */
switch (dst_key_alg(key)) {
case DST_ALG_RSAMD5:
break;
case DST_ALG_DH:
break;
case DST_ALG_DSA:
break;
case DST_ALG_RSASHA1:
break;
case DST_ALG_NSEC3DSA:
break;
case DST_ALG_NSEC3RSASHA1:
break;
case DST_ALG_RSASHA256:
break;
case DST_ALG_RSASHA512:
break;
case DST_ALG_HMACMD5:
break;
case DST_ALG_HMACSHA1:
break;
case DST_ALG_HMACSHA224:
break;
case DST_ALG_HMACSHA256:
break;
case DST_ALG_HMACSHA384:
break;
case DST_ALG_HMACSHA512:
break;
default:
break;
}
isc_buffer_t b;
isc_region_t r;
const char *s;
if (result != ISC_R_SUCCESS) {
return (DST_R_INVALIDPRIVATEKEY);
}
isc_buffer_usedregion(&b, &r);
}
return (result);
}
/*! \file */