LoadPrivateKey loads private key from keyFilePath, and verifies the hash head.
(keyFilePath string, masterKey []byte)
| 117 | |
| 118 | // LoadPrivateKey loads private key from keyFilePath, and verifies the hash head. |
| 119 | func 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. |
| 130 | func EncodePrivateKey(key *asymmetric.PrivateKey, masterKey []byte) (keyBytes []byte, err error) { |