summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-07 00:32:48 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-07 00:32:48 +0000
commit41ae3f6cbee385c8fae31e716ca3037983cb1b7a (patch)
tree91eafd0a2b5bad8c8b490b3e612137e777a10f93
parentupdated manpage (diff)
minor cleanups
-rw-r--r--src/auth_algo.c4
-rw-r--r--src/key_derivation.c5
-rw-r--r--src/uanytun.c15
3 files changed, 14 insertions, 10 deletions
diff --git a/src/auth_algo.c b/src/auth_algo.c
index 1476ad0..0193fa6 100644
--- a/src/auth_algo.c
+++ b/src/auth_algo.c
@@ -200,7 +200,7 @@ void auth_algo_sha1_generate(auth_algo_t* aa, key_derivation_t* kd, encrypted_pa
HMAC_Init_ex(&params->ctx_, aa->key_.buf_, aa->key_.length_, EVP_sha1(), NULL);
}
else {
- HMAC_Init_ex(&params->ctx_, NULL, 0, EVP_sha1(), NULL);
+ HMAC_Init_ex(&params->ctx_, NULL, 0, NULL, NULL);
#endif
}
@@ -254,7 +254,7 @@ int auth_algo_sha1_check_tag(auth_algo_t* aa, key_derivation_t* kd, encrypted_pa
HMAC_Init_ex(&params->ctx_, aa->key_.buf_, aa->key_.length_, EVP_sha1(), NULL);
}
else {
- HMAC_Init_ex(&params->ctx_, NULL, 0, EVP_sha1(), NULL);
+ HMAC_Init_ex(&params->ctx_, NULL, 0, NULL, NULL);
#endif
}
diff --git a/src/key_derivation.c b/src/key_derivation.c
index a2726d7..f2094e0 100644
--- a/src/key_derivation.c
+++ b/src/key_derivation.c
@@ -124,7 +124,7 @@ int key_derivation_init(key_derivation_t* kd, const char* type, int8_t ld_kdr, c
int key_derivation_generate_master_key(key_derivation_t* kd, const char* passphrase, u_int16_t key_length)
{
- if(!kd || !passphrase)
+ if(!kd || !passphrase)
return -1;
if(!key_length || (key_length % 8)) {
@@ -181,7 +181,7 @@ int key_derivation_generate_master_key(key_derivation_t* kd, const char* passphr
int key_derivation_generate_master_salt(key_derivation_t* kd, const char* passphrase, u_int16_t salt_length)
{
- if(!kd || !passphrase)
+ if(!kd || !passphrase)
return -1;
if(!salt_length || (salt_length % 8)) {
@@ -429,7 +429,6 @@ int key_derivation_aesctr_generate(key_derivation_t* kd, satp_prf_label_t label,
}
err = gcry_cipher_setctr(params->handle_, params->ctr_.buf_, KD_AESCTR_CTR_LENGTH);
-
if(err) {
log_printf(ERR, "failed to set key derivation CTR: %s", gcry_strerror(err));
return -1;
diff --git a/src/uanytun.c b/src/uanytun.c
index b857afd..e403d40 100644
--- a/src/uanytun.c
+++ b/src/uanytun.c
@@ -148,6 +148,9 @@ int init_main_loop(options_t* opt, cipher_t* c, auth_algo_t* aa, key_derivation_
int process_tun_data(tun_device_t* dev, udp_socket_t* sock, options_t* opt, plain_packet_t* plain_packet, encrypted_packet_t* encrypted_packet,
cipher_t* c, auth_algo_t* aa, key_derivation_t* kd_out, seq_nr_t seq_nr)
{
+ plain_packet_set_payload_length(plain_packet, -1);
+ encrypted_packet_set_length(encrypted_packet, -1);
+
int len = tun_read(dev, plain_packet_get_payload(plain_packet), plain_packet_get_payload_length(plain_packet));
if(len == -1) {
log_printf(ERR, "error on reading from device: %m");
@@ -179,6 +182,9 @@ int process_tun_data(tun_device_t* dev, udp_socket_t* sock, options_t* opt, plai
int process_sock_data(tun_device_t* dev, udp_socket_t* sock, options_t* opt, plain_packet_t* plain_packet, encrypted_packet_t* encrypted_packet,
cipher_t* c, auth_algo_t* aa, key_derivation_t* kd_in, seq_win_t* seq_win)
{
+ plain_packet_set_payload_length(plain_packet, -1);
+ encrypted_packet_set_length(encrypted_packet, -1);
+
udp_endpoint_t remote;
memset(&remote, 0, sizeof(udp_endpoint_t));
int len = udp_read(sock, encrypted_packet_get_packet(encrypted_packet), encrypted_packet_get_length(encrypted_packet), &remote);
@@ -252,9 +258,6 @@ int main_loop(tun_device_t* dev, udp_socket_t* sock, options_t* opt)
int return_value = 0;
while(!return_value) {
- plain_packet_set_payload_length(&plain_packet, -1);
- encrypted_packet_set_length(&encrypted_packet, -1);
-
FD_ZERO(&readfds);
FD_SET(dev->fd_, &readfds);
FD_SET(sock->fd_, &readfds);
@@ -277,12 +280,14 @@ int main_loop(tun_device_t* dev, udp_socket_t* sock, options_t* opt)
if(FD_ISSET(dev->fd_, &readfds)) {
return_value = process_tun_data(dev, sock, opt, &plain_packet, &encrypted_packet, &c, &aa, &kd_out, seq_nr);
seq_nr++;
- continue;
+ if(return_value)
+ break;
}
if(FD_ISSET(sock->fd_, &readfds)) {
return_value = process_sock_data(dev, sock, opt, &plain_packet, &encrypted_packet, &c, &aa, &kd_in, &seq_win);
- continue;
+ if(return_value)
+ break;
}
}