1
$\begingroup$

As described in RFC 8017, RSASSA-PKCS1-V1_5 uses the following bytes during the encoding process :

0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20

Does anybody know how to compute these values?

$\endgroup$
4
  • $\begingroup$ What do you mean by compute? $\endgroup$ – kelalaka Nov 22 '20 at 19:01
  • $\begingroup$ I mean : where do these values come from ? $\endgroup$ – cmdEvo Nov 22 '20 at 19:28
  • $\begingroup$ Yes, I have already read this part of the RFC but can somebody explain it to me ? $\endgroup$ – cmdEvo Nov 22 '20 at 19:46
  • $\begingroup$ Effectively the reverse of, but also answered by, crypto.stackexchange.com/questions/19542/… (3447 was the prior version of 8017) $\endgroup$ – dave_thompson_085 Nov 23 '20 at 8:17
0
$\begingroup$

Digging the RFC 8017

9.2. EMSA-PKCS1-v1_5

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

and

A.2.4. RSASSA-PKCS-v1_5

The object identifier for RSASSA-PKCS1-v1_5 SHALL be one of the
following.

Both combined below;

Hash algorithm   OID                           the DER encoding T of the DigestInfo
------------------------------------------------------------------------------------------
MD2              md2WithRSAEncryption          (0x)30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 02 05 00 04 10 || H.
MD5              md5WithRSAEncryption          (0x)30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 05 05 00 04 10 || H.
SHA-1            sha1WithRSAEncryption         (0x)30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14 || H.
SHA-224          sha224WithRSAEncryption       (0x)30 2d 30 0d 06 09 60 86 48 01 65 03 04 02 04 05 00 04 1c || H.
SHA-256          sha256WithRSAEncryption       (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
SHA-384          sha384WithRSAEncryption       (0x)30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00 04 30 || H.
SHA-512          sha512WithRSAEncryption       (0x)30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00 04 40 || H.
SHA-512/224      sha512-224WithRSAEncryption   (0x)30 2d 30 0d 06 09 60 86 48 01 65 03 04 02 05 05 00 04 1c || H.
SHA-512/256      sha512-256WithRSAEncryption   (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 06 05 00 04 20 || H.

and in

B.1. Hash Functions

The object identifiers id-md2, id-md5, id-sha1, id-sha224, id-sha256, id-sha384, id-sha512, id-sha512/224, and id-sha512/256 identify the
respective hash functions:

   id-md2      OBJECT IDENTIFIER ::= {
       iso (1) member-body (2) us (840) rsadsi (113549)
       digestAlgorithm (2) 2
   }

   id-md5      OBJECT IDENTIFIER ::= {
       iso (1) member-body (2) us (840) rsadsi (113549)
       digestAlgorithm (2) 5
   }
   ...

Therefore it is the DER encoding of the above object identifiers. See example on A Layman's Guide to a Subset of ASN.1, BER, and DER (5.9)

$\endgroup$
1
  • 1
    $\begingroup$ thank you for your help ! $\endgroup$ – cmdEvo Nov 22 '20 at 20:40

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.