aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArlo Breault <arlolra@gmail.com>2013-05-16 12:05:50 -0700
committerNick Mathewson <nickm@torproject.org>2013-05-17 10:11:33 -0400
commit0ab38b93660b4c9cb53771a454805e978ad9f406 (patch)
tree5efcd897310a37b85ad5435e8437cfab7dd92ec0
parent95c34399cfb66a46371562f1532e8aa396243876 (diff)
downloadtor-0ab38b93660b4c9cb53771a454805e978ad9f406.tar
tor-0ab38b93660b4c9cb53771a454805e978ad9f406.tar.gz
Remove PK_PKCS1_PADDING
See #8792
-rw-r--r--src/common/crypto.c2
-rw-r--r--src/common/crypto.h4
-rw-r--r--src/test/test_crypto.c25
3 files changed, 11 insertions, 20 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 31a0df1ed..bda1ed0c3 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 38eb45517..2886306a6 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 4b7e7f298..839de7dd5 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 */