From 0de4082e86ac1193eb83805d5ea1d749f3f2bee7 Mon Sep 17 00:00:00 2001 From: John Hood Date: Tue, 20 Oct 2015 02:39:36 -0400 Subject: [PATCH] base64: remove a timing variation --- src/crypto/base64.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/crypto/base64.cc b/src/crypto/base64.cc index e3e1997..94ab76d 100644 --- a/src/crypto/base64.cc +++ b/src/crypto/base64.cc @@ -45,8 +45,13 @@ static unsigned char base64_char_to_sixbit(char c) * Yes, this is slow. But it's also very simple, and easy to verify. * We don't need performance here. */ - const char *match = strchr(table, c); - if (!match) { + const char *match = NULL; + for ( const char *search = table; *search; search++ ) { + if ( *search == c ) { + match = search; + } + } + if ( !match ) { return 0xff; } return match - table;