diff --git a/internal/configfile/config.go b/internal/configfile/config.go index 72d4e11..6069612 100644 --- a/internal/configfile/config.go +++ b/internal/configfile/config.go @@ -55,20 +55,20 @@ func Write(c ConfigFile) error { func LoadPrivateKey() (*ecdh.PrivateKey, error) { fp := path.Join(Path, PrivateKeyFileName) - return crypto.LoadPrivateKey(fp) + return crypto.LoadPrivateKeyFromFile(fp) } func LoadPublicKey() (*ecdh.PublicKey, error) { fp := path.Join(Path, PublicKeyFileName) - return crypto.LoadPublicKey(fp) + return crypto.LoadPublicKeyFromFile(fp) } func SavePrivateKey(k *ecdh.PrivateKey) error { fp := path.Join(Path, PrivateKeyFileName) - return crypto.SavePrivateKey(fp, k) + return crypto.SavePrivateKeyToFile(fp, k) } func SavePublicKey(k *ecdh.PublicKey) error { fp := path.Join(Path, PublicKeyFileName) - return crypto.SavePublicKey(fp, k) + return crypto.SavePublicKeyToFile(fp, k) } diff --git a/internal/server/server.go b/internal/server/server.go index 79ea2a2..9b5540f 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -37,11 +37,11 @@ type controller struct { func newHttpHandler() http.Handler { r := mux.NewRouter() - pbk, err := crypto.LoadPublicKey(config.Default.PublicKeyPath) + pbk, err := crypto.LoadPublicKeyFromFile(config.Default.PublicKeyPath) if err != nil { panic("could not load server's public key") } - pvk, err := crypto.LoadPrivateKey(config.Default.PrivateKeyPath) + pvk, err := crypto.LoadPrivateKeyFromFile(config.Default.PrivateKeyPath) if err != nil { panic("could not load server's private key") } diff --git a/pkg/crypto/keys.go b/pkg/crypto/keys.go index ae84d08..a24054d 100644 --- a/pkg/crypto/keys.go +++ b/pkg/crypto/keys.go @@ -80,7 +80,7 @@ func PublicKeyFromBytes(keyBytes []byte) *ecdh.PublicKey { return key } -func LoadPrivateKey(fp string) (*ecdh.PrivateKey, error) { +func LoadPrivateKeyFromFile(fp string) (*ecdh.PrivateKey, error) { var kb []byte var err error if os.Getenv("CCCLIP_LOAD_RAW_KEYS") == "" { @@ -96,7 +96,7 @@ func LoadPrivateKey(fp string) (*ecdh.PrivateKey, error) { return PrivateKeyFromBytes(kb), nil } -func LoadPublicKey(fp string) (*ecdh.PublicKey, error) { +func LoadPublicKeyFromFile(fp string) (*ecdh.PublicKey, error) { var kb []byte var err error if os.Getenv("CCCLIP_LOAD_RAW_KEYS") == "" { @@ -112,11 +112,11 @@ func LoadPublicKey(fp string) (*ecdh.PublicKey, error) { return PublicKeyFromBytes(kb), nil } -func SavePrivateKey(fp string, k *ecdh.PrivateKey) error { +func SavePrivateKeyToFile(fp string, k *ecdh.PrivateKey) error { return saveKey(fp, k.Bytes(), privateKeyFileMode) } -func SavePublicKey(fp string, k *ecdh.PublicKey) error { +func SavePublicKeyToFile(fp string, k *ecdh.PublicKey) error { return saveKey(fp, k.Bytes(), publicKeyFileMode) }