Skip to content

Commit

Permalink
ktls: add ktls_supported field to s2n_cipher (#3806)
Browse files Browse the repository at this point in the history
  • Loading branch information
toidiu authored Feb 3, 2023
1 parent fdf0b20 commit ecedd2b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions crypto/s2n_aead_cipher_aes_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ const struct s2n_cipher s2n_aes128_gcm = {
.set_encryption_key = s2n_aead_cipher_aes128_gcm_set_encryption_key,
.set_decryption_key = s2n_aead_cipher_aes128_gcm_set_decryption_key,
.destroy_key = s2n_aead_cipher_aes_gcm_destroy_key,
.ktls_supported = true,
};

const struct s2n_cipher s2n_aes256_gcm = {
Expand Down
1 change: 1 addition & 0 deletions crypto/s2n_cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct s2n_cipher {
struct s2n_composite_cipher comp;
} io;
uint8_t key_material_size;
bool ktls_supported;
uint8_t (*is_available)(void);
int (*init)(struct s2n_session_key *key);
int (*set_decryption_key)(struct s2n_session_key *key, struct s2n_blob *in);
Expand Down
42 changes: 42 additions & 0 deletions tests/unit/s2n_ktls_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

#include "crypto/s2n_cipher.h"
#include "s2n_test.h"

int main(int argc, char **argv)
{
BEGIN_TEST();

/* ktls_supported ciphers */
{
struct s2n_cipher cipher = s2n_aes128_gcm;
EXPECT_TRUE(cipher.ktls_supported);

cipher = s2n_aes256_gcm;
EXPECT_FALSE(cipher.ktls_supported);

cipher = s2n_tls13_aes128_gcm;
EXPECT_FALSE(cipher.ktls_supported);

cipher = s2n_tls13_aes256_gcm;
EXPECT_FALSE(cipher.ktls_supported);

cipher = s2n_chacha20_poly1305;
EXPECT_FALSE(cipher.ktls_supported);
};

END_TEST();
}

0 comments on commit ecedd2b

Please sign in to comment.