亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內(nèi)置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結(jié)構(gòu)heap) container/list(容器數(shù)據(jù)結(jié)構(gòu)list) container/ring(容器數(shù)據(jù)結(jié)構(gòu)ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(數(shù)據(jù)庫/sql) database/sql/driver(數(shù)據(jù)庫/sql/driver) debug debug/dwarf(調(diào)試/dwarf) debug/elf(調(diào)試/elf) debug/gosym(調(diào)試/gosym) debug/macho(調(diào)試/macho) debug/pe(調(diào)試/pe) debug/plan9obj(調(diào)試/plan9obj) encoding encoding(編碼) encoding/ascii85(編碼/ascii85) encoding/asn1(編碼/asn1) encoding/base32(編碼/base32) encoding/base64(編碼/base64) encoding/binary(編碼/binary) encoding/csv(編碼/csv) encoding/gob(編碼/gob) encoding/hex(編碼/hex) encoding/json(編碼/json) encoding/pem(編碼/pem) encoding/xml(編碼/xml) errors errors(錯誤) expvar expvar flag flag(命令行參數(shù)解析flag包) fmt fmt go go/ast(抽象語法樹) go/build go/constant(常量) go/doc(文檔) go/format(格式) go/importer go/parser go/printer go/scanner(掃描儀) go/token(令牌) go/types(類型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(圖像) image/color(顏色) image/color/palette(調(diào)色板) image/draw(繪圖) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系統(tǒng)) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路徑) plugin plugin(插件) reflect reflect(反射) regexp regexp(正則表達式) regexp/syntax runtime runtime(運行時) runtime/debug(調(diào)試) runtime/internal/sys runtime/pprof runtime/race(競爭) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉(zhuǎn)換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調(diào)用) testing testing(測試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
文字

  • import "encoding/asn1"

  • 概述

  • 索引

概述

按照 ITU-T Rec X.690 的規(guī)定,asn1 包實現(xiàn)了對 DER 編碼的 ASN.1 數(shù)據(jù)結(jié)構(gòu)的解析。

另見“ ASN.1,BER 和 DER 子集的外行指南”,http://luca.ntop.org/Teaching/Appunti/asn1.html。

索引

  • 常量

  • 變量

  • func Marshal(val interface{}) ([]byte, error)

  • func Unmarshal(b []byte, val interface{}) (rest []byte, err error)

  • func UnmarshalWithParams(b []byte, val interface{}, params string) (rest []byte, err error)

  • type BitString

  • func (b BitString) At(i int) int

  • func (b BitString) RightAlign() []byte

  • type Enumerated

  • type Flag

  • type ObjectIdentifier

  • func (oi ObjectIdentifier) Equal(other ObjectIdentifier) bool

  • func (oi ObjectIdentifier) String() string

  • type RawContent

  • type RawValue

  • type StructuralError

  • func (e StructuralError) Error() string

  • type SyntaxError

  • func (e SyntaxError) Error() string

包文件

asn1.go common.go marshal.go

常量

ASN.1 標簽表示以下對象的類型。

const (
        TagBoolean         = 1
        TagInteger         = 2
        TagBitString       = 3
        TagOctetString     = 4
        TagNull            = 5
        TagOID             = 6
        TagEnum            = 10
        TagUTF8String      = 12
        TagSequence        = 16
        TagSet             = 17
        TagPrintableString = 19
        TagT61String       = 20
        TagIA5String       = 22
        TagUTCTime         = 23
        TagGeneralizedTime = 24
        TagGeneralString   = 27)

ASN.1 類類型表示標簽的名稱空間。

const (
        ClassUniversal       = 0
        ClassApplication     = 1
        ClassContextSpecific = 2
        ClassPrivate         = 3)

變量

NullBytes 包含表示 DER 編碼的 ASN.1 NULL 類型的字節(jié)。

var NullBytes = []byte{TagNull, 0}

NullRawValue 是一個 RawValue,其標簽設(shè)置為 ASN.1 NULL 類型 tag(5)。

var NullRawValue = RawValue{Tag: TagNull}

func Marshal

func Marshal(val interface{}) ([]byte, error)

Marshal 返回 val 的 ASN.1 編碼。

除了由 Unmarshal 識別的結(jié)構(gòu)標簽之外,還可以使用以下內(nèi)容:

ia5:導(dǎo)致字符串被封送為ASN.1,IA5String值
omitempty:導(dǎo)致跳過空切片
printable:導(dǎo)致字符串被封送為ASN.1,PrintableString值
utf8:導(dǎo)致字符串被封送為ASN.1,UTF8String值
utc:導(dǎo)致time.Time被封送為ASN.1,UTCTime值
generalized:導(dǎo)致time.Time被封送為ASN.1,GeneralizedTime值

func Unmarshal

func Unmarshal(b []byte, val interface{}) (rest []byte, err error)

Unmarshal 分析 DER 編碼的 ASN.1 數(shù)據(jù)結(jié)構(gòu) b 并使用反射包填充 val 指向的任意值。由于 Unmarshal 使用反射包,因此寫入的結(jié)構(gòu)必須使用大寫字段名稱。

ASN.1 INTEGER 可以寫入 int,int32,int64 或 *big.Int(來自 math/big package)。如果編碼值不適合 Go 類型,Unmarshal 會返回解析錯誤。

一個 ASN.1 BIT STRING 可以寫入一個 BitString。

ASN.1 OCTET STRING 可以寫入 []byte。

一個 ASN.1 OBJECT IDENTIFIER 可以寫入一個 ObjectIdentifier。

一個 ASN.1 枚舉可以被寫入枚舉。

一次 ASN.1 UTCTIME 或 GENERALIZEDTIME 可寫入一次。

ASN.1 PrintableString 或 IA5String 可寫入字符串。

任何上面的 ASN.1 值都可以寫入 interface{}。存儲在接口中的值具有相應(yīng)的 Go 類型。對于整數(shù),該類型是 int64。

如果可以將 x 寫入片段的元素類型,則可以將 x 或 x 的 ASN.1 序列寫入片段。

如果可以將序列中的每個元素寫入結(jié)構(gòu)中的相應(yīng)元素,則可以將 ASN.1 SEQUENCE 或 SET 寫入結(jié)構(gòu)。

結(jié)構(gòu)字段上的以下標記對 Unmarshal 具有特殊意義:

application指定使用APPLICATION標記default:x設(shè)置可選整數(shù)字段的默認值(僅在可選的整數(shù)字段存在時使用)
explicit指定附加的顯式標記包裝隱式標記
可選標記該字段為ASN.1可選set會導(dǎo)致SET,而不是SEQUENCE類型
tag:x指定ASN.1標記號; 暗示ASN.1特定背景

如果結(jié)構(gòu)的第一個字段的類型是 RawContent,那么該結(jié)構(gòu)的原始 ASN1 內(nèi)容將被存儲在其中。

如果一個切片元素的類型名稱以“SET”結(jié)尾,那么它將被視為設(shè)置了“set”標簽。這可以用于無法給出 struct 標記的嵌套切片。

其他 ASN.1 類型不受支持;如果遇到,Unmarshal 將返回一個分析錯誤。

func UnmarshalWithParams

func UnmarshalWithParams(b []byte, val interface{}, params string) (rest []byte, err error)

UnmarshalWithParams 允許為頂層元素指定字段參數(shù)。參數(shù)的形式與字段標簽相同。

type BitString

當您需要 ASN.1 BIT STRING 類型時,BitString 是要使用的結(jié)構(gòu)。位串被填充到內(nèi)存中最近的字節(jié)并記錄有效位的數(shù)量。填充位將為零。

type BitString struct {
        Bytes     []byte // 比特打包成字節(jié)。
        BitLength int    // 比特長度。}

func (BitString) At

func (b BitString) At(i int) int

返回給定索引處的位。如果索引超出范圍,則返回 false。

func (BitString) RightAlign

func (b BitString) RightAlign() []byte

RightAlign 返回填充位在開始位置的片。切片可以與 BitString 共享內(nèi)存。

type Enumerated

Enumerated 被表示為一個純(plain) int。

type Enumerated int

type Flag

Flag 接受任何數(shù)據(jù),如果存在則設(shè)置為 true。

type Flag bool

type ObjectIdentifier

一個 ObjectIdentifier 表示一個 ASN.1 對象標識符。

type ObjectIdentifier []int

func (ObjectIdentifier) Equal

func (oi ObjectIdentifier) Equal(other ObjectIdentifier) bool

平等報告 oi 和其他是否表示相同的標識符。

func (ObjectIdentifier) String

func (oi ObjectIdentifier) String() string

type RawContent

RawContent 用于表示未解碼的 DER 數(shù)據(jù)需要為結(jié)構(gòu)體保留。要使用它,結(jié)構(gòu)的第一個字段必須有這種類型。任何其他字段都有這種類型的錯誤。

type RawContent []byte

type RawValue

一個 RawValue 表示一個未解碼的 ASN.1 對象。

type RawValue struct {
        Class, Tag int
        IsCompound bool
        Bytes      []byte
        FullBytes  []byte // 包括標簽和長度}

type StructuralError

StructuralError 表明 ASN.1 數(shù)據(jù)是有效的,但是接收它的 Go 類型不匹配。

type StructuralError struct {
        Msg string}

func (StructuralError) Error

func (e StructuralError) Error() string

type SyntaxError

SyntaxError 表明 ASN.1 數(shù)據(jù)無效。

type SyntaxError struct {
        Msg string}

func (SyntaxError) Error

func (e SyntaxError) Error() string
上一篇: 下一篇: