diff options
author | Vitezslav Cizek <vcizek@suse.com> | 2018-10-25 13:53:26 +0200 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2018-10-30 07:53:25 +1000 |
commit | 3afd38b277a806b901e039c6ad281c5e5c97ef67 (patch) | |
tree | ee174cf1541a939fa88fc66d9f245a0a11de53c9 | |
parent | 88e3cf0a1024f4afaf8e44553526eb326db102bc (diff) |
DSA: Check for sanity of input parameters
dsa_builtin_paramgen2 expects the L parameter to be greater than N,
otherwise the generation will get stuck in an infinite loop.
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7493)
-rw-r--r-- | crypto/dsa/dsa_gen.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 46f4f01ee0..383d853b6d 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -327,6 +327,12 @@ int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N, if (mctx == NULL) goto err; + /* make sure L > N, otherwise we'll get trapped in an infinite loop */ + if (L <= N) { + DSAerr(DSA_F_DSA_BUILTIN_PARAMGEN2, DSA_R_INVALID_PARAMETERS); + goto err; + } + if (evpmd == NULL) { if (N == 160) evpmd = EVP_sha1(); |