@@ -226,12 +226,6 @@ static int tsip_aes128_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
226226 0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,
227227 0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff
228228 };
229- WOLFSSL_SMALL_STACK_STATIC const byte oddCipher [] =
230- {
231- 0xb9 ,0xd7 ,0xcb ,0x08 ,0xb0 ,0xe1 ,0x7b ,0xa0 ,
232- 0xc2
233- };
234-
235229 WOLFSSL_SMALL_STACK_STATIC const byte ctr128Key [] =
236230 {
237231 0x2b ,0x7e ,0x15 ,0x16 ,0x28 ,0xae ,0xd2 ,0xa6 ,
@@ -249,13 +243,6 @@ static int tsip_aes128_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
249243 0x1e ,0x03 ,0x1d ,0xda ,0x2f ,0xbe ,0x03 ,0xd1 ,
250244 0x79 ,0x21 ,0x70 ,0xa0 ,0xf3 ,0x00 ,0x9c ,0xee
251245 };
252-
253- WOLFSSL_SMALL_STACK_STATIC const byte ctr128Wrap128Cipher [] =
254- {
255- 0xe1 ,0x33 ,0x38 ,0xe3 ,0x6c ,0xb7 ,0x19 ,0x62 ,
256- 0xe0 ,0x0d ,0x02 ,0x0b ,0x4c ,0xed ,0xbd ,0x86 ,
257- 0xd3 ,0xda ,0xe1 ,0x5b ,0x04
258- };
259246 WOLFSSL_SMALL_STACK_STATIC const byte ctr128Wrap128CipherLong [] =
260247 {
261248 0xe1 ,0x33 ,0x38 ,0xe3 ,0x6c ,0xb7 ,0x19 ,0x62 ,
@@ -274,14 +261,6 @@ static int tsip_aes128_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
274261 } testVec [] = {
275262 { ctr128Key , (int )sizeof (ctr128Key ), ctrIv ,
276263 ctrPlain , (int )sizeof (ctrPlain ), ctr128Cipher },
277- /* let's try with just 9 bytes, non block size test */
278- { ctr128Key , (int )sizeof (ctr128Key ), ctrIv ,
279- ctrPlain , (int )sizeof (oddCipher ), ctr128Cipher },
280- /* and an additional 9 bytes to reuse tmp left buffer */
281- { NULL , 0 , NULL , ctrPlain , (int )sizeof (oddCipher ), oddCipher },
282- /* Counter wrapping */
283- { ctr128Key , (int )sizeof (ctr128Key ), ctrIvWrap128 ,
284- ctrPlain , (int )sizeof (ctr128Wrap128Cipher ), ctr128Wrap128Cipher },
285264 { ctr128Key , (int )sizeof (ctr128Key ), ctrIvWrap128 ,
286265 ctrPlain , (int )sizeof (ctr128Wrap128CipherLong ),
287266 ctr128Wrap128CipherLong },
@@ -302,6 +281,22 @@ static int tsip_aes128_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
302281 goto out ;
303282 }
304283
284+ /* test failure cases - null */
285+ ret = wc_tsip_AesCtr (NULL , NULL , NULL , 1 );
286+ if (ret != BAD_FUNC_ARG ) {
287+ ret = -8 ; goto out ;
288+ }
289+ /* test failure cases - size, but no buffer */
290+ ret = wc_tsip_AesCtr (enc , NULL , NULL , 1 );
291+ if (ret != BAD_FUNC_ARG ) {
292+ ret = -9 ; goto out ;
293+ }
294+ /* test failure cases - non block aligned */
295+ ret = wc_tsip_AesCtr (enc , plain , cipher , 15 );
296+ if (ret != BAD_FUNC_ARG ) {
297+ ret = -10 ; goto out ;
298+ }
299+
305300 for (i = 0 ; i < AES_CTR_TEST_LEN ; i ++ ) {
306301 if (testVec [i ].key != NULL ) {
307302 ret = wc_AesSetKeyDirect (enc , testVec [i ].key , (word32 )testVec [i ].keySz ,
@@ -386,11 +381,6 @@ static int tsip_aes256_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
386381 0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,
387382 0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff
388383 };
389- WOLFSSL_SMALL_STACK_STATIC const byte oddCipher [] =
390- {
391- 0xb9 ,0xd7 ,0xcb ,0x08 ,0xb0 ,0xe1 ,0x7b ,0xa0 ,
392- 0xc2
393- };
394384 WOLFSSL_SMALL_STACK_STATIC const byte ctr256Key [] =
395385 {
396386 0x60 ,0x3d ,0xeb ,0x10 ,0x15 ,0xca ,0x71 ,0xbe ,
@@ -410,12 +400,6 @@ static int tsip_aes256_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
410400 0xdf ,0xc9 ,0xc5 ,0x8d ,0xb6 ,0x7a ,0xad ,0xa6 ,
411401 0x13 ,0xc2 ,0xdd ,0x08 ,0x45 ,0x79 ,0x41 ,0xa6
412402 };
413- WOLFSSL_SMALL_STACK_STATIC const byte ctr256Wrap128Cipher [] =
414- {
415- 0x50 ,0xfd ,0x97 ,0xc3 ,0xe6 ,0x1a ,0xbb ,0x48 ,
416- 0x73 ,0xfb ,0x78 ,0xdf ,0x1e ,0x8e ,0x77 ,0xe6 ,
417- 0x4b ,0x45 ,0x7c ,0xd6 ,0x8a
418- };
419403 WOLFSSL_SMALL_STACK_STATIC const byte ctr256Wrap128CipherLong [] =
420404 {
421405 0x50 ,0xfd ,0x97 ,0xc3 ,0xe6 ,0x1a ,0xbb ,0x48 ,
@@ -435,12 +419,6 @@ static int tsip_aes256_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
435419 } testVec [] = {
436420 { ctr256Key , (int )sizeof (ctr256Key ), ctrIv ,
437421 ctrPlain , (int )sizeof (ctrPlain ), ctr256Cipher },
438- /* let's try with just 9 bytes, non block size test */
439- { ctr256Key , (int )sizeof (ctr256Key ), ctrIv ,
440- ctrPlain , (int )sizeof (oddCipher ), ctr256Cipher },
441- /* Counter wrapping */
442- { ctr256Key , (int )sizeof (ctr256Key ), ctrIvWrap128 ,
443- ctrPlain , (int )sizeof (ctr256Wrap128Cipher ), ctr256Wrap128Cipher },
444422 { ctr256Key , (int )sizeof (ctr256Key ), ctrIvWrap128 ,
445423 ctrPlain , (int )sizeof (ctr256Wrap128CipherLong ),
446424 ctr256Wrap128CipherLong },
@@ -461,6 +439,22 @@ static int tsip_aes256_ctr_test(int prnt, tsip_aes_key_index_t* aes_key)
461439 goto out ;
462440 }
463441
442+ /* test failure cases - null */
443+ ret = wc_tsip_AesCtr (NULL , NULL , NULL , 1 );
444+ if (ret != BAD_FUNC_ARG ) {
445+ ret = -8 ; goto out ;
446+ }
447+ /* test failure cases - size, but no buffer */
448+ ret = wc_tsip_AesCtr (enc , NULL , NULL , 1 );
449+ if (ret != BAD_FUNC_ARG ) {
450+ ret = -9 ; goto out ;
451+ }
452+ /* test failure cases - non block aligned */
453+ ret = wc_tsip_AesCtr (enc , plain , cipher , 15 );
454+ if (ret != BAD_FUNC_ARG ) {
455+ ret = -10 ; goto out ;
456+ }
457+
464458 for (i = 0 ; i < AES_CTR_TEST_LEN ; i ++ ) {
465459 if (testVec [i ].key != NULL ) {
466460 ret = wc_AesSetKeyDirect (enc , testVec [i ].key , (word32 )testVec [i ].keySz ,
0 commit comments