1

For example, I've seen 3031300d060960864801650304020105000420 as an identifier for RSA/SHA256, 3020300c06082a864886f70d020505000410 for RSA/MD5. Where do these values come from?

I ran into one of these values here, where it said:

$t = '3031300d060960864801650304020105000420'; # sha256

and here:

case PGPHASHALGO_SHA256:
    t = stpcpy(t, " RSA/SHA256");
    prefix = "3031300d060960864801650304020105000420";
1
  • 1
    Please add references for I've seen, especially proving that you have seen specific values more than once (otherwise the question would be of little use).
    – user13695
    Jul 28, 2016 at 10:20

1 Answer 1

2

Of course writing the question led me to the answer...

These values come from RFC3447:

For the six hash functions mentioned in Appendix B.1, the DER
encoding T of the DigestInfo value is equal to the following:

MD2:     (0x)30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 02 05 00 04
               10 || H.
MD5:     (0x)30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 05 05 00 04
               10 || H.
SHA-1:   (0x)30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14 || H.
SHA-256: (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00
               04 20 || H.
SHA-384: (0x)30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00
               04 30 || H.
SHA-512: (0x)30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00
                  04 40 || H.
2
  • 1
    Well, they do not strictly come from that list, they come from the definition of the DigestInfo structure, the OIDs defined for certain algorithms, and the DER for ASN.1 encoding. But some programmers indeed may have simply copied from this list.
    – mkl
    Jul 28, 2016 at 13:39
  • Got a reference for them?
    – Synchro
    Jul 28, 2016 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.