Dead code: crypto/dh,modes,pkcs12,ripemd,rsa,srp
authorRich Salz <rsalz@openssl.org>
Tue, 3 Feb 2015 16:20:56 +0000 (11:20 -0500)
committerRich Salz <rsalz@openssl.org>
Tue, 3 Feb 2015 16:20:56 +0000 (11:20 -0500)
And an uncompiled C++ test file.
Also remove srp_lcl.h, with help from Richard.

Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/dh/dh_check.c
crypto/dh/dh_gen.c
crypto/modes/gcm128.c
crypto/pkcs12/p12_key.c
crypto/ripemd/asm/rips.cpp [deleted file]
crypto/ripemd/rmd_locl.h
crypto/rsa/rsa_null.c
crypto/srp/Makefile
crypto/srp/srp_lcl.h [deleted file]
crypto/srp/srp_lib.c
crypto/srp/srp_vfy.c

index 347467c6a43369dfe948f05fd33373ab0f1b0ae9..7a8e063fc81169c2aef448599630f928b2b9a1ac 100644 (file)
@@ -116,15 +116,7 @@ int DH_check(const DH *dh, int *ret)
         l = BN_mod_word(dh->p, 24);
         if (l != 11)
             *ret |= DH_NOT_SUITABLE_GENERATOR;
-    }
-#if 0
-    else if (BN_is_word(dh->g, DH_GENERATOR_3)) {
-        l = BN_mod_word(dh->p, 12);
-        if (l != 5)
-            *ret |= DH_NOT_SUITABLE_GENERATOR;
-    }
-#endif
-    else if (BN_is_word(dh->g, DH_GENERATOR_5)) {
+    } else if (BN_is_word(dh->g, DH_GENERATOR_5)) {
         l = BN_mod_word(dh->p, 10);
         if ((l != 3) && (l != 7))
             *ret |= DH_NOT_SUITABLE_GENERATOR;
index 9b9db6458b56a7d2b265f15fdf1d76e43fa4eba4..99ccae33bf910153daaf27d88cd590533d24da89 100644 (file)
@@ -136,17 +136,7 @@ static int dh_builtin_genparams(DH *ret, int prime_len, int generator,
         if (!BN_set_word(t2, 11))
             goto err;
         g = 2;
-    }
-#if 0                           /* does not work for safe primes */
-    else if (generator == DH_GENERATOR_3) {
-        if (!BN_set_word(t1, 12))
-            goto err;
-        if (!BN_set_word(t2, 5))
-            goto err;
-        g = 3;
-    }
-#endif
-    else if (generator == DH_GENERATOR_5) {
+    } else if (generator == DH_GENERATOR_5) {
         if (!BN_set_word(t1, 10))
             goto err;
         if (!BN_set_word(t2, 3))
index 5c75c91f8201da29c722f9e914deedb2935bb481..1d1b0d9b160108e5ad570fc800af7da2bfff9ca9 100644 (file)
@@ -1036,9 +1036,6 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
 # endif
 #endif
 
-#if 0
-    n = (unsigned int)mlen % 16; /* alternative to ctx->mres */
-#endif
     mlen += len;
     if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len))
         return -1;
index 99b8260c96c27902bac8cd492210d81e231a3a26..5a062087d1ec3bb7043c64101190b8ca2c305c2b 100644 (file)
@@ -118,13 +118,6 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
     int tmpn = n;
 #endif
 
-#if 0
-    if (!pass) {
-        PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI, ERR_R_PASSED_NULL_PARAMETER);
-        return 0;
-    }
-#endif
-
     EVP_MD_CTX_init(&ctx);
 #ifdef  DEBUG_KEYGEN
     fprintf(stderr, "KEYGEN DEBUG\n");
