re-work strict/relaxed base64 decoding implementation

Instead of one API function with an option parameter, provide two API
functions.
Instead of defaulting to strict decoding, default to relaxed decoding.
This commit is contained in:
Steffen Jaeckel
2017-02-17 11:18:58 +01:00
committed by Karel Miko
parent 53359ccfc6
commit c1dd1cbe30
7 changed files with 51 additions and 35 deletions
-5
View File
@@ -476,11 +476,6 @@
#define LTC_PKCS_1
#endif
#if (defined(LTC_BASE64) || defined(LTC_BASE64_URL)) && !defined(LTC_BASE64_STRICT)
/* By default we're doing strict decoding now */
#define LTC_BASE64_STRICT 1
#endif
#if defined(TFM_DESC) && defined(LTC_RSA_BLINDING)
#warning RSA blinding currently not supported in combination with TFM
#undef LTC_RSA_BLINDING
+8 -6
View File
@@ -3,18 +3,20 @@
int base64_encode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
#define base64_decode(i, il, o, ol) base64_decode_ex(i, il, o, ol, LTC_BASE64_STRICT)
int base64_decode_ex(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen, int strict);
int base64_decode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
int base64_strict_decode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
#endif
#ifdef LTC_BASE64_URL
int base64url_encode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
#define base64url_decode(i, il, o, ol) base64url_decode_ex(i, il, o, ol, LTC_BASE64_STRICT)
int base64url_decode_ex(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen, int strict);
int base64url_decode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
int base64url_strict_decode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
#endif
/* ===> LTC_HKDF -- RFC5869 HMAC-based Key Derivation Function <=== */