From a914d073aa30f91435c6229e1f597f5f4680f837 Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@h-da.de> Date: Fri, 5 Apr 2024 09:00:02 +0000 Subject: [PATCH] Add to remoteKMSMapping if remot kms information is present See merge request danet/quant!84 --- ekms/internal/kms/kms.go | 14 ++++++++------ ekms/internal/kms/kmsintercom.go | 5 ----- ekms/internal/kms/module.go | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ekms/internal/kms/kms.go b/ekms/internal/kms/kms.go index 62f0937f..91325426 100644 --- a/ekms/internal/kms/kms.go +++ b/ekms/internal/kms/kms.go @@ -226,6 +226,14 @@ func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *Remote kms.routingTable[pathId] = tmpRoute kms.routingTableMutex.Unlock() + if tmpRoute.RemoteKMS != nil { + kms.remoteKMSMappingMutex.Lock() + if _, ok := kms.remoteKMSMapping[tmpRoute.RemoteKMS.Id]; !ok { + kms.remoteKMSMapping[tmpRoute.RemoteKMS.Id] = tmpRoute.RemoteKMS + } + kms.remoteKMSMappingMutex.Unlock() + } + if tmpRoute.Previous == nil && tmpRoute.Next != nil && tmpRoute.RemoteKMS != nil { // generate pk key pk, err := crypto.Random256BitKey() @@ -242,12 +250,6 @@ func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *Remote return err } - kms.remoteKMSMappingMutex.Lock() - if _, ok := kms.remoteKMSMapping[tmpRoute.RemoteKMS.Id]; !ok { - kms.remoteKMSMapping[tmpRoute.RemoteKMS.Id] = tmpRoute.RemoteKMS - } - kms.remoteKMSMappingMutex.Unlock() - // update PKStore kms.PKStoreMutex.Lock() keys, ok := kms.PKStore[tmpRoute.RemoteKMS.Id] diff --git a/ekms/internal/kms/kmsintercom.go b/ekms/internal/kms/kmsintercom.go index 90c6a60a..74905be6 100644 --- a/ekms/internal/kms/kmsintercom.go +++ b/ekms/internal/kms/kmsintercom.go @@ -255,11 +255,6 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin }, pathId, processId) } else { log.Infof("%s received the final payload: %s", s.eKMS.kmsName, string(decryptedKey)) - s.eKMS.remoteKMSMappingMutex.Lock() - if _, ok := s.eKMS.remoteKMSMapping[route.RemoteKMS.Id]; !ok { - s.eKMS.remoteKMSMapping[route.RemoteKMS.Id] = route.RemoteKMS - } - s.eKMS.remoteKMSMappingMutex.Unlock() s.eKMS.PKStoreMutex.Lock() keys, ok := s.eKMS.PKStore[route.RemoteKMS.Id] if !ok { diff --git a/ekms/internal/kms/module.go b/ekms/internal/kms/module.go index 56865497..59efcaa3 100644 --- a/ekms/internal/kms/module.go +++ b/ekms/internal/kms/module.go @@ -218,7 +218,7 @@ type ETSI014HTTPQuantumModule struct { } func NewETSI014HTTPQuantumModule(addr, kmsId, slaveSAEID, masterSAEID string, master bool) (*ETSI014HTTPQuantumModule, error) { - parsedUrl, err := url.Parse("http://" + addr) + parsedUrl, err := url.Parse(addr) if err != nil { return nil, err } -- GitLab