Skip to content

Commit

Permalink
Merge pull request #649 from pabuhler/set-iv-len-once
Browse files Browse the repository at this point in the history
iv length is constant so set only once
  • Loading branch information
bifurcation authored May 3, 2023
2 parents fab73a3 + 05c52b6 commit 00a7f9b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crypto/cipher/aes_gcm_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ static srtp_err_status_t srtp_aes_gcm_openssl_context_init(void *cv,
return (srtp_err_status_init_fail);
}

if (!EVP_CIPHER_CTX_ctrl(c->ctx, EVP_CTRL_GCM_SET_IVLEN, 12, 0)) {
return (srtp_err_status_init_fail);
}

return (srtp_err_status_ok);
}

Expand All @@ -222,10 +226,6 @@ static srtp_err_status_t srtp_aes_gcm_openssl_set_iv(
debug_print(srtp_mod_aes_gcm, "setting iv: %s",
srtp_octet_string_hex_string(iv, 12));

if (!EVP_CIPHER_CTX_ctrl(c->ctx, EVP_CTRL_GCM_SET_IVLEN, 12, 0)) {
return (srtp_err_status_init_fail);
}

if (!EVP_CipherInit_ex(c->ctx, NULL, NULL, NULL, iv,
(c->dir == srtp_direction_encrypt ? 1 : 0))) {
return (srtp_err_status_init_fail);
Expand Down

0 comments on commit 00a7f9b

Please sign in to comment.