]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove unused isc_lfsr API
authorOndřej Surý <ondrej@isc.org>
Thu, 23 Apr 2020 10:16:22 +0000 (12:16 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 23 Apr 2020 10:16:22 +0000 (12:16 +0200)
The isc_lfsr API was used to generate message IDs in the past.
Currently, it's just cruft.

lib/isc/Makefile.am
lib/isc/include/isc/lfsr.h [deleted file]
lib/isc/lfsr.c [deleted file]
lib/isc/win32/libisc.def.in
lib/isc/win32/libisc.vcxproj.filters.in
lib/isc/win32/libisc.vcxproj.in
util/copyrights

index cb6d6b7d77f69b6e6e7f13baa9f28decc5758b57..83dd5acf2de5d4393c0f53e506de7f4ded5960e2 100644 (file)
@@ -41,7 +41,6 @@ libisc_la_HEADERS =                   \
        include/isc/iterated_hash.h     \
        include/isc/lang.h              \
        include/isc/lex.h               \
-       include/isc/lfsr.h              \
        include/isc/lib.h               \
        include/isc/likely.h            \
        include/isc/list.h              \
@@ -173,7 +172,6 @@ libisc_la_SOURCES =         \
        httpd.c                 \
        iterated_hash.c         \
        lex.c                   \
-       lfsr.c                  \
        lib.c                   \
        log.c                   \
        md.c                    \
diff --git a/lib/isc/include/isc/lfsr.h b/lib/isc/include/isc/lfsr.h
deleted file mode 100644 (file)
index 5e3947a..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 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/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef ISC_LFSR_H
-#define ISC_LFSR_H 1
-
-/*! \file isc/lfsr.h */
-
-#include <inttypes.h>
-
-#include <isc/lang.h>
-#include <isc/types.h>
-
-typedef struct isc_lfsr isc_lfsr_t;
-
-/*%
- * This function is called when reseeding is needed.  It is allowed to
- * modify any state in the LFSR in any way it sees fit OTHER THAN "bits".
- *
- * It MUST set "count" to a new value or the lfsr will never reseed again.
- *
- * Also, a reseed will never occur in the middle of an extraction.  This
- * is purely an optimization, and is probably what one would want.
- */
-typedef void (*isc_lfsrreseed_t)(isc_lfsr_t *, void *);
-
-/*%
- * The members of this structure can be used by the application, but care
- * needs to be taken to not change state once the lfsr is in operation.
- */
-struct isc_lfsr {
-       uint32_t         state;  /*%< previous state */
-       unsigned int     bits;   /*%< length */
-       uint32_t         tap;    /*%< bit taps */
-       unsigned int     count;  /*%< reseed count (in BITS!) */
-       isc_lfsrreseed_t reseed; /*%< reseed function */
-       void *           arg;    /*%< reseed function argument */
-};
-
-ISC_LANG_BEGINDECLS
-
-void
-isc_lfsr_init(isc_lfsr_t *lfsr, uint32_t state, unsigned int bits, uint32_t tap,
-             unsigned int count, isc_lfsrreseed_t reseed, void *arg);
-/*%<
- * Initialize an LFSR.
- *
- * Note:
- *
- *\li  Putting untrusted values into this function will cause the LFSR to
- *     generate (perhaps) non-maximal length sequences.
- *
- * Requires:
- *
- *\li  lfsr != NULL
- *
- *\li  8 <= bits <= 32
- *
- *\li  tap != 0
- */
-
-void
-isc_lfsr_generate(isc_lfsr_t *lfsr, void *data, unsigned int count);
-/*%<
- * Returns "count" bytes of data from the LFSR.
- *
- * Requires:
- *
- *\li  lfsr be valid.
- *
- *\li  data != NULL.
- *
- *\li  count > 0.
- */
-
-void
-isc_lfsr_skip(isc_lfsr_t *lfsr, unsigned int skip);
-/*%<
- * Skip "skip" states.
- *
- * Requires:
- *
- *\li  lfsr be valid.
- */
-
-uint32_t
-isc_lfsr_generate32(isc_lfsr_t *lfsr1, isc_lfsr_t *lfsr2);
-/*%<
- * Given two LFSRs, use the current state from each to skip entries in the
- * other.  The next states are then xor'd together and returned.
- *
- * WARNING:
- *
- *\li  This function is used only for very, very low security data, such
- *     as DNS message IDs where it is desired to have an unpredictable
- *     stream of bytes that are harder to predict than a simple flooding
- *     attack.
- *
- * Notes:
- *
- *\li  Since the current state from each of the LFSRs is used to skip
- *     state in the other, it is important that no state be leaked
- *     from either LFSR.
- *
- * Requires:
- *
- *\li  lfsr1 and lfsr2 be valid.
- *
- *\li  1 <= skipbits <= 31
- */
-
-ISC_LANG_ENDDECLS
-
-#endif /* ISC_LFSR_H */
diff --git a/lib/isc/lfsr.c b/lib/isc/lfsr.c
deleted file mode 100644 (file)
index 169b215..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 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/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*! \file */
-
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdlib.h>
-
-#include <isc/assertions.h>
-#include <isc/lfsr.h>
-#include <isc/util.h>
-
-#define VALID_LFSR(x) (x != NULL)
-
-void
-isc_lfsr_init(isc_lfsr_t *lfsr, uint32_t state, unsigned int bits, uint32_t tap,
-             unsigned int count, isc_lfsrreseed_t reseed, void *arg) {
-       REQUIRE(VALID_LFSR(lfsr));
-       REQUIRE(8 <= bits && bits <= 32);
-       REQUIRE(tap != 0);
-
-       lfsr->state = state;
-       lfsr->bits = bits;
-       lfsr->tap = tap;
-       lfsr->count = count;
-       lfsr->reseed = reseed;
-       lfsr->arg = arg;
-
-       if (count == 0 && reseed != NULL) {
-               reseed(lfsr, arg);
-       }
-       if (lfsr->state == 0) {
-               lfsr->state = 0xffffffffU >> (32 - lfsr->bits);
-       }
-}
-
-/*!
- * Return the next state of the lfsr.
- */
-static inline uint32_t
-lfsr_generate(isc_lfsr_t *lfsr) {
-       /*
-        * If the previous state is zero, we must fill it with something
-        * here, or we will begin to generate an extremely predictable output.
-        *
-        * First, give the reseed function a crack at it.  If the state is
-        * still 0, set it to all ones.
-        */
-       if (lfsr->state == 0) {
-               if (lfsr->reseed != NULL) {
-                       lfsr->reseed(lfsr, lfsr->arg);
-               }
-               if (lfsr->state == 0) {
-                       lfsr->state = 0xffffffffU >> (32 - lfsr->bits);
-               }
-       }
-
-       if (lfsr->state & 0x01) {
-               lfsr->state = (lfsr->state >> 1) ^ lfsr->tap;
-               return (1);
-       } else {
-               lfsr->state >>= 1;
-               return (0);
-       }
-}
-
-void
-isc_lfsr_generate(isc_lfsr_t *lfsr, void *data, unsigned int count) {
-       unsigned char *p;
-       unsigned int bit;
-       unsigned int byte;
-
-       REQUIRE(VALID_LFSR(lfsr));
-       REQUIRE(data != NULL);
-       REQUIRE(count > 0);
-
-       p = data;
-       byte = count;
-
-       while (byte--) {
-               *p = 0;
-               for (bit = 0; bit < 7; bit++) {
-                       *p |= lfsr_generate(lfsr);
-                       *p <<= 1;
-               }
-               *p |= lfsr_generate(lfsr);
-               p++;
-       }
-
-       if (lfsr->count != 0 && lfsr->reseed != NULL) {
-               if (lfsr->count <= count * 8) {
-                       lfsr->reseed(lfsr, lfsr->arg);
-               } else {
-                       lfsr->count -= (count * 8);
-               }
-       }
-}
-
-static inline uint32_t
-lfsr_skipgenerate(isc_lfsr_t *lfsr, unsigned int skip) {
-       while (skip--) {
-               (void)lfsr_generate(lfsr);
-       }
-
-       (void)lfsr_generate(lfsr);
-
-       return (lfsr->state);
-}
-
-/*
- * Skip "skip" states in "lfsr".
- */
-void
-isc_lfsr_skip(isc_lfsr_t *lfsr, unsigned int skip) {
-       REQUIRE(VALID_LFSR(lfsr));
-
-       while (skip--) {
-               (void)lfsr_generate(lfsr);
-       }
-}
-
-/*
- * Skip states in lfsr1 and lfsr2 using the other's current state.
- * Return the final state of lfsr1 ^ lfsr2.
- */
-uint32_t
-isc_lfsr_generate32(isc_lfsr_t *lfsr1, isc_lfsr_t *lfsr2) {
-       uint32_t state1, state2;
-       uint32_t skip1, skip2;
-
-       REQUIRE(VALID_LFSR(lfsr1));
-       REQUIRE(VALID_LFSR(lfsr2));
-
-       skip1 = lfsr1->state & 0x01;
-       skip2 = lfsr2->state & 0x01;
-
-       /* cross-skip. */
-       state1 = lfsr_skipgenerate(lfsr1, skip2);
-       state2 = lfsr_skipgenerate(lfsr2, skip1);
-
-       return (state1 ^ state2);
-}
index 7cd09bc70f7299c31216722e3d7fb966b6d6ec72..aecf8002448666c3644c576a22e3c7c75dfd6c05 100644 (file)
@@ -328,10 +328,6 @@ isc_lex_setsourceline
 isc_lex_setsourcename
 isc_lex_setspecials
 isc_lex_ungettoken
-isc_lfsr_generate
-isc_lfsr_generate32
-isc_lfsr_init
-isc_lfsr_skip
 isc_lib_register
 isc_log_categorybyname
 isc_log_closefilelogs
index 249e5271e3a4f36b350449169124fa3a92f224cb..f4e1964f06c48ccf340298ff6ac94ba3d7e77ac6 100644 (file)
     <ClInclude Include="..\include\isc\lex.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\include\isc\lfsr.h">
-      <Filter>Library Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\include\isc\lib.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
     <ClCompile Include="..\lex.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\lfsr.c">
-      <Filter>Library Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\lib.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
index aafc24a27648ea16f919048bec2a65628f0ff8b1..b4574460b708ce660383fbbea52828f92b0b093e 100644 (file)
@@ -326,7 +326,6 @@ copy InstallFiles ..\Build\Release\
     <ClInclude Include="..\include\isc\json.h" />
     <ClInclude Include="..\include\isc\lang.h" />
     <ClInclude Include="..\include\isc\lex.h" />
-    <ClInclude Include="..\include\isc\lfsr.h" />
     <ClInclude Include="..\include\isc\lib.h" />
     <ClInclude Include="..\include\isc\list.h" />
     <ClInclude Include="..\include\isc\log.h" />
@@ -434,7 +433,6 @@ copy InstallFiles ..\Build\Release\
     <ClCompile Include="..\httpd.c" />
     <ClCompile Include="..\iterated_hash.c" />
     <ClCompile Include="..\lex.c" />
-    <ClCompile Include="..\lfsr.c" />
     <ClCompile Include="..\lib.c" />
     <ClCompile Include="..\log.c" />
     <ClCompile Include="..\md.c" />
index 0f8982b09e2565407e9bd98672dd00884c5f3043..4557ac8b404c022f32f4d5c9802de64ab1f9c3c6 100644 (file)
 ./lib/isc/include/isc/iterated_hash.h          C       2008,2014,2016,2018,2019,2020
 ./lib/isc/include/isc/lang.h                   C       1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020
 ./lib/isc/include/isc/lex.h                    C       1998,1999,2000,2001,2002,2004,2005,2007,2008,2015,2016,2017,2018,2019,2020
-./lib/isc/include/isc/lfsr.h                   C       1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020
 ./lib/isc/include/isc/lib.h                    C       1999,2000,2001,2004,2005,2006,2007,2009,2016,2018,2019,2020
 ./lib/isc/include/isc/likely.h                 C       2017,2018,2019,2020
 ./lib/isc/include/isc/list.h                   C       1997,1998,1999,2000,2001,2002,2004,2006,2007,2011,2012,2013,2016,2018,2019,2020
 ./lib/isc/include/pkcs11/pkcs11.h              X       2019,2020
 ./lib/isc/iterated_hash.c                      C       2006,2008,2009,2016,2018,2019,2020
 ./lib/isc/lex.c                                        C       1998,1999,2000,2001,2002,2003,2004,2005,2007,2013,2014,2015,2016,2017,2018,2019,2020
-./lib/isc/lfsr.c                               C       1999,2000,2001,2002,2004,2005,2007,2016,2018,2019,2020
 ./lib/isc/lib.c                                        C       1999,2000,2001,2004,2005,2007,2009,2013,2014,2015,2016,2018,2019,2020
 ./lib/isc/log.c                                        C       1999,2000,2001,2002,2003,2004,2005,2006,2007,2009,2011,2012,2013,2014,2016,2017,2018,2019,2020
 ./lib/isc/md.c                                 C       2018,2019,2020