Define tagUTCTime and tagGeneralizedTime

They're only exported in Go1.6 and I'd like to support Go1.5 as well.

Closes: #15
This commit is contained in:
Andrew Ayer 2016-08-20 19:43:10 -07:00
parent b1dc229785
commit 1af6309367
1 changed files with 7 additions and 2 deletions

View File

@ -17,6 +17,11 @@ import (
"unicode" "unicode"
) )
const (
tagUTCTime = 23
tagGeneralizedTime = 24
)
func isDigit(b byte) bool { func isDigit(b byte) bool {
return unicode.IsDigit(rune(b)) return unicode.IsDigit(rune(b))
} }
@ -242,9 +247,9 @@ func parseGeneralizedTime(bytes []byte) (time.Time, error) {
func decodeASN1Time(value *asn1.RawValue) (time.Time, error) { func decodeASN1Time(value *asn1.RawValue) (time.Time, error) {
if !value.IsCompound && value.Class == 0 { if !value.IsCompound && value.Class == 0 {
if value.Tag == asn1.TagUTCTime { if value.Tag == tagUTCTime {
return parseUTCTime(value.Bytes) return parseUTCTime(value.Bytes)
} else if value.Tag == asn1.TagGeneralizedTime { } else if value.Tag == tagGeneralizedTime {
return parseGeneralizedTime(value.Bytes) return parseGeneralizedTime(value.Bytes)
} }
} }