summaryrefslogtreecommitdiffstats
path: root/src/protocols
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-30 03:44:06 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-30 03:44:06 +0100
commitd5a043a7c0672df5da19a6024da4ab1af45151a9 (patch)
treeebd86ebe9aaae77e7766c5fa804a847b2d23c537 /src/protocols
parent8088a82a2a91d29967cef920ba780eecdf72518e (diff)
downloadfastd-d5a043a7c0672df5da19a6024da4ab1af45151a9.tar
fastd-d5a043a7c0672df5da19a6024da4ab1af45151a9.zip
Rename methods to methods providers and method contexts to methods to reflect their function better
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c16
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h2
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.c16
-rw-r--r--src/protocols/ec25519_fhmqvc/state.c2
4 files changed, 18 insertions, 18 deletions
diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
index a8de436..05479d0 100644
--- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
@@ -41,7 +41,7 @@ static inline bool read_key(uint8_t key[32], const char *hexkey) {
static inline void check_session_refresh(fastd_context_t *ctx, fastd_peer_t *peer) {
protocol_session_t *session = &peer->protocol_state->session;
- if (!session->refreshing && session->method->method->session_want_refresh(ctx, session->method_state)) {
+ if (!session->refreshing && session->method->provider->session_want_refresh(ctx, session->method_state)) {
pr_verbose(ctx, "refreshing session with %P", peer);
session->handshakes_cleaned = true;
session->refreshing = true;
@@ -104,17 +104,17 @@ static void protocol_handle_recv(fastd_context_t *ctx, fastd_peer_t *peer, fastd
bool ok = false;
if (is_session_valid(ctx, &peer->protocol_state->old_session)) {
- if (peer->protocol_state->old_session.method->method->decrypt(ctx, peer, peer->protocol_state->old_session.method_state, &recv_buffer, buffer))
+ if (peer->protocol_state->old_session.method->provider->decrypt(ctx, peer, peer->protocol_state->old_session.method_state, &recv_buffer, buffer))
ok = true;
}
if (!ok) {
- if (peer->protocol_state->session.method->method->decrypt(ctx, peer, peer->protocol_state->session.method_state, &recv_buffer, buffer)) {
+ if (peer->protocol_state->session.method->provider->decrypt(ctx, peer, peer->protocol_state->session.method_state, &recv_buffer, buffer)) {
ok = true;
if (peer->protocol_state->old_session.method) {
pr_debug(ctx, "invalidating old session with %P", peer);
- peer->protocol_state->old_session.method->method->session_free(ctx, peer->protocol_state->old_session.method_state);
+ peer->protocol_state->old_session.method->provider->session_free(ctx, peer->protocol_state->old_session.method_state);
peer->protocol_state->old_session = (protocol_session_t){};
}
@@ -123,7 +123,7 @@ static void protocol_handle_recv(fastd_context_t *ctx, fastd_peer_t *peer, fastd
fastd_peer_unschedule_handshake(ctx, peer);
peer->protocol_state->session.handshakes_cleaned = true;
- if (peer->protocol_state->session.method->method->session_is_initiator(ctx, peer->protocol_state->session.method_state))
+ if (peer->protocol_state->session.method->provider->session_is_initiator(ctx, peer->protocol_state->session.method_state))
fastd_protocol_ec25519_fhmqvc_send_empty(ctx, peer, &peer->protocol_state->session);
}
@@ -153,7 +153,7 @@ static void session_send(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer_
size_t stat_size = buffer.len;
fastd_buffer_t send_buffer;
- if (!session->method->method->encrypt(ctx, peer, session->method_state, &send_buffer, buffer)) {
+ if (!session->method->provider->encrypt(ctx, peer, session->method_state, &send_buffer, buffer)) {
fastd_buffer_free(buffer);
pr_error(ctx, "failed to encrypt packet for %P", peer);
return;
@@ -171,7 +171,7 @@ static void protocol_send(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer
check_session_refresh(ctx, peer);
- if (peer->protocol_state->session.method->method->session_is_initiator(ctx, peer->protocol_state->session.method_state) && is_session_valid(ctx, &peer->protocol_state->old_session)) {
+ if (peer->protocol_state->session.method->provider->session_is_initiator(ctx, peer->protocol_state->session.method_state) && is_session_valid(ctx, &peer->protocol_state->old_session)) {
pr_debug2(ctx, "sending packet for old session to %P", peer);
session_send(ctx, peer, buffer, &peer->protocol_state->old_session);
}
@@ -181,7 +181,7 @@ static void protocol_send(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer
}
void fastd_protocol_ec25519_fhmqvc_send_empty(fastd_context_t *ctx, fastd_peer_t *peer, protocol_session_t *session) {
- session_send(ctx, peer, fastd_buffer_alloc(ctx, 0, alignto(session->method->method->min_encrypt_head_space, 8), session->method->method->min_encrypt_tail_space), session);
+ session_send(ctx, peer, fastd_buffer_alloc(ctx, 0, alignto(session->method->provider->min_encrypt_head_space, 8), session->method->provider->min_encrypt_tail_space), session);
}
const fastd_protocol_t fastd_protocol_ec25519_fhmqvc = {
diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
index 638117d..eae7f75 100644
--- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.h
@@ -106,7 +106,7 @@ static inline void hexdump(char out[65], const unsigned char d[32]) {
static inline bool is_session_valid(fastd_context_t *ctx, const protocol_session_t *session) {
- return (session->method && session->method->method->session_is_valid(ctx, session->method_state));
+ return (session->method && session->method->provider->session_is_valid(ctx, session->method_state));
}
#endif /* _FASTD_PROTOCOL_EC25519_FHMQVC_H_ */
diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c
index 0225513..4b70d9a 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.c
+++ b/src/protocols/ec25519_fhmqvc/handshake.c
@@ -71,22 +71,22 @@ static void derive_key(fastd_sha256_t *out, size_t blocks, const uint32_t *salt,
static inline void supersede_session(fastd_context_t *ctx, fastd_peer_t *peer, const fastd_method_info_t *method) {
if (is_session_valid(ctx, &peer->protocol_state->session) && !is_session_valid(ctx, &peer->protocol_state->old_session)) {
if (peer->protocol_state->old_session.method)
- peer->protocol_state->old_session.method->method->session_free(ctx, peer->protocol_state->old_session.method_state);
+ peer->protocol_state->old_session.method->provider->session_free(ctx, peer->protocol_state->old_session.method_state);
peer->protocol_state->old_session = peer->protocol_state->session;
}
else {
if (peer->protocol_state->session.method)
- peer->protocol_state->session.method->method->session_free(ctx, peer->protocol_state->session.method_state);
+ peer->protocol_state->session.method->provider->session_free(ctx, peer->protocol_state->session.method_state);
}
if (peer->protocol_state->old_session.method) {
if (peer->protocol_state->old_session.method != method) {
pr_debug(ctx, "method of %P has changed, terminating old session", peer);
- peer->protocol_state->old_session.method->method->session_free(ctx, peer->protocol_state->old_session.method_state);
+ peer->protocol_state->old_session.method->provider->session_free(ctx, peer->protocol_state->old_session.method_state);
peer->protocol_state->old_session = (protocol_session_t){};
}
else {
- peer->protocol_state->old_session.method->method->session_superseded(ctx, peer->protocol_state->old_session.method_state);
+ peer->protocol_state->old_session.method->provider->session_superseded(ctx, peer->protocol_state->old_session.method_state);
}
}
}
@@ -98,16 +98,16 @@ static inline bool new_session(fastd_context_t *ctx, fastd_peer_t *peer, const f
supersede_session(ctx, peer, method);
if (salt) {
- size_t blocks = block_count(method->method->key_length(ctx, method->ctx), sizeof(fastd_sha256_t));
+ size_t blocks = block_count(method->provider->key_length(ctx, method->method), sizeof(fastd_sha256_t));
fastd_sha256_t secret[blocks];
derive_key(secret, blocks, salt, method->name, A, B, X, Y, sigma);
- peer->protocol_state->session.method_state = method->method->session_init(ctx, method->ctx, (const uint8_t*)secret, initiator);
+ peer->protocol_state->session.method_state = method->provider->session_init(ctx, method->method, (const uint8_t*)secret, initiator);
}
else {
fastd_sha256_t hash;
fastd_sha256_blocks(&hash, X->u32, Y->u32, A->u32, B->u32, sigma->u32, NULL);
- peer->protocol_state->session.method_state = method->method->session_init_compat(ctx, method->ctx, hash.b, HASHBYTES, initiator);
+ peer->protocol_state->session.method_state = method->provider->session_init_compat(ctx, method->method, hash.b, HASHBYTES, initiator);
}
if (!peer->protocol_state->session.method_state)
@@ -131,7 +131,7 @@ static bool establish(fastd_context_t *ctx, fastd_peer_t *peer, const fastd_meth
return false;
}
- if (!salt && !method->method->session_init_compat) {
+ if (!salt && !method->provider->session_init_compat) {
pr_warn(ctx, "can't establish compat session with %P[%I] (method without compat support)", peer, remote_addr);
return false;
}
diff --git a/src/protocols/ec25519_fhmqvc/state.c b/src/protocols/ec25519_fhmqvc/state.c
index f27fcc6..46374cc 100644
--- a/src/protocols/ec25519_fhmqvc/state.c
+++ b/src/protocols/ec25519_fhmqvc/state.c
@@ -77,7 +77,7 @@ void fastd_protocol_ec25519_fhmqvc_init_peer_state(fastd_context_t *ctx, fastd_p
static void reset_session(fastd_context_t *ctx, protocol_session_t *session) {
if (session->method)
- session->method->method->session_free(ctx, session->method_state);
+ session->method->provider->session_free(ctx, session->method_state);
secure_memzero(session, sizeof(protocol_session_t));
}