func (client *clientImpl) loadTCertOwnerKDFKey(pwd []byte) error { // Load TCertOwnerKDFKey client.node.log.Debug("Loading TCertOwnerKDFKey at [%s]...", client.node.conf.getTCertOwnerKDFKeyPath()) missing, _ := utils.FilePathMissing(client.node.conf.getTCertOwnerKDFKeyPath()) if missing { client.node.log.Debug("Failed loading TCertOwnerKDFKey. File is missing.") return nil } pem, err := ioutil.ReadFile(client.node.conf.getTCertOwnerKDFKeyPath()) if err != nil { client.node.log.Error("Failed loading TCertOwnerKDFKey [%s].", err.Error()) return err } tCertOwnerKDFKey, err := utils.PEMtoAES(pem, pwd) if err != nil { client.node.log.Error("Failed parsing TCertOwnerKDFKey [%s].", err.Error()) return err } client.tCertOwnerKDFKey = tCertOwnerKDFKey client.node.log.Debug("Loading TCertOwnerKDFKey...done!") return nil }
func (ks *keyStore) loadKey(alias string) ([]byte, error) { path := ks.conf.getPathForAlias(alias) ks.log.Debug("Loading key [%s] at [%s]...", alias, path) pem, err := ioutil.ReadFile(path) if err != nil { ks.log.Error("Failed loading key [%s]: [%s].", alias, err.Error()) return nil, err } key, err := utils.PEMtoAES(pem, ks.pwd) if err != nil { ks.log.Error("Failed parsing key [%s]: [%s]", alias, err) return nil, err } return key, nil }
func (node *nodeImpl) loadEnrollmentChainKey(pwd []byte) error { node.log.Debug("Loading enrollment chain key at [%s]...", node.conf.getEnrollmentChainKeyPath()) pem, err := ioutil.ReadFile(node.conf.getEnrollmentChainKeyPath()) if err != nil { node.log.Error("Failed loading enrollment chain key [%s].", err.Error()) return err } enrollChainKey, err := utils.PEMtoAES(pem, pwd) if err != nil { node.log.Error("Failed parsing enrollment chain key [%s].", err.Error()) return err } node.enrollChainKey = enrollChainKey return nil }