-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
add bmp option #4537
base: master
Are you sure you want to change the base?
add bmp option #4537
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4537 +/- ##
==========================================
- Coverage 81.58% 78.86% -2.73%
==========================================
Files 356 331 -25
Lines 85292 80099 -5193
==========================================
- Hits 69589 63168 -6421
- Misses 15703 16931 +1228
|
Thanks for the fix! I guess that a test should also be added, using a pattern similar to https://github.com/secdev/scapy/blob/master/test/scapy/layers/x509.uts#L53 I managed to decrease the size of the certificate to 480 bytes using the following script: from scapy.all import *
load_layer("tls")
c = Cert("example_cert.pem")
del(c.tbsCertificate.serialNumber)
del(c.tbsCertificate.signature)
del(c.tbsCertificate.subject)
del(c.tbsCertificate.validity)
del(c.tbsCertificate.subjectPublicKeyInfo)
del(c.tbsCertificate.extensions)
del(c.x509Cert.signatureAlgorithm)
del(c.x509Cert.signatureValue)
open("example_cert.new.der", "wb").write(raw(c.x509Cert))
c = Cert("example_cert.new.pem")
c.x509Cert.show() |
I tried to add a test but encounter a few difficulties:
cert_with_bmp_string = base64.b64decode('MIIHKjCCB...Or8iY=')
c = X509_Cert(cert_with_bmp_string)
bmp_field_value = str(c.tbsCertificate.issuer[7].rdn[0].value.val, "utf-16be")
assert bmp_field_value == '[email protected]' But I really don't like it. So I tried to use the function c.tbsCertificate.get_issuer_str()
'/C=US/ST=CA/L=LG/O=Websense, Inc./OU=Websense Endpoint/CN=Websense Public Primary Certificate Authority/description=\x001\x002\x004\x006\x001\x008\x003\x005\x001\x004\x00E\x00P\x00@\x00w\x00e\x00b\x00s\x00e\x00n\x00s\x00e\x00.\x00c\x00o\x00m/[email protected]' This might be something that require deeper modification of the code. x.decode(errors="backslashreplace") So, in calculation:
cert_with_bmp_string = base64.b64decode('MIIHKjCCB...Or8iY=')
c = X509_Cert(cert_with_bmp_string)
assert '[email protected]' in c.tbsCertificate.get_issuer_str() @guedou, What do you think of my suggestion? should I include it in this PR? |
You can test Scapy with I think that your first test is quite fine, and that's what we usually do. |
This PR is a suggestion for a fix to #4536.
All I did is added the BMP_STRING format to the relevant type