diff options
author | Gibheer <gibheer@gmail.com> | 2015-03-25 20:43:18 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-03-25 20:43:18 +0100 |
commit | ba5a59931e015fc9a27ab631950c32fa890eec9f (patch) | |
tree | abfe8b2f20a02ae147b7f82be1fe6321e530d4e0 /private_key.go | |
parent | bb41ff218a14b6597607408de6efed37cc8dae40 (diff) |
reformat code with gofmt
Yes, I know that this breaks the history search, but it had to be done
sooner or later. I also adjusted my editor to follow the guidelines more
closely.
Diffstat (limited to 'private_key.go')
-rw-r--r-- | private_key.go | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/private_key.go b/private_key.go index 0591e18..4996f5e 100644 --- a/private_key.go +++ b/private_key.go @@ -1,43 +1,53 @@ package main import ( - "errors" - "github.com/gibheer/pki" + "errors" + "github.com/gibheer/pki" ) var ( - ErrNoPKFound = errors.New("no private key found") - ErrNoPUFound = errors.New("no public key found") - ErrUnknownFormat = errors.New("key is an unknown format") + ErrNoPKFound = errors.New("no private key found") + ErrNoPUFound = errors.New("no public key found") + ErrUnknownFormat = errors.New("key is an unknown format") ) // Read the private key from the path and try to figure out which type of key it // might be. func ReadPrivateKeyFile(path string) (pki.PrivateKey, error) { - raw_pk, err := readSectionFromFile(path, pki.PemLabelEcdsa) - if err == nil { - pk, err := pki.LoadPrivateKeyEcdsa(raw_pk) - if err != nil { return nil, err } - return pk, nil - } - raw_pk, err = readSectionFromFile(path, pki.PemLabelRsa) - if err == nil { - pk, err := pki.LoadPrivateKeyRsa(raw_pk) - if err != nil { return nil, err } - return pk, nil - } - return nil, ErrNoPKFound + raw_pk, err := readSectionFromFile(path, pki.PemLabelEcdsa) + if err == nil { + pk, err := pki.LoadPrivateKeyEcdsa(raw_pk) + if err != nil { + return nil, err + } + return pk, nil + } + raw_pk, err = readSectionFromFile(path, pki.PemLabelRsa) + if err == nil { + pk, err := pki.LoadPrivateKeyRsa(raw_pk) + if err != nil { + return nil, err + } + return pk, nil + } + return nil, ErrNoPKFound } // read the public key and try to figure out what kind of key it might be func ReadPublicKeyFile(path string) (pki.PublicKey, error) { - raw_pu, err := readSectionFromFile(path, pki.PemLabelPublic) - if err != nil { return nil, ErrNoPUFound } + raw_pu, err := readSectionFromFile(path, pki.PemLabelPublic) + if err != nil { + return nil, ErrNoPUFound + } - var public pki.PublicKey - public, err = pki.LoadPublicKeyEcdsa(raw_pu) - if err == nil { return public, nil } - public, err = pki.LoadPublicKeyRsa(raw_pu) - if err == nil { return public, nil } - return nil, ErrUnknownFormat + var public pki.PublicKey + public, err = pki.LoadPublicKeyEcdsa(raw_pu) + if err == nil { + return public, nil + } + public, err = pki.LoadPublicKeyRsa(raw_pu) + if err == nil { + return public, nil + } + return nil, ErrUnknownFormat } |