diff options
author | DexesTTP <dexes.ttp@gmail.com> | 2021-05-17 22:34:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-19 09:18:45 +0200 |
commit | 6d190b299e1f80387a117104841e9382a9814bdc (patch) | |
tree | 166ce8e002eab90df80f9fa7d84c42b9254f0744 /Userland/Libraries/LibTLS/CipherSuite.h | |
parent | 17a1f51579b07837ba8ccc43cc9672cbab271f09 (diff) | |
download | serenity-6d190b299e1f80387a117104841e9382a9814bdc.zip |
LibTLS: Define cipher suite parameters and components in a macro
Instead of sprinkling the definition of the ciper suites all over the
TLS implementation, let's regroup it all once and for all in a single
place, and then add our new implementations there.
Diffstat (limited to 'Userland/Libraries/LibTLS/CipherSuite.h')
-rw-r--r-- | Userland/Libraries/LibTLS/CipherSuite.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Userland/Libraries/LibTLS/CipherSuite.h b/Userland/Libraries/LibTLS/CipherSuite.h index 8f6638ca06..7fadbf839a 100644 --- a/Userland/Libraries/LibTLS/CipherSuite.h +++ b/Userland/Libraries/LibTLS/CipherSuite.h @@ -42,6 +42,31 @@ enum class SignatureAlgorithm : u8 { ECDSA = 3, }; +enum class CipherAlgorithm { + AES_128_CBC, + AES_128_GCM, + AES_128_CCM, + AES_128_CCM_8, + AES_256_CBC, + AES_256_GCM, +}; + +constexpr size_t cipher_key_size(CipherAlgorithm algorithm) +{ + switch (algorithm) { + case CipherAlgorithm::AES_128_CBC: + case CipherAlgorithm::AES_128_GCM: + case CipherAlgorithm::AES_128_CCM: + case CipherAlgorithm::AES_128_CCM_8: + return 128; + case CipherAlgorithm::AES_256_CBC: + case CipherAlgorithm::AES_256_GCM: + return 256; + default: + return 128; + } +} + struct SignatureAndHashAlgorithm { HashAlgorithm hash; SignatureAlgorithm signature; |