aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding
diff options
context:
space:
mode:
authorKyle Isom <kyle@gokyle.net>2014-02-13 12:54:04 -0500
committerAdam Langley <agl@golang.org>2014-02-13 12:54:04 -0500
commitfc8e77ca65ab7d4dfd6fd58ad67145f253aab829 (patch)
treeddff37ebd347952ab868c588b48f48729ce2f006 /src/pkg/encoding
parenteea28f6701ac888d5613470a88d09b634efc1d75 (diff)
downloadgo-fc8e77ca65ab7d4dfd6fd58ad67145f253aab829.tar.xz
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
Diffstat (limited to 'src/pkg/encoding')
-rw-r--r--src/pkg/encoding/asn1/asn1.go14
-rw-r--r--src/pkg/encoding/asn1/asn1_test.go4
2 files changed, 18 insertions, 0 deletions
diff --git a/src/pkg/encoding/asn1/asn1.go b/src/pkg/encoding/asn1/asn1.go
index b8a732e024..7a3c3797c8 100644
--- a/src/pkg/encoding/asn1/asn1.go
+++ b/src/pkg/encoding/asn1/asn1.go
@@ -23,6 +23,7 @@ import (
"fmt"
"math/big"
"reflect"
+ "strconv"
"time"
)
@@ -197,6 +198,19 @@ func (oi ObjectIdentifier) Equal(other ObjectIdentifier) bool {
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
// returns it. An object identifier is a sequence of variable length integers
// that are assigned in a hierarchy.
diff --git a/src/pkg/encoding/asn1/asn1_test.go b/src/pkg/encoding/asn1/asn1_test.go
index 4f60b6751d..b553f78e0a 100644
--- a/src/pkg/encoding/asn1/asn1_test.go
+++ b/src/pkg/encoding/asn1/asn1_test.go
@@ -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 {