From d7483d67f7aa8f80d5f880aa4650f2bdb90d6623 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Wed, 17 Jan 2001 00:33:37 +0000 Subject: [PATCH] Move dst_region_computeid into a new file dst/keyid.c, so that all of the dnssec code doesn't need to be linked in by using rdata routines. --- lib/dns/Makefile.in | 6 +++--- lib/dns/sec/dst/Makefile.in | 8 +++++--- lib/dns/sec/dst/dst_api.c | 29 +---------------------------- lib/dns/sec/dst/keyid.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 34 deletions(-) create mode 100644 lib/dns/sec/dst/keyid.c diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in index fc88349abf..a64e8c0ec2 100644 --- a/lib/dns/Makefile.in +++ b/lib/dns/Makefile.in @@ -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.118 2001/01/09 21:50:34 bwelling Exp $ +# $Id: Makefile.in,v 1.119 2001/01/17 00:33:33 bwelling Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -51,8 +51,8 @@ CONFOBJS = config/confacl.@O@ config/confcache.@O@ config/confcommon.@O@ \ DSTOBJS = sec/dst/dst_api.@O@ \ sec/dst/dst_lib.@O@ sec/dst/dst_parse.@O@ \ sec/dst/dst_result.@O@ sec/dst/gssapi_link.@O@ \ - sec/dst/hmac_link.@O@ sec/dst/openssl_link.@O@ \ - sec/dst/gssapictx.@O@ \ + sec/dst/gssapictx.@O@ sec/dst/hmac_link.@O@ \ + sec/dst/keyid.@O@ sec/dst/openssl_link.@O@ \ sec/dst/openssldh_link.@O@ sec/dst/opensslrsa_link.@O@ OPENSSLOBJS = sec/openssl/a_bitstr.@O@ sec/openssl/a_bytes.@O@ \ diff --git a/lib/dns/sec/dst/Makefile.in b/lib/dns/sec/dst/Makefile.in index 3f2634b049..20e10f6984 100644 --- a/lib/dns/sec/dst/Makefile.in +++ b/lib/dns/sec/dst/Makefile.in @@ -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.20 2001/01/09 21:55:26 bwelling Exp $ +# $Id: Makefile.in,v 1.21 2001/01/17 00:33:34 bwelling Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -33,11 +33,13 @@ LIBS = @LIBS@ # Alphabetically OBJS = dst_api.@O@ dst_lib.@O@ dst_parse.@O@ \ - dst_result.@O@ gssapi_link.@O@ gssapictx.@O@ hmac_link.@O@ \ + dst_result.@O@ gssapi_link.@O@ gssapictx.@O@ \ + hmac_link.@O@ keyid.@O@ \ openssl_link.@O@ openssldh_link.@O@ opensslrsa_link.@O@ SRCS = dst_api.c dst_lib.c dst_parse.c \ - dst_result.c gssapi_link.c gssapictx.c hmac_link.c \ + dst_result.c gssapi_link.c gssapictx.c \ + hmac_link.c keyid.c \ openssl_link.c openssldh_link.c opensslrsa_link.c SUBDIRS = include diff --git a/lib/dns/sec/dst/dst_api.c b/lib/dns/sec/dst/dst_api.c index 85796d3230..27addf4e8f 100644 --- a/lib/dns/sec/dst/dst_api.c +++ b/lib/dns/sec/dst/dst_api.c @@ -19,7 +19,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.69 2001/01/09 21:55:27 bwelling Exp $ + * $Id: dst_api.c,v 1.70 2001/01/17 00:33:36 bwelling Exp $ */ #include @@ -762,33 +762,6 @@ 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, const unsigned int alg) { - isc_uint32_t ac; - const unsigned char *p; - int size; - - REQUIRE(source != NULL); - - if (source->length < 4) - return (0); - - p = source->base; - size = source->length; - - if (alg == DST_ALG_RSAMD5) - return ((p[size - 3] << 8) + p[size - 2]); - - 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 ***/ diff --git a/lib/dns/sec/dst/keyid.c b/lib/dns/sec/dst/keyid.c new file mode 100644 index 0000000000..c1152585b2 --- /dev/null +++ b/lib/dns/sec/dst/keyid.c @@ -0,0 +1,33 @@ +#include + +#include +#include + +#include + +isc_uint16_t +dst_region_computeid(const isc_region_t *source, const unsigned int alg) { + isc_uint32_t ac; + const unsigned char *p; + int size; + + REQUIRE(source != NULL); + + if (source->length < 4) + return (0); + + p = source->base; + size = source->length; + + if (alg == DST_ALG_RSAMD5) + return ((p[size - 3] << 8) + p[size - 2]); + + 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)); +}