diff --git a/crypto/ripemd/asm/rips.cpp b/crypto/ripemd/asm/rips.cpp
deleted file mode 100644 (file)
index f7a1367..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// gettsc.inl
-//
-// gives access to the Pentium's (secret) cycle counter
-//
-// This software was written by Leonard Janke (janke@unixg.ubc.ca)
-// in 1996-7 and is entered, by him, into the public domain.
-
-#if defined(__WATCOMC__)
-void GetTSC(unsigned long&);
-#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
-#elif defined(__GNUC__)
-inline
-void GetTSC(unsigned long& tsc)
-{
-  asm volatile(".byte 15, 49\n\t"
-              : "=eax" (tsc)
-              :
-              : "%edx", "%eax");
-}
-#elif defined(_MSC_VER)
-inline
-void GetTSC(unsigned long& tsc)
-{
-  unsigned long a;
-  __asm _emit 0fh
-  __asm _emit 31h
-  __asm mov a, eax;
-  tsc=a;
-}
-#endif      
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <openssl/ripemd.h>
-
-#define ripemd160_block_x86 ripemd160_block_asm_host_order
-
-extern "C" {
-void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num);
-}
-
-void main(int argc,char *argv[])
-       {
-       unsigned char buffer[64*256];
-       RIPEMD160_CTX ctx;
-       unsigned long s1,s2,e1,e2;
-       unsigned char k[16];
-       unsigned long data[2];
-       unsigned char iv[8];
-       int i,num=0,numm;
-       int j=0;
-
-       if (argc >= 2)
-               num=atoi(argv[1]);
-
-       if (num == 0) num=16;
-       if (num > 250) num=16;
-       numm=num+2;
-#if 0
-       num*=64;
-       numm*=64;
-#endif
-
-       for (j=0; j<6; j++)
-               {
-               for (i=0; i<10; i++) /**/
-                       {
-                       ripemd160_block_x86(&ctx,buffer,numm);
-                       GetTSC(s1);
-                       ripemd160_block_x86(&ctx,buffer,numm);
-                       GetTSC(e1);
-                       GetTSC(s2);
-                       ripemd160_block_x86(&ctx,buffer,num);
-                       GetTSC(e2);
-                       ripemd160_block_x86(&ctx,buffer,num);
-                       }
-               printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num*64,
-                       e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
-               }
-       }
-
index 497a1a167ed0c586aaadaf465bb243d2924bd3e3..5a2eed386c3fa45b21fa75218367268e4b83dc29 100644 (file)
@@ -94,22 +94,14 @@ void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num);
 
 #include "md32_common.h"
 
-#if 0
-# define F1(x,y,z)        ((x)^(y)^(z))
-# define F2(x,y,z)       (((x)&(y))|((~x)&z))
-# define F3(x,y,z)       (((x)|(~y))^(z))
-# define F4(x,y,z)       (((x)&(z))|((y)&(~(z))))
-# define F5(x,y,z)        ((x)^((y)|(~(z))))
-#else
 /*
  * Transformed F2 and F4 are courtesy of Wei Dai <weidai@eskimo.com>
  */
-# define F1(x,y,z)       ((x) ^ (y) ^ (z))
-# define F2(x,y,z)       ((((y) ^ (z)) & (x)) ^ (z))
-# define F3(x,y,z)       (((~(y)) | (x)) ^ (z))
-# define F4(x,y,z)       ((((x) ^ (y)) & (z)) ^ (y))
-# define F5(x,y,z)       (((~(z)) | (y)) ^ (x))
-#endif
+#define F1(x,y,z)       ((x) ^ (y) ^ (z))
+#define F2(x,y,z)       ((((y) ^ (z)) & (x)) ^ (z))
+#define F3(x,y,z)       (((~(y)) | (x)) ^ (z))
+#define F4(x,y,z)       ((((x) ^ (y)) & (z)) ^ (y))
+#define F5(x,y,z)       (((~(z)) | (y)) ^ (x))
 
 #define RIPEMD160_A     0x67452301L
 #define RIPEMD160_B     0xEFCDAB89L
index 241b431ad581d31a7658ab9a0d1b1f534ce7b103..535660a7de4dc0aeec7a1eac48b4f5f1f8ca0a23 100644 (file)
@@ -79,9 +79,6 @@ static int RSA_null_public_decrypt(int flen, const unsigned char *from,
                                    unsigned char *to, RSA *rsa, int padding);
 static int RSA_null_private_decrypt(int flen, const unsigned char *from,
                                     unsigned char *to, RSA *rsa, int padding);
