mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
parent
95c34399cf
commit
0ab38b9366
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user