From 9d82f6657f72b6be747addf6b5e00be325ebbf64 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 8 Oct 2014 18:51:47 -0700 Subject: Improved error message --- cryptography/hazmat/primitives/asymmetric/dsa.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cryptography/hazmat/primitives/asymmetric/dsa.py b/cryptography/hazmat/primitives/asymmetric/dsa.py index 18076338..5e72299a 100644 --- a/cryptography/hazmat/primitives/asymmetric/dsa.py +++ b/cryptography/hazmat/primitives/asymmetric/dsa.py @@ -32,9 +32,12 @@ def _check_dsa_parameters(parameters): (1024, 160), (2048, 256), (3072, 256)): - raise ValueError("p and q lengths must be " - "one of these pairs (1024, 160) or (2048, 256) " - "or (3072, 256).") + raise ValueError( + "p and q's bit-lengths must be one of these pairs (1024, 160), " + "(2048, 256), or (3072, 256). Not ({0:d}, {1:d})".format( + utils.bit_length(parameters.p), utils.bit_length(parameters.q) + ) + ) if not (1 < parameters.g < parameters.p): raise ValueError("g, p don't satisfy 1 < g < p.") -- cgit v1.2.3