Skip to content

Commit

Permalink
Secret key is expected to be 32 characters long, convert
Browse files Browse the repository at this point in the history
debug assert into proper check, generate error and emit
appropriate message when it's not.

Fixes #2935
  • Loading branch information
sobomax committed Oct 24, 2022
1 parent d9883f2 commit f5703d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/digest_auth/dauth_nonce.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ int dauth_noncer_init(struct nonce_context *pub)
LM_ERR("EVP_EncryptInit_ex() failed\n");
goto e0;
}
DASSERT(EVP_CIPHER_CTX_key_length(self->ectx) == pub->secret.len);
if (EVP_CIPHER_CTX_key_length(self->ectx) != pub->secret.len) {
LM_ERR("Length of secret has to be %d characters\n",
EVP_CIPHER_CTX_key_length(self->ectx));
goto e0;
}
EVP_CIPHER_CTX_set_padding(self->ectx, 0);
if (EVP_DecryptInit_ex(self->dctx, EVP_aes_256_ecb(), NULL, key, NULL) != 1) {
LM_ERR("EVP_DecryptInit_ex() failed\n");
Expand Down

0 comments on commit f5703d1

Please sign in to comment.