40 Commits

Author SHA1 Message Date
Dave Rodgman
a7f3c4e1d0
Merge pull request #8822 from daverodgman/sha3-perf
SHA-3 performance & code size
2024-03-12 13:14:40 +00:00
Dave Rodgman
a38fad9dad Adjust defaults
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-03-04 18:27:32 +00:00
Dave Rodgman
8a4df2293a Adjust default unroll settings
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-03-01 15:12:59 +00:00
Dave Rodgman
40c837dc40 Simplify pi rolled-up variant
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-26 18:43:22 +00:00
Dave Rodgman
08b81bf1e8 Test all unroll variations
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-26 18:43:22 +00:00
Dave Rodgman
427a5a1915 Docs; minor tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 13:59:07 +00:00
Dave Rodgman
693fb4f0b2 roll up chi loop for gcc -Os
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 13:56:53 +00:00
Dave Rodgman
1cf3585ee4 pacify check-names
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 12:11:47 +00:00
Dave Rodgman
865480279c roll-up chi loop on clang
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 12:02:18 +00:00
Dave Rodgman
aaba623fb4 pacify check-names
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 10:52:54 +00:00
Dave Rodgman
a111c0c894 Improve docs; pacify check-names
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 09:36:33 +00:00
Dave Rodgman
6fd6542e9c Roll/unroll various bits
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-14 01:20:33 +00:00
Dave Rodgman
418f859579 fix cast warning
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 19:43:49 +00:00
Dave Rodgman
cfb126f1ba Read pi table in 4-byte chunks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 19:01:57 +00:00
Dave Rodgman
d407e0df1b Read rho table in 4-byte chunks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 19:01:57 +00:00
Dave Rodgman
255a0f5916 Rotate right instead of left
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 18:42:20 +00:00
Gilles Peskine
f8b983c855 Pack the iota round constants
This saves ~160 bytes of code size, at the cost of a bit of localized
complexity in the code. The impact on performance is measurable but small
(<5% observed on x86_64) and can go either way (there's a calculation vs
memory bandwidth compromise).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-13 18:14:58 +01:00
Gilles Peskine
a3172d1e96 Inline the SHA3 parameters table into a switch
This saves a few bytes of code size.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-08 10:47:08 +01:00
Chien Wong
4e9683e818
Reduce many unnecessary static memory consumption
.data section of ssl_client1 becomes 320 bytes smaller on AMD64.

Signed-off-by: Chien Wong <m@xv97.com>
2024-02-06 17:50:44 +08:00
Dave Rodgman
16799db69a update headers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-02 19:47:20 +00:00
Tom Cosgrove
876346e451 Remove always-false null pointer check in sha3.c that Coverity complains about
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-09-11 09:03:01 +01:00
Dave Rodgman
984309c2c3 Call mbedtls_platform_zeroize via mbedtls_sha3_free
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-30 19:22:28 +01:00
Dave Rodgman
dbddb00158 Ensure mbedtls_sha3_finish zeroizes the context
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-30 18:43:23 +01:00
Dave Rodgman
2c91f4b8b2 Fix for big-endian architectures
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 19:59:05 +01:00
Dave Rodgman
2f0f998ec4 Unify ABSORB and ABSORB8 to fix compile error
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 19:12:04 +01:00
Dave Rodgman
f213d0a7b0 Tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 17:09:47 +01:00
Dave Rodgman
1b42763516 Remove NULL checks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 17:09:02 +01:00
Dave Rodgman
cf4d2bdc09 Spell as SHA-3 not SHA3
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 17:08:09 +01:00
Dave Rodgman
9d7fa93e6c move mbedtls_sha3_family_functions out of public interface
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 16:50:15 +01:00
Dave Rodgman
1789d84282 remove not-needed fields from SHA-3 context
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 16:50:15 +01:00
Dave Rodgman
bcfd79c699 Consume input in 8-byte chunks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-07 16:50:15 +01:00
Pol Henarejos
a6779287e8
Style.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2023-02-08 00:50:04 +01:00
Pol Henarejos
39fb1d52d1
Update library/sha3.c
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Pol Henarejos <55573252+polhenarejos@users.noreply.github.com>
2022-10-13 08:29:47 +02:00
Pol Henarejos
7dbd5d1760
Add self tests (taken from #1549).
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-20 20:42:33 +02:00
Pol Henarejos
938b5abb13
Fix when reusing the same context for another operation.
Occurs in hmac, where multiple hashes are performed with the same context) and thus, it requires to reinitialize the internal states to 0.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-20 20:07:40 +02:00
Pol Henarejos
1f3ae1639d
olen parameter shall contain the length of the buffer.
For SHA-3 families, it must be at least 28, 32, 48 or 64, depending on the family.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-20 20:07:40 +02:00
Pol Henarejos
116411e1a9
Fix when no SHA3 family is found.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-20 20:07:39 +02:00
Pol Henarejos
85eeda0122
olen = 0 is not allowed for SHA-3.
Sanity checks are moved to mbedtls_sha3_xxx() functions.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-20 20:07:39 +02:00
Pol Henarejos
084649d189
SHA-3 does not use SHA3_ALT anymore.
Next releases will not use alt files.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-20 20:07:39 +02:00
Pol Henarejos
0cd1f1c77f
Add SHA-3 module.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-09 01:04:15 +02:00