/*
- * Copyright (C) 2005-2012 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
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;
* 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 {
}
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)
-{
- size_t len = strlen(buf);
- int ret = sc_send_bin_buffer(scc, buf, len);
-
- if (ret < 0 || ret == len)
- return ret;
- return -E_SHORT_WRITE;
-}
-
-__printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc,
- const char *fmt, ...)
-{
- char *msg;
- int ret;
- va_list ap;
-
- va_start(ap, fmt);
- ret = xvasprintf(&msg, fmt, ap);
- va_end(ap);
- ret = sc_send_bin_buffer(scc, msg, ret);
- free(msg);
- return ret;
-}