Replace OpenSSL base64 impl with a simple direct impl.

Unit tests, too.
This commit is contained in:
John Hood
2015-10-04 20:16:25 -04:00
parent 1307dc4a0f
commit db311f92f7
8 changed files with 256 additions and 88 deletions
+7 -2
View File
@@ -105,7 +105,7 @@ Base64Key::Base64Key( string printable_key )
string base64 = printable_key + "==";
size_t len = 16;
if ( !base64_decode( base64.data(), 24, (char *)&key[ 0 ], &len ) ) {
if ( !base64_decode( base64.data(), 24, key, &len ) ) {
throw CryptoException( "Key must be well-formed base64." );
}
@@ -124,11 +124,16 @@ Base64Key::Base64Key()
PRNG().fill( key, sizeof( key ) );
}
Base64Key::Base64Key(PRNG &prng)
{
prng.fill( key, sizeof( key ) );
}
string Base64Key::printable_key( void ) const
{
char base64[ 24 ];
base64_encode( (char *)key, 16, base64, 24 );
base64_encode( key, 16, base64, 24 );
if ( (base64[ 23 ] != '=')
|| (base64[ 22 ] != '=') ) {