-
Notifications
You must be signed in to change notification settings - Fork 2.8k
accept PKCS#3 DH parameters with privateValueLength included #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
library/dhm.c: accept (and ignore) optional privateValueLength for PKCS#3 DH parameters. PKCS#3 defines the ASN.1 encoding of a DH parameter set like this: ---------------- DHParameter ::= SEQUENCE { prime INTEGER, -- p base INTEGER, -- g privateValueLength INTEGER OPTIONAL } The fields of type DHParameter have the following meanings: o prime is the prime p. o base is the base g. o privateValueLength is the optional private-value length l. ---------------- See: ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-3.asc This optional parameter was added in PKCS#3 version 1.4, released November 1, 1993. dhm.c currently doesn't cope well with PKCS#3 files that have this optional final parameter included. i see errors like: ------------ dhm_parse_dhmfile returned -0x33E6 Last error was: -0x33E6 - DHM - The ASN.1 data is not formatted correctly : ASN1 - Actual length differs from expected lengt ------------ You can generate PKCS#3 files with this final parameter with recent versions of certtool from GnuTLS: certtool --generate-dh-params > dh.pem
Hi Daniel, Thanks for your contribution! I quickly looked at the patch and it looks good. We'll need some test cases for that but we can add them ourselves based on the command you mentioned. @pjbakker : Paul, can you take care of the legal details if any? Of course the next step is to actually use this parameter, which I just added as a todo item. |
On Tue 2015-04-07 05:03:17 -0400, Manuel Pégourié-Gonnard wrote:
great, i'm glad to hear it sounds sensible.
If you think that copyright is relevant in this case, i happily
I avoided doing that because it adding a new element to dhm_context If your structs were declared in an internal header and only referenced Fixing this would probably require changing dhm_init to return a
|
I agree with your comments regarding API/ABI changes. In the next major version we'll be moving some structure definitions to internal headers or even C files, but for most structures we prefer to allow people to use non-dynamic allocation, especially for the basic modules that may be used in environments where dynamic allocation is not welcome. (This obviously doesn't apply to the DHM module, the argument would probably be uniformity, and also that a few ABI changes are not such a big price to pay.) Anyway, I did not mean to imply your contribution was incomplete, just mentioning the next step we're likely to take FYI. Thanks for taking the ABI compatibility into consideration btw. [first message sent early due to misclicking, as well as closing/reopening, sorry for that] |
[previous message sent early due to misclicking, as well as closing/reopening, sorry for that] |
@dkg In order to be able to use a contribution a CLA needs to be signed. We need more rights than just GPL for that. Can you send me an e-mail (paul dot bakker at arm dot com) so I can send you the document? |
Merged, thanks! |
…ke-fix Add CMake option for explicitly link library to trusted_storage
…tificateVerify_Writing Review fix for Mbed-TLS#186 certificate verify writing
…v-bad-state-error Fix psa_key_derivation_input_integer() not detecting bad state
library/dhm.c: accept (and ignore) optional privateValueLength for
PKCS#3 DH parameters.
PKCS#3 defines the ASN.1 encoding of a DH parameter set like this:
DHParameter ::= SEQUENCE {
prime INTEGER, -- p
base INTEGER, -- g
privateValueLength INTEGER OPTIONAL }
The fields of type DHParameter have the following meanings:
See: ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-3.asc
This optional parameter was added in PKCS#3 version 1.4, released
November 1, 1993.
dhm.c currently doesn't cope well with PKCS#3 files that have this
optional final parameter included. i see errors like:
dhm_parse_dhmfile returned -0x33E6
Last error was: -0x33E6 - DHM - The ASN.1 data is not formatted correctly : ASN1 - Actual length differs from expected lengt
You can generate PKCS#3 files with this final parameter with recent
versions of certtool from GnuTLS:
certtool --generate-dh-params > dh.pem