"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/crypto/x509/x509_test.go" between
go1.19.src.tar.gz and go1.19.1.src.tar.gz

About: Google’s Go is a compiled, garbage-collected, concurrent programming language.
Latest stable release (1.19).

x509_test.go  (go1.19.src):x509_test.go  (go1.19.1.src)
skipping to change at line 71 skipping to change at line 71
const pkixPublicKey = "30820122300d06092a864886f70d01010105000382010f0030 82010a0282010100dd5a0f37d3ca5232852ccc0e81eebec270e2f2c6c44c6231d852971a0aad00aa 7399e9b9de444611083c59ea919a9d76c20a7be131a99045ec19a7bb452d647a72429e66b87e28be 9e8187ed1d2a2a01ef3eb2360706bd873b07f2d1f1a72337aab5ec94e983e39107f52c480d404915 e84d75a3db2cfd601726a128cb1d7f11492d4bdb53272e652276667220795c709b8a9b4af6489cbf 48bb8173b8fb607c834a71b6e8bf2d6aab82af3c8ad7ce16d8dcf58373a6edc427f7484d09744d4c 08f4e19ed07adbf6cb31243bc5d0d1145e77a08a6fc5efd208eca67d6abf2d6f38f58b6fdd7c2877 4fb0cc03fc4935c6e074842d2e1479d3d8787249258719f90203010001" const pkixPublicKey = "30820122300d06092a864886f70d01010105000382010f0030 82010a0282010100dd5a0f37d3ca5232852ccc0e81eebec270e2f2c6c44c6231d852971a0aad00aa 7399e9b9de444611083c59ea919a9d76c20a7be131a99045ec19a7bb452d647a72429e66b87e28be 9e8187ed1d2a2a01ef3eb2360706bd873b07f2d1f1a72337aab5ec94e983e39107f52c480d404915 e84d75a3db2cfd601726a128cb1d7f11492d4bdb53272e652276667220795c709b8a9b4af6489cbf 48bb8173b8fb607c834a71b6e8bf2d6aab82af3c8ad7ce16d8dcf58373a6edc427f7484d09744d4c 08f4e19ed07adbf6cb31243bc5d0d1145e77a08a6fc5efd208eca67d6abf2d6f38f58b6fdd7c2877 4fb0cc03fc4935c6e074842d2e1479d3d8787249258719f90203010001"
const errorContains = "use ParsePKIXPublicKey instead" const errorContains = "use ParsePKIXPublicKey instead"
derBytes, _ := hex.DecodeString(pkixPublicKey) derBytes, _ := hex.DecodeString(pkixPublicKey)
_, err := ParsePKCS1PublicKey(derBytes) _, err := ParsePKCS1PublicKey(derBytes)
if !strings.Contains(err.Error(), errorContains) { if !strings.Contains(err.Error(), errorContains) {
t.Errorf("expected error containing %q, got %s", errorContains, e rr) t.Errorf("expected error containing %q, got %s", errorContains, e rr)
} }
} }
func TestMarshalInvalidPublicKey(t *testing.T) {
_, err := MarshalPKIXPublicKey(&ecdsa.PublicKey{})
if err == nil {
t.Errorf("expected error, got MarshalPKIXPublicKey success")
}
_, err = MarshalPKIXPublicKey(&ecdsa.PublicKey{
Curve: elliptic.P256(),
X: big.NewInt(1), Y: big.NewInt(2),
})
if err == nil {
t.Errorf("expected error, got MarshalPKIXPublicKey success")
}
}
func testParsePKIXPublicKey(t *testing.T, pemBytes string) (pub any) { func testParsePKIXPublicKey(t *testing.T, pemBytes string) (pub any) {
block, _ := pem.Decode([]byte(pemBytes)) block, _ := pem.Decode([]byte(pemBytes))
pub, err := ParsePKIXPublicKey(block.Bytes) pub, err := ParsePKIXPublicKey(block.Bytes)
if err != nil { if err != nil {
t.Fatalf("Failed to parse public key: %s", err) t.Fatalf("Failed to parse public key: %s", err)
} }
pubBytes2, err := MarshalPKIXPublicKey(pub) pubBytes2, err := MarshalPKIXPublicKey(pub)
if err != nil { if err != nil {
t.Errorf("Failed to marshal public key for the second time: %s", err) t.Errorf("Failed to marshal public key for the second time: %s", err)
 End of changes. 1 change blocks. 
0 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)