X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt_common.c;h=022692adc52ce1cb8fe4ec925e93362e89b4b754;hp=e02dc6af5b88ac5d5deb83f10d333324448c112a;hb=a7b65e41e2062c44c535f7cb4609e7988fc8ac0d;hpb=1cefe6a503c74d609db4e99e689d46575a5e40fd diff --git a/crypt_common.c b/crypt_common.c index e02dc6af..022692ad 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2012 Andre Noll + * Copyright (C) 2005 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -11,8 +11,8 @@ #include "para.h" #include "error.h" #include "string.h" -#include "crypt_backend.h" #include "crypt.h" +#include "crypt_backend.h" /** If the key begins with this text, we treat it as an ssh key. */ #define KEY_TYPE_TXT "ssh-rsa" @@ -90,41 +90,31 @@ int base64_decode(char const *src, unsigned char *target, size_t targsize) switch (state) { case 0: - if (target) { - if (tarindex >= targsize) - return -E_BASE64; - target[tarindex] = (pos - Base64) << 2; - } + if (tarindex >= targsize) + return -E_BASE64; + target[tarindex] = (pos - Base64) << 2; state = 1; break; case 1: - if (target) { - if (tarindex + 1 >= targsize) - return -E_BASE64; - target[tarindex] |= (pos - Base64) >> 4; - target[tarindex+1] = ((pos - Base64) & 0x0f) - << 4 ; - } + if (tarindex + 1 >= targsize) + return -E_BASE64; + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex + 1] = ((pos - Base64) & 0x0f) << 4; tarindex++; state = 2; break; case 2: - if (target) { - if (tarindex + 1 >= targsize) - return -E_BASE64; - target[tarindex] |= (pos - Base64) >> 2; - target[tarindex+1] = ((pos - Base64) & 0x03) - << 6; - } + if (tarindex + 1 >= targsize) + return -E_BASE64; + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex + 1] = ((pos - Base64) & 0x03) << 6; tarindex++; state = 3; break; case 3: - if (target) { - if (tarindex >= targsize) - return -E_BASE64; - target[tarindex] |= (pos - Base64); - } + if (tarindex >= targsize) + return -E_BASE64; + target[tarindex] |= pos - Base64; tarindex++; state = 0; break; @@ -170,7 +160,7 @@ int base64_decode(char const *src, unsigned char *target, size_t targsize) * zeros. If we don't check them, they become a * subliminal channel. */ - if (target && target[tarindex] != 0) + if (target[tarindex] != 0) return -E_BASE64; } } else { @@ -321,33 +311,3 @@ int hash_compare(unsigned char *h1, unsigned char *h2) } return 0; } - -int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size) -{ - int n; - - assert(size); - n = sc_recv_bin_buffer(scc, buf, size - 1); - if (n >= 0) - buf[n] = '\0'; - else - *buf = '\0'; - return n; -} - -int sc_send_buffer(struct stream_cipher_context *scc, char *buf) -{ - return sc_send_bin_buffer(scc, buf, strlen(buf)); -} - -__printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc, - const char *fmt, ...) -{ - char *msg; - int ret; - - PARA_VSPRINTF(fmt, msg); - ret = sc_send_buffer(scc, msg); - free(msg); - return ret; -}