From 88a6bccf12f6a3375ebd93ee1f9bca6e4ee17b35 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 13 Mar 2023 16:20:17 -0400 Subject: [PATCH] Use b64 alphabet for b64 While POSIX hates +, b64 needs + --- confluent_osdeploy/utils/clortho.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/confluent_osdeploy/utils/clortho.c b/confluent_osdeploy/utils/clortho.c index d2e74312..887deee2 100644 --- a/confluent_osdeploy/utils/clortho.c +++ b/confluent_osdeploy/utils/clortho.c @@ -19,6 +19,7 @@ #define MAXPACKET 1024 static const char cryptalpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"; +static const char b64alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; unsigned char* genpasswd(int len) { unsigned char * passwd; @@ -56,10 +57,10 @@ char * b64e(uint8_t * data, uint32_t datalen) { currchunk[1] = remaining > 1 ? currptr[1] : 0; currchunk[2] = remaining > 2 ? currptr[2] : 0; currptr += 3; - currout[0] = cryptalpha[currchunk[0] >> 2]; - currout[1] = cryptalpha[(currchunk[0] << 4 | currchunk[1] >> 4) & 0x3f]; - currout[2] = remaining > 1 ? cryptalpha[(currchunk[1] << 2 | currchunk[2] >> 6) & 0x3f] : '='; - currout[3] = remaining > 2 ? cryptalpha[currchunk[2] & 0x3f] : '='; + currout[0] = b64alpha[currchunk[0] >> 2]; + currout[1] = b64alpha[(currchunk[0] << 4 | currchunk[1] >> 4) & 0x3f]; + currout[2] = remaining > 1 ? b64alpha[(currchunk[1] << 2 | currchunk[2] >> 6) & 0x3f] : '='; + currout[3] = remaining > 2 ? b64alpha[currchunk[2] & 0x3f] : '='; remaining -= 3; currout += 4; }