| 1 | // Copyright 2012 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/ct/x509`/ |
| 6 | |
| 7 | import ( |
| 8 | "bytesscip-go gomod github.com/golang/go/src go1.16 bytes/" |
| 9 | "encoding/hexscip-go gomod github.com/golang/go/src go1.16 `encoding/hex`/" |
| 10 | "testingscip-go gomod github.com/golang/go/src go1.16 testing/" |
| 11 | ) |
| 12 | |
| 13 | // Generated using: |
| 14 | // |
| 15 | // openssl ecparam -genkey -name secp384r1 -outform PEM |
| 16 | var ecPrivateKeyHexscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/ct/x509`/ecPrivateKeyHex. = `3081a40201010430bdb9839c08ee793d1157886a7a758a3c8b2a17a4df48f17ace57c72c56b4723cf21dcda21d4e1ad57ff034f19fcfd98ea00706052b81040022a16403620004feea808b5ee2429cfcce13c32160e1c960990bd050bb0fdf7222f3decd0a55008e32a6aa3c9062051c4cba92a7a3b178b24567412d43cdd2f882fa5addddd726fe3e208d2c26d733a773a597abb749714df7256ead5105fa6e7b3650de236b50` |
| 17 | |
| 18 | func TestParseECPrivateKeyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/ct/x509`/TestParseECPrivateKey().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) { |
| 19 | derBytes, _ := hexscip-go gomod github.com/golang/go/src go1.16 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.16 `encoding/hex`/DecodeString().(ecPrivateKeyHexscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/ct/x509`/ecPrivateKeyHex.) |
| 20 | key, err := ParseECPrivateKeyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/ct/x509`/ParseECPrivateKey().(derBytes) |
| 21 | if err != nil { |
| 22 | t.Errorfscip-go gomod github.com/golang/go/src go1.16 testing/common#Errorf().("failed to decode EC private key: %s", err) |
| 23 | } |
| 24 | serialized, err := MarshalECPrivateKeyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/ct/x509`/MarshalECPrivateKey().(key) |
| 25 | if err != nil { |
| 26 | t.Fatalfscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatalf().("failed to encode EC private key: %s", err) |
| 27 | } |
| 28 | if !bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(serialized, derBytes) { |
| 29 | t.Fatalfscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatalf().("serialized key differs: got %x, want %x", serialized, derBytes) |
| 30 | } |
| 31 | } |