-#if 0                           /* not currently used */
-static int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa);
-#endif
 static int RSA_null_init(RSA *rsa);
 static int RSA_null_finish(RSA *rsa);
 static RSA_METHOD rsa_null_meth = {
@@ -136,14 +133,6 @@ static int RSA_null_public_decrypt(int flen, const unsigned char *from,
     return -1;
 }
 
-#if 0                           /* not currently used */
-static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
-{
-    ... err(RSA_F_RSA_NULL_MOD_EXP, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
-    return -1;
-}
-#endif
-
 static int RSA_null_init(RSA *rsa)
 {
     return (1);
index 0c37ec7da729b29f65a8fb8c43de40138f9071d6..3674dd6cd6c263992392383ff6ed8390b4a38998 100644 (file)
@@ -82,7 +82,7 @@ srp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
 srp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
 srp_lib.o: ../../include/openssl/sha.h ../../include/openssl/srp.h
 srp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-srp_lib.o: ../cryptlib.h ../include/internal/bn_srp.h srp_lcl.h srp_lib.c
+srp_lib.o: ../cryptlib.h ../include/internal/bn_srp.h srp_lib.c
 srp_vfy.o: ../../e_os.h ../../include/openssl/asn1.h
 srp_vfy.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
 srp_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -94,4 +94,4 @@ srp_vfy.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
 srp_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
 srp_vfy.o: ../../include/openssl/srp.h ../../include/openssl/stack.h
 srp_vfy.o: ../../include/openssl/symhacks.h ../../include/openssl/txt_db.h
-srp_vfy.o: ../cryptlib.h srp_lcl.h srp_vfy.c
+srp_vfy.o: ../cryptlib.h srp_vfy.c
diff --git a/crypto/srp/srp_lcl.h b/crypto/srp/srp_lcl.h
deleted file mode 100644 (file)
index 9a7fce1..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* crypto/srp/srp_lcl.h */
-/*
- * Written by Peter Sylvester (peter.sylvester@edelweb.fr) for the EdelKey
- * project and contributed to the OpenSSL project 2004.
- */
-/* ====================================================================
- * Copyright (c) 2004 The OpenSSL Project.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
- *
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
- *    endorse or promote products derived from this software without
- *    prior written permission. For written permission, please contact
- *    licensing@OpenSSL.org.
- *
- * 5. Products derived from this software may not be called "OpenSSL"
- *    nor may "OpenSSL" appear in their names without prior written
- *    permission of the OpenSSL Project.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- *    acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
- *
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This product includes cryptographic software written by Eric Young
- * (eay@cryptsoft.com).  This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
-#ifndef HEADER_SRP_LCL_H
-# define HEADER_SRP_LCL_H
-
-# include <openssl/srp.h>
-# include <openssl/sha.h>
-
-# if 0
-#  define srp_bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
-   fprintf(stderr,"\n");}
-# else
-#  define   srp_bn_print(a)
-# endif
-
-
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif
index 6997a28957bd333fcd821e07adee08957dcda215..9e1de740c18eebb8bc604d345fb297b4c402c832 100644 (file)
@@ -59,7 +59,7 @@
  */
 #ifndef OPENSSL_NO_SRP
 # include "cryptlib.h"
-# include "srp_lcl.h"
+# include <openssl/sha.h>
 # include <openssl/srp.h>
 # include <openssl/evp.h>
 # include "internal/bn_srp.h"
@@ -317,9 +317,6 @@ char *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N)
     if ((g == NULL) || (N == NULL))
         return 0;
 
-    srp_bn_print(g);
-    srp_bn_print(N);
-
     for (i = 0; i < KNOWN_GN_NUMBER; i++) {
         if (BN_cmp(knowngN[i].g, g) == 0 && BN_cmp(knowngN[i].N, N) == 0)
             return knowngN[i].id;
index df82ca3830d7a77ffe8aa6f4fabc26a1e5cbe277..4aed5b4ba58e1d84523fa8fa1b0da10497b8073b 100644 (file)
@@ -59,7 +59,7 @@
  */
 #ifndef OPENSSL_NO_SRP
 # include "cryptlib.h"
-# include "srp_lcl.h"
+# include <openssl/sha.h>
 # include <openssl/srp.h>
 # include <openssl/evp.h>
 # include <openssl/buffer.h>
@@ -607,9 +607,6 @@ int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
         (verifier == NULL) || (N == NULL) || (g == NULL) || (bn_ctx == NULL))
         goto err;
 
-    srp_bn_print(N);
-    srp_bn_print(g);
-
     if (*salt == NULL) {
         RAND_pseudo_bytes(tmp2, SRP_RANDOM_SALT_LEN);
 
@@ -627,8 +624,6 @@ int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
         goto err;
     }
 
-    srp_bn_print(*verifier);
-
     result = 1;
 
  err: