tmplen = snprintf(tmp, sizeof(tmp), "%s%c%s%c%s", NONULL(authz), '\0', user, '\0', pass);
len = snprintf(buf, buflen, "%s ", cmd);
- len += mutt_to_base64(buf + len, tmp, tmplen, buflen - len);
+ len += mutt_b64_encode(buf + len, tmp, tmplen, buflen - len);
return len;
}
goto bail;
}
- len = mutt_from_base64(obuf, idata->buf + 2);
+ len = mutt_b64_decode(obuf, idata->buf + 2);
if (len == -1)
{
mutt_debug(1, "Error decoding base64 response.\n");
/* ibuf must be long enough to store the base64 encoding of obuf,
* plus the additional debris */
- mutt_to_base64(ibuf, obuf, strlen(obuf), sizeof(ibuf) - 2);
+ mutt_b64_encode(ibuf, obuf, strlen(obuf), sizeof(ibuf) - 2);
safe_strcat(ibuf, sizeof(ibuf), "\r\n");
mutt_socket_write(idata->conn, ibuf);
/* now start the security context initialisation loop... */
mutt_debug(2, "Sending credentials\n");
- mutt_to_base64(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
+ mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
gss_release_buffer(&min_stat, &send_token);
safe_strcat(buf1, sizeof(buf1), "\r\n");
mutt_socket_write(idata->conn, buf1);
goto bail;
}
- request_buf.length = mutt_from_base64(buf2, idata->buf + 2);
+ request_buf.length = mutt_b64_decode(buf2, idata->buf + 2);
request_buf.value = buf2;
sec_token = &request_buf;
goto err_abort_cmd;
}
- mutt_to_base64(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
+ mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
gss_release_buffer(&min_stat, &send_token);
safe_strcat(buf1, sizeof(buf1), "\r\n");
mutt_socket_write(idata->conn, buf1);
mutt_debug(1, "Error receiving server response.\n");
goto bail;
}
- request_buf.length = mutt_from_base64(buf2, idata->buf + 2);
+ request_buf.length = mutt_b64_decode(buf2, idata->buf + 2);
request_buf.value = buf2;
maj_stat = gss_unwrap(&min_stat, context, &request_buf, &send_token, &cflags, &quality);
goto err_abort_cmd;
}
- mutt_to_base64(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
+ mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
mutt_debug(2, "Requesting authorisation as %s\n", idata->conn->account.user);
safe_strcat(buf1, sizeof(buf1), "\r\n");
mutt_socket_write(idata->conn, buf1);
*
* | Function | Description
* | :----------------- | :-------------------------------------------------
- * | mutt_from_base64() | convert null-terminated base64 string to raw bytes
- * | mutt_to_base64() | convert raw bytes to null-terminated base64 string
+ * | mutt_b64_decode() | convert null-terminated base64 string to raw bytes
+ * | mutt_b64_encode() | convert raw bytes to null-terminated base64 string
*/
#include "config.h"
// clang-format on
/**
- * mutt_to_base64 - convert raw bytes to null-terminated base64 string
+ * mutt_b64_encode - convert raw bytes to null-terminated base64 string
* @param out Output buffer for the base64 encoded string
* @param cin Input buffer for the raw bytes
* @param len Length of the input buffer
* null-byte is returned (equivalent to calling strlen() on the output buffer
* after this function returns).
*/
-size_t mutt_to_base64(char *out, const char *cin, size_t len, size_t olen)
+size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen)
{
unsigned char *begin = (unsigned char *) out;
const unsigned char *in = (const unsigned char *) cin;
}
/**
- * mutt_from_base64 - convert null-terminated base64 string to raw bytes
+ * mutt_b64_decode - convert null-terminated base64 string to raw bytes
* @param out Output buffer for the raw bytes
* @param in Input buffer for the null-terminated base64-encoded string
* @retval n Number of bytes written on success
* null-terminated. If the input buffer contains invalid base64 characters,
* this function returns -1.
*/
-int mutt_from_base64(char *out, const char *in)
+int mutt_b64_decode(char *out, const char *in)
{
int len = 0;
unsigned char digit1, digit2, digit3, digit4;
#define base64val(c) Index_64[(unsigned int) (c)]
-size_t mutt_to_base64(char *out, const char *cin, size_t len, size_t olen);
-int mutt_from_base64(char *out, const char *in);
+size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen);
+int mutt_b64_decode(char *out, const char *in);
#endif /* _MUTT_BASE64_H */
size_t ret;
size_t in_len = MIN(3, dlen);
- ret = mutt_to_base64(encoded, d, in_len, sizeof(encoded));
+ ret = mutt_b64_encode(encoded, d, in_len, sizeof(encoded));
for (size_t i = 0; i < ret; i++)
*s++ = encoded[i];
static void b64_flush(struct B64Context *ctx, FILE *fout)
{
- /* for some reasons, mutt_to_base64 expects the
+ /* for some reasons, mutt_b64_encode expects the
* output buffer to be larger than 10B */
char encoded[11];
size_t ret;
/* ret should always be equal to 4 here, because ctx->size
* is a value between 1 and 3 (included), but let's not hardcode it
* and prefer the return value of the function */
- ret = mutt_to_base64(encoded, ctx->buffer, ctx->size, sizeof(encoded));
+ ret = mutt_b64_encode(encoded, ctx->buffer, ctx->size, sizeof(encoded));
for (size_t i = 0; i < ret; i++)
{
fputc(encoded[i], fout);