hmac_link.c revision 8688e7005afed694ca129d00d3cd73b32828804b
/*
* Portions Copyright (C) 1999-2002, 2004-2017 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* 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: hmac_link.c,v 1.19 2011/01/11 23:47:13 tbox Exp $
*/
#include <config.h>
#include "dst_internal.h"
#include "dst_parse.h"
#ifndef PK11_MD5_DISABLE
struct dst_hmacmd5_key {
unsigned char key[ISC_MD5_BLOCK_LENGTH];
};
#endif
static isc_result_t
return (DST_R_INVALIDPRIVATEKEY);
return (ISC_R_SUCCESS);
}
#ifndef PK11_MD5_DISABLE
static isc_result_t
if (hmacmd5ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static void
if (hmacmd5ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *digest;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (DST_R_VERIFYFAILURE);
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
else
return (ISC_FALSE);
}
static isc_result_t
isc_buffer_t b;
unsigned int bytes;
unsigned char data[ISC_MD5_BLOCK_LENGTH];
if (bytes > ISC_MD5_BLOCK_LENGTH) {
}
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_add(&b, bytes);
return (ret);
}
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static isc_result_t
unsigned int bytes;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int keylen;
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (r.length > ISC_MD5_BLOCK_LENGTH) {
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
unsigned char buf[2];
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
}
static isc_result_t
isc_buffer_t b;
unsigned int i;
/* read private key file */
&priv);
if (result != ISC_R_SUCCESS)
return (result);
case TAG_HMACMD5_KEY:
if (tresult != ISC_R_SUCCESS)
break;
case TAG_HMACMD5_BITS:
if (tresult != ISC_R_SUCCESS)
break;
default:
break;
}
}
return (result);
}
static dst_func_t hmacmd5_functions = {
NULL, /*%< createctx2 */
NULL, /*%< verify2 */
NULL, /*%< computesecret */
NULL, /*%< paramcompare */
NULL, /*%< cleanup */
NULL, /*%< fromlabel */
NULL, /*%< dump */
NULL, /*%< restore */
};
*funcp = &hmacmd5_functions;
return (ISC_R_SUCCESS);
}
#endif
struct dst_hmacsha1_key {
unsigned char key[ISC_SHA1_BLOCK_LENGTH];
};
static isc_result_t
if (hmacsha1ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static void
if (hmacsha1ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *digest;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (DST_R_VERIFYFAILURE);
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
else
return (ISC_FALSE);
}
static isc_result_t
isc_buffer_t b;
unsigned int bytes;
unsigned char data[ISC_SHA1_BLOCK_LENGTH];
if (bytes > ISC_SHA1_BLOCK_LENGTH) {
}
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_add(&b, bytes);
return (ret);
}
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static isc_result_t
unsigned int bytes;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int keylen;
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (r.length > ISC_SHA1_BLOCK_LENGTH) {
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
unsigned char buf[2];
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
}
static isc_result_t
isc_buffer_t b;
unsigned int i;
/* read private key file */
&priv);
if (result != ISC_R_SUCCESS)
return (result);
case TAG_HMACSHA1_KEY:
if (tresult != ISC_R_SUCCESS)
break;
case TAG_HMACSHA1_BITS:
if (tresult != ISC_R_SUCCESS)
break;
default:
break;
}
}
return (result);
}
static dst_func_t hmacsha1_functions = {
NULL, /*%< createctx2 */
NULL, /* verify2 */
NULL, /* computesecret */
NULL, /* paramcompare */
NULL, /* cleanup */
NULL, /* fromlabel */
NULL, /* dump */
NULL, /* restore */
};
*funcp = &hmacsha1_functions;
return (ISC_R_SUCCESS);
}
struct dst_hmacsha224_key {
unsigned char key[ISC_SHA224_BLOCK_LENGTH];
};
static isc_result_t
if (hmacsha224ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static void
if (hmacsha224ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *digest;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (DST_R_VERIFYFAILURE);
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
else
return (ISC_FALSE);
}
static isc_result_t
void (*callback)(int))
{
isc_buffer_t b;
unsigned int bytes;
unsigned char data[ISC_SHA224_BLOCK_LENGTH];
if (bytes > ISC_SHA224_BLOCK_LENGTH) {
}
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_add(&b, bytes);
return (ret);
}
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static isc_result_t
unsigned int bytes;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int keylen;
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (r.length > ISC_SHA224_BLOCK_LENGTH) {
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
unsigned char buf[2];
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
}
static isc_result_t
isc_buffer_t b;
unsigned int i;
/* read private key file */
&priv);
if (result != ISC_R_SUCCESS)
return (result);
case TAG_HMACSHA224_KEY:
if (tresult != ISC_R_SUCCESS)
break;
case TAG_HMACSHA224_BITS:
if (tresult != ISC_R_SUCCESS)
break;
default:
break;
}
}
return (result);
}
static dst_func_t hmacsha224_functions = {
NULL, /*%< createctx2 */
NULL, /* verify2 */
NULL, /* computesecret */
NULL, /* paramcompare */
NULL, /* cleanup */
NULL, /* fromlabel */
NULL, /* dump */
NULL, /* restore */
};
return (ISC_R_SUCCESS);
}
struct dst_hmacsha256_key {
unsigned char key[ISC_SHA256_BLOCK_LENGTH];
};
static isc_result_t
if (hmacsha256ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static void
if (hmacsha256ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *digest;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (DST_R_VERIFYFAILURE);
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
else
return (ISC_FALSE);
}
static isc_result_t
void (*callback)(int))
{
isc_buffer_t b;
unsigned int bytes;
unsigned char data[ISC_SHA256_BLOCK_LENGTH];
if (bytes > ISC_SHA256_BLOCK_LENGTH) {
}
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_add(&b, bytes);
return (ret);
}
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static isc_result_t
unsigned int bytes;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int keylen;
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (r.length > ISC_SHA256_BLOCK_LENGTH) {
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
unsigned char buf[2];
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
}
static isc_result_t
isc_buffer_t b;
unsigned int i;
/* read private key file */
&priv);
if (result != ISC_R_SUCCESS)
return (result);
case TAG_HMACSHA256_KEY:
if (tresult != ISC_R_SUCCESS)
break;
case TAG_HMACSHA256_BITS:
if (tresult != ISC_R_SUCCESS)
break;
default:
break;
}
}
return (result);
}
static dst_func_t hmacsha256_functions = {
NULL, /*%< createctx2 */
NULL, /* verify2 */
NULL, /* computesecret */
NULL, /* paramcompare */
NULL, /* cleanup */
NULL, /* fromlabel */
NULL, /* dump */
NULL, /* restore */
};
return (ISC_R_SUCCESS);
}
struct dst_hmacsha384_key {
unsigned char key[ISC_SHA384_BLOCK_LENGTH];
};
static isc_result_t
if (hmacsha384ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static void
if (hmacsha384ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *digest;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (DST_R_VERIFYFAILURE);
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
else
return (ISC_FALSE);
}
static isc_result_t
void (*callback)(int))
{
isc_buffer_t b;
unsigned int bytes;
unsigned char data[ISC_SHA384_BLOCK_LENGTH];
if (bytes > ISC_SHA384_BLOCK_LENGTH) {
}
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_add(&b, bytes);
return (ret);
}
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static isc_result_t
unsigned int bytes;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int keylen;
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (r.length > ISC_SHA384_BLOCK_LENGTH) {
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
unsigned char buf[2];
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
}
static isc_result_t
isc_buffer_t b;
unsigned int i;
/* read private key file */
&priv);
if (result != ISC_R_SUCCESS)
return (result);
case TAG_HMACSHA384_KEY:
if (tresult != ISC_R_SUCCESS)
break;
case TAG_HMACSHA384_BITS:
if (tresult != ISC_R_SUCCESS)
break;
default:
break;
}
}
return (result);
}
static dst_func_t hmacsha384_functions = {
NULL, /*%< createctx2 */
NULL, /* verify2 */
NULL, /* computesecret */
NULL, /* paramcompare */
NULL, /* cleanup */
NULL, /* fromlabel */
NULL, /* dump */
NULL, /* restore */
};
return (ISC_R_SUCCESS);
}
struct dst_hmacsha512_key {
unsigned char key[ISC_SHA512_BLOCK_LENGTH];
};
static isc_result_t
if (hmacsha512ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static void
if (hmacsha512ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *digest;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (DST_R_VERIFYFAILURE);
return (ISC_R_SUCCESS);
else
return (DST_R_VERIFYFAILURE);
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
else
return (ISC_FALSE);
}
static isc_result_t
void (*callback)(int))
{
isc_buffer_t b;
unsigned int bytes;
unsigned char data[ISC_SHA512_BLOCK_LENGTH];
if (bytes > ISC_SHA512_BLOCK_LENGTH) {
}
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_add(&b, bytes);
return (ret);
}
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static isc_result_t
unsigned int bytes;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int keylen;
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (r.length > ISC_SHA512_BLOCK_LENGTH) {
} else {
}
return (ISC_R_SUCCESS);
}
static isc_result_t
int cnt = 0;
unsigned char buf[2];
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
}
static isc_result_t
isc_buffer_t b;
unsigned int i;
/* read private key file */
&priv);
if (result != ISC_R_SUCCESS)
return (result);
case TAG_HMACSHA512_KEY:
if (tresult != ISC_R_SUCCESS)
break;
case TAG_HMACSHA512_BITS:
if (tresult != ISC_R_SUCCESS)
break;
default:
break;
}
}
return (result);
}
static dst_func_t hmacsha512_functions = {
NULL, /*%< createctx2 */
NULL, /* verify2 */
NULL, /* computesecret */
NULL, /* paramcompare */
NULL, /* cleanup */
NULL, /* fromlabel */
NULL, /* dump */
NULL, /* restore */
};
return (ISC_R_SUCCESS);
}
/*! \file */