Makefile: add new recipes and linter features (#244)

* Makefile: add new recipes and linter features

* expand linter coverage and fix issues

* Update makefile

* address PR nitterinos
This commit is contained in:
Adrian Gallagher
2019-01-31 14:53:24 +11:00
committed by GitHub
parent e182248387
commit 291e404a4a
85 changed files with 306 additions and 393 deletions

View File

@@ -43,7 +43,7 @@ func encodePEM(privKey *ecdsa.PrivateKey, pubKey bool) ([]byte, error) {
}
func decodePEM(PEMPrivKey, PEMPubKey []byte) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error) {
block, _ := pem.Decode([]byte(PEMPrivKey))
block, _ := pem.Decode(PEMPrivKey)
if block == nil {
return nil, nil, errors.New("priv block data is nil")
}
@@ -54,7 +54,7 @@ func decodePEM(PEMPrivKey, PEMPubKey []byte) (*ecdsa.PrivateKey, *ecdsa.PublicKe
return nil, nil, err
}
blockPub, _ := pem.Decode([]byte(PEMPubKey))
blockPub, _ := pem.Decode(PEMPubKey)
if block == nil {
return nil, nil, errors.New("pub block data is nil")
}
@@ -97,7 +97,8 @@ func main() {
}
if genKeys {
pKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
var pKey *ecdsa.PrivateKey
pKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
log.Fatal(err)
}
@@ -115,13 +116,15 @@ func main() {
}
} else {
pubKeyData, err := common.ReadFile("publickey.pem")
var pubKeyData []byte
pubKeyData, err = common.ReadFile("publickey.pem")
if err != nil {
log.Fatal(err)
}
log.Println("Successfully read PEM files.")
priv, _, err := decodePEM(privKeyData, pubKeyData)
var priv *ecdsa.PrivateKey
priv, _, err = decodePEM(privKeyData, pubKeyData)
if err != nil {
log.Fatal(err)
}