-
Notifications
You must be signed in to change notification settings - Fork 315
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
OpenSSL signatures no longer compatible with ecdsa RAW format (README outdated) #67
Comments
I can confirm this issue on Fedora 27. @jrconlin is right, with newer openssl versions, openssl writes the signature DER encoded. The following shows how to reproduce the issue and work around it: OpenSSL part:
How to make it work in Python ECDSA:
Note that the DER encoding adds 6 to 8 bytes overhead - depending on whether the highest bit of the most significant byte of each component is set or not. Since it's such a minimal DER file using a real DER-derserializer library would be overkill. I agree, getting an error like Btw, the current README has a section on openssl compatibility, but the commands listed there don't work with current openssl versions. |
the difference in expected sizes (70 vs 64) is likely from the fact that the signature is now ASN.1 encoded, if that's the case, it would make it a duplicate of #55 also, I agree that raising such unreadable AssertionError is bad idea – it should be I'll definitely want to get it fixed, but unlikely it will happen in the next 2 months. |
@tomato42 , yes this is what the OP and I wrote - DER is one of the ASN.1 encoding rules. I wouldn't call this an exact duplicate, though. This issue also is about improving the error handling and the documentation (the README example). Also, FWIW, this issue contains some self contained Python code for working around this issue. |
Yes, the issue is a simple documentation problem; the exceptions raised got fixed with #115 (the code now will always raise (Note that it uses but for new versions it uses different parameter than documented: |
Hi,
While trying to convert from ecdsa to python cryptography (which wraps OpenSSL) I discovered that the current iteration of OpenSSL (libssl 1.0.2g+) returns a DER formatted signature value instead of a raw pair of 32octect numbers. (FWIW: the signature appears to be a Sequence of NamedTypes containing Integers)
If, say, a JWT that has a signature from a direct OpenSSL wrapper that is unaware of this is attempted to be run through ecdsa, it'll fail due to the signature length check*. Folks who wish to use this library should check signature length != 64 and perform whatever transmogrification required to get the raw pair of key values that ecdsa requires.
Also: might want to update the examples in the "OpenSSL Compatibility" section of the README to reflect this.
I'm going to try to follow up with other library owners in the chain to make sure that they're aware or at least comment about this problem lest others develop the same drinking habit I seem to have.
*really wish that some of these returned more meaningful errors than "AssertionError(71, 64)"
The text was updated successfully, but these errors were encountered: