MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / LoadPrivateKey

Function LoadPrivateKey

crypto/kms/privatekeystore.go:119–127  ·  view source on GitHub ↗

LoadPrivateKey loads private key from keyFilePath, and verifies the hash head.

(keyFilePath string, masterKey []byte)

Source from the content-addressed store, hash-verified

117
118// LoadPrivateKey loads private key from keyFilePath, and verifies the hash head.
119func LoadPrivateKey(keyFilePath string, masterKey []byte) (key *asymmetric.PrivateKey, err error) {
120 fileContent, err := ioutil.ReadFile(keyFilePath)
121 if err != nil {
122 log.WithField("path", keyFilePath).WithError(err).Error("read key file failed")
123 return
124 }
125
126 return DecodePrivateKey(fileContent, masterKey)
127}
128
129// EncodePrivateKey encode private to key to string format.
130func EncodePrivateKey(key *asymmetric.PrivateKey, masterKey []byte) (keyBytes []byte, err error) {

Callers 7

getPublicFromConfigFunction · 0.92
runGenerateFunction · 0.92
TestFullProcessFunction · 0.92
InitLocalKeyPairFunction · 0.85
TestSaveLoadPrivateKeyFunction · 0.85
TestLoadPrivateKeyFunction · 0.85

Calls 4

WithFieldFunction · 0.92
DecodePrivateKeyFunction · 0.85
ErrorMethod · 0.80
WithErrorMethod · 0.80

Tested by 4

TestFullProcessFunction · 0.74
TestSaveLoadPrivateKeyFunction · 0.68
TestLoadPrivateKeyFunction · 0.68