From 6aca3d350424796f9788e68447d28d06c80e5c2a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 29 Nov 2013 08:16:14 +0100 Subject: Allow method init to fail --- src/methods/generic_gcm/generic_gcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/methods/generic_gcm') 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) -- cgit v1.2.3