Skip to content
Snippets Groups Projects
Commit c15cc8c3 authored by Martin Stiemerling's avatar Martin Stiemerling :speech_balloon:
Browse files

Removing stupid mistakes in scoping.

parent 0e7b5d2d
No related branches found
No related tags found
1 merge request!9First working draft version
...@@ -28,7 +28,7 @@ type qlElementId uint64 ...@@ -28,7 +28,7 @@ type qlElementId uint64
type qlElementLinkID int type qlElementLinkID int
// The general emulated KMS // The general emulated KMS
type eKMS struct { type EKMS struct {
kmsName string kmsName string
kmsUUID uuid.UUID kmsUUID uuid.UUID
qleMapMutex sync.Mutex qleMapMutex sync.Mutex
...@@ -39,7 +39,7 @@ type eKMS struct { ...@@ -39,7 +39,7 @@ type eKMS struct {
pbIC.UnimplementedKmsTalkerServer pbIC.UnimplementedKmsTalkerServer
} }
// Will keep information about the quantum elements that this eKMS is talking to // Will keep information about the quantum elements that this EKMS is talking to
// This actually constitutes a quantum element with only a single link // This actually constitutes a quantum element with only a single link
type QuantumElement struct { type QuantumElement struct {
qlID qlElementId qlID qlElementId
...@@ -49,9 +49,9 @@ type QuantumElement struct { ...@@ -49,9 +49,9 @@ type QuantumElement struct {
keyStoreRemote *kmsKeyStore // the keys th remote entity (peer) has produced and are ready to use keyStoreRemote *kmsKeyStore // the keys th remote entity (peer) has produced and are ready to use
} }
func NeweKMS(kmsName string, kmsUUID uuid.UUID) (newekms *eKMS) { func NewEKMS(kmsName string, kmsUUID uuid.UUID) (newEKMS *EKMS) {
return &eKMS{ return &EKMS{
kmsName: kmsName, kmsName: kmsName,
kmsUUID: kmsUUID, kmsUUID: kmsUUID,
QuantumElements: make(map[qlElementId]*QuantumElement), QuantumElements: make(map[qlElementId]*QuantumElement),
...@@ -59,7 +59,7 @@ func NeweKMS(kmsName string, kmsUUID uuid.UUID) (newekms *eKMS) { ...@@ -59,7 +59,7 @@ func NeweKMS(kmsName string, kmsUUID uuid.UUID) (newekms *eKMS) {
} }
} }
func (kms *eKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement { func (kms *EKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement {
//Get an emulated Quantumlayer //Get an emulated Quantumlayer
ql := quantumlayer.NewQuantumlayerEmuPRNG() ql := quantumlayer.NewQuantumlayerEmuPRNG()
...@@ -91,7 +91,7 @@ func (kms *eKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement { ...@@ -91,7 +91,7 @@ func (kms *eKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement {
return &qle return &qle
} }
func (kms *eKMS) GlobalKeyHandler(waitTime time.Duration) error { func (kms *EKMS) GlobalKeyHandler(waitTime time.Duration) error {
// periodically walk through QuantumElements and retrieve their // periodically walk through QuantumElements and retrieve their
// - local key bulk buffer // - local key bulk buffer
...@@ -127,7 +127,7 @@ func (kms *eKMS) GlobalKeyHandler(waitTime time.Duration) error { ...@@ -127,7 +127,7 @@ func (kms *eKMS) GlobalKeyHandler(waitTime time.Duration) error {
// This has a design flaw, as the generated ID is returned to the calling function and used there. // This has a design flaw, as the generated ID is returned to the calling function and used there.
// However, when being used a potential other caller might received the same qlElementId // However, when being used a potential other caller might received the same qlElementId
// TODO/XXX: This would be collision and must be eventually avoided // TODO/XXX: This would be collision and must be eventually avoided
func (kms *eKMS) GenerateNewQleID() (qlElementId, error) { func (kms *EKMS) GenerateNewQleID() (qlElementId, error) {
for { // this needs a condiction to stop! for { // this needs a condiction to stop!
bigRand, randError := rand.Int(rand.Reader, big.NewInt(100000)) bigRand, randError := rand.Int(rand.Reader, big.NewInt(100000))
if randError != nil { if randError != nil {
...@@ -145,7 +145,7 @@ func (kms *eKMS) GenerateNewQleID() (qlElementId, error) { ...@@ -145,7 +145,7 @@ func (kms *eKMS) GenerateNewQleID() (qlElementId, error) {
} }
// TODO/XXX error handling // TODO/XXX error handling
func (kms *eKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) { func (kms *EKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) {
//check if peer exists //check if peer exists
if _, there := kms.KmsPeers[kmsPeerSocket]; there { if _, there := kms.KmsPeers[kmsPeerSocket]; there {
log.Fatalf("Trying to add existing peer %s", kmsPeerSocket) log.Fatalf("Trying to add existing peer %s", kmsPeerSocket)
...@@ -161,6 +161,6 @@ func (kms *eKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) { ...@@ -161,6 +161,6 @@ func (kms *eKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) {
} }
// TODO/XXX error handling // TODO/XXX error handling
func (kms *eKMS) RemovePeer(kmsPeerSocket string) { func (kms *EKMS) RemovePeer(kmsPeerSocket string) {
} }
...@@ -18,7 +18,7 @@ var ( ...@@ -18,7 +18,7 @@ var (
type etsiServer struct { type etsiServer struct {
pb.UnimplementedKmsETSIServer pb.UnimplementedKmsETSIServer
handlingEkms *eKMS handlingEkms *EKMS
} }
func (es *etsiServer) ETSICapabilities(ctx context.Context, in *pb.ETSICapabilitiesRequest) (capReply *pb.ETSICapabilitiesReply, err error) { func (es *etsiServer) ETSICapabilities(ctx context.Context, in *pb.ETSICapabilitiesRequest) (capReply *pb.ETSICapabilitiesReply, err error) {
...@@ -104,7 +104,7 @@ func (es *etsiServer) GetEncryptKeys256Bit(ctx context.Context, in *pb.ETSIGetEn ...@@ -104,7 +104,7 @@ func (es *etsiServer) GetEncryptKeys256Bit(ctx context.Context, in *pb.ETSIGetEn
}, nil }, nil
} }
func StartETSI(listenAddr string, callingKMS *eKMS) { func StartETSI(listenAddr string, callingKMS *EKMS) {
flag.Parse() flag.Parse()
//lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *etsiPort)) //lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *etsiPort))
......
...@@ -26,7 +26,7 @@ type KmsETSIClient interface { ...@@ -26,7 +26,7 @@ type KmsETSIClient interface {
ETSICapabilities(ctx context.Context, in *ETSICapabilitiesRequest, opts ...grpc.CallOption) (*ETSICapabilitiesReply, error) ETSICapabilities(ctx context.Context, in *ETSICapabilitiesRequest, opts ...grpc.CallOption) (*ETSICapabilitiesReply, error)
ETSIGetQuantumInterfaces(ctx context.Context, in *ETSIKMSQuantumInterfaceListRequest, opts ...grpc.CallOption) (*ETSIKMSQuantumInterfaceListReply, error) ETSIGetQuantumInterfaces(ctx context.Context, in *ETSIKMSQuantumInterfaceListRequest, opts ...grpc.CallOption) (*ETSIKMSQuantumInterfaceListReply, error)
ETSIAddKMSPeer(ctx context.Context, in *ETSIKMSPeerRequest, opts ...grpc.CallOption) (*ETSIKMSPeerReply, error) ETSIAddKMSPeer(ctx context.Context, in *ETSIKMSPeerRequest, opts ...grpc.CallOption) (*ETSIKMSPeerReply, error)
ETSIRemoveKMSPeer(ctx context.Context, in *ETSIKMSPeerRequest, opts ...grpc.CallOption) (*ETSIKMSPeerReply, error) ETSIRemovEKMSPeer(ctx context.Context, in *ETSIKMSPeerRequest, opts ...grpc.CallOption) (*ETSIKMSPeerReply, error)
ETSIGetPeerList(ctx context.Context, in *ETSIKMSPeerListRequest, opts ...grpc.CallOption) (*ETSIKMSPeerListReply, error) ETSIGetPeerList(ctx context.Context, in *ETSIKMSPeerListRequest, opts ...grpc.CallOption) (*ETSIKMSPeerListReply, error)
ETSIGetEncryptKeys256Bit(ctx context.Context, in *ETSIGetEncryptKeys256BitRequest, opts ...grpc.CallOption) (*ETSIGetEncryptKeys256BitReply, error) ETSIGetEncryptKeys256Bit(ctx context.Context, in *ETSIGetEncryptKeys256BitRequest, opts ...grpc.CallOption) (*ETSIGetEncryptKeys256BitReply, error)
} }
...@@ -66,9 +66,9 @@ func (c *kmsETSIClient) ETSIAddKMSPeer(ctx context.Context, in *ETSIKMSPeerReque ...@@ -66,9 +66,9 @@ func (c *kmsETSIClient) ETSIAddKMSPeer(ctx context.Context, in *ETSIKMSPeerReque
return out, nil return out, nil
} }
func (c *kmsETSIClient) ETSIRemoveKMSPeer(ctx context.Context, in *ETSIKMSPeerRequest, opts ...grpc.CallOption) (*ETSIKMSPeerReply, error) { func (c *kmsETSIClient) ETSIRemovEKMSPeer(ctx context.Context, in *ETSIKMSPeerRequest, opts ...grpc.CallOption) (*ETSIKMSPeerReply, error) {
out := new(ETSIKMSPeerReply) out := new(ETSIKMSPeerReply)
err := c.cc.Invoke(ctx, "/kmsetsiproto.KmsETSI/ETSIRemoveKMSPeer", in, out, opts...) err := c.cc.Invoke(ctx, "/kmsetsiproto.KmsETSI/ETSIRemovEKMSPeer", in, out, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -101,7 +101,7 @@ type KmsETSIServer interface { ...@@ -101,7 +101,7 @@ type KmsETSIServer interface {
ETSICapabilities(context.Context, *ETSICapabilitiesRequest) (*ETSICapabilitiesReply, error) ETSICapabilities(context.Context, *ETSICapabilitiesRequest) (*ETSICapabilitiesReply, error)
ETSIGetQuantumInterfaces(context.Context, *ETSIKMSQuantumInterfaceListRequest) (*ETSIKMSQuantumInterfaceListReply, error) ETSIGetQuantumInterfaces(context.Context, *ETSIKMSQuantumInterfaceListRequest) (*ETSIKMSQuantumInterfaceListReply, error)
ETSIAddKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) ETSIAddKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error)
ETSIRemoveKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) ETSIRemovEKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error)
ETSIGetPeerList(context.Context, *ETSIKMSPeerListRequest) (*ETSIKMSPeerListReply, error) ETSIGetPeerList(context.Context, *ETSIKMSPeerListRequest) (*ETSIKMSPeerListReply, error)
ETSIGetEncryptKeys256Bit(context.Context, *ETSIGetEncryptKeys256BitRequest) (*ETSIGetEncryptKeys256BitReply, error) ETSIGetEncryptKeys256Bit(context.Context, *ETSIGetEncryptKeys256BitRequest) (*ETSIGetEncryptKeys256BitReply, error)
mustEmbedUnimplementedKmsETSIServer() mustEmbedUnimplementedKmsETSIServer()
...@@ -120,8 +120,8 @@ func (UnimplementedKmsETSIServer) ETSIGetQuantumInterfaces(context.Context, *ETS ...@@ -120,8 +120,8 @@ func (UnimplementedKmsETSIServer) ETSIGetQuantumInterfaces(context.Context, *ETS
func (UnimplementedKmsETSIServer) ETSIAddKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) { func (UnimplementedKmsETSIServer) ETSIAddKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIAddKMSPeer not implemented") return nil, status.Errorf(codes.Unimplemented, "method ETSIAddKMSPeer not implemented")
} }
func (UnimplementedKmsETSIServer) ETSIRemoveKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) { func (UnimplementedKmsETSIServer) ETSIRemovEKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIRemoveKMSPeer not implemented") return nil, status.Errorf(codes.Unimplemented, "method ETSIRemovEKMSPeer not implemented")
} }
func (UnimplementedKmsETSIServer) ETSIGetPeerList(context.Context, *ETSIKMSPeerListRequest) (*ETSIKMSPeerListReply, error) { func (UnimplementedKmsETSIServer) ETSIGetPeerList(context.Context, *ETSIKMSPeerListRequest) (*ETSIKMSPeerListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIGetPeerList not implemented") return nil, status.Errorf(codes.Unimplemented, "method ETSIGetPeerList not implemented")
...@@ -131,10 +131,10 @@ func (UnimplementedKmsETSIServer) ETSIGetEncryptKeys256Bit(context.Context, *ETS ...@@ -131,10 +131,10 @@ func (UnimplementedKmsETSIServer) ETSIGetEncryptKeys256Bit(context.Context, *ETS
} }
func (UnimplementedKmsETSIServer) mustEmbedUnimplementedKmsETSIServer() {} func (UnimplementedKmsETSIServer) mustEmbedUnimplementedKmsETSIServer() {}
// UnsafeKmsETSIServer may be embedded to opt out of forward compatibility for this service. // UnsafEKMSETSIServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to KmsETSIServer will // Use of this interface is not recommended, as added methods to KmsETSIServer will
// result in compilation errors. // result in compilation errors.
type UnsafeKmsETSIServer interface { type UnsafEKMSETSIServer interface {
mustEmbedUnimplementedKmsETSIServer() mustEmbedUnimplementedKmsETSIServer()
} }
...@@ -196,20 +196,20 @@ func _KmsETSI_ETSIAddKMSPeer_Handler(srv interface{}, ctx context.Context, dec f ...@@ -196,20 +196,20 @@ func _KmsETSI_ETSIAddKMSPeer_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _KmsETSI_ETSIRemoveKMSPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _KmsETSI_ETSIRemovEKMSPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ETSIKMSPeerRequest) in := new(ETSIKMSPeerRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(KmsETSIServer).ETSIRemoveKMSPeer(ctx, in) return srv.(KmsETSIServer).ETSIRemovEKMSPeer(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/kmsetsiproto.KmsETSI/ETSIRemoveKMSPeer", FullMethod: "/kmsetsiproto.KmsETSI/ETSIRemovEKMSPeer",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(KmsETSIServer).ETSIRemoveKMSPeer(ctx, req.(*ETSIKMSPeerRequest)) return srv.(KmsETSIServer).ETSIRemovEKMSPeer(ctx, req.(*ETSIKMSPeerRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
...@@ -270,8 +270,8 @@ var KmsETSI_ServiceDesc = grpc.ServiceDesc{ ...@@ -270,8 +270,8 @@ var KmsETSI_ServiceDesc = grpc.ServiceDesc{
Handler: _KmsETSI_ETSIAddKMSPeer_Handler, Handler: _KmsETSI_ETSIAddKMSPeer_Handler,
}, },
{ {
MethodName: "ETSIRemoveKMSPeer", MethodName: "ETSIRemovEKMSPeer",
Handler: _KmsETSI_ETSIRemoveKMSPeer_Handler, Handler: _KmsETSI_ETSIRemovEKMSPeer_Handler,
}, },
{ {
MethodName: "ETSIGetPeerList", MethodName: "ETSIGetPeerList",
......
...@@ -63,7 +63,7 @@ func TestMain(m *testing.M) { ...@@ -63,7 +63,7 @@ func TestMain(m *testing.M) {
func emulatedKMS(myName string, myUDPAddr string, peerUDPAddr string) { func emulatedKMS(myName string, myUDPAddr string, peerUDPAddr string) {
// Attach to eKMS // Attach to eKMS
emuKMS := kms.NeweKMS(myName, uuid.New()) emuKMS := kms.NewEKMS(myName, uuid.New())
// Fire up Quantum LinK // Fire up Quantum LinK
myQL := emuKMS.AddQuantumElement(myUDPAddr) myQL := emuKMS.AddQuantumElement(myUDPAddr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment