]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace the internal dst__id_calc() with the visible dst_region_computeid().
authorBrian Wellington <source@isc.org>
Mon, 31 Jul 2000 19:44:21 +0000 (19:44 +0000)
committerBrian Wellington <source@isc.org>
Mon, 31 Jul 2000 19:44:21 +0000 (19:44 +0000)
lib/dns/Makefile.in
lib/dns/sec/dst/Makefile.in
lib/dns/sec/dst/dst_api.c
lib/dns/sec/dst/dst_internal.h
lib/dns/sec/dst/dst_support.c [deleted file]
lib/dns/sec/dst/hmac_link.c
lib/dns/sec/dst/include/dst/dst.h
lib/dns/sec/dst/openssl_link.c
lib/dns/sec/dst/openssldh_link.c

index 24779452c44cd2442c4cb348c812c6b5ab269ecf..a939f54648edf9f88099fa46ff2ff3f4060ff07a 100644 (file)
@@ -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@ \
index 28aa24b49b57dd43806365e6752c6039a7bbf06d..4f79fc67af6fc2d908e90f9f835302e115f2a87a 100644 (file)
@@ -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}
index 9676defc62951f1e3bf4b2b8487926b34b32054c..c779d0bccfd5a744b243124c7c9f765b5ff61b99 100644 (file)
@@ -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
  ***/
index 007c8d02539509b55862731466298b71ece89065..cd1091fa57fef13c724a07732d5f9d2a135cb5d7 100644 (file)
@@ -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.
  */
diff --git a/lib/dns/sec/dst/dst_support.c b/lib/dns/sec/dst/dst_support.c
deleted file mode 100644 (file)
index 690fc01..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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));
-}
index 19f26b23842b839ab29aceae4eee609afe52cf39..84c650c4db7921b78b658be91a0fc2695b639c1a 100644 (file)
@@ -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;
 
index 5c15fa879d71c5852bc6ca7ae69d05f8441ddbcc..3acac4c7e6fd04e8c9e9d398ccbd2baa1b7aa06a 100644 (file)
@@ -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 */
index 61689c7bdf0e5bc23130851c62165b9c07913f5f..13bfe16eb542095d185b94e267d8ce00f88da2e0 100644 (file)
@@ -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);
index 915cacd0129e7bd9153bc8d9ecd275b374c78015..b71ec55f283bdef8b6505b54f8e07ce6ee686866 100644 (file)
@@ -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);