diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-02 13:42:55 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-02 13:42:55 +0100 |
commit | 7a3c8bee42879add84a143ff98f28cbd0251dc7b (patch) | |
tree | 3138520bf3e16cd33fa03dfe68c1fedf67c3d901 /src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c | |
parent | f2c2f2926bce65c5c09d274c514d382ffd98f78c (diff) | |
download | fastd-7a3c8bee42879add84a143ff98f28cbd0251dc7b.tar fastd-7a3c8bee42879add84a143ff98f28cbd0251dc7b.zip |
Allow flexible specification of methods provided by an implementation
Diffstat (limited to 'src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c')
-rw-r--r-- | src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c index 768e5c8..220e913 100644 --- a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c +++ b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c @@ -37,6 +37,10 @@ struct fastd_method_session_state { }; +static bool method_provides(fastd_context_t *ctx UNUSED, const char *name) { + return !strcmp(name, "xsalsa20-poly1305"); +} + static size_t method_max_packet_size(fastd_context_t *ctx) { return (fastd_max_packet_size(ctx) + COMMON_NONCEBYTES + crypto_secretbox_xsalsa20poly1305_ZEROBYTES - crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES); } @@ -58,7 +62,7 @@ static size_t method_key_length(fastd_context_t *ctx UNUSED) { return crypto_secretbox_xsalsa20poly1305_KEYBYTES; } -static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, const uint8_t *secret, bool initiator) { +static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, const char *name UNUSED, const 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); @@ -68,11 +72,11 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c return session; } -static fastd_method_session_state_t* method_session_init_compat(fastd_context_t *ctx, const uint8_t *secret, size_t length, bool initiator) { +static fastd_method_session_state_t* method_session_init_compat(fastd_context_t *ctx, const char *name, const uint8_t *secret, size_t length, bool initiator) { if (length < crypto_secretbox_xsalsa20poly1305_KEYBYTES) exit_bug(ctx, "xsalsa20-poly1305: tried to init with short secret"); - return method_session_init(ctx, secret, initiator); + return method_session_init(ctx, name, secret, initiator); } static bool method_session_is_valid(fastd_context_t *ctx, fastd_method_session_state_t *session) { @@ -162,7 +166,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho } const fastd_method_t fastd_method_xsalsa20_poly1305 = { - .name = "xsalsa20-poly1305", + .provides = method_provides, .max_packet_size = method_max_packet_size, .min_encrypt_head_space = method_min_encrypt_head_space, |