summaryrefslogtreecommitdiffstats
path: root/src/methods
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 08:16:14 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 08:16:14 +0100
commit6aca3d350424796f9788e68447d28d06c80e5c2a (patch)
tree44dc62c8dec9a68c9aab75c24e00ef536d25f7b4 /src/methods
parent8d3c7196bb301782e1a9ed690a66992b5d732911 (diff)
downloadfastd-6aca3d350424796f9788e68447d28d06c80e5c2a.tar
fastd-6aca3d350424796f9788e68447d28d06c80e5c2a.zip
Allow method init to fail
Diffstat (limited to 'src/methods')
-rw-r--r--src/methods/composed_gmac/composed_gmac.c8
-rw-r--r--src/methods/generic_gcm/generic_gcm.c6
2 files changed, 12 insertions, 2 deletions
diff --git a/src/methods/composed_gmac/composed_gmac.c b/src/methods/composed_gmac/composed_gmac.c
index cb0d5d6..b8ee2f6 100644
--- a/src/methods/composed_gmac/composed_gmac.c
+++ b/src/methods/composed_gmac/composed_gmac.c
@@ -147,7 +147,13 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
uint8_t zeroiv[session->gmac_cipher_info->iv_length];
memset(zeroiv, 0, session->gmac_cipher_info->iv_length);
- session->gmac_cipher->crypt(ctx, session->gmac_cipher_state, &H, &ZERO_BLOCK, sizeof(fastd_block128_t), zeroiv);
+ if (!session->gmac_cipher->crypt(ctx, session->gmac_cipher_state, &H, &ZERO_BLOCK, sizeof(fastd_block128_t), zeroiv)) {
+ session->cipher->free_state(ctx, session->cipher_state);
+ session->gmac_cipher->free_state(ctx, session->gmac_cipher_state);
+ free(session);
+
+ return NULL;
+ }
session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info, &session->ghash_ctx);
if (!session->ghash)
diff --git a/src/methods/generic_gcm/generic_gcm.c b/src/methods/generic_gcm/generic_gcm.c
index 9ce8522..9481100 100644
--- a/src/methods/generic_gcm/generic_gcm.c
+++ b/src/methods/generic_gcm/generic_gcm.c
@@ -113,7 +113,11 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
uint8_t zeroiv[session->cipher_info->iv_length];
memset(zeroiv, 0, session->cipher_info->iv_length);
- session->cipher->crypt(ctx, session->cipher_state, &H, &zeroblock, sizeof(fastd_block128_t), zeroiv);
+ if (!session->cipher->crypt(ctx, session->cipher_state, &H, &zeroblock, sizeof(fastd_block128_t), zeroiv)) {
+ session->cipher->free_state(ctx, session->cipher_state);
+ free(session);
+ return NULL;
+ }
session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info, &session->ghash_ctx);
if (!session->ghash)