]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/x509: export raw SubjectPublicKeyInfo.
authorAdam Langley <agl@golang.org>
Thu, 5 May 2011 17:37:42 +0000 (13:37 -0400)
committerAdam Langley <agl@golang.org>
Thu, 5 May 2011 17:37:42 +0000 (13:37 -0400)
The SPKI will probably be used for identifying public keys in future
HSTS specs.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4485044

src/pkg/crypto/x509/x509.go

index f2a039b5ad38610fc1e09a45f20db4ce2ca88115..d0c5a26a9a8fec9b50712a33cf3c610a5104e77d 100644 (file)
@@ -186,6 +186,7 @@ type validity struct {
 }
 
 type publicKeyInfo struct {
+       Raw       asn1.RawContent
        Algorithm algorithmIdentifier
        PublicKey asn1.BitString
 }
@@ -402,8 +403,10 @@ const (
 
 // A Certificate represents an X.509 certificate.
 type Certificate struct {
-       Raw                []byte // Complete ASN.1 DER content (certificate, signature algorithm and signature).
-       RawTBSCertificate  []byte // Certificate part of raw ASN.1 DER content.
+       Raw                     []byte // Complete ASN.1 DER content (certificate, signature algorithm and signature).
+       RawTBSCertificate       []byte // Certificate part of raw ASN.1 DER content.
+       RawSubjectPublicKeyInfo []byte // DER encoded SubjectPublicKeyInfo.
+
        Signature          []byte
        SignatureAlgorithm SignatureAlgorithm
 
@@ -567,6 +570,7 @@ func parseCertificate(in *certificate) (*Certificate, os.Error) {
        out := new(Certificate)
        out.Raw = in.Raw
        out.RawTBSCertificate = in.TBSCertificate.Raw
+       out.RawSubjectPublicKeyInfo = in.TBSCertificate.PublicKey.Raw
 
        out.Signature = in.SignatureValue.RightAlign()
        out.SignatureAlgorithm =
@@ -983,7 +987,7 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P
                Issuer:             parent.Subject.toRDNSequence(),
                Validity:           validity{template.NotBefore, template.NotAfter},
                Subject:            template.Subject.toRDNSequence(),
-               PublicKey:          publicKeyInfo{algorithmIdentifier{oidRSA}, encodedPublicKey},
+               PublicKey:          publicKeyInfo{nil, algorithmIdentifier{oidRSA}, encodedPublicKey},
                Extensions:         extensions,
        }