1 This test data was produced by creating a self-signed EC cert using OpenSSL,
2 and then extracting the relevant fields.
4 It uses RSA PKCS#1 v1.5 with SHA-256 and a 1024-bit key.
6 (1) Generate self-signed certificate
8 openssl genrsa -out rsa_key.pem 1024
9 openssl req -new -key rsa_key.pem -x509 -nodes -days 365 -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 (491 in this case)
24 openssl asn1parse -in cert.pem
26 openssl asn1parse -in cert.pem -out alg -noout -strparse 491
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 MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqR+B2Mj1irNp1JnY2zQIQRQPz7ybs6mUjHT3
41 hf5APyaig2u6fBPThqxssgg0YviqIj/70hVK/JXcqP1zgR5AhsA0agnwAjfB/ow4EH+3HEYV52q
42 pxN98pUxC+1l2hgVtn8xCS/JGyjK+6dv+lZw3ixJoX2RjVtdJ4/cn318EhhQIDAQAB
43 -----END PUBLIC KEY-----
45 $ openssl asn1parse -i < [PUBLIC KEY]
46 0:d=0 hl=3 l= 159 cons: SEQUENCE
47 3:d=1 hl=2 l= 13 cons: SEQUENCE
48 5:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption
49 16:d=2 hl=2 l= 0 prim: NULL
50 18:d=1 hl=3 l= 141 prim: BIT STRING
54 -----BEGIN ALGORITHM-----
56 -----END ALGORITHM-----
58 $ openssl asn1parse -i < [ALGORITHM]
59 0:d=0 hl=2 l= 13 cons: SEQUENCE
60 2:d=1 hl=2 l= 9 prim: OBJECT :sha256WithRSAEncryption
61 13:d=1 hl=2 l= 0 prim: NULL
66 MIIB46ADAgECAgkA3l4tFOVii0UwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCQVUxEzARBgN
67 VBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1
68 UEAwwGTXkga2V5MB4XDTE1MDcwMjE3MDYzOVoXDTE2MDcwMTE3MDYzOVowVjELMAkGA1UEBhMCQ
69 VUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0
70 ZDEPMA0GA1UEAwwGTXkga2V5MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqR+B2Mj1irNp
71 1JnY2zQIQRQPz7ybs6mUjHT3hf5APyaig2u6fBPThqxssgg0YviqIj/70hVK/JXcqP1zgR5AhsA
72 0agnwAjfB/ow4EH+3HEYV52qpxN98pUxC+1l2hgVtn8xCS/JGyjK+6dv+lZw3ixJoX2RjVtdJ4/
73 cn318EhhQIDAQABo1AwTjAdBgNVHQ4EFgQUzQBVKTEknyLndWd2HTsBdTKvyikwHwYDVR0jBBgw
74 FoAUzQBVKTEknyLndWd2HTsBdTKvyikwDAYDVR0TBAUwAwEB/w==
79 -----BEGIN SIGNATURE-----
80 A4GBADrHSmFSJw/Gv7hs5PNzpaJwAri/sitarIZfzN/SjR+n8L8yeTEoiDb1+BkxlFvXvPHTaOK
81 oO3WlslNNOxh1W5/JkYYGOUkCcyIjnln6qS560imcr3VNjomT/M8M2Iss+rJiKau1TRuaP7H8i6
82 +Gqf3saGdr8/LnvFAdNQvkalQt
83 -----END SIGNATURE-----
85 $ openssl asn1parse -i < [SIGNATURE]
86 0:d=0 hl=3 l= 129 prim: BIT STRING