aead: Support custom AEAD salt sizes

The salt, or often called implicit nonce, varies between AEAD algorithms and
their use in protocols. For IKE and ESP, GCM uses 4 bytes, while CCM uses
3 bytes. With TLS, however, AEAD mode uses 4 bytes for both GCM and CCM.

Our GCM backends currently support 4 bytes and CCM 3 bytes only. This is fine
until we go for CCM mode support in TLS, which requires 4 byte nonces.
This commit is contained in:
Martin Willi
2014-03-31 15:56:12 +02:00
parent e12eec1008
commit e5d73b0dfa
17 changed files with 131 additions and 43 deletions
+7 -1
View File
@@ -343,7 +343,8 @@ METHOD(aead_t, destroy, void,
/**
* See header
*/
ccm_aead_t *ccm_aead_create(encryption_algorithm_t algo, size_t key_size)
ccm_aead_t *ccm_aead_create(encryption_algorithm_t algo,
size_t key_size, size_t salt_size)
{
private_ccm_aead_t *this;
size_t icv_size;
@@ -360,6 +361,11 @@ ccm_aead_t *ccm_aead_create(encryption_algorithm_t algo, size_t key_size)
default:
return NULL;
}
if (salt_size && salt_size != SALT_SIZE)
{
/* currently not supported */
return NULL;
}
switch (algo)
{
case ENCR_AES_CCM_ICV8:
+3 -1
View File
@@ -44,8 +44,10 @@ struct ccm_aead_t {
*
* @param algo algorithm to implement, a CCM mode
* @param key_size key size in bytes
* @param salt_size size of implicit salt length
* @return aead, NULL if not supported
*/
ccm_aead_t *ccm_aead_create(encryption_algorithm_t algo, size_t key_size);
ccm_aead_t *ccm_aead_create(encryption_algorithm_t algo, size_t key_size,
size_t salt_size);
#endif /** CCM_AEAD_H_ @}*/