Skip to content

Commit

Permalink
tls: don't copy the key out of tls12_crypto_info_aes_gcm_128
Browse files Browse the repository at this point in the history
There's no need to copy the key to an on-stack buffer before calling
crypto_aead_setkey().

Fixes: 3c4d755 ("tls: kernel TLS support")
Signed-off-by: Sabrina Dubroca <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
qsn authored and davem330 committed Sep 13, 2018
1 parent f0e0d04 commit 7cba09c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,6 @@ void tls_sw_free_resources_rx(struct sock *sk)

int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
{
char keyval[TLS_CIPHER_AES_GCM_128_KEY_SIZE];
struct tls_crypto_info *crypto_info;
struct tls12_crypto_info_aes_gcm_128 *gcm_128_info;
struct tls_sw_context_tx *sw_ctx_tx = NULL;
Expand Down Expand Up @@ -1265,9 +1264,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)

ctx->push_pending_record = tls_sw_push_pending_record;

memcpy(keyval, gcm_128_info->key, TLS_CIPHER_AES_GCM_128_KEY_SIZE);

rc = crypto_aead_setkey(*aead, keyval,
rc = crypto_aead_setkey(*aead, gcm_128_info->key,
TLS_CIPHER_AES_GCM_128_KEY_SIZE);
if (rc)
goto free_aead;
Expand Down

0 comments on commit 7cba09c

Please sign in to comment.