@@ -11441,8 +11441,8 @@ int wc_AesXtsDecrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz,
1144111441}
1144211442#endif /* !WOLFSSL_ARMASM || WOLFSSL_ARMASM_NO_HW_CRYPTO */
1144311443
11444- /* Same as wc_AesXtsEncryptSector but the sector gets incremented by the
11445- * sectorSz every 32 blocks
11444+ /* Same as wc_AesXtsEncryptSector but the sector gets incremented by one every
11445+ * sectorSz bytes
1144611446 *
1144711447 * xaes AES keys to use for block encrypt
1144811448 * out output buffer to hold cipher text
@@ -11461,6 +11461,15 @@ int wc_AesXtsEncryptConsecutiveSectors(XtsAes* aes, byte* out, const byte* in,
1146111461 int sectorCount = sz / sectorSz ;
1146211462 int remainder = sz % sectorSz ;
1146311463
11464+ if (aes == NULL || out == NULL || in == NULL || sectorSz == 0 ) {
11465+ return BAD_FUNC_ARG ;
11466+ }
11467+
11468+ if (sz < AES_BLOCK_SIZE ) {
11469+ WOLFSSL_MSG ("Cipher text input too small for encryption ");
11470+ return BAD_FUNC_ARG ;
11471+ }
11472+
1146411473 while (sectorCount ) {
1146511474 ret = wc_AesXtsEncryptSector (aes , out + (iter * sectorSz ),
1146611475 in + (iter * sectorSz ), sectorSz , sector );
@@ -11498,6 +11507,15 @@ int wc_AesXtsDecryptConsecutiveSectors(XtsAes* aes, byte* out, const byte* in,
1149811507 int sectorCount = sz / sectorSz ;
1149911508 int remainder = sz % sectorSz ;
1150011509
11510+ if (aes == NULL || out == NULL || in == NULL || sectorSz == 0 ) {
11511+ return BAD_FUNC_ARG ;
11512+ }
11513+
11514+ if (sz < AES_BLOCK_SIZE ) {
11515+ WOLFSSL_MSG ("Cipher text input too small for decryption ");
11516+ return BAD_FUNC_ARG ;
11517+ }
11518+
1150111519 while (sectorCount ) {
1150211520 ret = wc_AesXtsDecryptSector (aes , out + (iter * sectorSz ),
1150311521 in + (iter * sectorSz ), sectorSz , sector );
0 commit comments