Commit e1bf165b authored by Adam Langley's avatar Adam Langley

crypto/x509: export raw SubjectPublicKeyInfo.

The SPKI will probably be used for identifying public keys in future
HSTS specs.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4485044
parent da39008a
...@@ -186,6 +186,7 @@ type validity struct { ...@@ -186,6 +186,7 @@ type validity struct {
} }
type publicKeyInfo struct { type publicKeyInfo struct {
Raw asn1.RawContent
Algorithm algorithmIdentifier Algorithm algorithmIdentifier
PublicKey asn1.BitString PublicKey asn1.BitString
} }
...@@ -404,6 +405,8 @@ const ( ...@@ -404,6 +405,8 @@ const (
type Certificate struct { type Certificate struct {
Raw []byte // Complete ASN.1 DER content (certificate, signature algorithm and signature). Raw []byte // Complete ASN.1 DER content (certificate, signature algorithm and signature).
RawTBSCertificate []byte // Certificate part of raw ASN.1 DER content. RawTBSCertificate []byte // Certificate part of raw ASN.1 DER content.
RawSubjectPublicKeyInfo []byte // DER encoded SubjectPublicKeyInfo.
Signature []byte Signature []byte
SignatureAlgorithm SignatureAlgorithm SignatureAlgorithm SignatureAlgorithm
...@@ -567,6 +570,7 @@ func parseCertificate(in *certificate) (*Certificate, os.Error) { ...@@ -567,6 +570,7 @@ func parseCertificate(in *certificate) (*Certificate, os.Error) {
out := new(Certificate) out := new(Certificate)
out.Raw = in.Raw out.Raw = in.Raw
out.RawTBSCertificate = in.TBSCertificate.Raw out.RawTBSCertificate = in.TBSCertificate.Raw
out.RawSubjectPublicKeyInfo = in.TBSCertificate.PublicKey.Raw
out.Signature = in.SignatureValue.RightAlign() out.Signature = in.SignatureValue.RightAlign()
out.SignatureAlgorithm = out.SignatureAlgorithm =
...@@ -983,7 +987,7 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P ...@@ -983,7 +987,7 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P
Issuer: parent.Subject.toRDNSequence(), Issuer: parent.Subject.toRDNSequence(),
Validity: validity{template.NotBefore, template.NotAfter}, Validity: validity{template.NotBefore, template.NotAfter},
Subject: template.Subject.toRDNSequence(), Subject: template.Subject.toRDNSequence(),
PublicKey: publicKeyInfo{algorithmIdentifier{oidRSA}, encodedPublicKey}, PublicKey: publicKeyInfo{nil, algorithmIdentifier{oidRSA}, encodedPublicKey},
Extensions: extensions, Extensions: extensions,
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment