Adds to DER format of ECDSA signature with extended ECDSA-Sig-Value and ECDSA-Full-R#369
Adds to DER format of ECDSA signature with extended ECDSA-Sig-Value and ECDSA-Full-R#369gstarovo wants to merge 3 commits intotlsfuzzer:masterfrom
Conversation
|
I will provide more coverage for the newly added code, as the results of the checks indicate coverage decline. |
0961801 to
e17d333
Compare
e17d333 to
7f2a47b
Compare
19ac7b2 to
f173f56
Compare
9c23305 to
b046e1f
Compare
src/ecdsa/der.py
Outdated
| body = string[1 + lengthlength : 1 + lengthlength + length] | ||
| rest = string[1 + lengthlength + length :] | ||
| if not body: | ||
| raise UnexpectedDER("Empty object identifier") |
There was a problem hiding this comment.
changed to "Empty BOOLEAN value"
src/ecdsa/der.py
Outdated
| if body == b"\x00": | ||
| return False, rest | ||
| # the workaround due to instrumental, that | ||
| # saves the binary data as UF-8 string |
There was a problem hiding this comment.
this method shouldn't be passed Unicode strings ever...
There was a problem hiding this comment.
added check to control if the body type is str, than it will be encoded to bytes
if isinstance(body, text_type):
body = body.encode("utf-8")
| point = ellipticcurve.AbstractPoint.from_bytes( | ||
| self.generator.curve(), r | ||
| ) | ||
| r = point[0] % n |
There was a problem hiding this comment.
When encoding is in format of r in the siganture is ECPoint (ECPoint ::= OCTET STRING) to get the r, I firstly have to get the point from bytes and then extract the x and provide the same operation that is in the sign:
r = p1.x() % n
src/ecdsa/keys.py
Outdated
| :param accelerate: an indicator for ECDSA sign operation to return | ||
| an ECPoint instead of a number of "r" parameter. | ||
| Applicable only for ECDSA key. | ||
| :type accelerate: boolean |
There was a problem hiding this comment.
but we already are using the sigencode for specifying the output format...
There was a problem hiding this comment.
Well, that is not nice workaround that is being propagated to ecdsa.py PrivateKey.sign() to signalize what type of the r (if int or a ECPoint) I want to return. So after that it can directly go to the sigencode function in correct format. I did not find a way how to do it differently, or how to get the whole point out of r directly in the sigencode function
There was a problem hiding this comment.
Instead of r being just an int or ECPoint, maybe to create a new class, that will have both values all the time, so the sigencode will get all the values. I will show that change in a new commit. I will then squash it to one, if it will be accepted.
src/ecdsa/keys.py
Outdated
| :param accelerate: an indicator for ECDSA sign operation to return | ||
| an ECPoint instead of a number of "r" parameter. | ||
| Applicable only for ECDSA key. | ||
| :type accelerate: boolean |
There was a problem hiding this comment.
same here, sigencode should specify the format we want...
src/ecdsa/keys.py
Outdated
| leak the key. Caller should try a better entropy source, retry with | ||
| different ``k``, or use the | ||
| :func:`~SigningKey.sign_deterministic` in such case. | ||
| :param accelerate: an indicator for ECDSA sign operation to return |
841cce2 to
9f5252e
Compare
9f5252e to
4984db1
Compare
2949133 to
0a9aebd
Compare
0a9aebd to
75a6f2e
Compare
The changes expand encoding/decoding of the ECDSA signature in DER format: expanded ECDSA-Sig-Value format and ECDSA-Full-R.
The definition of the formats can be found in document section C.5, page 114.
The changes bring supporting functions like encoding and decoding of boolean according to ASN.1 standard.
Beside that, the changes add parameter and slightly modifies ECDSA signing function for enabling return of the whole point (instead of 'r').
The testing coverage of encoding/decoding with new function is also present.
Also, there are some formatting changes made with black formatter.