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