Commit 38c34846 authored by Brian Wellington's avatar Brian Wellington
Browse files

Replace the internal dst__id_calc() with the visible dst_region_computeid().

parent 2b518b5f
......@@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.94 2000/07/27 09:45:47 tale Exp $
# $Id: Makefile.in,v 1.95 2000/07/31 19:44:12 bwelling Exp $
srcdir = @srcdir@
VPATH = @srcdir@
......@@ -45,8 +45,7 @@ CONFOBJS = config/confacl.@O@ config/confcache.@O@ config/confcommon.@O@ \
DSTOBJS = sec/dst/bsafe_link.@O@ sec/dst/dst_api.@O@ \
sec/dst/dst_parse.@O@ sec/dst/hmac_link.@O@ \
sec/dst/openssl_link.@O@ sec/dst/openssldh_link.@O@ \
sec/dst/dst_result.@O@ \
sec/dst/dst_support.@O@ sec/dst/dst_lib.@O@
sec/dst/dst_result.@O@ sec/dst/dst_lib.@O@
OPENSSLOBJS = sec/openssl/bn_add.@O@ sec/openssl/bn_asm.@O@ \
sec/openssl/bn_ctx.@O@ sec/openssl/bn_div.@O@ \
......
......@@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.13 2000/07/27 09:50:24 tale Exp $
# $Id: Makefile.in,v 1.14 2000/07/31 19:44:13 bwelling Exp $
srcdir = @srcdir@
VPATH = @srcdir@
......@@ -34,11 +34,11 @@ LIBS = @LIBS@
# Alphabetically
OBJS = bsafe_link.@O@ dst_api.@O@ dst_parse.@O@ hmac_link.@O@ \
openssl_link.@O@ openssldh_link.@O@ \
dst_result.@O@ dst_support.@O@ dst_lib.@O@
dst_result.@O@ dst_lib.@O@
SRCS = bsafe_link.c dst_api.c dst_parse.c hmac_link.c \
openssl_link.c openssldh_link.c \
dst_result.c dst_support.c dst_lib.c
dst_result.c dst_lib.c
SUBDIRS = include
TARGETS = ${OBJS}
......
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: dst_api.c,v 1.56 2000/06/12 18:05:10 bwelling Exp $
* $Id: dst_api.c,v 1.57 2000/07/31 19:44:14 bwelling Exp $
*/
#include <config.h>
......@@ -720,6 +720,30 @@ dst_key_secretsize(const dst_key_t *key, unsigned int *n) {
return (ISC_R_SUCCESS);
}
isc_uint16_t
dst_region_computeid(const isc_region_t *source) {
isc_uint32_t ac;
const unsigned char *p;
int size;
REQUIRE(source != NULL);
if (source->length == 0)
return (0);
p = source->base;
size = source->length;
for (ac = 0; size > 1; size -= 2, p += 2)
ac += ((*p) << 8) + *(p + 1);
if (size > 0)
ac += ((*p) << 8);
ac += (ac >> 16) & 0xffff;
return ((isc_uint16_t)(ac & 0xffff));
}
/***
*** Static methods
***/
......
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dst_internal.h,v 1.25 2000/06/22 21:56:36 tale Exp $ */
/* $Id: dst_internal.h,v 1.26 2000/07/31 19:44:15 bwelling Exp $ */
#ifndef DST_DST_INTERNAL_H
#define DST_DST_INTERNAL_H 1
......@@ -110,12 +110,6 @@ void dst__dnssafersa_destroy(void);
void dst__openssldsa_destroy(void);
void dst__openssldh_destroy(void);
/*
* Support functions.
*/
isc_uint16_t
dst__id_calc(const unsigned char *key, const int keysize);
/*
* Memory allocators using the DST memory pool.
*/
......
/*
* 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: dst_support.c,v 1.7 2000/06/09 20:58:35 gson Exp $
*/
#include <config.h>
#include <stdlib.h>
#include "dst_internal.h"
/*
* dst__id_calc
* Calculates the checksum used by DNS as a key id.
* Parameters
* key The key in DNS format
* length The length of the array
* Return
* N the 16 bit checksum.
*/
isc_uint16_t
dst__id_calc(const unsigned char *key, const int keysize) {
isc_uint32_t ac;
const unsigned char *kp = key;
int size = keysize;
if (key == NULL || (keysize <= 0))
return (-1);
for (ac = 0; size > 1; size -= 2, kp += 2)
ac += ((*kp) << 8) + *(kp + 1);
if (size > 0)
ac += ((*kp) << 8);
ac += (ac >> 16) & 0xffff;
return ((isc_uint16_t)(ac & 0xffff));
}
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: hmac_link.c,v 1.40 2000/07/18 18:15:27 bwelling Exp $
* $Id: hmac_link.c,v 1.41 2000/07/31 19:44:18 bwelling Exp $
*/
#include <config.h>
......@@ -208,8 +208,10 @@ hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data) {
memcpy(hkey->key, r.base, r.length);
keylen = r.length;
}
key->key_id = dst__id_calc(hkey->key, keylen);
r.base = hkey->key;
r.length = keylen;
key->key_id = dst_region_computeid(&r);
key->key_size = keylen * 8;
key->opaque = hkey;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dst.h,v 1.32 2000/07/27 09:50:30 tale Exp $ */
/* $Id: dst.h,v 1.33 2000/07/31 19:44:21 bwelling Exp $ */
#ifndef DST_DST_H
#define DST_DST_H 1
......@@ -492,6 +492,18 @@ dst_key_secretsize(const dst_key_t *key, unsigned int *n);
* "n" stores the size of a generated shared secret
*/
isc_uint16_t
dst_region_computeid(const isc_region_t *source);
/*
* Computes the key id of the key stored in the provided region.
*
* Requires:
* "source" contains a valid, non-NULL region.
*
* Returns:
* the key id
*/
ISC_LANG_ENDDECLS
#endif /* DST_DST_H */
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: openssl_link.c,v 1.31 2000/06/12 18:05:13 bwelling Exp $
* $Id: openssl_link.c,v 1.32 2000/07/31 19:44:19 bwelling Exp $
*/
#if defined(OPENSSL)
......@@ -210,7 +210,7 @@ openssldsa_generate(dst_key_t *key, int unused) {
return (result);
}
isc_buffer_usedregion(&dns, &r);
key->key_id = dst__id_calc(r.base, r.length);
key->key_id = dst_region_computeid(&r);
return (ISC_R_SUCCESS);
}
......@@ -307,8 +307,7 @@ openssldsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
r.base += p_bytes;
isc_buffer_remainingregion(data, &r);
key->key_id = dst__id_calc(r.base, 1 + ISC_SHA1_DIGESTLENGTH +
3 * p_bytes);
key->key_id = dst_region_computeid(&r);
key->key_size = p_bytes * 8;
isc_buffer_forward(data, 1 + ISC_SHA1_DIGESTLENGTH + 3 * p_bytes);
......@@ -421,7 +420,7 @@ openssldsa_fromfile(dst_key_t *key, const isc_uint16_t id, const char *filename)
if (ret != ISC_R_SUCCESS)
DST_RET(ret);
isc_buffer_usedregion(&dns, &r);
key->key_id = dst__id_calc(r.base, r.length);
key->key_id = dst_region_computeid(&r);
if (key->key_id != id)
DST_RET(DST_R_INVALIDPRIVATEKEY);
......
......@@ -19,7 +19,7 @@
/*
* Principal Author: Brian Wellington
* $Id: openssldh_link.c,v 1.25 2000/06/12 18:05:15 bwelling Exp $
* $Id: openssldh_link.c,v 1.26 2000/07/31 19:44:20 bwelling Exp $
*/
#if defined(OPENSSL)
......@@ -171,7 +171,7 @@ openssldh_generate(dst_key_t *key, int generator) {
return (result);
}
isc_buffer_usedregion(&dns, &r);
key->key_id = dst__id_calc(r.base, r.length);
key->key_id = dst_region_computeid(&r);
return (ISC_R_SUCCESS);
}
......@@ -369,7 +369,7 @@ openssldh_fromdns(dst_key_t *key, isc_buffer_t *data) {
r.base += publen;
isc_buffer_remainingregion(data, &r);
key->key_id = dst__id_calc(r.base, plen + glen + publen + 6);
key->key_id = dst_region_computeid(&r);
key->key_size = BN_num_bits(dh->p);
isc_buffer_forward(data, plen + glen + publen + 6);
......@@ -491,7 +491,7 @@ openssldh_fromfile(dst_key_t *key, const isc_uint16_t id, const char *filename)
if (ret != ISC_R_SUCCESS)
DST_RET(ret);
isc_buffer_usedregion(&dns, &r);
key->key_id = dst__id_calc(r.base, r.length);
key->key_id = dst_region_computeid(&r);
if (key->key_id != id)
DST_RET(DST_R_INVALIDPRIVATEKEY);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment