From 310cc1260fbd47016027bba04bc0c39b9c9144b3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 1 Nov 2013 00:25:06 +0100 Subject: Implement new session init API --- src/methods/aes128_gcm/aes128_gcm.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/methods/aes128_gcm') diff --git a/src/methods/aes128_gcm/aes128_gcm.c b/src/methods/aes128_gcm/aes128_gcm.c index 6608618..a2fbf17 100644 --- a/src/methods/aes128_gcm/aes128_gcm.c +++ b/src/methods/aes128_gcm/aes128_gcm.c @@ -59,10 +59,11 @@ static size_t method_min_decrypt_tail_space(fastd_context_t *ctx UNUSED) { } -static fastd_method_session_state_t* method_session_init_key(fastd_context_t *ctx, uint8_t *secret, size_t length, bool initiator) { - if (length < sizeof(fastd_block128_t)) - exit_bug(ctx, "aes128-gcm: tried to init with short secret"); +static size_t method_key_length(fastd_context_t *ctx UNUSED) { + return sizeof(fastd_block128_t); +} +static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, uint8_t *secret, bool initiator) { fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t)); fastd_method_common_init(ctx, &session->common, initiator); @@ -81,6 +82,13 @@ static fastd_method_session_state_t* method_session_init_key(fastd_context_t *ct return session; } +static fastd_method_session_state_t* method_session_init_compat(fastd_context_t *ctx, uint8_t *secret, size_t length, bool initiator) { + if (length < sizeof(fastd_block128_t)) + exit_bug(ctx, "aes128-gcm: tried to init with short secret"); + + return method_session_init(ctx, secret, initiator); +} + static bool method_session_is_valid(fastd_context_t *ctx, fastd_method_session_state_t *session) { return (session && fastd_method_session_common_is_valid(ctx, &session->common)); } @@ -230,7 +238,9 @@ const fastd_method_t fastd_method_aes128_gcm = { .min_encrypt_tail_space = method_min_encrypt_tail_space, .min_decrypt_tail_space = method_min_decrypt_tail_space, - .session_init_compat = method_session_init_key, + .key_length = method_key_length, + .session_init = method_session_init, + .session_init_compat = method_session_init_compat, .session_is_valid = method_session_is_valid, .session_is_initiator = method_session_is_initiator, .session_want_refresh = method_session_want_refresh, -- cgit v1.2.3