diff --git a/ekms/etsiqkdnclient/etsi-qkdn-client.go b/ekms/etsiqkdnclient/etsi-qkdn-client.go index c735e7316f354557b0099ed22a425312f66fbd66..3c371edd0b6338ab15e9c2b52d3c60b44acaddd8 100644 --- a/ekms/etsiqkdnclient/etsi-qkdn-client.go +++ b/ekms/etsiqkdnclient/etsi-qkdn-client.go @@ -184,9 +184,6 @@ func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKM } } - // Start the SDN/management and key retrieval interface - go kms.StartETSI(config.GRPCAddr, emuKMS) - // Start the akmsCkmsReceiverServer if config.AkmsCkmsServerPort != "" { akmsCkmsReceiverServer := akmsCkmsServer.NewAKMSReceiver(config.AkmsCkmsServerPort, emuKMS) diff --git a/ekms/internal/api/gen/proto/go/kmsintercom/kmsintercom.pb.go b/ekms/internal/api/gen/proto/go/kmsintercom/kmsintercom.pb.go index 9f408312653d459a5fbc8ea1ebbb868062a08ce0..da879bd4cf3a91ba5335afe35977d391010ae2dd 100644 --- a/ekms/internal/api/gen/proto/go/kmsintercom/kmsintercom.pb.go +++ b/ekms/internal/api/gen/proto/go/kmsintercom/kmsintercom.pb.go @@ -487,7 +487,8 @@ type KeyForwardingRequest struct { Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` PathId string `protobuf:"bytes,2,opt,name=pathId,proto3" json:"pathId,omitempty"` - Key *Key `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` //string payload = 3; + ProcessId string `protobuf:"bytes,3,opt,name=processId,proto3" json:"processId,omitempty"` + Key *Key `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` //string payload = 3; } func (x *KeyForwardingRequest) Reset() { @@ -536,6 +537,13 @@ func (x *KeyForwardingRequest) GetPathId() string { return "" } +func (x *KeyForwardingRequest) GetProcessId() string { + if x != nil { + return x.ProcessId + } + return "" +} + func (x *KeyForwardingRequest) GetKey() *Key { if x != nil { return x.Key @@ -933,101 +941,103 @@ var file_kmsintercom_kmsintercom_proto_rawDesc = []byte{ 0x4e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x22, 0x70, 0x0a, 0x14, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x64, 0x12, - 0x22, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, - 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x22, 0x35, 0x0a, 0x15, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x66, 0x0a, 0x18, 0x4b, 0x65, - 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6b, 0x65, - 0x79, 0x49, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6b, 0x65, 0x79, 0x49, - 0x64, 0x73, 0x22, 0x39, 0x0a, 0x19, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xa2, 0x01, - 0x0a, 0x12, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x65, - 0x79, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, - 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x22, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x6d, + 0x70, 0x22, 0x8e, 0x01, 0x0a, 0x14, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x74, 0x68, + 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x64, + 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x22, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x22, 0x33, 0x0a, 0x13, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, - 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x27, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x32, 0xd6, 0x05, 0x0a, 0x09, 0x4b, 0x6d, 0x73, 0x54, 0x61, 0x6c, 0x6b, 0x65, 0x72, 0x12, 0x6a, - 0x0a, 0x14, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, - 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x28, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x43, 0x61, 0x70, - 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x26, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, - 0x69, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0b, 0x53, 0x79, - 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, 0x75, 0x6c, 0x6b, 0x12, 0x1f, 0x2e, 0x6b, 0x6d, 0x73, 0x69, + 0x65, 0x79, 0x22, 0x35, 0x0a, 0x15, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x66, 0x0a, 0x18, 0x4b, 0x65, 0x79, + 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6b, 0x65, 0x79, + 0x49, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6b, 0x65, 0x79, 0x49, 0x64, + 0x73, 0x22, 0x39, 0x0a, 0x19, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xa2, 0x01, 0x0a, + 0x12, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x65, 0x79, + 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x22, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x6d, 0x73, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x22, 0x33, 0x0a, 0x13, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x27, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x32, + 0xd6, 0x05, 0x0a, 0x09, 0x4b, 0x6d, 0x73, 0x54, 0x61, 0x6c, 0x6b, 0x65, 0x72, 0x12, 0x6a, 0x0a, + 0x14, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, + 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x28, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x43, 0x61, 0x70, 0x61, + 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x26, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, + 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0b, 0x53, 0x79, 0x6e, + 0x63, 0x51, 0x6b, 0x64, 0x42, 0x75, 0x6c, 0x6b, 0x12, 0x1f, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, 0x75, + 0x6c, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, - 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x6d, 0x73, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, - 0x42, 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, - 0x0a, 0x11, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, - 0x75, 0x6c, 0x6b, 0x12, 0x25, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, - 0x6d, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, - 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6b, 0x6d, 0x73, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, - 0x49, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x8e, 0x01, 0x0a, 0x1f, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, - 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4b, 0x65, 0x79, 0x4e, 0x65, 0x67, - 0x6f, 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4b, 0x65, 0x79, 0x4e, 0x65, 0x67, 0x6f, 0x74, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, - 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x43, 0x6f, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4b, 0x65, 0x79, - 0x4e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0d, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, - 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6b, 0x6d, 0x73, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, - 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x64, 0x0a, 0x11, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, - 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6b, 0x6d, - 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, - 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0b, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, - 0x76, 0x65, 0x72, 0x79, 0x12, 0x1f, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, + 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, + 0x11, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, + 0x6c, 0x6b, 0x12, 0x25, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, + 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, + 0x6c, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6b, 0x6d, 0x73, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, + 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x8e, 0x01, 0x0a, 0x1f, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4b, 0x65, 0x79, 0x4e, 0x65, 0x67, 0x6f, + 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6d, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4b, 0x65, 0x79, 0x4e, 0x65, 0x67, 0x6f, 0x74, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x6b, + 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x43, 0x6f, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4b, 0x65, 0x79, 0x4e, + 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0d, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, + 0x72, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, + 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, + 0x0a, 0x11, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, + 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6b, 0x6d, 0x73, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x4e, 0x6f, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0b, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, + 0x65, 0x72, 0x79, 0x12, 0x1f, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, + 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xb7, 0x01, 0x0a, 0x0f, 0x63, 0x6f, - 0x6d, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x42, 0x10, 0x4b, - 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x46, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, - 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x71, 0x75, 0x61, 0x6e, 0x64, 0x74, 0x2f, 0x65, - 0x6b, 0x6d, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6b, 0x6d, 0x73, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x6b, 0x6d, - 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0xa2, 0x02, 0x03, 0x4b, 0x58, 0x58, 0xaa, - 0x02, 0x0b, 0x4b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0xca, 0x02, 0x0b, - 0x4b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0xe2, 0x02, 0x17, 0x4b, 0x6d, - 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x4b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x63, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xb7, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, + 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x42, 0x10, 0x4b, 0x6d, + 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x46, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, + 0x64, 0x65, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x71, 0x75, 0x61, 0x6e, 0x64, 0x74, 0x2f, 0x65, 0x6b, + 0x6d, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6b, 0x6d, 0x73, 0x2f, + 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x6b, 0x6d, 0x73, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0xa2, 0x02, 0x03, 0x4b, 0x58, 0x58, 0xaa, 0x02, + 0x0b, 0x4b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0xca, 0x02, 0x0b, 0x4b, + 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0xe2, 0x02, 0x17, 0x4b, 0x6d, 0x73, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x4b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, + 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/ekms/internal/api/kmsintercom/kmsintercom/kmsintercom.proto b/ekms/internal/api/kmsintercom/kmsintercom/kmsintercom.proto index 84de5baa39c259be325ab8b73950063fba7980f4..8d84b411d10b631d411dc4fdb03d262a76da51bc 100644 --- a/ekms/internal/api/kmsintercom/kmsintercom/kmsintercom.proto +++ b/ekms/internal/api/kmsintercom/kmsintercom/kmsintercom.proto @@ -64,7 +64,8 @@ message InterComTransportKeyNegotiationResponse { message KeyForwardingRequest { int64 timestamp = 1; string pathId = 2; - Key key = 3; + string processId = 3; + Key key = 4; //string payload = 3; } diff --git a/ekms/internal/kms/kms.go b/ekms/internal/kms/kms.go index 0f3d3d0957633b679787fb3e6789b6ee79ec0f60..24cf0e4f0a23272a641ec5eec4b8d61955a17eba 100644 --- a/ekms/internal/kms/kms.go +++ b/ekms/internal/kms/kms.go @@ -20,7 +20,6 @@ import ( healthpb "google.golang.org/grpc/health/grpc_health_v1" "code.fbi.h-da.de/danet/quant/ekms/internal/akmsCkmsClient" - pbETSI "code.fbi.h-da.de/danet/quant/ekms/internal/api/gen/proto/go/kmsetsi" pbIC "code.fbi.h-da.de/danet/quant/ekms/internal/api/gen/proto/go/kmsintercom" "code.fbi.h-da.de/danet/quant/ekms/internal/kms/crypto" "code.fbi.h-da.de/danet/quant/ekms/internal/kms/event" @@ -43,6 +42,12 @@ const ( BitKeyLen512 BitKeyLength = "512" ) +type PlatformKey struct { + Id uuid.UUID + Value []byte + ProcessId string +} + // The general emulated KMS. type EKMS struct { kmsName string @@ -53,13 +58,12 @@ type EKMS struct { quantumModulesMutex sync.RWMutex kmsPeersMutex sync.Mutex // NOTE: There is probably a better way to handle this - PKStore map[string]map[uuid.UUID][]byte + PKStore map[string]map[uuid.UUID]*PlatformKey PKStoreMutex sync.Mutex // TODO(maba): find a better name for this routingTable map[uuid.UUID]*Route routingTableMutex sync.RWMutex KmsPeers map[string]*kmsPeer - pbETSI.UnimplementedKmsETSIServer pbIC.UnimplementedKmsTalkerServer supportedKeyLengths map[BitKeyLength]bool eventBus *event.EventBus @@ -103,7 +107,7 @@ func NewEKMS(kmsName string, kmsUUID uuid.UUID, logOutput io.Writer, logLevel lo interComAddr: interComAddr, quantumModules: make(map[string]QuantumModule), routingTable: make(map[uuid.UUID]*Route), - PKStore: make(map[string]map[uuid.UUID][]byte), + PKStore: make(map[string]map[uuid.UUID]*PlatformKey), KmsPeers: make(map[string]*kmsPeer), supportedKeyLengths: make(map[BitKeyLength]bool), eventBus: event.NewEventBus(), @@ -219,7 +223,10 @@ func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop, initiatingAddress string return err } - err = tmpRoute.Next.SendPayload(pk, tmpRoute.PathId) + // generate process id + processId := uuid.New() + + err = tmpRoute.Next.SendInitialPayloadBasedOnGRPCClient(pk, tmpRoute.PathId, processId, kms.kmsUUID.String(), tmpRoute.InitiatingKMSAddress) if err != nil { log.Error(err) return err @@ -229,11 +236,19 @@ func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop, initiatingAddress string kms.PKStoreMutex.Lock() keys, ok := kms.PKStore[tmpRoute.InitiatingKMSAddress] if !ok { - kms.PKStore[tmpRoute.InitiatingKMSAddress] = map[uuid.UUID][]byte{ - pk.ID: pk.Key, + kms.PKStore[tmpRoute.InitiatingKMSAddress] = map[uuid.UUID]*PlatformKey{ + pk.ID: { + Id: pk.ID, + Value: pk.Key, + ProcessId: processId.String(), + }, } } else { - keys[pk.ID] = pk.Key + keys[pk.ID] = &PlatformKey{ + Id: pk.ID, + Value: pk.Key, + ProcessId: processId.String(), + } } kms.PKStoreMutex.Unlock() } @@ -260,10 +275,10 @@ func (kms *EKMS) GenerateAndSendKSAKey(address string, requestId string, number if !ok { // TODO: return proper error log.Errorf("path not found for: %s", address) - log.Errorf("error with he following pk store: %s", kms.PKStore) + log.Errorf("error with he following pk store: %v", kms.PKStore) return fmt.Errorf("") } - keyId, pk, err := RandomItemFromMapAndRemove[uuid.UUID, []byte](keyIds) + keyId, pk, err := RandomItemFromMapAndRemove[uuid.UUID, *PlatformKey](keyIds) if err != nil { log.Error(err) return err @@ -283,7 +298,7 @@ func (kms *EKMS) GenerateAndSendKSAKey(address string, requestId string, number } // encrypt the key - encryptedKSAKey, err := cryptoAlgo.Encrypt(ksaKey.Key, pk) + encryptedKSAKey, err := cryptoAlgo.Encrypt(ksaKey.Key, pk.Value) if err != nil { log.Error(err) return err @@ -326,7 +341,7 @@ func (kms *EKMS) GenerateAndSendKSAKey(address string, requestId string, number } // Use the real processID when we know what it is - err = kms.ckmsAkmsClient.SendKSAKeys(requestId, requestId, akmsKSAKeys) + err = kms.ckmsAkmsClient.SendKSAKeys(requestId, pk.ProcessId, akmsKSAKeys) if err != nil { log.Error(err) return err diff --git a/ekms/internal/kms/kmsetsi.go b/ekms/internal/kms/kmsetsi.go deleted file mode 100644 index f29eff6d0e1aa8a8d2d8e98197fccf5ad0b67236..0000000000000000000000000000000000000000 --- a/ekms/internal/kms/kmsetsi.go +++ /dev/null @@ -1,197 +0,0 @@ -package kms - -import ( - "context" - "flag" - "fmt" - "net" - "time" - - "github.com/google/uuid" - log "github.com/sirupsen/logrus" - - pb "code.fbi.h-da.de/danet/quant/ekms/internal/api/gen/proto/go/kmsetsi" - "code.fbi.h-da.de/danet/quant/ekms/internal/kms/crypto" - "code.fbi.h-da.de/danet/quant/ekms/internal/kms/event" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// TODO: remove etsiServer. -type etsiServer struct { - pb.UnimplementedKmsETSIServer - handlingEkms *EKMS -} - -func (es *etsiServer) ETSICapabilities(ctx context.Context, in *pb.ETSICapabilitiesRequest) (capReply *pb.ETSICapabilitiesReply, err error) { - log.Debugf("Received: %v", in.GetMyKmsName()) - - return &pb.ETSICapabilitiesReply{ - PeerKmsName: "whatever", - }, nil -} - -func (es *etsiServer) ETSIGetQuantumInterfaces(ctx context.Context, in *pb.ETSIKMSQuantumInterfaceListRequest) (qleReply *pb.ETSIKMSQuantumInterfaceListReply, err error) { - var qleList []*pb.QuantumElementInfo - - // Walk through QuantumLayerInterfaces and return their information - for _, qlWorks := range es.handlingEkms.quantumModules { - qleElement := pb.QuantumElementInfo{ - QleID: qlWorks.ID().String(), - UdpAddr: qlWorks.Address(), - } - qleList = append(qleList, &qleElement) - } - return &pb.ETSIKMSQuantumInterfaceListReply{ - QlElementInfo: qleList, - }, nil -} - -// TODO: reimplement. -func (es *etsiServer) ETSIAddKMSPeer(ctx context.Context, in *pb.ETSIKMSPeerRequest) (*pb.ETSIKMSPeerReply, error) { - // determine the kms structure to call - log.Debugf("AddKMSPeer called.") - - // Check first if KmsLocalQLEId is actually one of ours... - qleID := uuid.MustParse(in.KmsLocalQLEId) - servingQLE := es.handlingEkms.quantumModules[""] - if servingQLE == nil { - // no such element! - err := fmt.Errorf("Unknown local quantum element with ID %d", qleID) - - return &pb.ETSIKMSPeerReply{}, err - } - - // TODO: remove hardcoded id - _, err := es.handlingEkms.AddPeer("default", in.GetKmsPeerSocket(), servingQLE, nil) - if err != nil { - return nil, err - } - - return &pb.ETSIKMSPeerReply{ - KmsPeerName: es.handlingEkms.kmsName, - }, nil -} - -func (es *etsiServer) ETSIRemoveKMSPeer(ctx context.Context, in *pb.ETSIKMSPeerRequest) (*pb.ETSIKMSPeerReply, error) { - // kms.RemovePeer(in.GetKmsPeerSocket()) - - return &pb.ETSIKMSPeerReply{ - // KmsPeerName: kms.kmsName, - }, nil -} - -func (es *etsiServer) ETSIGetPeerList(ctx context.Context, in *pb.ETSIKMSPeerListRequest) (*pb.ETSIKMSPeerListReply, error) { - ep := make([]*pb.ETSIKMSPeer, 2) - - r := new(pb.ETSIKMSPeerListReply) - - r.Peer = ep - - p := pb.ETSIKMSPeer{ - PeerName: "Yo", - PeerStatus: "bla", - } - - r.Peer[0] = &p - - return r, nil -} - -func (es *etsiServer) ETSIAssignForwarding(ctx context.Context, in *pb.ETSIAssignForwardingRequest) (*pb.ETSIAssignForwardingReply, error) { - pathId, err := uuid.Parse(in.GetPathId()) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "The given path id %s is no uuid; err = %s", in.GetPathId(), err) - } - - var previousHop *kmsPeer - var nextHop *kmsPeer - var ok bool - if in.GetPrevHop() != "" { - previousHop, ok = es.handlingEkms.KmsPeers[in.GetPrevHop()] - if !ok { - return nil, status.Errorf(codes.InvalidArgument, "No peer for %s", in.GetPrevHop()) - } - } - if in.GetNextHop() != "" { - nextHop, ok = es.handlingEkms.KmsPeers[in.GetNextHop()] - if !ok { - return nil, status.Errorf(codes.InvalidArgument, "No peer for %s", in.GetNextHop()) - } - } - - // set the route within routing table - es.handlingEkms.routingTable[pathId] = &Route{ - PathId: pathId, - Previous: previousHop, - Next: nextHop, - } - - log.Infof("%s added a routing table entry for path id: %s", es.handlingEkms.kmsName, pathId.String()) - - err = es.handlingEkms.eventBus.Publish(event.NewRouteEvent()) - if err != nil { - log.Error(err) - } - - return &pb.ETSIAssignForwardingReply{ - Timestamp: time.Now().Unix(), - }, nil -} - -func (es *etsiServer) ETSISendPayload(ctx context.Context, in *pb.ETSISendPayloadRequest) (*pb.ETSISendPayloadResponse, error) { - pathId, err := uuid.Parse(in.GetPathId()) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "The given path id %s is no uuid; err = %s ", in.GetPathId(), err) - } - - route, ok := es.handlingEkms.routingTable[pathId] - if !ok { - return nil, status.Errorf(codes.Internal, "No route found for path id: %s", in.GetPathId()) - } - - // NOTE: For demo purpose only - //json, err := json.Marshal(KMSInfo{ - // Name: es.handlingEkms.kmsName, - // EncryptedMessage: in.Payload, - // DecryptedMessage: in.Payload, - //}) - //if err != nil { - // log.Println("Failed to marshal: ", err) - //} - - //err = sendKmsInfoMessage("http://172.20.10.21:4000/kmsinfo", json) - //if err != nil { - // log.Println("Failed to send KMS info message: ", err) - //} - - if err := route.Next.SendPayload(&crypto.Key{ - ID: uuid.New(), - Key: []byte(in.Payload), - }, pathId); err != nil { - return nil, status.Errorf(codes.Internal, "Failed to send payload: %s", err) - } - - return &pb.ETSISendPayloadResponse{ - Timestamp: time.Now().Unix(), - }, nil -} - -func StartETSI(listenAddr string, callingKMS *EKMS) { - flag.Parse() - - // lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *etsiPort)) - lis, err := net.Listen("tcp", listenAddr) - if err != nil { - log.Fatalf("failed to listen: %v", err) - } - s := grpc.NewServer() - pb.RegisterKmsETSIServer(s, &etsiServer{ - handlingEkms: callingKMS, - }) - log.Infof("server listening at %v", lis.Addr()) - if err := s.Serve(lis); err != nil { - log.Fatalf("failed to serve: %v", err) - } -} diff --git a/ekms/internal/kms/kmsintercom.go b/ekms/internal/kms/kmsintercom.go index 092a3150e0a9cbda22de082f2af22c0c6bcb91da..cc235d6567e744eb4cab5c15efc1e4f52a5d4fa5 100644 --- a/ekms/internal/kms/kmsintercom.go +++ b/ekms/internal/kms/kmsintercom.go @@ -207,7 +207,12 @@ func (s *kmsTalkerServer) InterComTransportKeyNegotiation(ctx context.Context, i } func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardingRequest) (capReply *pb.KeyForwardingResponse, err error) { - pathId, err := uuid.Parse(in.PathId) + pathId, err := uuid.Parse(in.GetPathId()) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "") + } + + processId, err := uuid.Parse(in.GetProcessId()) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "") } @@ -245,17 +250,25 @@ func (s *kmsTalkerServer) KeyForwarding(ctx context.Context, in *pb.KeyForwardin go route.Next.SendPayload(&crypto.Key{ ID: keyID, Key: decryptedKey, - }, pathId) //nolint:errcheck + }, pathId, processId) //nolint:errcheck } else { log.Infof("%s received the final payload: %s", s.eKMS.kmsName, string(decryptedKey)) s.eKMS.PKStoreMutex.Lock() keys, ok := s.eKMS.PKStore[route.InitiatingKMSAddress] if !ok { - s.eKMS.PKStore[route.InitiatingKMSAddress] = map[uuid.UUID][]byte{ - keyID: decryptedKey, + s.eKMS.PKStore[route.InitiatingKMSAddress] = map[uuid.UUID]*PlatformKey{ + keyID: { + Id: keyID, + Value: decryptedKey, + ProcessId: in.GetProcessId(), + }, } } else { - keys[keyID] = decryptedKey + keys[keyID] = &PlatformKey{ + Id: keyID, + Value: decryptedKey, + ProcessId: in.GetProcessId(), + } } log.Debug("Current PKSTORE: ", s.eKMS.PKStore) @@ -325,7 +338,7 @@ func (s *kmsTalkerServer) KeyDelivery(ctx context.Context, in *pb.KeyDeliveryReq } // decrypt the key cryptoAlgo := crypto.NewAES() - decryptedKSAKey, err := cryptoAlgo.Decrypt(encryptedKeyAsByte, pk) + decryptedKSAKey, err := cryptoAlgo.Decrypt(encryptedKeyAsByte, pk.Value) if err != nil { return nil, status.Errorf(codes.Internal, "%s", err) } @@ -348,7 +361,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(), in.GetRequestId(), akmsKSAKeys) //nolint:errcheck + go s.eKMS.ckmsAkmsClient.SendKSAKeys(in.GetRequestId(), pk.ProcessId, akmsKSAKeys) //nolint:errcheck return &pb.KeyDeliveryResponse{Timestamp: time.Now().Unix()}, nil } diff --git a/ekms/internal/kms/kmspeers.go b/ekms/internal/kms/kmspeers.go index 554f4f5a570960b0ebc4ec628ec794f5b67ca0bc..cf0d936dcf8e0306066de85c26ad3ea79ee7b47f 100644 --- a/ekms/internal/kms/kmspeers.go +++ b/ekms/internal/kms/kmspeers.go @@ -117,7 +117,14 @@ func (ph *kmsPeer) TransportKeyNegotiation() error { return nil } -func (ph *kmsPeer) SendPayload(payload *crypto.Key, pathId uuid.UUID) error { +func (ph *kmsPeer) SendInitialPayloadBasedOnGRPCClient(key *crypto.Key, pathId, processId uuid.UUID, kmsId string, remoteKMSAddress string) error { + if ph.peerClient.KmsTalkerClient != nil { + return ph.SendPayload(key, pathId, processId) + } + return fmt.Errorf("Could not find a valid peer client.") +} + +func (ph *kmsPeer) SendPayload(payload *crypto.Key, pathId, processId uuid.UUID) error { // NOTE: It should be assumed that there are keys available if we try to // send. if len(ph.servingQuantumModul.KeyStore().keyStore) == 0 { @@ -167,6 +174,7 @@ func (ph *kmsPeer) SendPayload(payload *crypto.Key, pathId uuid.UUID) error { _, err = ph.peerClient.KeyForwarding(ctx2, &pbIC.KeyForwardingRequest{ Timestamp: time.Now().Unix(), PathId: pathId.String(), + ProcessId: processId.String(), Key: &pbIC.Key{ Id: payload.ID.String(), Key: encryptedPayloadAsString,