summaryrefslogtreecommitdiff
path: root/src/pkg/asn1/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/asn1/common.go')
-rw-r--r--src/pkg/asn1/common.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/pkg/asn1/common.go b/src/pkg/asn1/common.go
index 4a5eca145..158987747 100644
--- a/src/pkg/asn1/common.go
+++ b/src/pkg/asn1/common.go
@@ -32,6 +32,7 @@ const (
tagIA5String = 22
tagUTCTime = 23
tagGeneralizedTime = 24
+ tagGeneralString = 27
)
const (
@@ -67,7 +68,8 @@ type tagAndLength struct {
// fieldParameters is the parsed representation of tag string from a structure field.
type fieldParameters struct {
optional bool // true iff the field is OPTIONAL
- explicit bool // true iff and EXPLICIT tag is in use.
+ explicit bool // true iff an EXPLICIT tag is in use.
+ application bool // true iff an APPLICATION tag is in use.
defaultValue *int64 // a default value for INTEGER typed fields (maybe nil).
tag *int // the EXPLICIT or IMPLICIT tag (maybe nil).
stringType int // the string tag to use when marshaling.
@@ -89,7 +91,6 @@ func parseFieldParameters(str string) (ret fieldParameters) {
ret.explicit = true
if ret.tag == nil {
ret.tag = new(int)
- *ret.tag = 0
}
case part == "ia5":
ret.stringType = tagIA5String
@@ -109,6 +110,11 @@ func parseFieldParameters(str string) (ret fieldParameters) {
}
case part == "set":
ret.set = true
+ case part == "application":
+ ret.application = true
+ if ret.tag == nil {
+ ret.tag = new(int)
+ }
}
}
return
@@ -127,14 +133,14 @@ func getUniversalType(t reflect.Type) (tagNumber int, isCompound, ok bool) {
case enumeratedType:
return tagEnum, false, true
}
- switch t := t.(type) {
- case *reflect.BoolType:
+ switch t.Kind() {
+ case reflect.Bool:
return tagBoolean, false, true
- case *reflect.IntType:
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return tagInteger, false, true
- case *reflect.StructType:
+ case reflect.Struct:
return tagSequence, true, true
- case *reflect.SliceType:
+ case reflect.Slice:
if t.Elem().Kind() == reflect.Uint8 {
return tagOctetString, false, true
}
@@ -142,7 +148,7 @@ func getUniversalType(t reflect.Type) (tagNumber int, isCompound, ok bool) {
return tagSet, true, true
}
return tagSequence, true, true
- case *reflect.StringType:
+ case reflect.String:
return tagPrintableString, false, true
}
return 0, false, false