diff options
Diffstat (limited to 'src/methods')
-rw-r--r-- | src/methods/cipher_test/cipher_test.c | 15 | ||||
-rw-r--r-- | src/methods/composed_gmac/composed_gmac.c | 37 | ||||
-rw-r--r-- | src/methods/generic_gcm/generic_gcm.c | 24 | ||||
-rw-r--r-- | src/methods/generic_gmac/generic_gmac.c | 22 | ||||
-rw-r--r-- | src/methods/generic_poly1305/generic_poly1305.c | 15 |
5 files changed, 52 insertions, 61 deletions
diff --git a/src/methods/cipher_test/cipher_test.c b/src/methods/cipher_test/cipher_test.c index 573e90a..067835e 100644 --- a/src/methods/cipher_test/cipher_test.c +++ b/src/methods/cipher_test/cipher_test.c @@ -33,12 +33,11 @@ struct fastd_method_session_state { const fastd_cipher_info_t *cipher_info; const fastd_cipher_t *cipher; - const fastd_cipher_context_t *cipher_ctx; fastd_cipher_state_t *cipher_state; }; -static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx) { +static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **info, const fastd_cipher_t **cipher) { size_t len = strlen(name); if (len < 12) @@ -54,7 +53,7 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe const fastd_cipher_info_t *cipher_info = NULL; if (ctx) { - *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &cipher_info, cctx); + *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &cipher_info); if (!*cipher) return false; } @@ -72,12 +71,12 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe static bool method_provides(const char *name) { - return cipher_get(NULL, name, NULL, NULL, NULL); + return cipher_get(NULL, name, NULL, NULL); } static size_t method_key_length(fastd_context_t *ctx, const char *name) { const fastd_cipher_info_t *info; - if (!cipher_get(NULL, name, &info, NULL, NULL)) + if (!cipher_get(NULL, name, &info, NULL)) exit_bug(ctx, "cipher-test: can't get cipher key length"); return info->key_length; @@ -88,10 +87,10 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c fastd_method_common_init(ctx, &session->common, initiator); - if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher, &session->cipher_ctx)) + if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher)) exit_bug(ctx, "cipher-test: can't instanciate cipher"); - session->cipher_state = session->cipher->init_state(ctx, session->cipher_ctx, secret); + session->cipher_state = session->cipher->init(ctx, secret); pr_warn(ctx, "using cipher-test method; this method must be used for testing and benchmarks only"); @@ -116,7 +115,7 @@ static void method_session_superseded(fastd_context_t *ctx, fastd_method_session static void method_session_free(fastd_context_t *ctx, fastd_method_session_state_t *session) { if (session) { - session->cipher->free_state(ctx, session->cipher_state); + session->cipher->free(ctx, session->cipher_state); free(session); } } diff --git a/src/methods/composed_gmac/composed_gmac.c b/src/methods/composed_gmac/composed_gmac.c index b8ee2f6..0705b7d 100644 --- a/src/methods/composed_gmac/composed_gmac.c +++ b/src/methods/composed_gmac/composed_gmac.c @@ -35,24 +35,21 @@ struct fastd_method_session_state { const fastd_cipher_info_t *cipher_info; const fastd_cipher_t *cipher; - const fastd_cipher_context_t *cipher_ctx; fastd_cipher_state_t *cipher_state; const fastd_cipher_info_t *gmac_cipher_info; const fastd_cipher_t *gmac_cipher; - const fastd_cipher_context_t *gmac_cipher_ctx; fastd_cipher_state_t *gmac_cipher_state; const fastd_mac_info_t *ghash_info; const fastd_mac_t *ghash; - const fastd_mac_context_t *ghash_ctx; fastd_mac_state_t *ghash_state; }; static bool cipher_get(fastd_context_t *ctx, const char *name, - const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx, - const fastd_cipher_info_t **gmac_cipher_info, const fastd_cipher_t **gmac_cipher, const fastd_cipher_context_t **gmac_cctx) { + const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, + const fastd_cipher_info_t **gmac_cipher_info, const fastd_cipher_t **gmac_cipher) { if (!fastd_mac_info_get_by_name("ghash")) return false; @@ -80,8 +77,8 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t *gmac_info = NULL; if (ctx) { - *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info, cctx); - *gmac_cipher = fastd_cipher_get_by_name(ctx, gmac_cipher_name, &gmac_info, gmac_cctx); + *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info); + *gmac_cipher = fastd_cipher_get_by_name(ctx, gmac_cipher_name, &gmac_info); if (!(*cipher && *gmac_cipher)) return false; } @@ -105,7 +102,7 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, static bool method_provides(const char *name) { const fastd_cipher_info_t *gmac_cipher_info; - if (!cipher_get(NULL, name, NULL, NULL, NULL, &gmac_cipher_info, NULL, NULL)) + if (!cipher_get(NULL, name, NULL, NULL, &gmac_cipher_info, NULL)) return false; if (gmac_cipher_info->iv_length <= COMMON_NONCEBYTES) @@ -118,7 +115,7 @@ static size_t method_key_length(fastd_context_t *ctx, const char *name) { const fastd_cipher_info_t *cipher_info; const fastd_cipher_info_t *gmac_cipher_info; - if (!cipher_get(NULL, name, &cipher_info, NULL, NULL, &gmac_cipher_info, NULL, NULL)) + if (!cipher_get(NULL, name, &cipher_info, NULL, &gmac_cipher_info, NULL)) exit_bug(ctx, "composed-gmac: can't get cipher key length"); return cipher_info->key_length + gmac_cipher_info->key_length; @@ -130,15 +127,15 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c fastd_method_common_init(ctx, &session->common, initiator); if (!cipher_get(ctx, name, - &session->cipher_info, &session->cipher, &session->cipher_ctx, - &session->gmac_cipher_info, &session->gmac_cipher, &session->gmac_cipher_ctx)) + &session->cipher_info, &session->cipher, + &session->gmac_cipher_info, &session->gmac_cipher)) exit_bug(ctx, "composed-gmac: can't instanciate cipher"); - session->cipher_state = session->cipher->init_state(ctx, session->cipher_ctx, secret); + session->cipher_state = session->cipher->init(ctx, secret); if (session->cipher_info->iv_length && session->cipher_info->iv_length <= COMMON_NONCEBYTES) exit_bug(ctx, "composed-gmac: iv_length to small"); - session->gmac_cipher_state = session->gmac_cipher->init_state(ctx, session->gmac_cipher_ctx, secret + session->cipher_info->key_length); + session->gmac_cipher_state = session->gmac_cipher->init(ctx, secret + session->cipher_info->key_length); if (session->gmac_cipher_info->iv_length <= COMMON_NONCEBYTES) exit_bug(ctx, "composed-gmac: GMAC cipher iv_length to small"); @@ -148,18 +145,18 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c memset(zeroiv, 0, session->gmac_cipher_info->iv_length); 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); + session->cipher->free(ctx, session->cipher_state); + session->gmac_cipher->free(ctx, session->gmac_cipher_state); free(session); return NULL; } - session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info, &session->ghash_ctx); + session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info); if (!session->ghash) exit_bug(ctx, "composed-gmac: can't instanciate ghash mac"); - session->ghash_state = session->ghash->init_state(ctx, session->ghash_ctx, H.b); + session->ghash_state = session->ghash->init(ctx, H.b); return session; } @@ -182,9 +179,9 @@ static void method_session_superseded(fastd_context_t *ctx, fastd_method_session static void method_session_free(fastd_context_t *ctx, fastd_method_session_state_t *session) { if (session) { - session->cipher->free_state(ctx, session->cipher_state); - session->gmac_cipher->free_state(ctx, session->gmac_cipher_state); - session->ghash->free_state(ctx, session->ghash_state); + session->cipher->free(ctx, session->cipher_state); + session->gmac_cipher->free(ctx, session->gmac_cipher_state); + session->ghash->free(ctx, session->ghash_state); free(session); } diff --git a/src/methods/generic_gcm/generic_gcm.c b/src/methods/generic_gcm/generic_gcm.c index 9481100..52065eb 100644 --- a/src/methods/generic_gcm/generic_gcm.c +++ b/src/methods/generic_gcm/generic_gcm.c @@ -33,17 +33,15 @@ struct fastd_method_session_state { const fastd_cipher_info_t *cipher_info; const fastd_cipher_t *cipher; - const fastd_cipher_context_t *cipher_ctx; fastd_cipher_state_t *cipher_state; const fastd_mac_info_t *ghash_info; const fastd_mac_t *ghash; - const fastd_mac_context_t *ghash_ctx; fastd_mac_state_t *ghash_state; }; -static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx) { +static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher) { if (!fastd_mac_info_get_by_name("ghash")) return false; @@ -62,7 +60,7 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe const fastd_cipher_info_t *info = NULL; if (ctx) { - *cipher = fastd_cipher_get_by_name(ctx, name_ctr, &info, cctx); + *cipher = fastd_cipher_get_by_name(ctx, name_ctr, &info); if (!*cipher) return false; } @@ -83,12 +81,12 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe static bool method_provides(const char *name) { - return cipher_get(NULL, name, NULL, NULL, NULL); + return cipher_get(NULL, name, NULL, NULL); } static size_t method_key_length(fastd_context_t *ctx, const char *name) { const fastd_cipher_info_t *cipher_info; - if (!cipher_get(NULL, name, &cipher_info, NULL, NULL)) + if (!cipher_get(NULL, name, &cipher_info, NULL)) exit_bug(ctx, "generic-gcm: can't get cipher key length"); return cipher_info->key_length; @@ -99,10 +97,10 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c fastd_method_common_init(ctx, &session->common, initiator); - if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher, &session->cipher_ctx)) + if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher)) exit_bug(ctx, "generic-gcm: can't instanciate cipher"); - session->cipher_state = session->cipher->init_state(ctx, session->cipher_ctx, secret); + session->cipher_state = session->cipher->init(ctx, secret); static const fastd_block128_t zeroblock = {}; fastd_block128_t H; @@ -114,16 +112,16 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c memset(zeroiv, 0, session->cipher_info->iv_length); if (!session->cipher->crypt(ctx, session->cipher_state, &H, &zeroblock, sizeof(fastd_block128_t), zeroiv)) { - session->cipher->free_state(ctx, session->cipher_state); + session->cipher->free(ctx, session->cipher_state); free(session); return NULL; } - session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info, &session->ghash_ctx); + session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info); if (!session->ghash) exit_bug(ctx, "generic-gcm: can't instanciate ghash mac"); - session->ghash_state = session->ghash->init_state(ctx, session->ghash_ctx, H.b); + session->ghash_state = session->ghash->init(ctx, H.b); return session; } @@ -153,8 +151,8 @@ static void method_session_superseded(fastd_context_t *ctx, fastd_method_session static void method_session_free(fastd_context_t *ctx, fastd_method_session_state_t *session) { if (session) { - session->cipher->free_state(ctx, session->cipher_state); - session->ghash->free_state(ctx, session->ghash_state); + session->cipher->free(ctx, session->cipher_state); + session->ghash->free(ctx, session->ghash_state); free(session); } diff --git a/src/methods/generic_gmac/generic_gmac.c b/src/methods/generic_gmac/generic_gmac.c index 5501076..4de7ad8 100644 --- a/src/methods/generic_gmac/generic_gmac.c +++ b/src/methods/generic_gmac/generic_gmac.c @@ -33,17 +33,15 @@ struct fastd_method_session_state { const fastd_cipher_info_t *cipher_info; const fastd_cipher_t *cipher; - const fastd_cipher_context_t *cipher_ctx; fastd_cipher_state_t *cipher_state; const fastd_mac_info_t *ghash_info; const fastd_mac_t *ghash; - const fastd_mac_context_t *ghash_ctx; fastd_mac_state_t *ghash_state; }; -static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx) { +static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher) { if (!fastd_mac_info_get_by_name("ghash")) return false; @@ -65,7 +63,7 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe const fastd_cipher_info_t *info = NULL; if (ctx) { - *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info, cctx); + *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info); if (!*cipher) return false; } @@ -86,12 +84,12 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe static bool method_provides(const char *name) { - return cipher_get(NULL, name, NULL, NULL, NULL); + return cipher_get(NULL, name, NULL, NULL); } static size_t method_key_length(fastd_context_t *ctx, const char *name) { const fastd_cipher_info_t *cipher_info; - if (!cipher_get(NULL, name, &cipher_info, NULL, NULL)) + if (!cipher_get(NULL, name, &cipher_info, NULL)) exit_bug(ctx, "generic-gmac: can't get cipher key length"); return cipher_info->key_length + sizeof(fastd_block128_t); @@ -102,19 +100,19 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c fastd_method_common_init(ctx, &session->common, initiator); - if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher, &session->cipher_ctx)) + if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher)) exit_bug(ctx, "generic-gmac: can't instanciate cipher"); - session->cipher_state = session->cipher->init_state(ctx, session->cipher_ctx, secret); + session->cipher_state = session->cipher->init(ctx, secret); if (session->cipher_info->iv_length <= COMMON_NONCEBYTES) exit_bug(ctx, "generic-gmac: iv_length to small"); - session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info, &session->ghash_ctx); + session->ghash = fastd_mac_get_by_name(ctx, "ghash", &session->ghash_info); if (!session->ghash) exit_bug(ctx, "generic-gmac: can't instanciate ghash mac"); - session->ghash_state = session->ghash->init_state(ctx, session->ghash_ctx, secret + session->cipher_info->key_length); + session->ghash_state = session->ghash->init(ctx, secret + session->cipher_info->key_length); return session; } @@ -144,8 +142,8 @@ static void method_session_superseded(fastd_context_t *ctx, fastd_method_session static void method_session_free(fastd_context_t *ctx, fastd_method_session_state_t *session) { if (session) { - session->cipher->free_state(ctx, session->cipher_state); - session->ghash->free_state(ctx, session->ghash_state); + session->cipher->free(ctx, session->cipher_state); + session->ghash->free(ctx, session->ghash_state); free(session); } diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c index 3820907..c40e70f 100644 --- a/src/methods/generic_poly1305/generic_poly1305.c +++ b/src/methods/generic_poly1305/generic_poly1305.c @@ -38,12 +38,11 @@ struct fastd_method_session_state { const fastd_cipher_info_t *cipher_info; const fastd_cipher_t *cipher; - const fastd_cipher_context_t *cipher_ctx; fastd_cipher_state_t *cipher_state; }; -static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx) { +static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher) { size_t len = strlen(name); if (len < 9) @@ -59,7 +58,7 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe const fastd_cipher_info_t *info = NULL; if (ctx) { - *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info, cctx); + *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info); if (!*cipher) return false; } @@ -80,12 +79,12 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe static bool method_provides(const char *name) { - return cipher_get(NULL, name, NULL, NULL, NULL); + return cipher_get(NULL, name, NULL, NULL); } static size_t method_key_length(fastd_context_t *ctx, const char *name) { const fastd_cipher_info_t *cipher_info; - if (!cipher_get(NULL, name, &cipher_info, NULL, NULL)) + if (!cipher_get(NULL, name, &cipher_info, NULL)) exit_bug(ctx, "generic-poly1305: can't get cipher key length"); return cipher_info->key_length; @@ -96,10 +95,10 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c fastd_method_common_init(ctx, &session->common, initiator); - if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher, &session->cipher_ctx)) + if (!cipher_get(ctx, name, &session->cipher_info, &session->cipher)) exit_bug(ctx, "generic-poly1305: can't instanciate cipher"); - session->cipher_state = session->cipher->init_state(ctx, session->cipher_ctx, secret); + session->cipher_state = session->cipher->init(ctx, secret); if (session->cipher_info->iv_length <= COMMON_NONCEBYTES) exit_bug(ctx, "generic-poly1305: iv_length to small"); @@ -125,7 +124,7 @@ static void method_session_superseded(fastd_context_t *ctx, fastd_method_session static void method_session_free(fastd_context_t *ctx, fastd_method_session_state_t *session) { if (session) { - session->cipher->free_state(ctx, session->cipher_state); + session->cipher->free(ctx, session->cipher_state); free(session); } } |