-
-
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.62% 78.69% -2.94%
==========================================
Files 358 333 -25
Lines 85652 80454 -5198
==========================================
- Hits 69915 63313 -6602
- Misses 15737 17141 +1404
|
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 == '1246183514EP@websense.com' 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/emailAddress=support@websense.com' 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 '1246183514EP@websense.com' 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. |
ab5f9a0
to
eb78e88
Compare
test was added and rebased on the updated master |
This PR is a suggestion for a fix to #4536.
All I did is added the BMP_STRING format to the relevant type