Commit fc8e77ca authored by Kyle Isom's avatar Kyle Isom Committed by Adam Langley

crypto/x509: Add certificate signature request (CSR) support.

This change adds support for parsing and serialisation of PKCS #10,
certificate signature requests.

LGTM=agl
R=golang-codereviews, agl
CC=agl, golang-codereviews, nick
https://golang.org/cl/49830048
parent eea28f67
...@@ -30,6 +30,13 @@ type AttributeTypeAndValue struct { ...@@ -30,6 +30,13 @@ type AttributeTypeAndValue struct {
Value interface{} Value interface{}
} }
// AttributeTypeAndValueSET represents a set of ASN.1 sequences of
// AttributeTypeAndValue sequences from RFC 2986 (PKCS #10).
type AttributeTypeAndValueSET struct {
Type asn1.ObjectIdentifier
Value [][]AttributeTypeAndValue `asn1:"set"`
}
// Extension represents the ASN.1 structure of the same name. See RFC // Extension represents the ASN.1 structure of the same name. See RFC
// 5280, section 4.2. // 5280, section 4.2.
type Extension struct { type Extension struct {
......
This diff is collapsed.
This diff is collapsed.
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"reflect" "reflect"
"strconv"
"time" "time"
) )
...@@ -197,6 +198,19 @@ func (oi ObjectIdentifier) Equal(other ObjectIdentifier) bool { ...@@ -197,6 +198,19 @@ func (oi ObjectIdentifier) Equal(other ObjectIdentifier) bool {
return true return true
} }
func (oi ObjectIdentifier) String() string {
var s string
for i, v := range oi {
if i > 0 {
s += "."
}
s += strconv.Itoa(v)
}
return s
}
// parseObjectIdentifier parses an OBJECT IDENTIFIER from the given bytes and // parseObjectIdentifier parses an OBJECT IDENTIFIER from the given bytes and
// returns it. An object identifier is a sequence of variable length integers // returns it. An object identifier is a sequence of variable length integers
// that are assigned in a hierarchy. // that are assigned in a hierarchy.
......
...@@ -232,6 +232,10 @@ func TestObjectIdentifier(t *testing.T) { ...@@ -232,6 +232,10 @@ func TestObjectIdentifier(t *testing.T) {
} }
} }
} }
if s := ObjectIdentifier([]int{1, 2, 3, 4}).String(); s != "1.2.3.4" {
t.Errorf("bad ObjectIdentifier.String(). Got %s, want 1.2.3.4", s)
}
} }
type timeTest struct { type timeTest struct {
......
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