X7ROOT File Manager
Current Path:
/opt/golang/1.22.0/src/crypto/x509
opt
/
golang
/
1.22.0
/
src
/
crypto
/
x509
/
📁
..
📄
boring.go
(993 B)
📄
boring_test.go
(3.75 KB)
📄
cert_pool.go
(8.93 KB)
📄
cert_pool_test.go
(2.25 KB)
📄
example_test.go
(5.32 KB)
📄
hybrid_pool_test.go
(3.72 KB)
📁
internal
📄
name_constraints_test.go
(44.92 KB)
📄
notboring.go
(258 B)
📄
oid.go
(5.75 KB)
📄
oid_test.go
(3.7 KB)
📄
parser.go
(36.57 KB)
📄
parser_test.go
(2.63 KB)
📄
pem_decrypt.go
(7.2 KB)
📄
pem_decrypt_test.go
(8.92 KB)
📄
pkcs1.go
(4.66 KB)
📄
pkcs8.go
(5.8 KB)
📄
pkcs8_test.go
(8.95 KB)
📁
pkix
📄
platform_root_cert.pem
(749 B)
📄
platform_root_key.pem
(227 B)
📄
platform_test.go
(7.28 KB)
📄
root.go
(2.03 KB)
📄
root_aix.go
(410 B)
📄
root_bsd.go
(748 B)
📄
root_darwin.go
(3.48 KB)
📄
root_darwin_test.go
(3.7 KB)
📄
root_linux.go
(1.11 KB)
📄
root_plan9.go
(828 B)
📄
root_solaris.go
(538 B)
📄
root_test.go
(2.62 KB)
📄
root_unix.go
(2.67 KB)
📄
root_unix_test.go
(6.07 KB)
📄
root_wasm.go
(373 B)
📄
root_windows.go
(8.74 KB)
📄
root_windows_test.go
(3.43 KB)
📄
sec1.go
(4.58 KB)
📄
sec1_test.go
(5.36 KB)
📄
test-file.crt
(1.9 KB)
📁
testdata
📄
verify.go
(35.3 KB)
📄
verify_test.go
(108.97 KB)
📄
x509.go
(82.3 KB)
📄
x509_test.go
(159.96 KB)
📄
x509_test_import.go
(1.7 KB)
Editing: parser_test.go
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package x509 import ( "encoding/asn1" "testing" cryptobyte_asn1 "golang.org/x/crypto/cryptobyte/asn1" ) func TestParseASN1String(t *testing.T) { tests := []struct { name string tag cryptobyte_asn1.Tag value []byte expected string expectedErr string }{ { name: "T61String", tag: cryptobyte_asn1.T61String, value: []byte{80, 81, 82}, expected: string("PQR"), }, { name: "PrintableString", tag: cryptobyte_asn1.PrintableString, value: []byte{80, 81, 82}, expected: string("PQR"), }, { name: "PrintableString (invalid)", tag: cryptobyte_asn1.PrintableString, value: []byte{1, 2, 3}, expectedErr: "invalid PrintableString", }, { name: "UTF8String", tag: cryptobyte_asn1.UTF8String, value: []byte{80, 81, 82}, expected: string("PQR"), }, { name: "UTF8String (invalid)", tag: cryptobyte_asn1.UTF8String, value: []byte{255}, expectedErr: "invalid UTF-8 string", }, { name: "BMPString", tag: cryptobyte_asn1.Tag(asn1.TagBMPString), value: []byte{80, 81}, expected: string("偑"), }, { name: "BMPString (invalid length)", tag: cryptobyte_asn1.Tag(asn1.TagBMPString), value: []byte{255}, expectedErr: "invalid BMPString", }, { name: "IA5String", tag: cryptobyte_asn1.IA5String, value: []byte{80, 81}, expected: string("PQ"), }, { name: "IA5String (invalid)", tag: cryptobyte_asn1.IA5String, value: []byte{255}, expectedErr: "invalid IA5String", }, { name: "NumericString", tag: cryptobyte_asn1.Tag(asn1.TagNumericString), value: []byte{49, 50}, expected: string("12"), }, { name: "NumericString (invalid)", tag: cryptobyte_asn1.Tag(asn1.TagNumericString), value: []byte{80}, expectedErr: "invalid NumericString", }, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { out, err := parseASN1String(tc.tag, tc.value) if err != nil && err.Error() != tc.expectedErr { t.Fatalf("parseASN1String returned unexpected error: got %q, want %q", err, tc.expectedErr) } else if err == nil && tc.expectedErr != "" { t.Fatalf("parseASN1String didn't fail, expected: %s", tc.expectedErr) } if out != tc.expected { t.Fatalf("parseASN1String returned unexpected value: got %q, want %q", out, tc.expected) } }) } }
Upload File
Create Folder