mirror of https://github.com/secdev/scapy.git
381 lines
21 KiB
Plaintext
381 lines
21 KiB
Plaintext
|
# Cert extension - Regression Test Campaign
|
||
|
|
||
|
# Try me with:
|
||
|
# bash test/run_tests -t test/cert.uts -F
|
||
|
|
||
|
|
||
|
########### PKCS helpers ###############################################
|
||
|
|
||
|
+ PKCS helpers tests
|
||
|
|
||
|
= PKCS os2ip basic tests
|
||
|
pkcs_os2ip('\x00\x00\xff\xff') == 0xffff and pkcs_os2ip('\xff\xff\xff\xff\xff') == 0xffffffffff
|
||
|
|
||
|
= PKCS i2osp basic tests
|
||
|
pkcs_i2osp(0xffff, 4) == '\x00\x00\xff\xff' and pkcs_i2osp(0xffff, 2) == '\xff\xff' and pkcs_i2osp(0xffffeeee, 3) == '\xff\xff\xee\xee'
|
||
|
|
||
|
|
||
|
########### PubKey class ###############################################
|
||
|
|
||
|
+ PubKey class tests
|
||
|
|
||
|
= PubKey class : Importing PEM-encoded RSA public key
|
||
|
x = PubKey("""
|
||
|
-----BEGIN PUBLIC KEY-----
|
||
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmFdqP+nTEZukS0lLP+yj
|
||
|
1gNImsEIf7P2ySTunceYxwkm4VE5QReDbb2L5/HLA9pPmIeQLSq/BgO1meOcbOSJ
|
||
|
2YVHQ28MQ56+8Crb6n28iycX4hp0H3AxRAjh0edX+q3yilvYJ4W9/NnIb/wAZwS0
|
||
|
oJif/tTkVF77HybAfJde5Eqbp+bCKIvMWnambh9DRUyjrBBZo5dA1o32zpuFBrJd
|
||
|
I8dmUpw9gtf0F0Ba8lGZm8Uqc0GyXeXOJUE2u7CiMu3M77BM6ZLLTcow5+bQImkm
|
||
|
TL1SGhzwfinME1e6p3Hm//pDjuJvFaY22k05LgLuyqc59vFiB3Toldz8+AbMNjvz
|
||
|
AwIDAQAB
|
||
|
-----END PUBLIC KEY-----
|
||
|
""")
|
||
|
type(x) is PubKeyRSA
|
||
|
|
||
|
= PubKey class : key format is PEM
|
||
|
x.frmt == "PEM"
|
||
|
|
||
|
= PubKey class : Importing DER-encoded RSA Key
|
||
|
y = PubKey('0\x82\x01"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\x98Wj?\xe9\xd3\x11\x9b\xa4KIK?\xec\xa3\xd6\x03H\x9a\xc1\x08\x7f\xb3\xf6\xc9$\xee\x9d\xc7\x98\xc7\t&\xe1Q9A\x17\x83m\xbd\x8b\xe7\xf1\xcb\x03\xdaO\x98\x87\x90-*\xbf\x06\x03\xb5\x99\xe3\x9cl\xe4\x89\xd9\x85GCo\x0cC\x9e\xbe\xf0*\xdb\xea}\xbc\x8b\'\x17\xe2\x1at\x1fp1D\x08\xe1\xd1\xe7W\xfa\xad\xf2\x8a[\xd8\'\x85\xbd\xfc\xd9\xc8o\xfc\x00g\x04\xb4\xa0\x98\x9f\xfe\xd4\xe4T^\xfb\x1f&\xc0|\x97^\xe4J\x9b\xa7\xe6\xc2(\x8b\xccZv\xa6n\x1fCEL\xa3\xac\x10Y\xa3\x97@\xd6\x8d\xf6\xce\x9b\x85\x06\xb2]#\xc7fR\x9c=\x82\xd7\xf4\x17@Z\xf2Q\x99\x9b\xc5*sA\xb2]\xe5\xce%A6\xbb\xb0\xa22\xed\xcc\xef\xb0L\xe9\x92\xcbM\xca0\xe7\xe6\xd0"i&L\xbdR\x1a\x1c\xf0~)\xcc\x13W\xba\xa7q\xe6\xff\xfaC\x8e\xe2o\x15\xa66\xdaM9.\x02\xee\xca\xa79\xf6\xf1b\x07t\xe8\x95\xdc\xfc\xf8\x06\xcc6;\xf3\x03\x02\x03\x01\x00\x01')
|
||
|
type(y) is PubKeyRSA
|
||
|
|
||
|
= PubKey class : key format is DER
|
||
|
y.frmt == "DER"
|
||
|
|
||
|
= PubKey class : checking modulus value
|
||
|
x.modulus == y.modulus and x.modulus == 19231328316532061413420367242571475005688288081144416166988378525696075445024135424022026378563116068168327239354659928492979285632474448448624869172454076124150405352043642781483254546569202103296262513098482624188672299255268092629150366527784294463900039290024710152521604731213565912934889752122898104556895316819303096201441834849255370122572613047779766933573375974464479123135292080801384304131606933504677232323037116557327478512106367095125103346134248056463878553619525193565824925835325216545121044922690971718737998420984924512388011040969150550056783451476150234324593710633552558175109683813482739004163L
|
||
|
|
||
|
= PubKey class : checking public exponent value
|
||
|
x.pubExp == y.pubExp and x.pubExp == 65537L
|
||
|
|
||
|
= PubKey class : Importing PEM-encoded ECDSA public key
|
||
|
z = PubKey("""
|
||
|
-----BEGIN PUBLIC KEY-----
|
||
|
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE55WjbZjS/88K1kYagsO9wtKifw0IKLp4
|
||
|
Jd5qtmDF2Zu+xrwrBRT0HBnPweDU+RsFxcyU/QxD9WYORzYarqxbcA==
|
||
|
-----END PUBLIC KEY-----
|
||
|
""")
|
||
|
type(z) is PubKeyECDSA
|
||
|
|
||
|
= PubKey class : checking curve
|
||
|
z.key.curve.name == "SECP256k1"
|
||
|
|
||
|
= PubKey class : checking point value
|
||
|
z.key.pubkey.point.x() == 104748656174769496952370005421566518252704263000192720134585149244759951661467L
|
||
|
|
||
|
|
||
|
########### PrivKey class ###############################################
|
||
|
|
||
|
+ PrivKey class tests
|
||
|
|
||
|
= PrivKey class : Importing PEM-encoded RSA private key
|
||
|
x = PrivKey("""
|
||
|
-----BEGIN RSA PRIVATE KEY-----
|
||
|
MIIEowIBAAKCAQEAmFdqP+nTEZukS0lLP+yj1gNImsEIf7P2ySTunceYxwkm4VE5
|
||
|
QReDbb2L5/HLA9pPmIeQLSq/BgO1meOcbOSJ2YVHQ28MQ56+8Crb6n28iycX4hp0
|
||
|
H3AxRAjh0edX+q3yilvYJ4W9/NnIb/wAZwS0oJif/tTkVF77HybAfJde5Eqbp+bC
|
||
|
KIvMWnambh9DRUyjrBBZo5dA1o32zpuFBrJdI8dmUpw9gtf0F0Ba8lGZm8Uqc0Gy
|
||
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|
||
|
KgaIHdXkJ4+AuugrstE4gQKBgFK0d1/8g7SeA+Cdz84YNaqMt5NeaDPXbsTA23Qx
|
||
|
UBU0rYDxoKTdFybv9a6SfA83sCLM31K/A8FTNJL2CDGA9WNBL3fOSs2GYg88AVBG
|
||
|
pUJHeDK+0748OcPUSPaG+pVIETSn5RRgffq16r0nWYUvSdAn8cuTqw3y+yC1pZS6
|
||
|
AU8dAoGBAL5QCi0dTWKN3kf3cXaCAnYiWe4Qg2S+SgLE+F1U4Xws2rqAuSvIiuT5
|
||
|
i5+Mqk9ZCGdoReVbAovJFoRqe7Fj9yWM+b1awGjL0bOTtnqx0iljob6uFyhpl1xg
|
||
|
W3a3ICJ/ZYLvkgb4IBEteOwWpp37fX57vzhW8EmUV2UX7ve1uNRI
|
||
|
-----END RSA PRIVATE KEY-----
|
||
|
""")
|
||
|
type(x) is PrivKeyRSA
|
||
|
|
||
|
= PrivKey class : checking public attributes
|
||
|
assert(x.modulus == 19231328316532061413420367242571475005688288081144416166988378525696075445024135424022026378563116068168327239354659928492979285632474448448624869172454076124150405352043642781483254546569202103296262513098482624188672299255268092629150366527784294463900039290024710152521604731213565912934889752122898104556895316819303096201441834849255370122572613047779766933573375974464479123135292080801384304131606933504677232323037116557327478512106367095125103346134248056463878553619525193565824925835325216545121044922690971718737998420984924512388011040969150550056783451476150234324593710633552558175109683813482739004163L)
|
||
|
x.pubExp == 65537L
|
||
|
|
||
|
= PrivKey class : checking private attributes
|
||
|
assert(x.prime1 == 140977881300857803928857666115326329496639762170623218602431133528876162476487960230341078724702018316260690172014674492782486113504117653531825010840338251572887403113276393351318549036549656895326851872473595350667293402676143426484331639796163189182788306480699144107905869179435145810212051656274284113969L)
|
||
|
assert(x.prime2 == 136413798668820291889092636919077529673097927884427227010121877374504825870002258140616512268521246045642663981036167305976907058413796938050224182519965099316625879807962173794483933183111515251808827349718943344770056106787713032506379905031673992574818291891535689493330517205396872699985860522390496583027L)
|
||
|
assert(x.exponent1 == 46171616708754015342920807261537213121074749458020000367465429453038710215532257783908950878847126373502288079285334594398328912526548076894076506899568491565992572446455658740752572386903609191774044411412991906964352741123956581870694330173563737928488765282233340389888026245745090096745219902501964298369L)
|
||
|
assert(x.exponent2 == 58077388505079936284685944662039782610415160654764308528562806086690474868010482729442634318267235411531220690585030443434512729356878742778542733733189895801341155353491318998637269079682889033003797865508917973141494201620317820971253064836562060222814287812344611566640341960495346782352037479526674026269L)
|
||
|
x.privExp == 15879630313397508329451198152673380989865598204237760057319927734227125481903063742175442230739018051313441697936698689753842471306305671266572085925009572141819112648211571007521954312641597446020984266846581125287547514750428503480880603089110687015181510081018160579576523796170439894692640171752302225125980423560965987469457505107324833137678663960560798216976668670722016960863268272661588745006387723814962668678285659376534048525020951633874488845649968990679414325096323920666486328886913648207836459784281744709948801682209478580185160477801656666089536527545026197569990716720623647770979759861119273292833L
|
||
|
|
||
|
= PrivKey class : Importing PEM-encoded ECDSA private key
|
||
|
y = PrivKey("""
|
||
|
-----BEGIN EC PRIVATE KEY-----
|
||
|
MHQCAQEEIMiRlFoy6046m1NXu911ukXyjDLVgmOXWCKWdQMd8gCRoAcGBSuBBAAK
|
||
|
oUQDQgAE55WjbZjS/88K1kYagsO9wtKifw0IKLp4Jd5qtmDF2Zu+xrwrBRT0HBnP
|
||
|
weDU+RsFxcyU/QxD9WYORzYarqxbcA==
|
||
|
-----END EC PRIVATE KEY-----
|
||
|
""")
|
||
|
type(y) is PrivKeyECDSA
|
||
|
|
||
|
= PrivKey class : checking public attributes
|
||
|
assert(y.key.curve.name == "SECP256k1")
|
||
|
y.key.privkey.public_key.point.y() == 86290575637772818452062569410092503179882738810918951913926481113065456425840L
|
||
|
|
||
|
= PrivKey class : checking private attributes
|
||
|
y.key.privkey.secret_multiplier == 90719786431263082134670936670180839782031078050773732489701961692235185651857L
|
||
|
|
||
|
|
||
|
########### Cert class ##############################################
|
||
|
|
||
|
+ Cert class tests
|
||
|
|
||
|
= Cert class : Importing PEM-encoded X.509 Certificate
|
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ME1e6p3Hm//pDjuJvFaY22k05LgLuyqc59vFiB3To
|
||
|
ldz8+AbMNjvzAwIDAQABo4IBHzCCARswHQYDVR0OBBYEFPPYTt6Q9+Zd0s4zzVxW
|
||
|
jG+XFDFLMIHrBgNVHSMEgeMwgeCAFPPYTt6Q9+Zd0s4zzVxWjG+XFDFLoYG8pIG5
|
||
|
MIG2MQswCQYDVQQGEwJGUjEOMAwGA1UECBMFUGFyaXMxDjAMBgNVBAcTBVBhcmlz
|
||
|
MRcwFQYDVQQKEw5NdXNocm9vbSBDb3JwLjEeMBwGA1UECxMVTXVzaHJvb20gVlBO
|
||
|
IFNlcnZpY2VzMSUwIwYDVQQDExxJS0V2MiBYLjUwOSBUZXN0IGNlcnRpZmljYXRl
|
||
|
MScwJQYJKoZIhvcNAQkBFhhpa2V2Mi10ZXN0QG11c2hyb29tLmNvcnCCCQC0XnBD
|
||
|
5wkLcTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQA2zt0BvXofiVvH
|
||
|
MWlftZCstQaawej1SmxrAfDB4NUM24NsG+UZI88XA5XM6QolmfyKnNromMLC1+6C
|
||
|
aFxjq3jC/qdS7ifalFLQVo7ik/te0z6Olo0RkBNgyagWPX2LR5kHe9RvSDuoPIsb
|
||
|
SHMmJA98AZwatbvEhmzMINJNUoHVzhPeHZnIaBgUBg02XULk/ElidO51Rf3gh8dR
|
||
|
/kgFQSQT687vs1x9TWD00z0Q2bs2UF3Ob3+NYkEGEo5F9RePQm0mY94CT2xs6WpH
|
||
|
o060Fo7fVpAFktMWx1vpu+wsEbQAhgGqV0fCR2QwKDIbTrPW/p9HJtJDYVjYdAFx
|
||
|
r3s7V77y
|
||
|
-----END CERTIFICATE-----
|
||
|
""")
|
||
|
|
||
|
= Cert class : Checking version
|
||
|
x.version == 3
|
||
|
|
||
|
= Cert class : Checking certificate serial number extraction
|
||
|
x.serial == 0xB45E7043E7090B71
|
||
|
|
||
|
= Cert class : Checking signature algorithm
|
||
|
x.sigAlg == 'sha1-with-rsa-signature'
|
||
|
|
||
|
= Cert class : Checking issuer extraction in basic format (/C=FR ...)
|
||
|
x.issuer_str == '/C=FR/ST=Paris/L=Paris/O=Mushroom Corp./OU=Mushroom VPN Services/CN=IKEv2 X.509 Test certificate/emailAddress=ikev2-test@mushroom.corp'
|
||
|
|
||
|
= Cert class : Checking subject extraction in basic format (/C=FR ...)
|
||
|
x.subject_str == '/C=FR/ST=Paris/L=Paris/O=Mushroom Corp./OU=Mushroom VPN Services/CN=IKEv2 X.509 Test certificate/emailAddress=ikev2-test@mushroom.corp'
|
||
|
|
||
|
= Cert class : Checking start date extraction in simple and tuple formats
|
||
|
assert(x.notBefore_str_simple == '07/13/06')
|
||
|
x.notBefore == (2006, 7, 13, 7, 38, 59, 3, 194, -1)
|
||
|
|
||
|
= Cert class : Checking end date extraction in simple and tuple formats
|
||
|
assert(x.notAfter_str_simple == '03/30/26')
|
||
|
x.notAfter == (2026, 3, 30, 7, 38, 59, 0, 89, -1)
|
||
|
|
||
|
= Cert class : Checking RSA public key
|
||
|
assert(type(x.pubKey) is PubKeyRSA)
|
||
|
assert(x.pubKey.modulus == 19231328316532061413420367242571475005688288081144416166988378525696075445024135424022026378563116068168327239354659928492979285632474448448624869172454076124150405352043642781483254546569202103296262513098482624188672299255268092629150366527784294463900039290024710152521604731213565912934889752122898104556895316819303096201441834849255370122572613047779766933573375974464479123135292080801384304131606933504677232323037116557327478512106367095125103346134248056463878553619525193565824925835325216545121044922690971718737998420984924512388011040969150550056783451476150234324593710633552558175109683813482739004163L)
|
||
|
x.pubKey.pubExp == 0x10001
|
||
|
|
||
|
= Cert class : Checking extensions
|
||
|
assert(x.cA)
|
||
|
assert(x.authorityKeyID == '\xf3\xd8N\xde\x90\xf7\xe6]\xd2\xce3\xcd\\V\x8co\x97\x141K')
|
||
|
not hasattr(x, "keyUsage")
|
||
|
|
||
|
= Cert class : Importing another PEM-encoded X.509 Certificate
|
||
|
y = Cert("""
|
||
|
-----BEGIN CERTIFICATE-----
|
||
|
MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw
|
||
|
CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu
|
||
|
ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg
|
||
|
RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV
|
||
|
UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu
|
||
|
Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq
|
||
|
hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf
|
||
|
Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q
|
||
|
RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/
|
||
|
BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD
|
||
|
AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY
|
||
|
JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv
|
||
|
6pZjamVFkpUBtA==
|
||
|
-----END CERTIFICATE-----
|
||
|
""")
|
||
|
|
||
|
= Cert class : Checking ECDSA public key
|
||
|
assert(type(y.pubKey) is PubKeyECDSA)
|
||
|
assert(y.pubKey.key.curve.name == 'SECP384r1')
|
||
|
y.pubKey.key.pubkey.point.x() == 3987178688175281746349180015490646948656137448666005327832107126183726641822596270780616285891030558662603987311874L
|
||
|
|
||
|
= Cert class : Checking ECDSA signature
|
||
|
y.signatureValue == '0d\x020%\xa4\x81E\x02k\x12KutO\xc8#\xe3p\xf2ur\xde|\x89\xf0\xcf\x91ra\x9e^\x10\x92YV\xb9\x83\xc7\x10\xe78\xe9X&6}\xd5\xe44\x869\x020|6S\xf00\xe5bc:\x99\xe2\xb6\xa3;\x9b4\xfa\x1e\xda\x10\x92q^\x91\x13\xa7\xdd\xa4n\x92\xcc2\xd6\xf5!f\xc7/\xea\x96cjeE\x92\x95\x01\xb4'
|
||
|
|
||
|
|
||
|
########### CRL class ###############################################
|
||
|
|
||
|
+ CRL class tests
|
||
|
|
||
|
= CRL class : Importing PEM-encoded CRL
|
||
|
x = CRL("""
|
||
|
-----BEGIN X509 CRL-----
|
||
|
MIICHjCCAYcwDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMxFzAVBgNVBAoT
|
||
|
DlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAxIFB1YmxpYyBQcmltYXJ5
|
||
|
IENlcnRpZmljYXRpb24gQXV0aG9yaXR5Fw0wNjExMDIwMDAwMDBaFw0wNzAyMTcy
|
||
|
MzU5NTlaMIH2MCECECzSS2LEl6QXzW6jyJx6LcgXDTA0MDQwMTE3NTYxNVowIQIQ
|
||
|
OkXeVssCzdzcTndjIhvU1RcNMDEwNTA4MTkyMjM0WjAhAhBBXYg2gRUg1YCDRqhZ
|
||
|
kngsFw0wMTA3MDYxNjU3MjNaMCECEEc5gf/9hIHxlfnrGMJ8DfEXDTAzMDEwOTE4
|
||
|
MDYxMlowIQIQcFR+auK62HZ/R6mZEEFeZxcNMDIwOTIzMTcwMDA4WjAhAhB+C13e
|
||
|
GPI5ZoKmj2UiOCPIFw0wMTA1MDgxOTA4MjFaMCICEQDQVEhgGGfTrTXKLw1KJ5Ve
|
||
|
Fw0wMTEyMTExODI2MjFaMA0GCSqGSIb3DQEBBQUAA4GBACLJ9rsdoaU9JMf/sCIR
|
||
|
s3AGW8VV3TN2oJgiCGNEac9PRyV3mRKE0hmuIJTKLFSaa4HSAzimWpWNKuJhztsZ
|
||
|
zXUnWSZ8VuHkgHEaSbKqzUlb2g+o/848CvzJrcbeyEBkDCYJI5C3nLlQA49LGJ+w
|
||
|
4GUPYBwaZ+WFxCX1C8kzglLm
|
||
|
-----END X509 CRL-----
|
||
|
""")
|
||
|
|
||
|
= CRL class : Checking version
|
||
|
x.version == 1
|
||
|
|
||
|
= CRL class : Checking issuer extraction in basic format (/C=FR ...)
|
||
|
x.issuer_str == '/C=US/O=VeriSign, Inc./OU=Class 1 Public Primary Certification Authority'
|
||
|
|
||
|
= CRL class : Checking lastUpdate date extraction in tuple format
|
||
|
x.lastUpdate == (2006, 11, 2, 0, 0, 0, 3, 306, -1)
|
||
|
|
||
|
= CRL class : Checking nextUpdate date extraction in tuple format
|
||
|
x.nextUpdate == (2007, 2, 17, 23, 59, 59, 5, 48, -1)
|
||
|
|
||
|
= CRL class : Checking number of revoked certificates
|
||
|
len(x.revoked_cert_serials) == 7
|
||
|
|
||
|
= CRL class : Checking presence of one revoked certificate
|
||
|
(94673785334145723688625287778885438961L, '030109180612') in x.revoked_cert_serials
|
||
|
|
||
|
########### High-level methods ###############################################
|
||
|
|
||
|
= Cert class : Checking isIssuerCert()
|
||
|
c0 = Cert("""
|
||
|
-----BEGIN CERTIFICATE-----
|
||
|
MIIFVjCCBD6gAwIBAgIJAJmDv7HOC+iUMA0GCSqGSIb3DQEBCwUAMIHGMQswCQYD
|
||
|
VQQGEwJVUzEQMA4GA1UECBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEl
|
||
|
MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEzMDEGA1UECxMq
|
||
|
aHR0cDovL2NlcnRzLnN0YXJmaWVsZHRlY2guY29tL3JlcG9zaXRvcnkvMTQwMgYD
|
||
|
VQQDE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0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
||
|
ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg
|
||
|
nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1
|
||
|
HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N
|
||
|
Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN
|
||
|
dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0
|
||
|
HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO
|
||
|
BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G
|
||
|
CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU
|
||
|
sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3
|
||
|
4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg
|
||
|
8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
|
||
|
pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1
|
||
|
mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
|
||
|
-----END CERTIFICATE-----
|
||
|
""")
|
||
|
c0.isIssuerCert(c1) and c1.isIssuerCert(c2) and not c0.isIssuerCert(c2)
|
||
|
|
||
|
= Cert class : Checking isSelfSigned()
|
||
|
c2.isSelfSigned() and not c1.isSelfSigned() and not c0.isSelfSigned()
|
||
|
|
||
|
= PubKey class : Checking verifyCert()
|
||
|
c2.pubKey.verifyCert(c2) and c1.pubKey.verifyCert(c0)
|
||
|
|
||
|
= Chain class : Checking chain construction
|
||
|
assert(len(Chain([c0, c1, c2])) == 3)
|
||
|
assert(len(Chain([c0], c1)) == 2)
|
||
|
len(Chain([c0], c2)) == 1
|
||
|
|
||
|
= Chain class : Checking chain verification
|
||
|
assert(Chain([], c0).verifyChain([c2], [c1]))
|
||
|
not Chain([c1]).verifyChain([c0])
|
||
|
|