Subject: [pkix] [RFC 6960] How to calculate the issuerKeyHash?

From: "Annie Yousar" <[email-masked]>
Date: Thu, 11 Sep 2014 15:17:42 +0200 (CEST)

Dear all,
on p. 13 in RFC 6960 we read

     o  issuerKeyHash is the hash of the issuer's public key.  The hash
        shall be calculated over the value (excluding tag and length) of
        the subject public key field in the issuer's certificate.

It is not clear which tag is exluded.
Let us make an example. Take the public key:

-----BEGIN PUBLIC KEY-----
MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhAJ6Yu4Y8e3ENVMwV0U/BczPwPtRTh1yB
BeLcW4yQeqtTAgMBAAE=
-----END PUBLIC KEY-----

This is Peter's ASN.1 dump:
   0   60: SEQUENCE {
   2   13:   SEQUENCE {
   4    9:     OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1)
  15    0:     NULL
         :     }
  17   43:   BIT STRING, encapsulates {
  20   40:     SEQUENCE {
  22   33:       INTEGER
         :         00 9E 98 BB 86 3C 7B 71 0D 54 CC 15 D1 4F C1 73
         :         33 F0 3E D4 53 87 5C 81 05 E2 DC 5B 8C 90 7A AB
         :         53
  57    3:       INTEGER 65537
         :       }
         :     }
         :   }

Therefore this public RSA key is in fact of type SubjectPublicKeyInfo as
described in RFC 5280, and could appear in a certificate:

SubjectPublicKeyInfo  ::=  SEQUENCE  {
        algorithm            AlgorithmIdentifier,
        subjectPublicKey     BIT STRING  }

The hex data for the key identifier used in AKI and SKI (refer to RFC
5280) is
30280221009E98BB863C7B710D54CC15D14FC17333F03
ED453875C8105E2DC5B8C907AAB530203010001

with the BIT STRING's tag, length and unused bits peeled off.
The keyIdentifier value is computed as
92:FB:90:FA:21:0B:77:8C:91:3E:C2:0F:A7:C2:54:56:CA:F6:A0:03

Which tag is excluded for IssuerKeyHash calculation?
The SEQUENCE's tag or the BIT STRINGS's tag?
And what about the unused bits byte in the latter case?

Regards,
Ann.

---

From: Russ Housley <[email-masked]>
Date: Mon, 15 Sep 2014 10:47:51 -0400

You need to look at SubjectPublicKey, not SubjectPublicKeyInfo.  So, this is the BIT STRING.  And, the BIT STRING length and tags are omitted from the hash calculation.

Russ

On Sep 11, 2014, at 9:17 AM, Annie Yousar wrote:

> _______________________________________________
> pkix mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/pkix