[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Remove PK_PKCS1_PADDING



commit 0ab38b93660b4c9cb53771a454805e978ad9f406
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Thu May 16 12:05:50 2013 -0700

    Remove PK_PKCS1_PADDING
    
    See #8792
---
 src/common/crypto.c    |    2 --
 src/common/crypto.h    |    4 ----
 src/test/test_crypto.c |   25 +++++++++++--------------
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/src/common/crypto.c b/src/common/crypto.c
index 31a0df1..bda1ed0 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -114,7 +114,6 @@ crypto_get_rsa_padding_overhead(int padding)
   switch (padding)
     {
     case RSA_PKCS1_OAEP_PADDING: return PKCS1_OAEP_PADDING_OVERHEAD;
-    case RSA_PKCS1_PADDING: return PKCS1_PADDING_OVERHEAD;
     default: tor_assert(0); return -1;
     }
 }
@@ -126,7 +125,6 @@ crypto_get_rsa_padding(int padding)
 {
   switch (padding)
     {
-    case PK_PKCS1_PADDING: return RSA_PKCS1_PADDING;
     case PK_PKCS1_OAEP_PADDING: return RSA_PKCS1_OAEP_PADDING;
     default: tor_assert(0); return -1;
     }
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 38eb455..2886306 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -69,13 +69,9 @@
  * signs removed. */
 #define BASE64_DIGEST256_LEN 43
 
-/** Constant used to indicate PKCS1 padding for public-key encryption */
-#define PK_PKCS1_PADDING      60001
 /** Constant used to indicate OAEP padding for public-key encryption */
 #define PK_PKCS1_OAEP_PADDING 60002
 
-/** Number of bytes added for PKCS1 padding. */
-#define PKCS1_PADDING_OVERHEAD 11
 /** Number of bytes added for PKCS1-OAEP padding. */
 #define PKCS1_OAEP_PADDING_OVERHEAD 42
 
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 4b7e7f2..839de7d 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -394,7 +394,7 @@ test_crypto_pk(void)
   char *encoded = NULL;
   char data1[1024], data2[1024], data3[1024];
   size_t size;
-  int i, j, p, len;
+  int i, len;
 
   /* Public-key ciphers */
   pk1 = pk_generate(0);
@@ -478,19 +478,16 @@ test_crypto_pk(void)
 
   /* Try with hybrid encryption wrappers. */
   crypto_rand(data1, 1024);
-  for (i = 0; i < 2; ++i) {
-    for (j = 85; j < 140; ++j) {
-      memset(data2,0,1024);
-      memset(data3,0,1024);
-      p = (i==0)?PK_PKCS1_PADDING:PK_PKCS1_OAEP_PADDING;
-      len = crypto_pk_public_hybrid_encrypt(pk1,data2,sizeof(data2),
-                                            data1,j,p,0);
-      test_assert(len>=0);
-      len = crypto_pk_private_hybrid_decrypt(pk1,data3,sizeof(data3),
-                                             data2,len,p,1);
-      test_eq(len,j);
-      test_memeq(data1,data3,j);
-    }
+  for (i = 85; i < 140; ++i) {
+    memset(data2,0,1024);
+    memset(data3,0,1024);
+    len = crypto_pk_public_hybrid_encrypt(pk1,data2,sizeof(data2),
+                                          data1,i,PK_PKCS1_OAEP_PADDING,0);
+    test_assert(len>=0);
+    len = crypto_pk_private_hybrid_decrypt(pk1,data3,sizeof(data3),
+                                           data2,len,PK_PKCS1_OAEP_PADDING,1);
+    test_eq(len,i);
+    test_memeq(data1,data3,i);
   }
 
   /* Try copy_full */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits