LEFT | RIGHT |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package x509 | 5 package x509 |
6 | 6 |
7 import ( | 7 import ( |
8 "encoding/hex" | 8 "encoding/hex" |
9 "testing" | 9 "testing" |
10 ) | 10 ) |
11 | 11 |
12 // Generated using: | 12 // Generated using: |
13 // openssl ecparam -genkey -name secp384r1 -outform PEM | 13 // openssl ecparam -genkey -name secp384r1 -outform PEM |
14 var ecPrivateKeyHex = `3081a40201010430bdb9839c08ee793d1157886a7a758a3c8b2a17a4d
f48f17ace57c72c56b4723cf21dcda21d4e1ad57ff034f19fcfd98ea00706052b81040022a164036
20004feea808b5ee2429cfcce13c32160e1c960990bd050bb0fdf7222f3decd0a55008e32a6aa3c9
062051c4cba92a7a3b178b24567412d43cdd2f882fa5addddd726fe3e208d2c26d733a773a597abb
749714df7256ead5105fa6e7b3650de236b50` | 14 var ecPrivateKeyHex = `3081a40201010430bdb9839c08ee793d1157886a7a758a3c8b2a17a4d
f48f17ace57c72c56b4723cf21dcda21d4e1ad57ff034f19fcfd98ea00706052b81040022a164036
20004feea808b5ee2429cfcce13c32160e1c960990bd050bb0fdf7222f3decd0a55008e32a6aa3c9
062051c4cba92a7a3b178b24567412d43cdd2f882fa5addddd726fe3e208d2c26d733a773a597abb
749714df7256ead5105fa6e7b3650de236b50` |
15 | 15 |
16 func TestParseECPrivateKey(t *testing.T) { | 16 func TestParseECPrivateKey(t *testing.T) { |
17 derBytes, _ := hex.DecodeString(ecPrivateKeyHex) | 17 derBytes, _ := hex.DecodeString(ecPrivateKeyHex) |
18 _, err := ParseECPrivateKey(derBytes) | 18 _, err := ParseECPrivateKey(derBytes) |
19 if err != nil { | 19 if err != nil { |
20 t.Errorf("failed to decode EC private key: %s", err) | 20 t.Errorf("failed to decode EC private key: %s", err) |
21 } | 21 } |
22 } | 22 } |
23 | |
24 // Generated using: | |
25 // openssl ecparam -genkey -name secp521r1 -outform DER | |
26 var sec1ECPrivateKeyHex = `06052b810400233081dc02010104420182862bb6159ad8f7a7b87
b9987d11513040ce2826d0ca42145be3fe79e38cd5c61cd105b7a516615bb8bf2e3b4fe4a9ea3d5f
fdee54e0cb2511dd1faaa8d2922f2a00706052b81040023a18189038186000400e6ce21bd953454b
7667a9201bc5a3b87905816f0ad46ebc3eb82960f1613920872279c54d64d91f94c6677127f29b09
fe0e84763fe48c2f32bd8f214e341ea419c00eca0aafdd5da266425364cf8140f9be8810d9ef3378
4a43e11873367b0494065684ee3b4afc7c379de9f96fe7933c6f25b43d4f0e701ec1b515083dab73
d9cb15f` | |
27 | |
28 func TestParseSEC1PrivateKey(t *testing.T) { | |
29 derBytes, _ := hex.DecodeString(sec1ECPrivateKeyHex) | |
30 _, err := ParseSEC1PrivateKey(derBytes) | |
31 if err != nil { | |
32 t.Errorf("failed to decode SEC1 EC private key: %s", err) | |
33 } | |
34 } | |
LEFT | RIGHT |