diff --git a/goKMS/config/config.go b/goKMS/config/config.go index 1f764c651e13aa444bb4f7e84186a902b5ee25f4..63af65d69e7ab58fc86150ff1c8117282c330e23 100644 --- a/goKMS/config/config.go +++ b/goKMS/config/config.go @@ -33,22 +33,22 @@ type QuantumModule struct { MasterMode bool `yaml:"MasterMode"` } -func NewEKMSInfo(id uuid.UUID, version *kmsVersionInformation, channel chan string) *EKMSInfo { - return &EKMSInfo{ +func NewKMSInfo(id uuid.UUID, version *kmsVersionInformation, channel chan string) *KMSInfo { + return &KMSInfo{ id: id, version: version, KmsPeerUpdateChannel: channel, } } -type EKMSInfo struct { +type KMSInfo struct { // Information used to fill the ETSI GS QKD 15 yang model id uuid.UUID version *kmsVersionInformation KmsPeerUpdateChannel chan string // used to get updates from KmsPeer part } -func NewEKMSVersionInformation(firmware string, swVersion string, hwVersion string) *kmsVersionInformation { +func NewKMSVersionInformation(firmware string, swVersion string, hwVersion string) *kmsVersionInformation { return &kmsVersionInformation{ firmware: firmware, swVersion: swVersion, @@ -74,10 +74,10 @@ func (kvi *kmsVersionInformation) HardwareVersion() string { return kvi.hwVersion } -func (qkdnInfo *EKMSInfo) Version() *kmsVersionInformation { +func (qkdnInfo *KMSInfo) Version() *kmsVersionInformation { return qkdnInfo.version } -func (qkdnInfo *EKMSInfo) ID() uuid.UUID { +func (qkdnInfo *KMSInfo) ID() uuid.UUID { return qkdnInfo.id } diff --git a/goKMS/gnmiHandlers/kms/assignForwardingHandler.go b/goKMS/gnmiHandlers/kms/assignForwardingHandler.go index 35b2cdb0e697cdad8e76f1f453872c8d6ae8144d..6f8d4682590e2dbf1ccee259f10d0ce3b92e46d2 100644 --- a/goKMS/gnmiHandlers/kms/assignForwardingHandler.go +++ b/goKMS/gnmiHandlers/kms/assignForwardingHandler.go @@ -14,10 +14,10 @@ import ( // AssignForwardingHandler is the implementation of a gnmitarget.PathHandler. type AssignForwardingHandler struct { handler.DefaultPathHandler - kms *kms.EKMS + kms *kms.KMS } -func NewAssignForwardingHandler(kms *kms.EKMS) *AssignForwardingHandler { +func NewAssignForwardingHandler(kms *kms.KMS) *AssignForwardingHandler { return &AssignForwardingHandler{ DefaultPathHandler: handler.DefaultPathHandler{ Name: "kms-assign-forwarding-handler", diff --git a/goKMS/gnmiHandlers/kms/createRouteHandler.go b/goKMS/gnmiHandlers/kms/createRouteHandler.go index 87f0a92463c6f4d8256632b4399af0dbc7d53b67..69e58c50eb242199b7b7f0b18408d059494256a6 100644 --- a/goKMS/gnmiHandlers/kms/createRouteHandler.go +++ b/goKMS/gnmiHandlers/kms/createRouteHandler.go @@ -14,11 +14,11 @@ import ( type CreateRouteHandler struct { handler.DefaultPathHandler - kms *kms.EKMS + kms *kms.KMS events <-chan event.Event } -func NewCreateRouteHandler(kms *kms.EKMS) *CreateRouteHandler { +func NewCreateRouteHandler(kms *kms.KMS) *CreateRouteHandler { return &CreateRouteHandler{ DefaultPathHandler: handler.DefaultPathHandler{ Name: "kms-create-route-handler", diff --git a/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go b/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go index 9c07fbec5851af55e2f18190c107d189b2690d80..625af8133d95f8a150797a6a9426ea746217f48f 100644 --- a/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go +++ b/goKMS/gnmiHandlers/kms/keyRoutingSessionsHandler.go @@ -15,11 +15,11 @@ import ( type KeyRoutingSessionHandler struct { handler.DefaultPathHandler - kms *kms.EKMS + kms *kms.KMS events <-chan event.Event } -func NewKeyRoutingSessionHandler(kms *kms.EKMS) *KeyRoutingSessionHandler { +func NewKeyRoutingSessionHandler(kms *kms.KMS) *KeyRoutingSessionHandler { return &KeyRoutingSessionHandler{ DefaultPathHandler: handler.DefaultPathHandler{ Name: "kms-key-routing-session-handler", @@ -143,7 +143,7 @@ func (yh *KeyRoutingSessionHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnm return nil } -func (yh *KeyRoutingSessionHandler) updateOrCreateKeyRoutingSessions(kms *kms.EKMS) ([]*gnmi.Notification, error) { +func (yh *KeyRoutingSessionHandler) updateOrCreateKeyRoutingSessions(kms *kms.KMS) ([]*gnmi.Notification, error) { yh.Config.Lock() defer yh.Config.Unlock() diff --git a/goKMS/gnmiHandlers/kms/kmsHandler.go b/goKMS/gnmiHandlers/kms/kmsHandler.go index 6aed0ced2aca108fdec928dc6b7a84038b0b7b30..87a4a64978a2c4a714ca659141c38c2884caf546 100644 --- a/goKMS/gnmiHandlers/kms/kmsHandler.go +++ b/goKMS/gnmiHandlers/kms/kmsHandler.go @@ -12,10 +12,10 @@ import ( type KmsHandler struct { handler.DefaultPathHandler - kmsInfo *config.EKMSInfo + kmsInfo *config.KMSInfo } -func NewKmsHandler(kmsInfo *config.EKMSInfo) *KmsHandler { +func NewKmsHandler(kmsInfo *config.KMSInfo) *KmsHandler { return &KmsHandler{ DefaultPathHandler: handler.DefaultPathHandler{ Name: "kms-handler", @@ -45,7 +45,7 @@ func (yh *KmsHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnmi.Update) erro return nil } -func (yh *KmsHandler) updateOrCreateKMS(kmsInfo *config.EKMSInfo) ([]*gnmi.Notification, error) { +func (yh *KmsHandler) updateOrCreateKMS(kmsInfo *config.KMSInfo) ([]*gnmi.Notification, error) { yh.Config.Lock() defer yh.Config.Unlock() diff --git a/goKMS/gnmiHandlers/kms/peerHandler.go b/goKMS/gnmiHandlers/kms/peerHandler.go index 4d15cb244a0fd4b584378bce86c8c0dcca79430b..e8475ec55fb8995b0dbebe9a8ca5efd503593c66 100644 --- a/goKMS/gnmiHandlers/kms/peerHandler.go +++ b/goKMS/gnmiHandlers/kms/peerHandler.go @@ -16,10 +16,10 @@ import ( type PeerHandler struct { handler.DefaultPathHandler events <-chan event.Event - kms *kms.EKMS + kms *kms.KMS } -func NewPeerHandler(kms *kms.EKMS) *PeerHandler { +func NewPeerHandler(kms *kms.KMS) *PeerHandler { return &PeerHandler{ DefaultPathHandler: handler.DefaultPathHandler{ Name: "kms-peer-handler", @@ -75,7 +75,7 @@ func (yh *PeerHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnmi.Update) err return nil } -func (yh *PeerHandler) updateOrCreatePeerTable(kms *kms.EKMS) ([]*gnmi.Notification, error) { +func (yh *PeerHandler) updateOrCreatePeerTable(kms *kms.KMS) ([]*gnmi.Notification, error) { yh.Config.Lock() defer yh.Config.Unlock() diff --git a/goKMS/kms/kms.go b/goKMS/kms/kms.go index 382b86b49d972a4778a65bc2c33e1c467eab0abf..f8588b483b4f01b71df3457cdfff0690bd869483 100644 --- a/goKMS/kms/kms.go +++ b/goKMS/kms/kms.go @@ -62,7 +62,7 @@ type PlatformKey struct { } // The general emulated KMS. -type EKMS struct { +type KMS struct { kmsName string kmsUUID uuid.UUID interComAddr string @@ -84,8 +84,8 @@ type EKMS struct { pbIC.UnimplementedKmsTalkerServer supportedKeyLengths map[BitKeyLength]bool eventBus *event.EventBus - CkmsAkmsClient client.CkmsAkmsClient - CkmsAkmsServer *server.AKMSReceiverServer + CKMSAkmsClient client.CkmsAkmsClient + CKMSAkmsServer *server.AKMSReceiverServer } type TlsData struct { @@ -103,7 +103,7 @@ type QuantumElementInterface interface { GetQlID() qlElementId }*/ -func NewEKMS(kmsUUID uuid.UUID, logOutput io.Writer, logLevel log.Level, logInJson bool, config *config.Config) (newEKMS *EKMS) { +func NewKMS(kmsUUID uuid.UUID, logOutput io.Writer, logLevel log.Level, logInJson bool, config *config.Config) (newKMS *KMS) { /* * Setup logging */ @@ -133,7 +133,7 @@ func NewEKMS(kmsUUID uuid.UUID, logOutput io.Writer, logLevel log.Level, logInJs ckmsAkmsClient := client.NewCkmsAkmsClient(config.AkmsURL) - createdEKMS := &EKMS{ + createdEKMS := &KMS{ kmsName: config.Name, kmsUUID: kmsUUID, interComAddr: config.InterComAddr, @@ -146,7 +146,7 @@ func NewEKMS(kmsUUID uuid.UUID, logOutput io.Writer, logLevel log.Level, logInJs KmsPeers: make(map[string]*peers.Peer), supportedKeyLengths: make(map[BitKeyLength]bool), eventBus: event.NewEventBus(), - CkmsAkmsClient: ckmsAkmsClient, + CKMSAkmsClient: ckmsAkmsClient, } createdEKMS.supportedKeyLengths[BitKeyLen256] = true @@ -162,15 +162,15 @@ func NewEKMS(kmsUUID uuid.UUID, logOutput io.Writer, logLevel log.Level, logInJs // Start the akmsCkmsReceiverServer if config.AkmsCkmsServerPort != "" { - createdEKMS.CkmsAkmsServer = server.NewAKMSReceiver(config.AkmsCkmsServerPort, createdEKMS.eventBus, createdEKMS.GenerateAndSendKSAKey) + createdEKMS.CKMSAkmsServer = server.NewAKMSReceiver(config.AkmsCkmsServerPort, createdEKMS.eventBus, createdEKMS.GenerateAndSendKSAKey) log.Infof("Starting AKMS receiver server on port: %s", config.AkmsCkmsServerPort) - go createdEKMS.CkmsAkmsServer.Serve() + go createdEKMS.CKMSAkmsServer.Serve() } return createdEKMS } -func initializePeers(kms *EKMS, config *config.Config) error { +func initializePeers(kms *KMS, config *config.Config) error { var qm peers.QuantumModule var err error for _, peer := range config.Peers { @@ -239,7 +239,7 @@ func initializePeers(kms *EKMS, config *config.Config) error { return nil } -func (kms *EKMS) startGRPC(interComAddr string, quantumAddress string, tlsData TlsData) { +func (kms *KMS) startGRPC(interComAddr string, quantumAddress string, tlsData TlsData) { interKMSLis, err := net.Listen("tcp", interComAddr) if err != nil { log.Fatalf("failed to listen: %v", err) @@ -261,7 +261,7 @@ func (kms *EKMS) startGRPC(interComAddr string, quantumAddress string, tlsData T healthpb.RegisterHealthServer(interKMSServer, healthCheck) pbIC.RegisterKmsTalkerServer(interKMSServer, &kmsTalkerServer{ keyNegotiationMap: make(map[uuid.UUID]*store.KmsKSElement), - eKMS: kms, + KMS: kms, }) quantumLis, err := net.Listen("tcp", quantumAddress) @@ -270,7 +270,7 @@ func (kms *EKMS) startGRPC(interComAddr string, quantumAddress string, tlsData T } quantumServ := grpc.NewServer() pbQS.RegisterKmsQkdmCommunicationServiceServer(quantumServ, &quipSecServer{ - eKMS: kms, + KMS: kms, }) go func() { @@ -290,7 +290,7 @@ func (kms *EKMS) startGRPC(interComAddr string, quantumAddress string, tlsData T } } -func (kms *EKMS) AddQuantumElement(qm peers.QuantumModule) error { +func (kms *KMS) AddQuantumElement(qm peers.QuantumModule) error { kms.quantumModulesMutex.Lock() defer kms.quantumModulesMutex.Unlock() log.Infof("quantum module address: %s ", qm.Address()) @@ -298,7 +298,7 @@ func (kms *EKMS) AddQuantumElement(qm peers.QuantumModule) error { return nil } -func (kms *EKMS) AddPeer(peerKmsId string, kmsPeerSocket string, servingQLE peers.QuantumModule, client *peers.GRPCClient) (*peers.Peer, error) { +func (kms *KMS) AddPeer(peerKmsId string, kmsPeerSocket string, servingQLE peers.QuantumModule, client *peers.GRPCClient) (*peers.Peer, error) { // check if peer exists if _, there := kms.KmsPeers[peerKmsId]; there { log.Errorf("Trying to add existing peer %s, with KMS ID %s", kmsPeerSocket, peerKmsId) @@ -318,7 +318,7 @@ func (kms *EKMS) AddPeer(peerKmsId string, kmsPeerSocket string, servingQLE peer return peer, nil } -func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *RemoteKMS) error { +func (kms *KMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *RemoteKMS) error { pathId, err := uuid.Parse(pId) if err != nil { return fmt.Errorf("the given path id %s is no uuid; err = %w", pathId, err) @@ -402,7 +402,7 @@ func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *Remote return nil } -func (kms *EKMS) GetSpecificPK(remoteKMSId string, keyId uuid.UUID) (*PlatformKey, error) { +func (kms *KMS) GetSpecificPK(remoteKMSId string, keyId uuid.UUID) (*PlatformKey, error) { kms.PKStoreMutex.Lock() defer kms.PKStoreMutex.Unlock() @@ -419,7 +419,7 @@ func (kms *EKMS) GetSpecificPK(remoteKMSId string, keyId uuid.UUID) (*PlatformKe return pk, nil } -func (kms *EKMS) GetRandomItemFromPKStore(remoteKMSId string) (uuid.UUID, *PlatformKey, error) { +func (kms *KMS) GetRandomItemFromPKStore(remoteKMSId string) (uuid.UUID, *PlatformKey, error) { kms.PKStoreMutex.Lock() defer kms.PKStoreMutex.Unlock() @@ -432,7 +432,7 @@ func (kms *EKMS) GetRandomItemFromPKStore(remoteKMSId string) (uuid.UUID, *Platf return util.RandomItemFromMapAndRemove(keyIds) } -func (kms *EKMS) GetRemoteKMS(remoteKMSId string) (*RemoteKMS, error) { +func (kms *KMS) GetRemoteKMS(remoteKMSId string) (*RemoteKMS, error) { kms.remoteKMSMappingMutex.RLock() defer kms.remoteKMSMappingMutex.RUnlock() @@ -444,7 +444,7 @@ func (kms *EKMS) GetRemoteKMS(remoteKMSId string) (*RemoteKMS, error) { } // NOTE: address/remoteid still have to decide. -func (kms *EKMS) GenerateAndSendKSAKey(remoteKMSId string, pathId uuid.UUID, requestId string, number int) error { +func (kms *KMS) GenerateAndSendKSAKey(remoteKMSId string, pathId uuid.UUID, requestId string, number int) error { if number < 1 { log.Errorf("number must be positive and at least 1, provided: %d\n", number) return fmt.Errorf("number must be positive and at least 1, provided: %d", number) @@ -536,7 +536,7 @@ func (kms *EKMS) GenerateAndSendKSAKey(remoteKMSId string, pathId uuid.UUID, req } // Use the real processID when we know what it is - err = kms.CkmsAkmsClient.SendKSAKeys(requestId, pk.ProcessId, akmsKSAKeys) + err = kms.CKMSAkmsClient.SendKSAKeys(requestId, pk.ProcessId, akmsKSAKeys) if err != nil { log.Error(err) return err @@ -545,12 +545,12 @@ func (kms *EKMS) GenerateAndSendKSAKey(remoteKMSId string, pathId uuid.UUID, req return nil } -func (kms *EKMS) EventBus() *event.EventBus { +func (kms *KMS) EventBus() *event.EventBus { return kms.eventBus } // TODO/XXX error handling. -func (kms *EKMS) RemovePeer(kmsPeerSocket string) { +func (kms *KMS) RemovePeer(kmsPeerSocket string) { if _, there := kms.KmsPeers[kmsPeerSocket]; there { // peer.quit <- true delete(kms.KmsPeers, kmsPeerSocket) @@ -559,7 +559,7 @@ func (kms *EKMS) RemovePeer(kmsPeerSocket string) { log.Errorf("%s: Can not find a peer with socket: %s", kms.kmsName, kmsPeerSocket) } -func (kms *EKMS) FindPeerUuid(lookup uuid.UUID) (peer *peers.Peer) { +func (kms *KMS) FindPeerUuid(lookup uuid.UUID) (peer *peers.Peer) { if kms.KmsPeers != nil { for _, peer = range kms.KmsPeers { if peer.Id() == lookup { @@ -571,7 +571,7 @@ func (kms *EKMS) FindPeerUuid(lookup uuid.UUID) (peer *peers.Peer) { return nil } -func (kms *EKMS) RoutingTableDeepCopy() map[uuid.UUID]*Route { +func (kms *KMS) RoutingTableDeepCopy() map[uuid.UUID]*Route { routingTableCopy := make(map[uuid.UUID]*Route, len(kms.KmsPeers)) kms.routingTableMutex.Lock() @@ -583,7 +583,7 @@ func (kms *EKMS) RoutingTableDeepCopy() map[uuid.UUID]*Route { return routingTableCopy } -func (kms *EKMS) PeersDeepCopy() map[string]*peers.Peer { +func (kms *KMS) PeersDeepCopy() map[string]*peers.Peer { peersCopy := make(map[string]*peers.Peer, len(kms.KmsPeers)) kms.kmsPeersMutex.Lock() diff --git a/goKMS/kms/kmsintercom.go b/goKMS/kms/kmsintercom.go index 2a06a343e0690ffea3a8a37b1bbcd9093dc237d9..65e205912a3a9f168990d9376f992315fb6e91de 100644 --- a/goKMS/kms/kmsintercom.go +++ b/goKMS/kms/kmsintercom.go @@ -28,7 +28,7 @@ import ( type kmsTalkerServer struct { pb.UnimplementedKmsTalkerServer keyNegotiationMap map[uuid.UUID]*store.KmsKSElement - eKMS *EKMS + KMS *KMS } // This must somehow find out and agree to a specific key length. @@ -47,7 +47,7 @@ func (s *kmsTalkerServer) InterComCapabilities(ctx context.Context, in *pb.Inter func (s *kmsTalkerServer) KeyIdNotification(ctx context.Context, in *pb.KeyIdNotificationRequest) (*pb.KeyIdNotificationResponse, error) { // check if a peer exists - peer, ok := s.eKMS.KmsPeers[in.GetKmsId()] + peer, ok := s.KMS.KmsPeers[in.GetKmsId()] if !ok { // TODO: proper error message return nil, status.Error(codes.Internal, "peer does not exist") @@ -102,7 +102,7 @@ func (s *kmsTalkerServer) SyncQkdBulk(ctx context.Context, in *pb.SyncQkdBulkReq p, _ := peer.FromContext(ctx) log.Infof("Received SyncQkdBulkRequest from %s", p.Addr.String()) // check if a peer exists - peer, ok := s.eKMS.KmsPeers[in.GetKmsId()] + peer, ok := s.KMS.KmsPeers[in.GetKmsId()] if !ok { // TODO: proper error message return nil, status.Errorf(codes.Internal, "peer does not exist") @@ -128,7 +128,7 @@ func (s *kmsTalkerServer) SyncQkdBulk(ctx context.Context, in *pb.SyncQkdBulkReq } func (s *kmsTalkerServer) SyncKeyIdsForBulk(ctx context.Context, in *pb.SyncKeyIdsForBulkRequest) (*pb.SyncKeyIdsForBulkResponse, error) { - peer, ok := s.eKMS.KmsPeers[in.GetKmsId()] + peer, ok := s.KMS.KmsPeers[in.GetKmsId()] if !ok { return nil, status.Errorf(codes.Internal, "For KMS id: %s, no peer exists", in.GetKmsId()) } @@ -187,7 +187,7 @@ func (s *kmsTalkerServer) InterComTransportKeyNegotiation(ctx context.Context, i return nil, status.Errorf(codes.InvalidArgument, "path id: %s can not be parsed to uuid", in.GetPathID()) } - route, ok := s.eKMS.routingTable[pathId] + route, ok := s.KMS.routingTable[pathId] if !ok { return nil, status.Errorf(codes.Internal, "There is no route for the given pathID: %s .", in.PathID) } @@ -229,12 +229,12 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin return nil, status.Errorf(codes.InvalidArgument, "") } - route, ok := s.eKMS.routingTable[pathId] + route, ok := s.KMS.routingTable[pathId] if !ok { return nil, status.Errorf(codes.Internal, "There is no route for the given pathID: %s .", in.PathId) } - log.Infof("%s received a key: %s, from %s", s.eKMS.kmsName, in.GetKey(), route.Previous.TcpSocketStr) + log.Infof("%s received a key: %s, from %s", s.KMS.kmsName, in.GetKey(), route.Previous.TcpSocketStr) keyAsByte, err := base64.StdEncoding.DecodeString(in.GetKey().GetKey()) if err != nil { @@ -253,7 +253,7 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin keyID, err := uuid.Parse(in.GetKey().GetId()) if route.Next != nil { - log.Infof("%s forwards payload to : %s", s.eKMS.kmsName, route.Next.TcpSocketStr) + log.Infof("%s forwards payload to : %s", s.KMS.kmsName, route.Next.TcpSocketStr) if err != nil { return nil, status.Errorf(codes.Internal, "%s", err) } @@ -264,11 +264,11 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin Key: decryptedKey, }, pathId, processId) } else { - log.Infof("%s received the final payload: %s", s.eKMS.kmsName, string(decryptedKey)) - s.eKMS.PKStoreMutex.Lock() - keys, ok := s.eKMS.PKStore[route.RemoteKMS.Id] + log.Infof("%s received the final payload: %s", s.KMS.kmsName, string(decryptedKey)) + s.KMS.PKStoreMutex.Lock() + keys, ok := s.KMS.PKStore[route.RemoteKMS.Id] if !ok { - s.eKMS.PKStore[route.RemoteKMS.Id] = map[uuid.UUID]*PlatformKey{ + s.KMS.PKStore[route.RemoteKMS.Id] = map[uuid.UUID]*PlatformKey{ keyID: { Id: keyID, Value: decryptedKey, @@ -283,12 +283,12 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin } } - log.Debug("Current PKSTORE: ", s.eKMS.PKStore) - s.eKMS.PKStoreMutex.Unlock() + log.Debug("Current PKSTORE: ", s.KMS.PKStore) + s.KMS.PKStoreMutex.Unlock() var gRPCTransportCreds credentials.TransportCredentials - if s.eKMS.tlsData.TLS { - gRPCTransportCreds, err = util.GenerateGRPCClientTransportCredsWithTLS(s.eKMS.tlsData.CaFile, s.eKMS.tlsData.CertFile, s.eKMS.tlsData.KeyFile) + if s.KMS.tlsData.TLS { + gRPCTransportCreds, err = util.GenerateGRPCClientTransportCredsWithTLS(s.KMS.tlsData.CaFile, s.KMS.tlsData.CertFile, s.KMS.tlsData.KeyFile) if err != nil { log.Fatalf("unable to generate TLS creds: %v", err) } @@ -329,7 +329,7 @@ func (s *kmsTalkerServer) AckKeyForwarding(ctx context.Context, in *pb.AckKeyFor // - Are pathId and processId valid? // - Is the keyId valid? - err = s.eKMS.CkmsAkmsServer.Receiver.InformReceiver(pathId) + err = s.KMS.CKMSAkmsServer.Receiver.InformReceiver(pathId) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "Failed while informing Receiver; err: %v", err) } @@ -345,7 +345,7 @@ func (s *kmsTalkerServer) KeyDelivery(ctx context.Context, in *pb.KeyDeliveryReq } // look up PK - pk, err := s.eKMS.GetSpecificPK(in.GetKmsId(), keyId) + pk, err := s.KMS.GetSpecificPK(in.GetKmsId(), keyId) if err != nil { return nil, status.Errorf(codes.NotFound, "%s", err) } @@ -382,7 +382,7 @@ func (s *kmsTalkerServer) KeyDelivery(ctx context.Context, in *pb.KeyDeliveryReq } // Use the real processID when we know what it is - go s.eKMS.CkmsAkmsClient.SendKSAKeys(in.GetRequestId(), pk.ProcessId, akmsKSAKeys) //nolint:errcheck + go s.KMS.CKMSAkmsClient.SendKSAKeys(in.GetRequestId(), pk.ProcessId, akmsKSAKeys) //nolint:errcheck return &pb.KeyDeliveryResponse{Timestamp: time.Now().Unix()}, nil } diff --git a/goKMS/kms/quipsec.go b/goKMS/kms/quipsec.go index d457c8fd45257e698aa5f7e468239036aec54ffb..127ec781073d4ba8ccdf9fd959ea7ac10206e04b 100644 --- a/goKMS/kms/quipsec.go +++ b/goKMS/kms/quipsec.go @@ -17,7 +17,7 @@ import ( type quipSecServer struct { pb.UnimplementedKmsQkdmCommunicationServiceServer - eKMS *EKMS + KMS *KMS } func (qs *quipSecServer) PushKeys(ctx context.Context, req *pb.PushKeysRequest) (*pb.PushKeysResponse, error) { @@ -31,7 +31,7 @@ func (qs *quipSecServer) PushKeys(ctx context.Context, req *pb.PushKeysRequest) // TODO: qm.address is used as key for map. could be // used here to directly access. - for _, qm := range qs.eKMS.quantumModules { + for _, qm := range qs.KMS.quantumModules { if qm.Address() == host { eqm, ok := qm.(*peers.EmulatedQuantumModule) if !ok { @@ -53,7 +53,7 @@ func (qs *quipSecServer) PushKeys(ctx context.Context, req *pb.PushKeysRequest) BulkKey: &req.GetKeyBulk().Keys, } eqm.RawBulkKeysMutex.Unlock() - logrus.Debugf("%s received a new bulk from: %s with id: %s and a length of: %d", qs.eKMS.kmsName, qm.Address(), req.GetKeyBulk().GetKeyId(), req.GetKeyBulk().GetKeyLength()) + logrus.Debugf("%s received a new bulk from: %s with id: %s and a length of: %d", qs.KMS.kmsName, qm.Address(), req.GetKeyBulk().GetKeyId(), req.GetKeyBulk().GetKeyLength()) return &pb.PushKeysResponse{Timestamp: time.Now().Unix()}, nil } } diff --git a/goKMS/main.go b/goKMS/main.go index 16b8dcded2862ae9fef9b667de33d998e59340b9..18d552c537effd0206716aa3a03a423c8a8dd06c 100644 --- a/goKMS/main.go +++ b/goKMS/main.go @@ -92,7 +92,7 @@ func main() { resolveHostnameToIPForQuantumModules(kmsConfig) kmsInfo := generateKMSInfo(kmsId) - kms := kms.NewEKMS(kmsId, os.Stdout, log.GetLevel(), false, kmsConfig) + kms := kms.NewKMS(kmsId, os.Stdout, log.GetLevel(), false, kmsConfig) schema, err := gnmitargetygot.Schema() if err != nil { @@ -120,7 +120,7 @@ func main() { } } -// TODO: a better place would probably kms.NewEKMS(). +// TODO: a better place would probably kms.NewKMS(). func resolveHostnameToIPForQuantumModules(config *config.Config) { const connectionRetries = 60 var ipAddr []net.IP @@ -154,8 +154,8 @@ func resolveHostnameToIPForQuantumModules(config *config.Config) { } } -func generateKMSInfo(id uuid.UUID) *config.EKMSInfo { - kmsVersionInformation := config.NewEKMSVersionInformation("danet-emulated-kms", "0.1.0", "0.1.0") +func generateKMSInfo(id uuid.UUID) *config.KMSInfo { + kmsVersionInformation := config.NewKMSVersionInformation("danet-emulated-kms", "0.1.0", "0.1.0") - return config.NewEKMSInfo(id, kmsVersionInformation, make(chan string)) + return config.NewKMSInfo(id, kmsVersionInformation, make(chan string)) }