diff --git a/akms-simulator/akms-simulator.go b/akms-simulator/akms-simulator.go index 6edfe88c86a4a8bcb0360297b6ca6d7fa960a804..050e2afde84891bedcacba891fa5c0e57376553c 100644 --- a/akms-simulator/akms-simulator.go +++ b/akms-simulator/akms-simulator.go @@ -38,7 +38,7 @@ func main() { router := http.NewServeMux() router.HandleFunc("/api/v1/keys/push_ksa_key", handlePushKsaKey) - router.HandleFunc("/debug/get_log_file", getLogFile) + router.HandleFunc("/debug/get_log_file", logFileRequest) server := &http.Server{ Addr: ":4444", @@ -77,7 +77,25 @@ func main() { } } -func getLogFile(w http.ResponseWriter, r *http.Request) { +func logFileRequest(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodDelete { + if _, err := os.Stat("akms-simulator.log"); err == nil { + err := os.Remove("akms-simulator.log") + if err != nil { + logrus.Errorf("Error deleting log file: %s", err) + w.WriteHeader(http.StatusInternalServerError) + return + } + } + logrus.Info("Log file deleted or never existed in the first place") + w.WriteHeader(http.StatusNoContent) + return + } else if r.Method != http.MethodGet { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + logrus.Errorf("Method not allowed: %s", r.Method) + return + } + logrus.Info("Log file requested") http.ServeFile(w, r, "akms-simulator.log") } diff --git a/config/controller/add_devices.sh b/config/controller/add_devices.sh index e91aae019f56cdf793dcb1db79a00ccfa062c549..530178711de63b7a2b4fd31c7878bd780bf99161 100755 --- a/config/controller/add_devices.sh +++ b/config/controller/add_devices.sh @@ -6,7 +6,7 @@ GOSDNC_PATH="./artifacts/gosdnc" GOSDN_ADDRESS="127.0.0.1:55055" ADMINPW="TestPassword" -KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +KMS_PLUGIN="e404ecf7-4860-41ee-9cee-3dd6af6c5e2b" PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" ## Adjust this if timer is to short. SLEEP_TIMER=20 diff --git a/config/controller/add_devices_no_sleep.sh b/config/controller/add_devices_no_sleep.sh index 2b9418e2008a05d54f8a8fa373cdb012e4eb5185..b585fd618ccd26434cb784a4718821332fc3f263 100755 --- a/config/controller/add_devices_no_sleep.sh +++ b/config/controller/add_devices_no_sleep.sh @@ -6,7 +6,7 @@ GOSDNC_PATH="./artifacts/gosdnc" GOSDN_ADDRESS="127.0.0.1:55055" ADMINPW="TestPassword" -KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +KMS_PLUGIN="e404ecf7-4860-41ee-9cee-3dd6af6c5e2b" PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" echo 'Logging in via gosdnc and setting up KMS in controller...' diff --git a/config/scripts/add_kms_and_user_to_controller.sh b/config/scripts/add_kms_and_user_to_controller.sh index c9b61bdfc97c0360ca93a00c18757a00ff6a09c1..e7b80205782c8a30980ea544e72a4d4053517507 100755 --- a/config/scripts/add_kms_and_user_to_controller.sh +++ b/config/scripts/add_kms_and_user_to_controller.sh @@ -6,7 +6,7 @@ GOSDNC_PATH="./gosdnc" GOSDN_ADDRESS="172.100.20.2:55055" ADMINPW="TestPassword" -KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +KMS_PLUGIN="e404ecf7-4860-41ee-9cee-3dd6af6c5e2b" PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" ## Adjust this if timer is to short. SLEEP_TIMER=20 diff --git a/goKMS/api/gen/proto/go/kmsintercom/kmsintercom.pb.go b/goKMS/api/gen/proto/go/kmsintercom/kmsintercom.pb.go index 13650227b0cb3157f6f2da17a783e4c6346e7089..d054ebed3ea4d231b0cba9b08e34e85befb8f8dd 100644 --- a/goKMS/api/gen/proto/go/kmsintercom/kmsintercom.pb.go +++ b/goKMS/api/gen/proto/go/kmsintercom/kmsintercom.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: kmsintercom/kmsintercom.proto @@ -27,8 +27,9 @@ type InterComCapabilitiesRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - MyKmsName string `protobuf:"bytes,2,opt,name=myKmsName,proto3" json:"myKmsName,omitempty"` + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + KmsId string `protobuf:"bytes,2,opt,name=kmsId,proto3" json:"kmsId,omitempty"` + ResetKeyStore bool `protobuf:"varint,3,opt,name=resetKeyStore,proto3" json:"resetKeyStore,omitempty"` } func (x *InterComCapabilitiesRequest) Reset() { @@ -70,13 +71,20 @@ func (x *InterComCapabilitiesRequest) GetTimestamp() int64 { return 0 } -func (x *InterComCapabilitiesRequest) GetMyKmsName() string { +func (x *InterComCapabilitiesRequest) GetKmsId() string { if x != nil { - return x.MyKmsName + return x.KmsId } return "" } +func (x *InterComCapabilitiesRequest) GetResetKeyStore() bool { + if x != nil { + return x.ResetKeyStore + } + return false +} + // The response message containing the replying kms' name. type InterComCapabilitiesReply struct { state protoimpl.MessageState @@ -1020,169 +1028,171 @@ var File_kmsintercom_kmsintercom_proto protoreflect.FileDescriptor var file_kmsintercom_kmsintercom_proto_rawDesc = []byte{ 0x0a, 0x1d, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x0b, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x22, 0x59, 0x0a, 0x1b, + 0x0b, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x22, 0x77, 0x0a, 0x1b, 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, 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, 0x1c, 0x0a, 0x09, 0x6d, 0x79, 0x4b, - 0x6d, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x79, - 0x4b, 0x6d, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x5b, 0x0a, 0x19, 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, 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, 0x20, 0x0a, 0x0b, 0x70, 0x65, 0x65, 0x72, 0x4b, 0x6d, 0x73, 0x4e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x65, 0x65, 0x72, 0x4b, 0x6d, 0x73, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x60, 0x0a, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, - 0x75, 0x6c, 0x6b, 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, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, - 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x22, 0x7c, 0x0a, 0x18, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, - 0x79, 0x49, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, + 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, + 0x24, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x53, 0x74, 0x6f, 0x72, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x65, 0x74, 0x4b, 0x65, 0x79, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x5b, 0x0a, 0x19, 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, 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, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6b, - 0x65, 0x79, 0x49, 0x64, 0x22, 0x39, 0x0a, 0x19, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, - 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, 0x6c, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x65, 0x65, 0x72, 0x4b, 0x6d, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x65, 0x65, 0x72, 0x4b, 0x6d, 0x73, 0x4e, 0x61, + 0x6d, 0x65, 0x22, 0x60, 0x0a, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, 0x75, 0x6c, + 0x6b, 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, + 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x62, 0x75, + 0x6c, 0x6b, 0x49, 0x64, 0x22, 0x7c, 0x0a, 0x18, 0x53, 0x79, 0x6e, 0x63, 0x4b, 0x65, 0x79, 0x49, + 0x64, 0x73, 0x46, 0x6f, 0x72, 0x42, 0x75, 0x6c, 0x6b, 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, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x6b, 0x65, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, + 0x49, 0x64, 0x22, 0x39, 0x0a, 0x19, 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, 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, 0x4b, 0x0a, + 0x13, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, 0x75, 0x6c, 0x6b, 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, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x06, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x22, 0x7a, 0x0a, 0x26, 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, 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, 0x44, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x6b, 0x65, + 0x79, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6b, 0x65, + 0x79, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x22, 0x47, 0x0a, 0x27, 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, 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, - 0x4b, 0x0a, 0x13, 0x53, 0x79, 0x6e, 0x63, 0x51, 0x6b, 0x64, 0x42, 0x75, 0x6c, 0x6b, 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, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x62, 0x75, 0x6c, 0x6b, 0x49, 0x64, 0x22, 0x7a, 0x0a, 0x26, - 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, 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, 0x44, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x74, 0x68, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, - 0x6b, 0x65, 0x79, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x6b, 0x65, 0x79, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x22, 0x47, 0x0a, 0x27, 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, 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, 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, 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, 0x83, 0x01, 0x0a, 0x17, 0x41, 0x63, - 0x6b, 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, 0x14, 0x0a, 0x05, 0x4b, 0x65, 0x79, - 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x22, - 0x38, 0x0a, 0x18, 0x41, 0x63, 0x6b, 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, + 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, 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, 0x83, 0x01, 0x0a, 0x17, 0x41, 0x63, 0x6b, 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, 0x14, 0x0a, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, - 0x18, 0x04, 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, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x04, 0x6b, - 0x65, 0x79, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x6d, 0x73, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x04, 0x6b, 0x65, 0x79, - 0x73, 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, 0x3d, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, - 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6e, 0x6f, - 0x6e, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x32, 0xb9, 0x06, 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, 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, 0x61, 0x0a, 0x10, 0x41, 0x63, 0x6b, 0x4b, 0x65, 0x79, 0x46, 0x6f, - 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x24, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x41, 0x63, 0x6b, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, - 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, - 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x41, 0x63, 0x6b, - 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, + 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, 0x14, 0x0a, 0x05, 0x4b, 0x65, 0x79, 0x49, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x22, 0x38, 0x0a, + 0x18, 0x41, 0x63, 0x6b, 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, + 0x14, 0x0a, 0x05, 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6b, 0x6d, 0x73, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x18, 0x04, + 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, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x04, 0x6b, 0x65, 0x79, + 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 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, 0x3d, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6e, + 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x32, 0xb9, 0x06, 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, 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, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0xb0, 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, 0x3f, 0x63, 0x6f, 0x64, 0x65, 0x2e, - 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, - 0x74, 0x2f, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x2f, 0x67, 0x6f, 0x4b, 0x4d, 0x53, 0x2f, 0x61, 0x70, - 0x69, 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, + 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, 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, 0x61, 0x0a, 0x10, 0x41, 0x63, 0x6b, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, + 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x24, 0x2e, 0x6b, 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x41, 0x63, 0x6b, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x77, 0x61, + 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6b, + 0x6d, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x6f, 0x6d, 0x2e, 0x41, 0x63, 0x6b, 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, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0xb0, 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, 0x3f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x62, + 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74, 0x2f, + 0x71, 0x75, 0x61, 0x6e, 0x74, 0x2f, 0x67, 0x6f, 0x4b, 0x4d, 0x53, 0x2f, 0x61, 0x70, 0x69, 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 ( @@ -1198,7 +1208,7 @@ func file_kmsintercom_kmsintercom_proto_rawDescGZIP() []byte { } var file_kmsintercom_kmsintercom_proto_msgTypes = make([]protoimpl.MessageInfo, 17) -var file_kmsintercom_kmsintercom_proto_goTypes = []interface{}{ +var file_kmsintercom_kmsintercom_proto_goTypes = []any{ (*InterComCapabilitiesRequest)(nil), // 0: kmsintercom.InterComCapabilitiesRequest (*InterComCapabilitiesReply)(nil), // 1: kmsintercom.InterComCapabilitiesReply (*SyncQkdBulkRequest)(nil), // 2: kmsintercom.SyncQkdBulkRequest @@ -1249,7 +1259,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_kmsintercom_kmsintercom_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*InterComCapabilitiesRequest); i { case 0: return &v.state @@ -1261,7 +1271,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*InterComCapabilitiesReply); i { case 0: return &v.state @@ -1273,7 +1283,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*SyncQkdBulkRequest); i { case 0: return &v.state @@ -1285,7 +1295,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*SyncKeyIdsForBulkRequest); i { case 0: return &v.state @@ -1297,7 +1307,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*SyncKeyIdsForBulkResponse); i { case 0: return &v.state @@ -1309,7 +1319,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*SyncQkdBulkResponse); i { case 0: return &v.state @@ -1321,7 +1331,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*InterComTransportKeyNegotiationRequest); i { case 0: return &v.state @@ -1333,7 +1343,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*InterComTransportKeyNegotiationResponse); i { case 0: return &v.state @@ -1345,7 +1355,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*KeyForwardingRequest); i { case 0: return &v.state @@ -1357,7 +1367,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*KeyForwardingResponse); i { case 0: return &v.state @@ -1369,7 +1379,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*AckKeyForwardingRequest); i { case 0: return &v.state @@ -1381,7 +1391,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*AckKeyForwardingResponse); i { case 0: return &v.state @@ -1393,7 +1403,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*KeyIdNotificationRequest); i { case 0: return &v.state @@ -1405,7 +1415,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*KeyIdNotificationResponse); i { case 0: return &v.state @@ -1417,7 +1427,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*KeyDeliveryRequest); i { case 0: return &v.state @@ -1429,7 +1439,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*KeyDeliveryResponse); i { case 0: return &v.state @@ -1441,7 +1451,7 @@ func file_kmsintercom_kmsintercom_proto_init() { return nil } } - file_kmsintercom_kmsintercom_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_kmsintercom_kmsintercom_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*Key); i { case 0: return &v.state diff --git a/goKMS/api/gen/proto/go/kmsintercom/kmsintercom_grpc.pb.go b/goKMS/api/gen/proto/go/kmsintercom/kmsintercom_grpc.pb.go index 32a2d9c941b222de7152b493e8bce4efb44b21d3..8516ca86bef8ce798862ffbe2a1503f202de8f6c 100644 --- a/goKMS/api/gen/proto/go/kmsintercom/kmsintercom_grpc.pb.go +++ b/goKMS/api/gen/proto/go/kmsintercom/kmsintercom_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: kmsintercom/kmsintercom.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( KmsTalker_InterComCapabilities_FullMethodName = "/kmsintercom.KmsTalker/InterComCapabilities" @@ -32,6 +32,8 @@ const ( // KmsTalkerClient is the client API for KmsTalker service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// should be renamed to InterCom or KMSInterCom type KmsTalkerClient interface { InterComCapabilities(ctx context.Context, in *InterComCapabilitiesRequest, opts ...grpc.CallOption) (*InterComCapabilitiesReply, error) SyncQkdBulk(ctx context.Context, in *SyncQkdBulkRequest, opts ...grpc.CallOption) (*SyncQkdBulkResponse, error) @@ -53,8 +55,9 @@ func NewKmsTalkerClient(cc grpc.ClientConnInterface) KmsTalkerClient { } func (c *kmsTalkerClient) InterComCapabilities(ctx context.Context, in *InterComCapabilitiesRequest, opts ...grpc.CallOption) (*InterComCapabilitiesReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(InterComCapabilitiesReply) - err := c.cc.Invoke(ctx, KmsTalker_InterComCapabilities_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_InterComCapabilities_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -62,8 +65,9 @@ func (c *kmsTalkerClient) InterComCapabilities(ctx context.Context, in *InterCom } func (c *kmsTalkerClient) SyncQkdBulk(ctx context.Context, in *SyncQkdBulkRequest, opts ...grpc.CallOption) (*SyncQkdBulkResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SyncQkdBulkResponse) - err := c.cc.Invoke(ctx, KmsTalker_SyncQkdBulk_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_SyncQkdBulk_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -71,8 +75,9 @@ func (c *kmsTalkerClient) SyncQkdBulk(ctx context.Context, in *SyncQkdBulkReques } func (c *kmsTalkerClient) SyncKeyIdsForBulk(ctx context.Context, in *SyncKeyIdsForBulkRequest, opts ...grpc.CallOption) (*SyncKeyIdsForBulkResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SyncKeyIdsForBulkResponse) - err := c.cc.Invoke(ctx, KmsTalker_SyncKeyIdsForBulk_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_SyncKeyIdsForBulk_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -80,8 +85,9 @@ func (c *kmsTalkerClient) SyncKeyIdsForBulk(ctx context.Context, in *SyncKeyIdsF } func (c *kmsTalkerClient) InterComTransportKeyNegotiation(ctx context.Context, in *InterComTransportKeyNegotiationRequest, opts ...grpc.CallOption) (*InterComTransportKeyNegotiationResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(InterComTransportKeyNegotiationResponse) - err := c.cc.Invoke(ctx, KmsTalker_InterComTransportKeyNegotiation_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_InterComTransportKeyNegotiation_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -89,8 +95,9 @@ func (c *kmsTalkerClient) InterComTransportKeyNegotiation(ctx context.Context, i } func (c *kmsTalkerClient) KeyForwarding(ctx context.Context, in *KeyForwardingRequest, opts ...grpc.CallOption) (*KeyForwardingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(KeyForwardingResponse) - err := c.cc.Invoke(ctx, KmsTalker_KeyForwarding_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_KeyForwarding_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -98,8 +105,9 @@ func (c *kmsTalkerClient) KeyForwarding(ctx context.Context, in *KeyForwardingRe } func (c *kmsTalkerClient) AckKeyForwarding(ctx context.Context, in *AckKeyForwardingRequest, opts ...grpc.CallOption) (*AckKeyForwardingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AckKeyForwardingResponse) - err := c.cc.Invoke(ctx, KmsTalker_AckKeyForwarding_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_AckKeyForwarding_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -107,8 +115,9 @@ func (c *kmsTalkerClient) AckKeyForwarding(ctx context.Context, in *AckKeyForwar } func (c *kmsTalkerClient) KeyIdNotification(ctx context.Context, in *KeyIdNotificationRequest, opts ...grpc.CallOption) (*KeyIdNotificationResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(KeyIdNotificationResponse) - err := c.cc.Invoke(ctx, KmsTalker_KeyIdNotification_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_KeyIdNotification_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -116,8 +125,9 @@ func (c *kmsTalkerClient) KeyIdNotification(ctx context.Context, in *KeyIdNotifi } func (c *kmsTalkerClient) KeyDelivery(ctx context.Context, in *KeyDeliveryRequest, opts ...grpc.CallOption) (*KeyDeliveryResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(KeyDeliveryResponse) - err := c.cc.Invoke(ctx, KmsTalker_KeyDelivery_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, KmsTalker_KeyDelivery_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -126,7 +136,9 @@ func (c *kmsTalkerClient) KeyDelivery(ctx context.Context, in *KeyDeliveryReques // KmsTalkerServer is the server API for KmsTalker service. // All implementations must embed UnimplementedKmsTalkerServer -// for forward compatibility +// for forward compatibility. +// +// should be renamed to InterCom or KMSInterCom type KmsTalkerServer interface { InterComCapabilities(context.Context, *InterComCapabilitiesRequest) (*InterComCapabilitiesReply, error) SyncQkdBulk(context.Context, *SyncQkdBulkRequest) (*SyncQkdBulkResponse, error) @@ -140,9 +152,12 @@ type KmsTalkerServer interface { mustEmbedUnimplementedKmsTalkerServer() } -// UnimplementedKmsTalkerServer must be embedded to have forward compatible implementations. -type UnimplementedKmsTalkerServer struct { -} +// UnimplementedKmsTalkerServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedKmsTalkerServer struct{} func (UnimplementedKmsTalkerServer) InterComCapabilities(context.Context, *InterComCapabilitiesRequest) (*InterComCapabilitiesReply, error) { return nil, status.Errorf(codes.Unimplemented, "method InterComCapabilities not implemented") @@ -169,6 +184,7 @@ func (UnimplementedKmsTalkerServer) KeyDelivery(context.Context, *KeyDeliveryReq return nil, status.Errorf(codes.Unimplemented, "method KeyDelivery not implemented") } func (UnimplementedKmsTalkerServer) mustEmbedUnimplementedKmsTalkerServer() {} +func (UnimplementedKmsTalkerServer) testEmbeddedByValue() {} // UnsafeKmsTalkerServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to KmsTalkerServer will @@ -178,6 +194,13 @@ type UnsafeKmsTalkerServer interface { } func RegisterKmsTalkerServer(s grpc.ServiceRegistrar, srv KmsTalkerServer) { + // If the following call pancis, it indicates UnimplementedKmsTalkerServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&KmsTalker_ServiceDesc, srv) } diff --git a/goKMS/api/kmsintercom/kmsintercom/kmsintercom.proto b/goKMS/api/kmsintercom/kmsintercom/kmsintercom.proto index 46bd6fccabb3a3061958b42749d0e65d9a15f60b..acd7f935bf319375e9bb8b405e009b649784586b 100644 --- a/goKMS/api/kmsintercom/kmsintercom/kmsintercom.proto +++ b/goKMS/api/kmsintercom/kmsintercom/kmsintercom.proto @@ -19,7 +19,8 @@ service KmsTalker { // The request message containing the requesting kms' name. message InterComCapabilitiesRequest { int64 timestamp = 1; - string myKmsName = 2; + string kmsId = 2; + bool resetKeyStore = 3; } // The response message containing the replying kms' name. diff --git a/goKMS/kms/kms.go b/goKMS/kms/kms.go index 39c99108ce6bf382a279a81d2cf66917796b5fa2..0862711365b1f4e3293bd9bfd916c0e8d85e3a04 100644 --- a/goKMS/kms/kms.go +++ b/goKMS/kms/kms.go @@ -69,7 +69,7 @@ type KMS struct { remoteKMSMappingMutex sync.RWMutex quantumModules map[string]peers.QuantumModule quantumModulesMutex sync.RWMutex - kmsPeersMutex sync.Mutex + kmsPeersMutex sync.RWMutex // NOTE: There is probably a better way to handle this PKStore map[string]map[uuid.UUID]*PlatformKey PKStoreMutex sync.Mutex @@ -302,7 +302,8 @@ func (kms *KMS) AddQuantumElement(qm peers.QuantumModule) error { func (kms *KMS) AddPeer(peerKmsId string, kmsPeerSocket string, servingQLE peers.QuantumModule, client *peers.GRPCClient) (*peers.KmsPeer, error) { // check if peer exists - if _, there := kms.KmsPeers[peerKmsId]; there { + _, err := kms.FindPeerById(peerKmsId) + if err == nil { log.Errorf("Trying to add existing peer %s, with KMS ID %s", kmsPeerSocket, peerKmsId) return nil, fmt.Errorf("trying to add existing peer %s, with KMS ID %s", kmsPeerSocket, peerKmsId) } @@ -316,7 +317,37 @@ func (kms *KMS) AddPeer(peerKmsId string, kmsPeerSocket string, servingQLE peers defer kms.kmsPeersMutex.Unlock() kms.KmsPeers[peerKmsId] = peer - // go peer.PeerHandler(kms.kmsName) + go func() { + restartWaitingTime := time.Duration(3) * time.Second + ticker := time.NewTicker(restartWaitingTime) + defer ticker.Stop() + + InitialResetLoop: + for !peer.QuantumModule().IsActive() { + select { + case <-ticker.C: + if client := peer.Client().KmsTalkerClient; client != nil { + log.Debugf("Sending initial peer setup request to peer: %s with the request to reset the corresponding key store", peerKmsId) + ctx, cancel := context.WithTimeout(context.Background(), kms.gRPCTimeout) + defer cancel() + _, err := client.InterComCapabilities(ctx, &pbIC.InterComCapabilitiesRequest{ + Timestamp: time.Now().Unix(), + KmsId: kms.kmsUUID.String(), + ResetKeyStore: true, + }) + if err == nil { + if err := peer.QuantumModule().Initialize(); err != nil { + log.Fatalf("Failed to initialized quantum module: %s for peer: %s", peer.QuantumModule().ID(), peer.GetKmsPeerId()) + } + log.Debugf("Successfully initialized quantum module: %s for peer %s", peer.QuantumModule().ID(), peerKmsId) + break InitialResetLoop + } + } + } + } + log.Debugf("Successfully initialized peer: %s", peerKmsId) + }() + return peer, nil } @@ -328,18 +359,16 @@ func (kms *KMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *util.Re var previousHop *peers.KmsPeer var nextHop *peers.KmsPeer - var ok bool if pHop != "" { - previousHop, ok = kms.KmsPeers[pHop] - if !ok { + previousHop, err = kms.FindPeerById(pHop) + if err != nil { return fmt.Errorf("no peer found for %s", pHop) } } if nHop != "" { - nextHop, ok = kms.KmsPeers[nHop] - - if !ok { - return fmt.Errorf("no peer found for %s", nHop) + nextHop, err = kms.FindPeerById(nHop) + if err != nil { + return fmt.Errorf("no peer found for %s", pHop) } } @@ -355,6 +384,11 @@ func (kms *KMS) AssignForwardingRoute(pId, pHop, nHop string, remoteKMS *util.Re kms.routingTable[pathId] = tmpRoute kms.routingTableMutex.Unlock() + if tmpRoute.RemoteKMS == nil { + log.Error("NOOOOO REMOTE KMS") + return fmt.Errorf("NOOOOO REMOTE KMS") + } + if tmpRoute.RemoteKMS != nil { kms.remoteKMSMappingMutex.Lock() if _, ok := kms.remoteKMSMapping[tmpRoute.RemoteKMS.Id]; !ok { @@ -495,25 +529,30 @@ func (kms *KMS) EventBus() *event.EventBus { } // TODO/XXX error handling. -func (kms *KMS) RemovePeer(kmsPeerSocket string) { - if _, there := kms.KmsPeers[kmsPeerSocket]; there { - // peer.quit <- true - delete(kms.KmsPeers, kmsPeerSocket) - return +func (kms *KMS) RemovePeer(kmsPeerSocket string) error { + _, err := kms.FindPeerById(kmsPeerSocket) + if err != nil { + return fmt.Errorf("Could not remove peer with id: %s, not found", kmsPeerSocket) } - log.Errorf("%s: Can not find a peer with socket: %s", kms.kmsName, kmsPeerSocket) + + kms.kmsPeersMutex.Lock() + defer kms.kmsPeersMutex.Unlock() + // peer.quit <- true + delete(kms.KmsPeers, kmsPeerSocket) + + return nil } -func (kms *KMS) FindPeerUuid(lookup uuid.UUID) (peer *peers.KmsPeer) { - if kms.KmsPeers != nil { - for _, peer = range kms.KmsPeers { - if peer.GetKmsPeerId() == lookup { - return peer - } - } +func (kms *KMS) FindPeerById(id string) (*peers.KmsPeer, error) { + kms.kmsPeersMutex.RLock() + defer kms.kmsPeersMutex.RUnlock() + + peer, ok := kms.KmsPeers[id] + if !ok { + return nil, fmt.Errorf("No peer found for id: %s", id) } - return nil + return peer, nil } func (kms *KMS) RoutingTableDeepCopy() map[uuid.UUID]*Route { @@ -531,8 +570,8 @@ func (kms *KMS) RoutingTableDeepCopy() map[uuid.UUID]*Route { func (kms *KMS) PeersDeepCopy() map[string]*peers.KmsPeer { peersCopy := make(map[string]*peers.KmsPeer, len(kms.KmsPeers)) - kms.kmsPeersMutex.Lock() - defer kms.kmsPeersMutex.Unlock() + kms.kmsPeersMutex.RLock() + defer kms.kmsPeersMutex.RUnlock() for k, v := range kms.KmsPeers { peersCopy[k] = v } diff --git a/goKMS/kms/kmsintercom.go b/goKMS/kms/kmsintercom.go index 1c52e43d92744e9b633978f165dfef0028681775..6e7d61cd11254b1431550f6b8b70f51151c28bab 100644 --- a/goKMS/kms/kmsintercom.go +++ b/goKMS/kms/kmsintercom.go @@ -33,21 +33,37 @@ type kmsTalkerServer struct { } func (s *kmsTalkerServer) InterComCapabilities(ctx context.Context, in *pb.InterComCapabilitiesRequest) (capReply *pb.InterComCapabilitiesReply, err error) { - log.Debugf("Received: %v", in.GetMyKmsName()) + log.Debugf("Received InterComCapabilities request from peer KMS: %v", in.GetKmsId()) + + peerKmsId := in.GetKmsId() + peer, err := s.kms.FindPeerById(peerKmsId) + if err != nil { + return nil, status.Errorf(codes.Aborted, err.Error(), in.GetKmsId()) + } + + if in.ResetKeyStore { + log.Debugf("Resetting quantum module: %s for peer: %s", peer.QuantumModule().ID(), peerKmsId) + peer.QuantumModule().Reset() + log.Debugf("Initializing quantum module: %s for peer: %s", peer.QuantumModule().ID(), peerKmsId) + if err := peer.QuantumModule().Initialize(); err != nil { + return nil, status.Errorf(codes.Aborted, err.Error(), in.GetKmsId()) + } + log.Debugf("Successfully initialized quantum module: %s for peer %s", peer.QuantumModule().ID(), peerKmsId) + } // NOTE: InterComCapabilities should return the capabilities of the kms. // This could include supported key sizes, crypto algorithms, etc. // Therefore the proto definitions should be extended accordingly. return &pb.InterComCapabilitiesReply{ + Timestamp: time.Now().Unix(), PeerKmsName: s.kms.kmsName, }, nil } func (s *kmsTalkerServer) KeyIdNotification(ctx context.Context, in *pb.KeyIdNotificationRequest) (*pb.KeyIdNotificationResponse, error) { - // check if a peer exists - peer, ok := s.kms.KmsPeers[in.GetKmsId()] - if !ok { + peer, err := s.kms.FindPeerById(in.GetKmsId()) + if err != nil { return nil, status.Errorf(codes.Internal, "peer with ID: %s does not exist in peers", in.GetKmsId()) } @@ -56,6 +72,15 @@ func (s *kmsTalkerServer) KeyIdNotification(ctx context.Context, in *pb.KeyIdNot return nil, status.Error(codes.Internal, "expected etsi014 quantum module") } + switch { + case !eqm.IsActive(): + log.Debugf("The key store for quantum module: %s is not active and denied incoming key sync attempts, current key store length: %d", eqm.ID(), eqm.KeyStore().Length()) + return nil, status.Errorf(codes.Aborted, "The corresponding key store is not active and does not accept incoming key sync attempts") + case eqm.KeyStore().Length() >= int(eqm.MaxKeyFillLevel()): + log.Debugf("The key store for quantum module: %s is at its maximum key fill level and does not accept incoming key sync attempts", eqm.ID()) + return nil, status.Errorf(codes.Aborted, "The corresponding key store is at its maximum key fill level and does not accept incoming key sync attempts") + } + etsi14KeyIds := make([]etsi14.KeyIDsRequestKeyIDsInner, len(in.KeyIds)) for i, keyid := range in.KeyIds { etsi14KeyIds[i] = etsi14.KeyIDsRequestKeyIDsInner{ @@ -82,8 +107,8 @@ 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.kms.KmsPeers[in.GetKmsId()] - if !ok { + peer, err := s.kms.FindPeerById(in.GetKmsId()) + if err != nil { return nil, status.Errorf(codes.Internal, "peer with ID: %s does not exist in peers", in.GetKmsId()) } @@ -107,8 +132,8 @@ 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.kms.KmsPeers[in.GetKmsId()] - if !ok { + peer, err := s.kms.FindPeerById(in.GetKmsId()) + if err != nil { return nil, status.Errorf(codes.Internal, "For KMS id: %s, no peer exists", in.GetKmsId()) } @@ -131,7 +156,9 @@ func (s *kmsTalkerServer) SyncKeyIdsForBulk(ctx context.Context, in *pb.SyncKeyI } for keyId, key := range keyData { - eqm.KeyStore().AddKey(keyId, key) + if err := eqm.KeyStore().AddKey(keyId, key); err != nil { + log.Error(err) + } } delete(eqm.RawBulkKeys, in.GetBulkId()) diff --git a/goKMS/kms/peers/danetQuantummodule.go b/goKMS/kms/peers/danetQuantummodule.go index 797f906e41d95f69b4f605f8984b9eee4a5cbab6..fa1487c1545f18b2be7987aac3553c9ddfc930bb 100644 --- a/goKMS/kms/peers/danetQuantummodule.go +++ b/goKMS/kms/peers/danetQuantummodule.go @@ -22,6 +22,7 @@ type DanetQuantumModule struct { // QuantumElementLink *quantumlayer.QuantumlayerEmuPRNG // contains information about the quantum links // key stores of unchopped bulk keys go here addr string + active bool // determs if the module is active to receive keys RawBulkKeysMutex sync.Mutex RawBulkKeys map[int64]*quantumlayer.QuantumLayerBulkKey keyStore *store.KmsKeyStore // the keys used between two peers. @@ -35,6 +36,7 @@ func NewDanetQuantumModule(kmsUDPAddr string, kmsId string) *DanetQuantumModule QlID: uuid.New(), kmsId: kmsId, addr: kmsUDPAddr, + active: false, RawBulkKeys: make(map[int64]*quantumlayer.QuantumLayerBulkKey), keyStore: store.NewKmsKeyStore(256), kmsClient: nil, @@ -48,9 +50,20 @@ func (qm *DanetQuantumModule) ID() uuid.UUID { } func (qm *DanetQuantumModule) Initialize() error { + qm.RawBulkKeysMutex.Lock() + defer qm.RawBulkKeysMutex.Unlock() + qm.active = true return nil } +func (qm *DanetQuantumModule) Reset() { + qm.RawBulkKeysMutex.Lock() + defer qm.RawBulkKeysMutex.Unlock() + qm.active = false + qm.RawBulkKeys = make(map[int64]*quantumlayer.QuantumLayerBulkKey) + qm.KeyStore().Reset() +} + func (qm *DanetQuantumModule) SetKmsPeerInformation(kmsClient *GRPCClient, kmsEventBus *event.EventBus, kmsTcpSocketStr string) error { qm.kmsClient = kmsClient qm.kmsEventBus = kmsEventBus @@ -62,6 +75,10 @@ func (qm *DanetQuantumModule) Address() string { return qm.addr } +func (qm *DanetQuantumModule) IsActive() bool { + return qm.active +} + func (qm *DanetQuantumModule) Sync() error { rawBulkKeyIds := util.KeysOfMap(qm.RawBulkKeys) log.Info("Found the following bulk key ids for usage: ", rawBulkKeyIds) @@ -103,7 +120,9 @@ func (qm *DanetQuantumModule) Sync() error { } for keyId, key := range keyData { - qm.keyStore.AddKey(keyId, key) + if err := qm.keyStore.AddKey(keyId, key); err != nil { + log.Error(err) + } } qm.RawBulkKeysMutex.Lock() diff --git a/goKMS/kms/peers/etsi14Quantummodule.go b/goKMS/kms/peers/etsi14Quantummodule.go index 0bd98eeadc5ad482ca34cb361231ef64133f8f59..41119283a6261e0b8299f03e64048df48288887d 100644 --- a/goKMS/kms/peers/etsi14Quantummodule.go +++ b/goKMS/kms/peers/etsi14Quantummodule.go @@ -31,6 +31,8 @@ type ETSI014HTTPQuantumModule struct { keyFetchInterval int keyFetchAmount int64 maxKeyFillLevel uint64 + stopFetch context.CancelFunc + active bool } func NewETSI014HTTPQuantumModule(addr, kmsId, localSAEID, targetSAEID string, tlsConfig config.TLSConfig, master bool, keyFetchInterval int, keyFetchAmount int64, maxKeyFillLevel uint64) (*ETSI014HTTPQuantumModule, error) { @@ -94,6 +96,7 @@ func NewETSI014HTTPQuantumModule(addr, kmsId, localSAEID, targetSAEID string, tl keyFetchInterval: keyFetchInterval, keyFetchAmount: keyFetchAmount, maxKeyFillLevel: maxKeyFillLevel, + active: false, }, nil } @@ -106,22 +109,52 @@ func (qm *ETSI014HTTPQuantumModule) Client() *etsi14ClientImpl.ClientImpl { } func (qm *ETSI014HTTPQuantumModule) Initialize() error { - // start polling keys - if qm.master { - go func() { - restartWaitingTime := time.Duration(2) * time.Minute - ticker := time.NewTicker(restartWaitingTime) - defer ticker.Stop() - - // immediately start with the ticker instead of waiting the defined amount - for ; true; <-ticker.C { - qm.doKeyFetching() - } - }() + if !qm.active { + var ctx context.Context + ctx, qm.stopFetch = context.WithCancel(context.Background()) + + qm.active = true + + // start polling keys + if qm.master { + go func() { + restartWaitingTime := time.Duration(2) * time.Minute + ticker := time.NewTicker(restartWaitingTime) + defer ticker.Stop() + + RestartFetchLoop: + for { + // immediately start with the ticker instead of waiting the defined amount + qm.doKeyFetching(ctx) + select { + case <-ticker.C: + continue + case <-ctx.Done(): + break RestartFetchLoop + } + } + }() + } } return nil } +func (qm *ETSI014HTTPQuantumModule) Reset() { + if qm.master && qm.stopFetch != nil { + qm.stopFetch() + } + qm.active = false + qm.KeyStore().Reset() +} + +func (qm *ETSI014HTTPQuantumModule) MaxKeyFillLevel() uint64 { + return qm.maxKeyFillLevel +} + +func (qm *ETSI014HTTPQuantumModule) IsActive() bool { + return qm.active +} + func (qm *ETSI014HTTPQuantumModule) SetKmsPeerInformation(kmsClient *GRPCClient, kmsEventBus *event.EventBus, kmsTcpSocketStr string) error { qm.kmsClient = kmsClient return nil @@ -176,52 +209,57 @@ func (qm *ETSI014HTTPQuantumModule) GetKeyWithIds(keyIds []etsi14ClientGenerated return container, nil } -func (qm *ETSI014HTTPQuantumModule) doKeyFetching() { +func (qm *ETSI014HTTPQuantumModule) doKeyFetching(ctx context.Context) { ticker := time.NewTicker(time.Duration(qm.keyFetchInterval) * time.Second) defer ticker.Stop() failedAttemps := 0 - // TODO: add context/channel to stop - for range ticker.C { - if failedAttemps == maxFailedKeyRequestAttempts { - log.Errorf("stopped trying to fetch keys from qkd module after %d tries", failedAttemps) - break - } - - if qm.keyStore.Length() < int(qm.maxKeyFillLevel) { - container, err := qm.GetKeys(qm.keyFetchAmount, 256, nil, nil, nil) - if err != nil { - log.Error(err) - failedAttemps++ - continue - } - - keyIds := make([]string, len(container.GetKeys())) - for i, keyItem := range container.GetKeys() { - keyIds[i] = keyItem.GetKeyID() - } - - _, err = qm.kmsClient.KeyIdNotification(context.Background(), - &pbIC.KeyIdNotificationRequest{ - Timestamp: time.Now().Unix(), - KmsId: qm.kmsId, - KeyIds: keyIds, - }) - if err != nil { - log.Error(err) - failedAttemps++ - continue +FetchLoop: + for { + select { + case <-ticker.C: + if failedAttemps == maxFailedKeyRequestAttempts { + log.Errorf("stopped trying to fetch keys from qkd module after %d tries", failedAttemps) + break FetchLoop } - err = store.AddETSIKeysToKeystore(qm.keyStore, container.GetKeys()) - if err != nil { - log.Error(err) - failedAttemps++ - continue + if qm.keyStore.Length() < int(qm.maxKeyFillLevel) { + container, err := qm.GetKeys(qm.keyFetchAmount, 256, nil, nil, nil) + if err != nil { + log.Error(err) + failedAttemps++ + continue + } + + keyIds := make([]string, len(container.GetKeys())) + for i, keyItem := range container.GetKeys() { + keyIds[i] = keyItem.GetKeyID() + } + + _, err = qm.kmsClient.KeyIdNotification(context.Background(), + &pbIC.KeyIdNotificationRequest{ + Timestamp: time.Now().Unix(), + KmsId: qm.kmsId, + KeyIds: keyIds, + }) + if err != nil { + log.Error(err) + failedAttemps++ + continue + } + + err = store.AddETSIKeysToKeystore(qm.keyStore, container.GetKeys()) + if err != nil { + log.Error(err) + failedAttemps++ + continue + } + + failedAttemps = 0 } - - failedAttemps = 0 + case <-ctx.Done(): + break FetchLoop } } } diff --git a/goKMS/kms/peers/kmsPeer.go b/goKMS/kms/peers/kmsPeer.go index d8049675b8e499d146709d4da80d72ea314b57f0..643a8dbeae24cffc7b4a6c3e82588e013fd0c455 100644 --- a/goKMS/kms/peers/kmsPeer.go +++ b/goKMS/kms/peers/kmsPeer.go @@ -93,10 +93,6 @@ func NewKmsPeer(peerKmsId string, quantummodule QuantumModule, tcpSocketStr stri gRPCTimeout: gRPCTimeout, } - if err := quantummodule.Initialize(); err != nil { - return nil, err - } - return kmsPeer, nil } diff --git a/goKMS/kms/peers/quantummodule.go b/goKMS/kms/peers/quantummodule.go index cb9753ac1fede1fcc0aa29f27894a54166a9ca22..166293631135285d0a91e937b3f380226c2a86dd 100644 --- a/goKMS/kms/peers/quantummodule.go +++ b/goKMS/kms/peers/quantummodule.go @@ -22,4 +22,6 @@ type QuantumModule interface { SetKeyStore(*store.KmsKeyStore) Sync() error Address() string + IsActive() bool + Reset() } diff --git a/goKMS/kms/quipsec.go b/goKMS/kms/quipsec.go index d2a850923c9f10ed3c28bd4eb98e00e996cb8638..da6c9c4ec4fad45007f0057338d7dce2035f7ea6 100644 --- a/goKMS/kms/quipsec.go +++ b/goKMS/kms/quipsec.go @@ -49,12 +49,16 @@ func (qs *quipSecServer) PushKeys(ctx context.Context, req *pb.PushKeysRequest) } eqm.RawBulkKeysMutex.Lock() + defer eqm.RawBulkKeysMutex.Unlock() + if !eqm.IsActive() { + logrus.Debugf("Quantum module: %s is not active and denied incoming bulk keys", eqm.ID()) + return nil, status.Errorf(codes.Aborted, "Currently no new bulk keys are accepted") + } eqm.RawBulkKeys[bulkKeyId] = &quantumlayer.QuantumLayerBulkKey{ BulkKeyId: bulkKeyId, BulkKeyLength: int(req.GetKeyBulk().GetKeyLength()), 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.KMS.kmsName, qm.Address(), req.GetKeyBulk().GetKeyId(), req.GetKeyBulk().GetKeyLength()) return &pb.PushKeysResponse{Timestamp: time.Now().Unix()}, nil diff --git a/goKMS/kms/store/kms-keystore.go b/goKMS/kms/store/kms-keystore.go index 9a4334b1a7f2abacf635a586e93957e8c5769264..ef1a5212aa1933dc2ca104d64b72412bfb879c94 100644 --- a/goKMS/kms/store/kms-keystore.go +++ b/goKMS/kms/store/kms-keystore.go @@ -47,14 +47,13 @@ func (ks *KmsKeyStore) Length() int { return len(ks.keyStore) } -func (ks *KmsKeyStore) AddKey(keyId uuid.UUID, keyToadd []byte) { +func (ks *KmsKeyStore) AddKey(keyId uuid.UUID, keyToadd []byte) error { ks.keyStoreMutex.Lock() defer ks.keyStoreMutex.Unlock() // test for collisions - if _, notThere := ks.keyStore[keyId]; notThere { - log.Errorf("Whop: addKey collisions of key id %s", keyId) - return + if _, keyIdExists := ks.keyStore[keyId]; keyIdExists { + return fmt.Errorf("Key with id %s already exists", keyId) } newKeyElement := &KmsKSElement{ @@ -64,6 +63,7 @@ func (ks *KmsKeyStore) AddKey(keyId uuid.UUID, keyToadd []byte) { } // ok to add ks.keyStore[newKeyElement.KeyID] = newKeyElement + return nil } func (ks *KmsKeyStore) GetKey() (*KmsKSElement, error) { @@ -102,6 +102,12 @@ func (ks *KmsKeyStore) DeleteKey(keyId uuid.UUID) { delete(ks.keyStore, keyId) } +func (ks *KmsKeyStore) Reset() { + ks.keyStoreMutex.Lock() + defer ks.keyStoreMutex.Unlock() + ks.keyStore = make(map[uuid.UUID]*KmsKSElement) +} + func AddETSIKeysToKeystore(keyStore *KmsKeyStore, keyContainer []etsi14.KeyContainerKeysInner) error { for _, keyItem := range keyContainer { // decode base64 encoded key string @@ -114,7 +120,10 @@ func AddETSIKeysToKeystore(keyStore *KmsKeyStore, keyContainer []etsi14.KeyConta return err } // add to keystore - keyStore.AddKey(keyId, key) + if err := keyStore.AddKey(keyId, key); err != nil { + log.Error(err) + } } + log.Debugf("Current key store length: %d", keyStore.Length()) return nil } diff --git a/goKMS/qkdnManager/server.go b/goKMS/qkdnManager/server.go index 8d496bc54dcbbe5a8d8e6093dd55865cb0bcfa90..ea3235f26d12de7eb710ff9c3ec246c29459d222 100644 --- a/goKMS/qkdnManager/server.go +++ b/goKMS/qkdnManager/server.go @@ -3,11 +3,13 @@ package qkdnmanager import ( "encoding/json" "errors" + "fmt" "net/http" "time" "code.fbi.h-da.de/danet/quant/goKMS/config" "code.fbi.h-da.de/danet/quant/goKMS/kms" + "code.fbi.h-da.de/danet/quant/goKMS/kms/peers" "github.com/google/uuid" "github.com/sirupsen/logrus" ) @@ -18,12 +20,14 @@ const operationalState = "operationalState" const qkdInterface = "qkdInterface" const interCKMSInterface = "interCKMSInterface" const akmsInterface = "akmsInterface" +const setKeyStore = "setKeyStore" var endpoints = map[string]string{ operationalState: "/operationalState", qkdInterface: "/qkdInterface", interCKMSInterface: "/interCKMSInterface", akmsInterface: "/akmsInterface", + setKeyStore: "/setKeyStore", } type QkdnManagerServer struct { @@ -72,6 +76,7 @@ func (qs *QkdnManagerServer) addHandlersToMux(mux *http.ServeMux) { mux.HandleFunc(APIPrefix+endpoints[qkdInterface], qs.handleHttpQkdInterface) mux.HandleFunc(APIPrefix+endpoints[interCKMSInterface], qs.handleHttpInterCKMSInterface) mux.HandleFunc(APIPrefix+endpoints[akmsInterface], qs.handleHttpAkmsInterface) + mux.HandleFunc(APIPrefix+endpoints[setKeyStore], qs.handleSetKeyStore) } func (qs *QkdnManagerServer) startServer() { @@ -127,7 +132,8 @@ func (qs *QkdnManagerServer) handleHttpInterCKMSInterface(w http.ResponseWriter, logrus.Debugf("Handler for InterCKMSInterface got request from: %s", r.RemoteAddr) var peers []Peer - for _, peer := range qs.kms.KmsPeers { + peerMapCopy := qs.kms.PeersDeepCopy() + for _, peer := range peerMapCopy { peers = append(peers, Peer{ Peer_ID: peer.GetKmsPeerId(), Running: true, @@ -153,7 +159,7 @@ func (qs *QkdnManagerServer) handleHttpInterCKMSInterface(w http.ResponseWriter, } func (qs *QkdnManagerServer) handleHttpAkmsInterface(w http.ResponseWriter, r *http.Request) { - logrus.Debugf("Handler for AkmsInterface got requestfrom: %s", r.RemoteAddr) + logrus.Debugf("Handler for AkmsInterface got request from: %s", r.RemoteAddr) data := &KmsData{ KMS_ID: qs.kms.GetID(), @@ -172,3 +178,55 @@ func (qs *QkdnManagerServer) handleHttpAkmsInterface(w http.ResponseWriter, r *h logrus.Error(err) } } + +func (qs *QkdnManagerServer) handleSetKeyStore(w http.ResponseWriter, r *http.Request) { + logrus.Debugf("Handler for SetKeyStore got request from: %s", r.RemoteAddr) + + err := r.ParseForm() + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + keyFillLevel := r.Form.Get("KeyFillLevel") + peerIDs, ok := r.Form["PeerIds"] + if !ok { + http.Error(w, fmt.Sprintf("No peer IDs provided."), http.StatusBadRequest) + return + } + fetch := r.Form.Get("Fetch") + + logrus.Debugf("KeyFillLevel: %s, PeerIDs: %v, Fetch: %s", keyFillLevel, peerIDs, fetch) + + for _, peerID := range peerIDs { + peerUUID, err := uuid.Parse(peerID) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + peer, err := qs.kms.FindPeerById(peerUUID.String()) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + eqm, ok := peer.QuantumModule().(*peers.ETSI014HTTPQuantumModule) + if !ok { + http.Error(w, fmt.Sprintf("QuantumModule is not of Type ETSI014"), http.StatusBadRequest) + return + } + if fetch == "true" { + if err := eqm.Initialize(); err != nil { + http.Error(w, fmt.Sprintf("Failed to restart fetching for quantum module of peer: %s", peerID), http.StatusBadRequest) + return + } + } else if fetch == "false" { + eqm.Reset() + } + } + + w.WriteHeader(http.StatusOK) + _, err = w.Write([]byte("OK\n")) + if err != nil { + logrus.Error(err) + } +} diff --git a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go index 8fcc70042d87d4cdaf3fb3fbf01d238f3e95f8f4..f0e36b6de8afc130f152c96d1e4253cc78ba3496 100644 --- a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go +++ b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go @@ -193,7 +193,7 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo err = json.Unmarshal(body, &logFile2) if err != nil { - t.Errorf("Error parsing body into PushKSAKeyRequest: %s", err) + t.Errorf("Error parsing logFile answer from AKMS: %s. \n Most likely the AKMS never received a ksa key. It told us: %s", err, string(body)) return } assert.NotNil(t, logFile2.Source) diff --git a/integration-tests/code/integrationTestUtils/integrationTestUtils.go b/integration-tests/code/integrationTestUtils/integrationTestUtils.go index 03122ab70bbeee43d21fd2eb1184487646765dad..ce98b597af4caf1e537a723502105ace11f094aa 100644 --- a/integration-tests/code/integrationTestUtils/integrationTestUtils.go +++ b/integration-tests/code/integrationTestUtils/integrationTestUtils.go @@ -24,3 +24,17 @@ func RunGosdncScript(script string, controllerURL string) (string, error) { return outputString, err } + +// Supports only kms00 to kms09. +func RestartKMS(dockerComposeFilePath string, kmsNumber int) error { + cmd := exec.Command("docker-compose", "-f", dockerComposeFilePath, "restart", fmt.Sprintf("kms0%d", kmsNumber)) + + output, err := cmd.CombinedOutput() + outputString := string(output) + + if strings.Contains(outputString, "error") || strings.Contains(outputString, "ERROR") || err != nil { + err = fmt.Errorf("error in output: %s", outputString) + } + + return err +} diff --git a/integration-tests/code/testRestartOfKMSTest/testRestartOfKMS_test.go b/integration-tests/code/testRestartOfKMSTest/testRestartOfKMS_test.go new file mode 100644 index 0000000000000000000000000000000000000000..9e97686c80580fb9b7e945b1b764f81b55f52128 --- /dev/null +++ b/integration-tests/code/testRestartOfKMSTest/testRestartOfKMS_test.go @@ -0,0 +1,248 @@ +package integration_tests + +import ( + "bytes" + "encoding/json" + "fmt" + "time" + + "io" + "net/http" + "os" + "testing" + + "code.fbi.h-da.de/danet/quant/goKMS/config" + kmstls "code.fbi.h-da.de/danet/quant/goKMS/kms/tls" + utils "code.fbi.h-da.de/danet/quant/integration-tests/code/integrationTestUtils" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" +) + +// For log file. +type LogFile struct { + Source string `json:"source"` + Body PushKSAKeyRequest `json:"body"` +} +type PushKSAKeyRequest struct { + RequestID string `json:"request_ID"` + ProcessID string `json:"process_ID"` + KSAKeys []KSAKey `json:"ksa_keys"` +} + +type KSAKey struct { + KeyID string `json:"key_ID"` + Key string `json:"key"` +} + +// For request. +type KeyProperties struct { + Number int `json:"number"` + KeyLength int `json:"key_length"` + Timeout int `json:"timeout"` + TTL int `json:"TTL"` +} + +type RequestData struct { + ReceivingCKMSID string `json:"receiving_CKMS_ID"` + RequestID string `json:"request_ID"` + KeyProperties KeyProperties `json:"key_properties"` +} + +func TestRestartOfKMS(t *testing.T) { //nolint:gocyclo + gosdncScript := "../../config/gosdnc/add_devices.sh" + gosdncScript_ENV := os.Getenv("INTEGRATION_TEST_GOSDNC_SCRIPT") + if gosdncScript_ENV != "" { + gosdncScript = gosdncScript_ENV + } + cleanupScript := "../../config/gosdnc/delete_devices.sh" + cleanupScript_ENV := os.Getenv("INTEGRATION_TEST_CLEANUP_SCRIPT") + if cleanupScript_ENV != "" { + cleanupScript = cleanupScript_ENV + } + controllerURL := "127.0.0.1:55055" + controllerURL_ENV := os.Getenv("INTEGRATION_TEST_CONTROLLER_URL") + if controllerURL_ENV != "" { + controllerURL = controllerURL_ENV + } + kms1AkmsURL := "127.0.0.1:9696" + kms1AkmsURL_ENV := os.Getenv("INTEGRATION_TEST_KMS1_AKMS_URL") + if kms1AkmsURL_ENV != "" { + kms1AkmsURL = kms1AkmsURL_ENV + } + logFileURL := "127.0.0.1:4444" + logFileURL_ENV := os.Getenv("INTEGRATION_TEST_LOG_FILE1_URL") + if logFileURL_ENV != "" { + logFileURL = logFileURL_ENV + } + logFileURL2 := "127.0.0.1:4445" + logFileURL_ENV2 := os.Getenv("INTEGRATION_TEST_LOG_FILE2_URL") + if logFileURL_ENV2 != "" { + logFileURL2 = logFileURL_ENV2 + } + + // Tell the qkdn-controller what devices to use. + _, err := utils.RunGosdncScript(gosdncScript, controllerURL) + if err != nil { + currentFolderPath := os.Getenv("PWD") + t.Errorf("Error running gosdnc script. Current folder path: %s, Error: %s", currentFolderPath, err) + } + defer utils.RunGosdncScript(cleanupScript, controllerURL) //nolint:errcheck + + clients := getHttpClients(t) + + for testRun := range []int{0, 1} { + cleanupLogFiles(t, clients, []string{logFileURL, logFileURL2}) + requestId := uuid.New().String() + + url := fmt.Sprintf("https://%s/api/v1/keys/ksa_key_req", kms1AkmsURL) + data := RequestData{ + ReceivingCKMSID: "5e41c291-6121-4335-84f6-41e04b8bdaa2", + RequestID: requestId, + KeyProperties: KeyProperties{ + Number: 1, + KeyLength: 256, + Timeout: 20, + TTL: 24, + }, + } + + jsonData, err := json.Marshal(data) + if err != nil { + fmt.Println(err) + return + } + + resp, err := clients[0].Post(url, "application/json", bytes.NewBuffer(jsonData)) + if err != nil { + t.Errorf("Error making HTTP request: %s", err) + return + } + defer resp.Body.Close() //nolint:errcheck + + if resp.StatusCode != http.StatusNoContent { + t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode) + } + + // Get logfile of akms + resp, err = clients[0].Get("https://" + logFileURL + "/debug/get_log_file") + if err != nil { + t.Errorf("Error making HTTP request: %s", err) + return + } + defer resp.Body.Close() //nolint:errcheck + + body, err := io.ReadAll(resp.Body) + if err != nil { + t.Errorf("Error reading response body: %s", err) + return + } + + var logFile LogFile + err = json.Unmarshal(body, &logFile) + if err != nil { + t.Errorf("Error parsing logFile answer from AKMS: %s. \n Most likely the AKMS never received a ksa key. It told us: %s", err, string(body)) + return + } + assert.NotNil(t, logFile.Source) + assert.Equal(t, requestId, logFile.Body.RequestID) + assert.NotNil(t, logFile.Body.ProcessID) + assert.Equal(t, 1, len(logFile.Body.KSAKeys)) + assert.NotNil(t, logFile.Body.KSAKeys[0].KeyID) + assert.NotNil(t, logFile.Body.KSAKeys[0].Key) + + time.Sleep(5 * time.Second) + resp, err = clients[1].Get("https://" + logFileURL2 + "/debug/get_log_file") + if err != nil { + t.Errorf("Error making HTTP request: %s", err) + return + } + defer resp.Body.Close() //nolint:errcheck + + body, err = io.ReadAll(resp.Body) + if err != nil { + t.Errorf("Error reading response body: %s", err) + return + } + var logFile2 LogFile + + err = json.Unmarshal(body, &logFile2) + if err != nil { + t.Errorf("Error parsing logFile answer from AKMS: %s. \n Most likely the AKMS never received a ksa key. It told us: %s", err, string(body)) + return + } + assert.NotNil(t, logFile2.Source) + assert.Equal(t, requestId, logFile2.Body.RequestID) + assert.NotNil(t, logFile2.Body.ProcessID) + assert.Equal(t, 1, len(logFile2.Body.KSAKeys)) + assert.NotNil(t, logFile2.Body.KSAKeys[0].KeyID) + assert.NotNil(t, logFile2.Body.KSAKeys[0].Key) + + // Check that both log files are identical except for the source. + assert.NotEqual(t, logFile.Source, logFile2.Source) + assert.Equal(t, logFile.Body.RequestID, logFile2.Body.RequestID) + assert.Equal(t, logFile.Body.ProcessID, logFile2.Body.ProcessID) + assert.Equal(t, logFile.Body.KSAKeys[0].KeyID, logFile2.Body.KSAKeys[0].KeyID) + assert.Equal(t, logFile.Body.KSAKeys[0].Key, logFile2.Body.KSAKeys[0].Key) + + if testRun == 0 { + // Restart KMS1 + err = utils.RestartKMS("../../docker-compose.yml", 2) + if err != nil { + t.Errorf("Error restarting KMS: %s", err) + return + } + time.Sleep(10 * time.Second) + } + } +} + +func getHttpClients(t *testing.T) []*http.Client { + // Get the clients for the two AKMS simulators. + // AKMS1 + tlsConfig := config.TLSConfig{ + Active: true, + CAFile: "../../../artifacts/integration-tests/ssl/ca.crt", + CertFile: "../../../artifacts/integration-tests/ssl/kms/kms1-selfsigned.crt", + KeyFile: "../../../artifacts/integration-tests/ssl/kms/kms1-selfsigned.key", + } + + tlsConf, err := kmstls.GenerateTLSLibraryConfig(tlsConfig) + if err != nil { + t.Errorf("Error generating TLS config: %s", err) + } + transport := &http.Transport{ + TLSClientConfig: tlsConf, + } + client1 := &http.Client{Transport: transport} + + // AKMS2 + tlsConfig = config.TLSConfig{ + Active: true, + CAFile: "../../../artifacts/integration-tests/ssl/ca.crt", + CertFile: "../../../artifacts/integration-tests/ssl/kms/kms2-selfsigned.crt", + KeyFile: "../../../artifacts/integration-tests/ssl/kms/kms2-selfsigned.key", + } + + tlsConf, err = kmstls.GenerateTLSLibraryConfig(tlsConfig) + if err != nil { + t.Errorf("Error generating TLS config: %s", err) + } + transport = &http.Transport{ + TLSClientConfig: tlsConf, + } + client2 := &http.Client{Transport: transport} + + return []*http.Client{client1, client2} +} + +func cleanupLogFiles(t *testing.T, clients []*http.Client, logFileURLs []string) { + for i, url := range logFileURLs { + // Make sure logFiles for akms_simulator_1 don't exist. + request, _ := http.NewRequest("DELETE", "https://"+url+"/debug/get_log_file", nil) + _, err := clients[i].Do(request) + if err != nil { + t.Errorf("Error making HTTP request: %s", err) + return + } + } +} diff --git a/integration-tests/config/gosdnc/add_devices.sh b/integration-tests/config/gosdnc/add_devices.sh index fac6c4f05e474d2aa7e049acfaa273bd733206f8..377fc421c5c8d278b129b12a4ac641bc0b3a993e 100755 --- a/integration-tests/config/gosdnc/add_devices.sh +++ b/integration-tests/config/gosdnc/add_devices.sh @@ -6,7 +6,7 @@ GOSDNC_PATH="../../../artifacts/gosdnc" CONTROLLER_ADDRESS=$1 ADMINPW="TestPassword" -KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +KMS_PLUGIN="e404ecf7-4860-41ee-9cee-3dd6af6c5e2b" PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" cd ../../config/gosdnc diff --git a/integration-tests/config/gosdnc/delete_devices.sh b/integration-tests/config/gosdnc/delete_devices.sh index 2d5955ec1c56407e79ed0e871b7fed2502a73450..b5f05838152f2a5f019f4cd3c0a7ccbde2bb9020 100755 --- a/integration-tests/config/gosdnc/delete_devices.sh +++ b/integration-tests/config/gosdnc/delete_devices.sh @@ -3,7 +3,7 @@ GOSDNC_PATH="../../../artifacts/gosdnc" GOSDN_ADDRESS=$1 ADMINPW="TestPassword" -KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +KMS_PLUGIN="e404ecf7-4860-41ee-9cee-3dd6af6c5e2b" PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" cd ../../config/gosdnc diff --git a/quantumlayer/quantumlayer-emulator.go b/quantumlayer/quantumlayer-emulator.go index 644306784330861ae972fcca6ae62f0fd0968cf5..e4766318989ae9413b3a1aa59682c765f75b8167 100644 --- a/quantumlayer/quantumlayer-emulator.go +++ b/quantumlayer/quantumlayer-emulator.go @@ -38,10 +38,15 @@ func (ql *QuantumlayerEmulator) Start() { logrus.Error("Error generating random numbers: ", err) continue } - err = ql.sendDatatoKMS(data, length, iteration) - if err != nil { - logrus.Error("Error sending data to KMS: ", err) - continue + + for { + err = ql.sendDatatoKMS(data, length, iteration) + if err != nil { + logrus.Error("Error sending data to KMS, will retry: ", err) + time.Sleep(1 * time.Second) + continue + } + break } logrus.Infof("Iteration %d: Sent %d bytes to KMS", iteration, length) iteration++