mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 09:36:46 +00:00
This commit resolves issue #46. The GCM mode was using the wrong master SALT length. The master SALT should be 96 bits instead of 112 bits. Note, GCM mode uses the legacy CTR mode for the KDF. The legagacy CTR mode cipher implementations assume a 112 bit SALT. Changes to the cipher abstraction layer API are required to provide the ability to specify the SALT length. For now this commit modifies the SRTP layer to ensure the SALT is zero-appended before initializing the KDF. This commit also provides public definitions for the GCM cipher suite master key sizes to avoid confusion for application developers.
This commit is contained in:
@@ -73,7 +73,7 @@ extern cipher_type_t aes_gcm_256_openssl;
|
||||
|
||||
/*
|
||||
* This function allocates a new instance of this crypto engine.
|
||||
* The key_len parameter should be one of 30 or 46 for
|
||||
* The key_len parameter should be one of 28 or 44 for
|
||||
* AES-128-GCM or AES-256-GCM respectively. Note that the
|
||||
* key length includes the 14 byte salt value that is used when
|
||||
* initializing the KDF.
|
||||
@@ -89,8 +89,8 @@ err_status_t aes_gcm_openssl_alloc (cipher_t **c, int key_len)
|
||||
/*
|
||||
* Verify the key_len is valid for one of: AES-128/256
|
||||
*/
|
||||
if (key_len != AES_128_KEYSIZE_WSALT &&
|
||||
key_len != AES_256_KEYSIZE_WSALT) {
|
||||
if (key_len != AES_128_GCM_KEYSIZE_WSALT &&
|
||||
key_len != AES_256_GCM_KEYSIZE_WSALT) {
|
||||
return (err_status_bad_param);
|
||||
}
|
||||
|
||||
@@ -108,14 +108,14 @@ err_status_t aes_gcm_openssl_alloc (cipher_t **c, int key_len)
|
||||
|
||||
/* increment ref_count */
|
||||
switch (key_len) {
|
||||
case AES_128_KEYSIZE_WSALT:
|
||||
case AES_128_GCM_KEYSIZE_WSALT:
|
||||
(*c)->type = &aes_gcm_128_openssl;
|
||||
(*c)->algorithm = AES_128_GCM;
|
||||
aes_gcm_128_openssl.ref_count++;
|
||||
((aes_gcm_ctx_t*)(*c)->state)->key_size = AES_128_KEYSIZE;
|
||||
((aes_gcm_ctx_t*)(*c)->state)->tag_len = GCM_AUTH_TAG_LEN;
|
||||
break;
|
||||
case AES_256_KEYSIZE_WSALT:
|
||||
case AES_256_GCM_KEYSIZE_WSALT:
|
||||
(*c)->type = &aes_gcm_256_openssl;
|
||||
(*c)->algorithm = AES_256_GCM;
|
||||
aes_gcm_256_openssl.ref_count++;
|
||||
@@ -376,11 +376,11 @@ char aes_gcm_256_openssl_description[] = "AES-256 GCM using openssl";
|
||||
* values we're derived from independent test code
|
||||
* using OpenSSL.
|
||||
*/
|
||||
uint8_t aes_gcm_test_case_0_key[AES_128_KEYSIZE_WSALT] = {
|
||||
uint8_t aes_gcm_test_case_0_key[AES_128_GCM_KEYSIZE_WSALT] = {
|
||||
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
|
||||
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
|
||||
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
|
||||
0x09, 0x0a, 0x0b, 0x0c,
|
||||
};
|
||||
|
||||
uint8_t aes_gcm_test_case_0_iv[12] = {
|
||||
@@ -419,7 +419,7 @@ uint8_t aes_gcm_test_case_0_ciphertext[68] = {
|
||||
};
|
||||
|
||||
cipher_test_case_t aes_gcm_test_case_0 = {
|
||||
AES_128_KEYSIZE_WSALT, /* octets in key */
|
||||
AES_128_GCM_KEYSIZE_WSALT, /* octets in key */
|
||||
aes_gcm_test_case_0_key, /* key */
|
||||
aes_gcm_test_case_0_iv, /* packet index */
|
||||
60, /* octets in plaintext */
|
||||
@@ -431,13 +431,13 @@ cipher_test_case_t aes_gcm_test_case_0 = {
|
||||
NULL /* pointer to next testcase */
|
||||
};
|
||||
|
||||
uint8_t aes_gcm_test_case_1_key[AES_256_KEYSIZE_WSALT] = {
|
||||
uint8_t aes_gcm_test_case_1_key[AES_256_GCM_KEYSIZE_WSALT] = {
|
||||
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
|
||||
0xa5, 0x59, 0x09, 0xc5, 0x54, 0x66, 0x93, 0x1c,
|
||||
0xaf, 0xf5, 0x26, 0x9a, 0x21, 0xd5, 0x14, 0xb2,
|
||||
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
|
||||
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
|
||||
0x09, 0x0a, 0x0b, 0x0c,
|
||||
|
||||
};
|
||||
|
||||
@@ -477,7 +477,7 @@ uint8_t aes_gcm_test_case_1_ciphertext[68] = {
|
||||
};
|
||||
|
||||
cipher_test_case_t aes_gcm_test_case_1 = {
|
||||
AES_256_KEYSIZE_WSALT, /* octets in key */
|
||||
AES_256_GCM_KEYSIZE_WSALT, /* octets in key */
|
||||
aes_gcm_test_case_1_key, /* key */
|
||||
aes_gcm_test_case_1_iv, /* packet index */
|
||||
60, /* octets in plaintext */
|
||||
|
Reference in New Issue
Block a user