• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1This test data was produced by creating a self-signed RSA cert using OpenSSL,
2and then extracting the relevant fields.
3
4It uses RSA PKCS#1 v1.5 with SHA-512 and a 2048-bit key.
5
6(1) Generate self-signed certificate
7
8  openssl genrsa -out rsa_key.pem 2048
9  openssl req -new -key rsa_key.pem -x509 -nodes -days 365 -sha512 -out cert.pem
10
11(2) Extract public key
12
13  openssl x509 -in cert.pem -pubkey -noout > pubkey.pem
14  cat pubkey.pem
15
16(3) Extract signed data (tbsCertificate)
17
18  openssl asn1parse -in cert.pem -out tbs -noout -strparse 4
19  base64 tbs
20
21(4) Extract signature algorithm
22
23  # Find the offset of the signature algorithm near the end (589 in this case)
24  openssl asn1parse -in cert.pem
25
26  openssl asn1parse -in cert.pem -out alg -noout -strparse 589
27  base64 alg
28
29(5) Extract the signature
30
31  # Find the final offset of BIT STRING (506 in this case)
32  openssl asn1parse -in cert.pem
33
34  openssl asn1parse -in cert.pem -out sig -noout -strparse 506
35  base64 sig
36
37
38$ openssl asn1parse -i < [PUBLIC KEY]
39    0:d=0  hl=4 l= 290 cons: SEQUENCE
40    4:d=1  hl=2 l=  13 cons:  SEQUENCE
41    6:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
42   17:d=2  hl=2 l=   0 prim:   NULL
43   19:d=1  hl=4 l= 271 prim:  BIT STRING
44-----BEGIN PUBLIC KEY-----
45MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzcu2shJRrXFAwMkf30y2AY1zIg9VF/h
46egYcejzdR2AzUb8vU2TXld2i8pp44l+DrvtqmzS7G+yxx3uOx+zsoqBaUT0c9HfkbE+IRmcLkQF
47vYpSpm6Eu8OS14CSmEtiR91Et8LR0+bd0Gn3pgmb+epFJBaBPeDSiI/smqKCs7yP04+tS4Q4r47
48G04LhSp4/hmqH32b4Gcm9nsihHV9FfPfVdxDQUEJp3AgyBPwhPZEAyhoQS73TjjxXHqJRSz37Sl
49ueMVPuNncqbT4nAMKz25J1CtRlQh21uZzfY2QRP3m6rAZquQUos1febC6A7qmhQljWKKmXtfVY+
50fAamstdHrWwIDAQAB
51-----END PUBLIC KEY-----
52
53$ openssl asn1parse -i < [ALGORITHM]
54    0:d=0  hl=2 l=  13 cons: SEQUENCE
55    2:d=1  hl=2 l=   9 prim:  OBJECT            :sha512WithRSAEncryption
56   13:d=1  hl=2 l=   0 prim:  NULL
57-----BEGIN ALGORITHM-----
58MA0GCSqGSIb3DQEBDQUA
59-----END ALGORITHM-----
60
61-----BEGIN DATA-----
62MIICRaADAgECAgkA7jWRLkwHvHswDQYJKoZIhvcNAQENBQAwRTELMAkGA1UEBhMCQVUxEzARBgN
63VBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0xNT
64A3MjgwMjIyMzFaFw0xNjA3MjcwMjIyMzFaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lL
65VN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB
66AQUAA4IBDwAwggEKAoIBAQDNy7ayElGtcUDAyR/fTLYBjXMiD1UX+F6Bhx6PN1HYDNRvy9TZNeV
673aLymnjiX4Ou+2qbNLsb7LHHe47H7OyioFpRPRz0d+RsT4hGZwuRAW9ilKmboS7w5LXgJKYS2JH
683US3wtHT5t3QafemCZv56kUkFoE94NKIj+yaooKzvI/Tj61LhDivjsbTguFKnj+GaoffZvgZyb2
69eyKEdX0V899V3ENBQQmncCDIE/CE9kQDKGhBLvdOOPFceolFLPftKW54xU+42dyptPicAwrPbkn
70UK1GVCHbW5nN9jZBE/ebqsBmq5BSizV95sLoDuqaFCWNYoqZe19Vj58Bqay10etbAgMBAAGjUDB
71OMB0GA1UdDgQWBBRsCPajkEscZM6SpLbNTa/7dY5azzAfBgNVHSMEGDAWgBRsCPajkEscZM6SpL
72bNTa/7dY5azzAMBgNVHRMEBTADAQH/
73-----END DATA-----
74
75$ openssl asn1parse -i < [SIGNATURE]
76    0:d=0  hl=4 l= 257 prim: BIT STRING
77-----BEGIN SIGNATURE-----
78A4IBAQAhKSNq+X/CfzhtNsMo6MJpTBjJBV5fhHerIZr6e3ozCTBCR29vYsVnJ4/6i5lL1pNeOhM
79ldthnuSlMzTS1Zme1OqRWB3U8QmwCFwhDxW/i4fdT8kxDAmELNp4z0GcXbe27V895PE0R/m8P47
80B6xbra+SQlEMW12K1EndUqrO6vgLbobV14mveWdgc0KIOnDKgsTHV8NTV1w3qtp1ujfvizYfBZu
81yyMOA1yZPDpREZtClro7lufwDQ7+LgSdtNLMDAMzapfIjAEPVNVLmJzMgzaHqMsZM8gP8vWAdfc
82R4mCmWXVotrM6d1rjJGdRADAONYCC4/+d1IMkVGoVfpaej6I
83-----END SIGNATURE-----
84