From 5412caeb1f05aa1083cc3858545a53238dc431ed Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2015 08:25:08 +0000 Subject: handle case where type is neither ENCRYPTED nor AX --- src/cadet/gnunet-service-cadet_tunnel.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/cadet/gnunet-service-cadet_tunnel.c') diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index b4eca603d..c73edf48e 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c @@ -3088,23 +3088,30 @@ GCT_handle_encrypted (struct CadetTunnel *t, unsigned int off; type = ntohs (msg->type); - if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type) + switch (type) { - const struct GNUNET_CADET_Encrypted *emsg; + case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED: + { + const struct GNUNET_CADET_Encrypted *emsg; - emsg = (struct GNUNET_CADET_Encrypted *) msg; - payload_size = size - sizeof (struct GNUNET_CADET_Encrypted); - decrypted_size = t_decrypt_and_validate (t, cbuf, &emsg[1], payload_size, - emsg->iv, &emsg->hmac); - } - else if (GNUNET_MESSAGE_TYPE_CADET_AX == type) - { - const struct GNUNET_CADET_AX *emsg; + emsg = (struct GNUNET_CADET_Encrypted *) msg; + payload_size = size - sizeof (struct GNUNET_CADET_Encrypted); + decrypted_size = t_decrypt_and_validate (t, cbuf, &emsg[1], payload_size, + emsg->iv, &emsg->hmac); + } + break; + case GNUNET_MESSAGE_TYPE_CADET_AX: + { + const struct GNUNET_CADET_AX *emsg; - emsg = (struct GNUNET_CADET_AX *) msg; - decrypted_size = t_ax_decrypt_and_validate (t, cbuf, emsg, size); + emsg = (struct GNUNET_CADET_AX *) msg; + decrypted_size = t_ax_decrypt_and_validate (t, cbuf, emsg, size); + } + break; + default: + GNUNET_break_op (0); + return; } - if (-1 == decrypted_size) { GNUNET_break_op (0); -- cgit v1.2.3