Improve the Base64 line size for NO_ASN
case. Fix report of unread ret
.
This commit is contained in:
parent
cfc0aeb857
commit
a4caa42793
@ -15573,10 +15573,9 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
|
||||
/* get curve id */
|
||||
if ((ret = CheckCurve(oidSum)) < 0)
|
||||
ret = ECC_CURVE_OID_E;
|
||||
return ECC_CURVE_OID_E;
|
||||
else {
|
||||
curve_id = ret;
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,11 @@
|
||||
#ifndef NO_CODING
|
||||
|
||||
#include <wolfssl/wolfcrypt/coding.h>
|
||||
#include <wolfssl/wolfcrypt/asn.h> /* For PEM_LINE_SZ */
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
#ifndef NO_ASN
|
||||
#include <wolfssl/wolfcrypt/asn.h> /* For PEM_LINE_SZ */
|
||||
#endif
|
||||
|
||||
enum {
|
||||
BAD = 0xFF, /* invalid encoding */
|
||||
@ -42,6 +43,14 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
#ifndef BASE64_LINE_SZ
|
||||
#ifdef NO_ASN
|
||||
#define BASE64_LINE_SZ 64
|
||||
#else
|
||||
#define BASE64_LINE_SZ PEM_LINE_SZ
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_BASE64_DECODE
|
||||
|
||||
static
|
||||
@ -91,7 +100,7 @@ int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
{
|
||||
word32 i = 0;
|
||||
word32 j = 0;
|
||||
word32 plainSz = inLen - ((inLen + (PEM_LINE_SZ - 1)) / PEM_LINE_SZ );
|
||||
word32 plainSz = inLen - ((inLen + (BASE64_LINE_SZ - 1)) / BASE64_LINE_SZ );
|
||||
int ret;
|
||||
const byte maxIdx = (byte)sizeof(base64Decode) + BASE64_MIN - 1;
|
||||
|
||||
@ -291,7 +300,7 @@ static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
|
||||
int getSzOnly = (out == NULL);
|
||||
|
||||
word32 outSz = (inLen + 3 - 1) / 3 * 4;
|
||||
word32 addSz = (outSz + PEM_LINE_SZ - 1) / PEM_LINE_SZ; /* new lines */
|
||||
word32 addSz = (outSz + BASE64_LINE_SZ - 1) / BASE64_LINE_SZ; /* new lines */
|
||||
|
||||
if (escaped == WC_ESC_NL_ENC)
|
||||
addSz *= 3; /* instead of just \n, we're doing %0A triplet */
|
||||
@ -328,8 +337,8 @@ static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
|
||||
|
||||
inLen -= 3;
|
||||
|
||||
/* Insert newline after PEM_LINE_SZ, unless no \n requested */
|
||||
if (escaped != WC_NO_NL_ENC && (++n % (PEM_LINE_SZ/4)) == 0 && inLen) {
|
||||
/* Insert newline after BASE64_LINE_SZ, unless no \n requested */
|
||||
if (escaped != WC_NO_NL_ENC && (++n % (BASE64_LINE_SZ/4)) == 0 && inLen) {
|
||||
ret = CEscape(escaped, '\n', out, &i, *outLen, 1, getSzOnly);
|
||||
if (ret != 0) break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user