Skip to content

Commit ecedd2b

Browse files
authored
ktls: add ktls_supported field to s2n_cipher (#3806)
1 parent fdf0b20 commit ecedd2b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

crypto/s2n_aead_cipher_aes_gcm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ const struct s2n_cipher s2n_aes128_gcm = {
390390
.set_encryption_key = s2n_aead_cipher_aes128_gcm_set_encryption_key,
391391
.set_decryption_key = s2n_aead_cipher_aes128_gcm_set_decryption_key,
392392
.destroy_key = s2n_aead_cipher_aes_gcm_destroy_key,
393+
.ktls_supported = true,
393394
};
394395

395396
const struct s2n_cipher s2n_aes256_gcm = {

crypto/s2n_cipher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct s2n_cipher {
8181
struct s2n_composite_cipher comp;
8282
} io;
8383
uint8_t key_material_size;
84+
bool ktls_supported;
8485
uint8_t (*is_available)(void);
8586
int (*init)(struct s2n_session_key *key);
8687
int (*set_decryption_key)(struct s2n_session_key *key, struct s2n_blob *in);

tests/unit/s2n_ktls_test.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
#include "crypto/s2n_cipher.h"
17+
#include "s2n_test.h"
18+
19+
int main(int argc, char **argv)
20+
{
21+
BEGIN_TEST();
22+
23+
/* ktls_supported ciphers */
24+
{
25+
struct s2n_cipher cipher = s2n_aes128_gcm;
26+
EXPECT_TRUE(cipher.ktls_supported);
27+
28+
cipher = s2n_aes256_gcm;
29+
EXPECT_FALSE(cipher.ktls_supported);
30+
31+
cipher = s2n_tls13_aes128_gcm;
32+
EXPECT_FALSE(cipher.ktls_supported);
33+
34+
cipher = s2n_tls13_aes256_gcm;
35+
EXPECT_FALSE(cipher.ktls_supported);
36+
37+
cipher = s2n_chacha20_poly1305;
38+
EXPECT_FALSE(cipher.ktls_supported);
39+
};
40+
41+
END_TEST();
42+
}

0 commit comments

Comments
 (0)