Paul Elliott
5e69aa5709
Remove NULL check for set nonce
...
Also remove tests which would pass NULL to this function.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
2e450093e1
Remove variables declared as unused
...
They are now always being used.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
efda3408ce
Fix formatting issues
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
3242f6c8ef
Fix formatting issue
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
b8db2c5726
Remove extra blank lines
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
daf5c8954c
Remove extraneous state checks
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
6f0e72038d
Align set nonce variables with psa convention
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
f127763ec9
Align generate nonce variables with psa convention
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
d9343f2f0f
Refactor is_encrypt into aead setup arguments
...
Avoid touching the operation until later.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
36869706e2
Remove duplicated statements in documentation.
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-19 19:18:28 +01:00
Paul Elliott
e0a12bd852
Refactor aead setup functions into single function
...
Move common encrypt / decrypt code into common function, and roll in
previously refactored setup checks function, as this is now the only
place it is called.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-19 19:18:28 +01:00
Paul Elliott
5d3a3c3ee4
Fix arguments formatting mistake
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-19 19:18:28 +01:00
Paul Elliott
66696b5591
Improve nonce length checks
...
Add the missing nonce length checks (this function is being used by
oneshot functions as well as multipart, and thus all cipher suites are
being used) and cover the case where a NULL buffer gets passed in.
Extended the set nonce test to cover this.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-16 18:44:50 +01:00
Paul Elliott
814fffbd72
Remove overly strict final checks
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-16 18:44:42 +01:00
Paul Elliott
91b021e4c7
Add finish buffer size test
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:53:54 +01:00
Paul Elliott
43fbda648d
Add test for update buffer size
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:53:53 +01:00
Paul Elliott
693bf312d9
Fix _arg argument not being cast to correct type
...
Also change to TEST_EQUAL, as this is now possible.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:53:53 +01:00
Paul Elliott
56e4aa6ae2
Restore accidentally deleted blank lines
...
Script to generate test data was missing a '\n'
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:53:53 +01:00
Paul Elliott
863864a2f7
Add multipart set nonce test
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:53:53 +01:00
Paul Elliott
ecce901907
Change over to specific per algorith size checks
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:53:53 +01:00
Paul Elliott
0a6a5694d9
Add missing include to PSA test driver
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 15:30:01 +01:00
Paul Elliott
41ffae17b1
Fix incorrect function documentation
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 21:53:12 +01:00
Paul Elliott
26f4aef3a7
Remove aead_verify call from test driver
...
Function was removed, but missed this reference.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 21:53:12 +01:00
Paul Elliott
ed08cf884a
Add safety check to chachapoly finish
...
Previous code checked that the buffer was big enough for the tag size
for the given algorithm, however chachapoly finish expects a 16 byte
buffer passed in, no matter what. If we start supporting smaller
chachapoly tags in the future, this could potentially end up in buffer
overflow, so add a safety check.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
2fe5db87d5
Fix passing wrong tag size to GCM finish
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
99f548d974
Fix format issues with check nonce size
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
ebf91638b5
Move set nonce / set length tests to positive test
...
Previous test in state test was not actually making sure that the
operatioon could be completed using set lengths / set nonce in either
order, thus changed the 'normal' encrypt / decrypt tests to run in
alternating order.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
329d5381a5
Add 0 length part tests
...
Add tests to do zero length part, n length part until done, to exercise
the zero length edge case.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
243080ca7d
Clarify comments on state test.
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
97fd1bad83
Convert over to using a single internal test func
...
Make all encrypt/decrypt tests use the same function. Cleanup arguments
that were poorly named and document internal function. Removed one test
as I didn't want to write another test purely for it, when its already
tested in one shot.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-22 18:52:20 +01:00
Paul Elliott
315628d91a
Remove internal aead_verify endpoint
...
The internal verify endpoint was only calling the finish endpoint to get
a tag to compare against the tag passed in. Moved this logic to the
driver wrapper (still allowing a driver to call verify if required) and
removed the internal implementation endpoint.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
32925b9e5b
Make sure unused parts of tag buffer are cleared
...
We already did this on failure, but make sure the buffer does not leak
what was in it previously on success
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
e0fcb3b99e
Add 'too big' tests for nonce generation
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
d85f547b65
Add expected size to nonce generation test
...
Also add unneeded copy-paste in the test descriptions.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
374a2be588
Add missing state test coverage
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
481be341ef
Make state tests more readable
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
96b0173cec
Add common nonce checking to oneshot encrypt
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
a561444561
Add missing space
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-21 18:51:23 +01:00
Paul Elliott
ed68d7464d
Move buffer size checks up to psa_crypto layer
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 20:40:47 +01:00
Paul Elliott
c2b7144da0
Simplify logic and factor out initial checks
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 20:40:47 +01:00
Paul Elliott
7f429b747b
Remove code duplication and fix formatting
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 20:40:47 +01:00
Paul Elliott
87c909a8c5
Make auxiliary function static
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 20:40:47 +01:00
Paul Elliott
a8940ed876
Fix documented error codes
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 20:40:47 +01:00
Paul Elliott
e24f1a1a9d
Fix missed driver wrapper tests
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 14:39:05 +01:00
Paul Elliott
16906f9011
Add missing frees to generate nonce test
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-24 14:39:05 +01:00
Paul Elliott
cf2d66e022
Remove permitting of 8 byte nonce with PolyChaCha
...
Also unify nonce length checking
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-23 18:50:59 +01:00
Paul Elliott
0187651647
Test all set lengths and set/generate nonce orders
...
Test that the two are completely interchangeable in order.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-23 18:30:20 +01:00
Paul Elliott
3bd5dbacc1
Improve generate nonce test
...
Make sure the generated nonce works to encrypt test data if the
generated nonce is valid.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-23 18:30:20 +01:00
Paul Elliott
95271f10c3
Call set_nonce direct rather than by wrapper
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-23 18:30:20 +01:00
Paul Elliott
8fc45169f1
Fix compiler errors on many platforms.
...
Also added comment to explain why I added a seemingly pointless goto
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-06-23 16:06:59 +01:00