mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 12:20:52 +02:00
move length check before dispatch
This commit is contained in:
@@ -477,12 +477,15 @@ 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 + BASE64_LINE_SZ - 1) / BASE64_LINE_SZ; /* new lines */
|
||||
word32 outSz;
|
||||
word32 addSz;
|
||||
|
||||
if (in == NULL && inLen > 0)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
outSz = (inLen + 3 - 1) / 3 * 4;
|
||||
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 */
|
||||
else if (escaped == WC_NO_NL_ENC)
|
||||
|
||||
@@ -1789,6 +1789,10 @@
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (sz % DES_BLOCK_SIZE != 0) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
if (des->devId != INVALID_DEVID) {
|
||||
int ret = wc_CryptoCb_Des3Encrypt(des, out, in, sz);
|
||||
@@ -1819,10 +1823,6 @@
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
||||
if (sz % DES_BLOCK_SIZE != 0) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
blocks = sz / DES_BLOCK_SIZE;
|
||||
while (blocks--) {
|
||||
xorbuf((byte*)des->reg, in, DES_BLOCK_SIZE);
|
||||
@@ -1844,6 +1844,10 @@
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (sz % DES_BLOCK_SIZE != 0) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
if (des->devId != INVALID_DEVID) {
|
||||
int ret = wc_CryptoCb_Des3Decrypt(des, out, in, sz);
|
||||
@@ -1874,10 +1878,6 @@
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
||||
if (sz % DES_BLOCK_SIZE != 0) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
blocks = sz / DES_BLOCK_SIZE;
|
||||
while (blocks--) {
|
||||
XMEMCPY(des->tmp, in, DES_BLOCK_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user