Skip to content
Snippets Groups Projects

Add method to push a platform key to the pkstore

Merged Malte Bauch requested to merge add-pk-key-method into master
All threads resolved!
+ 25
19
@@ -355,25 +355,7 @@ func (kms *KMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *RemoteK
processId := uuid.New()
// update PKStore
kms.PKStoreMutex.Lock()
keys, ok := kms.PKStore[tmpRoute.RemoteKMS.Id]
if !ok {
kms.PKStore[tmpRoute.RemoteKMS.Id] = map[uuid.UUID]*PlatformKey{
pathId: {
Id: pk.ID,
Value: pk.Key,
ProcessId: processId.String(),
},
}
} else {
keys[pathId] = &PlatformKey{
Id: pk.ID,
Value: pk.Key,
ProcessId: processId.String(),
}
}
log.Debug("Current PKSTORE: ", kms.PKStore)
kms.PKStoreMutex.Unlock()
kms.AddSpecificPlatformKey(tmpRoute.RemoteKMS.Id, pathId, processId, pk)
remoteKMSAdrress := fmt.Sprintf("%s:%d", remoteKMS.Address, remoteKMS.Port)
@@ -387,6 +369,30 @@ func (kms *KMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *RemoteK
return nil
}
func (kms *KMS) AddSpecificPlatformKey(remoteKMSId string, pathId uuid.UUID, processId uuid.UUID, key *crypto.Key) {
kms.PKStoreMutex.Lock()
defer kms.PKStoreMutex.Unlock()
keys, ok := kms.PKStore[remoteKMSId]
if !ok {
kms.PKStore[remoteKMSId] = map[uuid.UUID]*PlatformKey{
pathId: {
Id: key.ID,
Value: key.Key,
ProcessId: processId.String(),
},
}
} else {
keys[pathId] = &PlatformKey{
Id: key.ID,
Value: key.Key,
ProcessId: processId.String(),
}
}
log.Debug("Current store of platform keys: ", kms.PKStore)
}
func (kms *KMS) GetSpecificPlatformKey(remoteKMSId string, keyId uuid.UUID) (*PlatformKey, error) {
kms.PKStoreMutex.Lock()
defer kms.PKStoreMutex.Unlock()
Loading