OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package asn1 | 5 package asn1 |
6 | 6 |
7 import ( | 7 import ( |
8 "reflect" | 8 "reflect" |
9 "strconv" | 9 "strconv" |
10 "strings" | 10 "strings" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 switch t { | 120 switch t { |
121 case objectIdentifierType: | 121 case objectIdentifierType: |
122 return tagOID, false, true | 122 return tagOID, false, true |
123 case bitStringType: | 123 case bitStringType: |
124 return tagBitString, false, true | 124 return tagBitString, false, true |
125 case timeType: | 125 case timeType: |
126 return tagUTCTime, false, true | 126 return tagUTCTime, false, true |
127 case enumeratedType: | 127 case enumeratedType: |
128 return tagEnum, false, true | 128 return tagEnum, false, true |
129 } | 129 } |
130 » switch t := t.(type) { | 130 » switch t.Kind() { |
131 » case *reflect.BoolType: | 131 » case reflect.Bool: |
132 return tagBoolean, false, true | 132 return tagBoolean, false, true |
133 » case *reflect.IntType: | 133 » case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.In
t64: |
134 return tagInteger, false, true | 134 return tagInteger, false, true |
135 » case *reflect.StructType: | 135 » case reflect.Struct: |
136 return tagSequence, true, true | 136 return tagSequence, true, true |
137 » case *reflect.SliceType: | 137 » case reflect.Slice: |
138 if t.Elem().Kind() == reflect.Uint8 { | 138 if t.Elem().Kind() == reflect.Uint8 { |
139 return tagOctetString, false, true | 139 return tagOctetString, false, true |
140 } | 140 } |
141 if strings.HasSuffix(t.Name(), "SET") { | 141 if strings.HasSuffix(t.Name(), "SET") { |
142 return tagSet, true, true | 142 return tagSet, true, true |
143 } | 143 } |
144 return tagSequence, true, true | 144 return tagSequence, true, true |
145 » case *reflect.StringType: | 145 » case reflect.String: |
146 return tagPrintableString, false, true | 146 return tagPrintableString, false, true |
147 } | 147 } |
148 return 0, false, false | 148 return 0, false, false |
149 } | 149 } |
OLD | NEW |