diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-10-11 16:06:37 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-10-11 16:06:37 +0000 |
commit | a8cba88dc0cb0ad94ffc57d7c08ad35d2c511a27 (patch) | |
tree | bfd72ffd1cd4cb3bd83f6296a8c6383701a2a53c /usr.sbin/rpki-client | |
parent | 20fb6c1d86349034454a7f82237c21cbe46f844a (diff) |
base64_encode() should not add any newlines into the output. Because
of this switch from EVP_EncodeUpdate() plus complexity to the much
simpler use of calling EVP_EncodeBlock() directly.
OK job@
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r-- | usr.sbin/rpki-client/encoding.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/usr.sbin/rpki-client/encoding.c b/usr.sbin/rpki-client/encoding.c index b3dd38c208c..ff6d8731b70 100644 --- a/usr.sbin/rpki-client/encoding.c +++ b/usr.sbin/rpki-client/encoding.c @@ -1,4 +1,4 @@ -/* $OpenBSD: encoding.c,v 1.3 2021/09/01 08:09:41 claudio Exp $ */ +/* $OpenBSD: encoding.c,v 1.4 2021/10/11 16:06:36 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> * @@ -67,12 +67,8 @@ fail: int base64_encode(const unsigned char *in, size_t inlen, char **out) { - static EVP_ENCODE_CTX *ctx; unsigned char *to; - int tolen; - - if (ctx == NULL && (ctx = EVP_ENCODE_CTX_new()) == NULL) - err(1, "EVP_ENCODE_CTX_new"); + size_t tolen; *out = NULL; @@ -82,16 +78,9 @@ base64_encode(const unsigned char *in, size_t inlen, char **out) if ((to = malloc(tolen)) == NULL) return -1; - EVP_EncodeInit(ctx); - if (EVP_EncodeUpdate(ctx, to, &tolen, in, inlen) != 1) - goto fail; - EVP_EncodeFinal(ctx, to + tolen, &tolen); + EVP_EncodeBlock(to, in, inlen); *out = to; return 0; - -fail: - free(to); - return -1; } /* |