diff --git a/goKMS/gnmiHandlers/kms/assignForwardingHandler.go b/goKMS/gnmiHandlers/kms/assignForwardingHandler.go index 6f8d4682590e2dbf1ccee259f10d0ce3b92e46d2..d5edbbd6ec36192acd81ef2d39547b2ba4a7ef03 100644 --- a/goKMS/gnmiHandlers/kms/assignForwardingHandler.go +++ b/goKMS/gnmiHandlers/kms/assignForwardingHandler.go @@ -52,7 +52,6 @@ func (yh *AssignForwardingHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnmi var nextHopString string var prevHopString string - var initiatingKmsAddressString string if nextHop != nil { nextHopString = nextHop.GetNodeId() @@ -73,10 +72,10 @@ func (yh *AssignForwardingHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnmi log.Error("initiatingKmsAddress must have either an IP address or a hostname") return fmt.Errorf("initiatingKmsAddress must have either an IP address or a hostname") } - initiatingKmsAddressString = fmt.Sprintf("%s:%d", addressPrefix, initiatingKmsAddress.GetPort()) + initKMS = &kms.RemoteKMS{ Id: initiatingKmsAddress.GetNodeId(), - Address: initiatingKmsAddressString, + Address: addressPrefix, Port: initiatingKmsAddress.GetPort(), } } diff --git a/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go b/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go index 6572621a06af04b75e7d673acfe550658bafb0e7..e8a09b4ccab0bdd8b27fb7528d8a6d47d680611d 100644 --- a/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go +++ b/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go @@ -2,7 +2,6 @@ package kmsHandler import ( "fmt" - "strings" "code.fbi.h-da.de/danet/gnmi-target/handler" "code.fbi.h-da.de/danet/quant/goKMS/kms" @@ -106,7 +105,7 @@ func (yh *KeyRoutingSessionHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnm var nextHopString string var prevHopString string - var initiatingKmsAddressString string + if nextHop != nil { nextHopString = nextHop.GetNodeId() } @@ -126,10 +125,10 @@ func (yh *KeyRoutingSessionHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnm log.Error("initiatingKmsAddress must have either an IP address or a hostname") return fmt.Errorf("initiatingKmsAddress must have either an IP address or a hostname") } - initiatingKmsAddressString = fmt.Sprintf("%s:%d", addressPrefix, initiatingKmsAddress.GetPort()) + initKMS = &kms.RemoteKMS{ Id: initiatingKmsAddress.GetNodeId(), - Address: initiatingKmsAddressString, + Address: addressPrefix, Port: initiatingKmsAddress.GetPort(), } } @@ -181,9 +180,9 @@ func (yh *KeyRoutingSessionHandler) updateOrCreateKeyRoutingSessions(kms *kms.KM if route.RemoteKMS != nil { confTempRoutingSessionInitAddress := confTempRoutingSession.GetOrCreateInitiatingKmsAddress() if route.RemoteKMS.Address != "" { - confTempRoutingSessionInitAddress.IpAddress = ygot.String(strings.Split(route.RemoteKMS.Address, ":")[0]) // TODO: maybe split address in remote kms and not in one string? + confTempRoutingSessionInitAddress.IpAddress = ygot.String(route.RemoteKMS.Address) confTempRoutingSessionInitAddress.Port = ygot.Uint16(route.RemoteKMS.Port) - confTempRoutingSessionInitAddress.Hostname = ygot.String(strings.Split(route.RemoteKMS.Address, ":")[0]) // TODO: get real hostname here + confTempRoutingSessionInitAddress.Hostname = ygot.String(route.RemoteKMS.Address) // TODO: get real hostname here } if route.RemoteKMS.Id != "" { confTempRoutingSessionInitAddress.NodeId = ygot.String(route.RemoteKMS.Id) diff --git a/goKMS/kms/crypto/crypto.go b/goKMS/kms/crypto/crypto.go index 40667457e4a33a7888ebca3a1d23014fff51ac5c..1fe6c939f1a3e1931cbd8261fd5fafc418cadf49 100644 --- a/goKMS/kms/crypto/crypto.go +++ b/goKMS/kms/crypto/crypto.go @@ -46,8 +46,7 @@ func (a *AES) Decrypt(nonce, ciphertext []byte, key []byte) ([]byte, error) { return nil, err } - // TODO: Not sure if we should assume that we get non standard nonce sizes - // here. Normally it would be 12 bytes. + // Note: This works under the assumption of every other implementation using the commonly used nonce size of 12 bytes. gcm, err := cipher.NewGCM(c) if err != nil { return nil, err diff --git a/goKMS/kms/event/bus.go b/goKMS/kms/event/bus.go index a1c297ba66d0427dde6e379d8a8b876d469bba46..301b883b09fa8d71d10cfae043415fc5adad0e80 100644 --- a/goKMS/kms/event/bus.go +++ b/goKMS/kms/event/bus.go @@ -30,7 +30,6 @@ func (b *EventBus) Subscribe(topic Topic) (<-chan Event, error) { return newSubChan, nil } -// TODO: check the functionality of this method. func (b *EventBus) Publish(event Event) error { subs, ok := b.subscribers[event.Topic()] if !ok { diff --git a/goKMS/kms/kms.go b/goKMS/kms/kms.go index d9c64995ca6c6af057d89828daddae6bb8f91dc2..44220445c260f97e5bb9bdf4eede85e0fd5c46a2 100644 --- a/goKMS/kms/kms.go +++ b/goKMS/kms/kms.go @@ -375,7 +375,9 @@ func (kms *KMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *RemoteK log.Debug("Current PKSTORE: ", kms.PKStore) kms.PKStoreMutex.Unlock() - err = tmpRoute.Next.SendInitialPayloadBasedOnGRPCClient(pk, tmpRoute.PathId, processId, kms.kmsUUID.String(), remoteKMS.Address) + remoteKMSAdrress := fmt.Sprintf("%s:%d", remoteKMS.Address, remoteKMS.Port) + + err = tmpRoute.Next.SendInitialPayloadBasedOnGRPCClient(pk, tmpRoute.PathId, processId, kms.kmsUUID.String(), remoteKMSAdrress) if err != nil { log.Error(err) return err @@ -460,7 +462,9 @@ func (kms *KMS) GenerateAndSendKSAKey(remoteKMSId string, pathId uuid.UUID, requ akmsKSAKeys[i] = *akmsKSAKey } - err = kms.sendKSAKeysToPlatformKmsPeer(remoteKMS.Address, platformKey.Id.String(), requestID, ksaKeys) + remoteKMSAdrress := fmt.Sprintf("%s:%d", remoteKMS.Address, remoteKMS.Port) + + err = kms.sendKSAKeysToPlatformKmsPeer(remoteKMSAdrress, platformKey.Id.String(), requestID, ksaKeys) if err != nil { log.Error(err) return err diff --git a/goKMS/kms/kmsintercom.go b/goKMS/kms/kmsintercom.go index 73536849293eb0a918d0c4988c940439f876d0df..42eb8afce8e3abea3901afc3f01461a7e22fb007 100644 --- a/goKMS/kms/kmsintercom.go +++ b/goKMS/kms/kmsintercom.go @@ -262,7 +262,9 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin s.storeReceivedPlatformKey(route.RemoteKMS.Id, in.GetProcessId(), keyID, decryptedKey) - err = s.sendAcknowledgeKeyForwarding(ctx, route.RemoteKMS.Address, in.PathId, in.ProcessId, in.GetKey().GetId()) + remoteKMSAdrress := fmt.Sprintf("%s:%d", route.RemoteKMS.Address, route.RemoteKMS.Port) + + err = s.sendAcknowledgeKeyForwarding(ctx, remoteKMSAdrress, in.PathId, in.ProcessId, in.GetKey().GetId()) if err != nil { return nil, err } diff --git a/goKMS/kms/peers/peers.go b/goKMS/kms/peers/peers.go index fbdfddcadb5ab2f69366e3e2d0281431255db962..4184cc5b937366facde181c8af7f0eeb575d8323 100644 --- a/goKMS/kms/peers/peers.go +++ b/goKMS/kms/peers/peers.go @@ -79,9 +79,8 @@ func NewKmsPeer(peerKmsId string, servQM QuantumModule, tcpSocketStr string, int // We need multiple peer clients! peerClient: client, // TODO: change this, only for demo purposes - peerStatus: KmsPeerUp, - peerKmsId: peerKmsIdUUID, - // TODO: move this into a config + peerStatus: KmsPeerUp, + peerKmsId: peerKmsIdUUID, interComAddr: interComAddr, // NOTE a peer could have multiple quantum modules servingQuantumModul: servQM, diff --git a/goKMS/kms/peers/qmodule.go b/goKMS/kms/peers/qmodule.go index 8af73685cb16e89673e1641370557c4e5e0b8359..5d140f3ea2592d30ab8415f1d888a5ccd7c37f43 100644 --- a/goKMS/kms/peers/qmodule.go +++ b/goKMS/kms/peers/qmodule.go @@ -91,7 +91,6 @@ func (eqe *EmulatedQuantumModule) Sync() error { bulkKey, ok := eqe.RawBulkKeys[initialPeerSetupResponse.BulkId] if !ok { - // TODO: add proper error message return fmt.Errorf("could not find raw bulk key with id: %d", initialPeerSetupResponse.BulkId) }