Blowfish accepts variable key len in cipher layer

This commit is contained in:
Manuel Pégourié-Gonnard 2014-06-23 12:10:59 +02:00 committed by Paul Bakker
parent ed5c03ff1d
commit 398c57b0b3
4 changed files with 38 additions and 5 deletions

View File

@ -10,6 +10,7 @@ Features
* Support for CCM and CCM_8 ciphersuites * Support for CCM and CCM_8 ciphersuites
* Support for parsing and verifying RSASSA-PSS signatures in the X.509 * Support for parsing and verifying RSASSA-PSS signatures in the X.509
modules (certificates, CRLs and CSRs). modules (certificates, CRLs and CSRs).
* Blowfish in the cipher layer now supports variable length keys.
Changes Changes
* Add LINK_WITH_PTHREAD option in CMake for explicit linking that is * Add LINK_WITH_PTHREAD option in CMake for explicit linking that is

View File

@ -168,8 +168,11 @@ int cipher_setkey( cipher_context_t *ctx, const unsigned char *key,
if( NULL == ctx || NULL == ctx->cipher_info ) if( NULL == ctx || NULL == ctx->cipher_info )
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA ); return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
if( (int) ctx->cipher_info->key_length != key_length ) if( ( ctx->cipher_info->flags & POLARSSL_CIPHER_VARIABLE_KEY_LEN ) == 0 &&
(int) ctx->cipher_info->key_length != key_length )
{
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA ); return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
ctx->key_length = key_length; ctx->key_length = key_length;
ctx->operation = operation; ctx->operation = operation;

View File

@ -1180,7 +1180,7 @@ const cipher_info_t blowfish_ecb_info = {
128, 128,
"BLOWFISH-ECB", "BLOWFISH-ECB",
8, 8,
0, POLARSSL_CIPHER_VARIABLE_KEY_LEN,
8, 8,
&blowfish_info &blowfish_info
}; };
@ -1192,7 +1192,7 @@ const cipher_info_t blowfish_cbc_info = {
128, 128,
"BLOWFISH-CBC", "BLOWFISH-CBC",
8, 8,
0, POLARSSL_CIPHER_VARIABLE_KEY_LEN,
8, 8,
&blowfish_info &blowfish_info
}; };
@ -1205,7 +1205,7 @@ const cipher_info_t blowfish_cfb64_info = {
128, 128,
"BLOWFISH-CFB64", "BLOWFISH-CFB64",
8, 8,
0, POLARSSL_CIPHER_VARIABLE_KEY_LEN,
8, 8,
&blowfish_info &blowfish_info
}; };
@ -1218,7 +1218,7 @@ const cipher_info_t blowfish_ctr_info = {
128, 128,
"BLOWFISH-CTR", "BLOWFISH-CTR",
8, 8,
0, POLARSSL_CIPHER_VARIABLE_KEY_LEN,
8, 8,
&blowfish_info &blowfish_info
}; };

View File

@ -550,6 +550,18 @@ BLOWFISH Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CTR depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_BLOWFISH_CTR:128:16:16: enc_dec_buf_multipart:POLARSSL_CIPHER_BLOWFISH_CTR:128:16:16:
BLOWFISH CBC Encrypt and decrypt 7 bytes, 192-bits key
depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CBC:POLARSSL_CIPHER_PADDING_PKCS7
enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:"BLOWFISH-CBC":192:7:-1
BLOWFISH CTR Encrypt and decrypt 7 bytes, 192-bits key
depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CTR:"BLOWFISH-CTR":192:7:-1
BLOWFISH CFB64 Encrypt and decrypt 7 bytes, 192-bits key
depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CFB64:"BLOWFISH-CFB64":192:7:-1
BLOWFISH ECB Encrypt test vector (SSLeay) #1 BLOWFISH ECB Encrypt test vector (SSLeay) #1
depends_on:POLARSSL_BLOWFISH_C depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_ENCRYPT:"00000000000000000000000000000000":"0000000000000000":"4ef997456198dd78":0 test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_ENCRYPT:"00000000000000000000000000000000":"0000000000000000":"4ef997456198dd78":0
@ -562,6 +574,14 @@ BLOWFISH ECB Encrypt test vector (SSLeay) #3
depends_on:POLARSSL_BLOWFISH_C depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_ENCRYPT:"fedcba9876543210fedcba9876543210":"0123456789abcdef":"0aceab0fc6a0a28d":0 test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_ENCRYPT:"fedcba9876543210fedcba9876543210":"0123456789abcdef":"0aceab0fc6a0a28d":0
BLOWFISH ECB Encrypt test vector (SSLeay) #3, 64-bit key
depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_ENCRYPT:"fedcba9876543210":"0123456789abcdef":"0aceab0fc6a0a28d":0
BLOWFISH ECB Encrypt test vector (SSLeay) #3, 192-bit key
depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_ENCRYPT:"fedcba9876543210fedcba9876543210fedcba9876543210":"0123456789abcdef":"0aceab0fc6a0a28d":0
BLOWFISH ECB Decrypt test vector (SSLeay) #1 BLOWFISH ECB Decrypt test vector (SSLeay) #1
depends_on:POLARSSL_BLOWFISH_C depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"00000000000000000000000000000000":"4ef997456198dd78":"0000000000000000":0 test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"00000000000000000000000000000000":"4ef997456198dd78":"0000000000000000":0
@ -573,3 +593,12 @@ test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"ffffffffffffffffffff
BLOWFISH ECB Decrypt test vector (SSLeay) #3 BLOWFISH ECB Decrypt test vector (SSLeay) #3
depends_on:POLARSSL_BLOWFISH_C depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"3849674c2602319e3849674c2602319e":"a25e7856cf2651eb":"51454b582ddf440a":0 test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"3849674c2602319e3849674c2602319e":"a25e7856cf2651eb":"51454b582ddf440a":0
BLOWFISH ECB Decrypt test vector (SSLeay) #3, 64-bit key
depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"3849674c2602319e":"a25e7856cf2651eb":"51454b582ddf440a":0
BLOWFISH ECB Decrypt test vector (SSLeay) #3, 192-bit key
depends_on:POLARSSL_BLOWFISH_C
test_vec_ecb:POLARSSL_CIPHER_BLOWFISH_ECB:POLARSSL_DECRYPT:"3849674c2602319e3849674c2602319e3849674c2602319e":"a25e7856cf2651eb":"51454b582ddf440a":0