Use a EC key to sign CT signatures, plus properly load it

This commit is contained in:
Roland Shoemaker 2015-12-15 13:49:26 -08:00
parent 0bda0a92c3
commit c3d77873c4
3 changed files with 14 additions and 7 deletions

View File

@ -293,7 +293,7 @@
"logs": [
{
"uri": "http://127.0.0.1:4500",
"key": "MHQCAQEEIGKI6QpOXNTBGdVaZ0938b0DEelF50qUDiWXvuB5oezjoAcGBSuBBAAKoUQDQgAEG7RPTHSjHhVDpR6XSishp/soJqHJHDvGpyc6TGJdHx+aD0wpi9knCJFpaxPTNDg0wWc3PtzLmlhlzeXu4lhDpQ=="
"key": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYggOxPnPkzKBIhTacSYoIfnSL2jPugcbUKx83vFMvk5gKAz/AGe87w20riuPwEGn229hKVbEKHFB61NIqNHC3Q=="
}
],
"intermediateBundleFilename": "test/test-ca.pem"

View File

@ -1,5 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIGKI6QpOXNTBGdVaZ0938b0DEelF50qUDiWXvuB5oezjoAcGBSuBBAAK
oUQDQgAEG7RPTHSjHhVDpR6XSishp/soJqHJHDvGpyc6TGJdHx+aD0wpi9knCJFp
axPTNDg0wWc3PtzLmlhlzeXu4lhDpQ==
MHcCAQEEIOCtGlGt/WT7471dOHdfBg43uJWJoZDkZAQjWfTitcVNoAoGCCqGSM49
AwEHoUQDQgAEYggOxPnPkzKBIhTacSYoIfnSL2jPugcbUKx83vFMvk5gKAz/AGe8
7w20riuPwEGn229hKVbEKHFB61NIqNHC3Q==
-----END EC PRIVATE KEY-----

View File

@ -16,6 +16,7 @@ import (
"encoding/asn1"
"encoding/base64"
"encoding/json"
"encoding/pem"
"flag"
"fmt"
"io/ioutil"
@ -142,13 +143,19 @@ func main() {
keyBytes, err := ioutil.ReadFile(*signingKey)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to read signing key file\n")
fmt.Fprintf(os.Stderr, "failed to read signing key file: %s\n", err)
return
}
key, err := x509.ParseECPrivateKey(keyBytes)
keyBlock, _ := pem.Decode(keyBytes)
if keyBlock == nil {
fmt.Fprintf(os.Stderr, "failed to parse signing key PEM\n")
return
}
key, err := x509.ParseECPrivateKey(keyBlock.Bytes)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to parse signing key file\n")
fmt.Fprintf(os.Stderr, "failed to parse signing key file: %s\n", err)
return
}