-
Notifications
You must be signed in to change notification settings - Fork 0
[ADD] issuer info #1
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
base: master
Are you sure you want to change the base?
Conversation
TODO: has a bug with public_bytes() in next lines
|
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |
|
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |
|
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |
blaggacao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some quick comments, I hope to be able to do a full review in the coming days. Honestly it might take well into the christmas holiday, though, I've to double check with @Deiber as well.
signxml/xades/__init__.py
Outdated
| serial_element = XADES132.IssuerSerialV2( | ||
| # TODO implement, wtf? | ||
| DS.X09IssuerName(issuer_string(cert)), | ||
| DS.X509SerialNumber(f"cert.get_serial_number()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite yet: <xsd:element name="IssuerSerialV2" type="xsd:base64Binary" minOccurs="0"/>
The whole ASN.1 object shall be DER encoded and put here as bytestring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compared the result from XML signed (xades-bes) and what get_serial_number() it's ok.
which schema file got it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you implemented the legacy IssuerSerial
See the schema of IssuerSerialV2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw our latest commit, the object itself is der encoded, not one of it's members...
| usp := UnignedSignatureProperties, c. 4.3.6 | ||
| udop := UnignedDataObjectProperties, c. 4.3.7 | ||
| Electronic signature forms elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Electronic signature grammar (I guess that's what it is) by mode"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with that, just those ? look a little grammar-ish. But yep, in xml, that is probably not a common usage of a word...
| udop := UnignedDataObjectProperties, c. 4.3.7 | ||
| Electronic signature forms elements | ||
| Mention differences between nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodes -> modes
| return XADES132.QualifyingProperties(*qp_elements, **qp_attributes) | ||
|
|
||
|
|
||
| class XAdESEPESSigner(XAdESSigner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be an excellent idea, I have to think around it a bit.. Thanks 👍
|
@ovnicraft Thanks a lot for your PR! I'll have a look asap, and meanwhile I should probably reconfigure the commitlinter 😉 - until then, let's ignore him. |
|
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |
|
@ovnicraft I thought a little about the class base implemnetaiton of the different signature modes. I like the idea, it's hackable. Not sure if you've seen it, I've put a (still) unused enum at the beginning of the file, it was intended to server as a type switch aprameter for a mdoe dispatcher, with your prob=osal that would be a class dispatcher based on the enum, what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a spec inconsistency about IssuerServialV2
Or am I missign something?
signxml/xades/__init__.py
Outdated
| serial_element = XADES132.IssuerSerialV2( | ||
| # TODO implement, wtf? | ||
| DS.X09IssuerName(issuer_string(cert)), | ||
| DS.X509SerialNumber(b64encode(_der.encode_der_integer(cert.get_serial_number()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec is something like:
XADES132.IssuerSerialV2(b64encode(_der.encode...(asn_obj)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO must defined from DS.X509SerialNumber element wil double check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ASN object still is not the one required... :( - I feel you are close! 😉
signxml/xades/__init__.py
Outdated
| serial_element = XADES132.IssuerSerialV2( | ||
| DS.X09IssuerName(issuer_string(cert)), | ||
| DS.X509SerialNumber(f"cert.get_serial_number()") | ||
| b64encode(_der.encode_der_integer(cert.get_serial_number())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's not the ASN object required here, it's the IssuerSerial object...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read this:
https://www.pyopenssl.org/en/stable/api/crypto.html#OpenSSL.crypto.X509.get_serial_number
I am calling get_serial_number()
Certificate has:
- issuer
- issuer serial number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see:
| Returns: | The serial number. |
| Return type: | int |
But what needs DER encoding is this RFC IssuerSerial ASN object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IssuerSerial ::= SEQUENCE {
issuer GeneralNames,
serialNumber CertificateSerialNumber
}
taken from: https://tools.ietf.org/html/rfc5035
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GeneralNames can be quite some different objects, but I haven't yet analyzed how that poses encoding challenges...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note also: it seems to be a sequence, or array of unnamed objects (if I understand the ASN spec grammar correctly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO DER representation must be done at application (signxml) level; so pyopenssl and cryptography provide API to solve this. AFAIK i do it.
IssueSerial comes from certificate from pyopenssl in 2 objects
SerialNameSerialNumber
Here we need to identify what needs the V2 on new spec; in legacy they has 2 elements on XML and i understood in V2 just one: SerialNumber
You can check my PR X509Name class and my own implementation to reverse get_components()
In terms of X509 Object all Issue serial is represented by:
as RFC mentioned defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not construe the mentioned ASN object using some ASN generator? (pyasn.1 - I guess) - and then DER encode through one of the APIs you mention.
Or could you point me to the pyopenssl IssuerSerial object? I haven't seen it. Is it a sequence as the spec mandates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the name string, what's the difference between your implementation and https://cryptography.io/en/latest/x509/reference/#cryptography.x509.Name.rfc4514_string ?
|
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |

TODO: