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
Branches
No related tags found
1 merge request!9First working draft version
......@@ -28,7 +28,7 @@ type qlElementId uint64
type qlElementLinkID int
// The general emulated KMS
type eKMS struct {
type EKMS struct {
kmsName string
kmsUUID uuid.UUID
qleMapMutex sync.Mutex
......@@ -39,7 +39,7 @@ type eKMS struct {
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
type QuantumElement struct {
qlID qlElementId
......@@ -49,9 +49,9 @@ type QuantumElement struct {
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,
kmsUUID: kmsUUID,
QuantumElements: make(map[qlElementId]*QuantumElement),
......@@ -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
ql := quantumlayer.NewQuantumlayerEmuPRNG()
......@@ -91,7 +91,7 @@ func (kms *eKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement {
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
// - local key bulk buffer
......@@ -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.
// However, when being used a potential other caller might received the same qlElementId
// 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!
bigRand, randError := rand.Int(rand.Reader, big.NewInt(100000))
if randError != nil {
......@@ -145,7 +145,7 @@ func (kms *eKMS) GenerateNewQleID() (qlElementId, error) {
}
// TODO/XXX error handling
func (kms *eKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) {
func (kms *EKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) {
//check if peer exists
if _, there := kms.KmsPeers[kmsPeerSocket]; there {
log.Fatalf("Trying to add existing peer %s", kmsPeerSocket)
......@@ -161,6 +161,6 @@ func (kms *eKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) {
}
// TODO/XXX error handling
func (kms *eKMS) RemovePeer(kmsPeerSocket string) {
func (kms *EKMS) RemovePeer(kmsPeerSocket string) {
}
......@@ -18,7 +18,7 @@ var (
type etsiServer struct {
pb.UnimplementedKmsETSIServer
handlingEkms *eKMS
handlingEkms *EKMS
}
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
}, nil
}
func StartETSI(listenAddr string, callingKMS *eKMS) {
func StartETSI(listenAddr string, callingKMS *EKMS) {
flag.Parse()
//lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *etsiPort))
......
......@@ -26,7 +26,7 @@ type KmsETSIClient interface {
ETSICapabilities(ctx context.Context, in *ETSICapabilitiesRequest, opts ...grpc.CallOption) (*ETSICapabilitiesReply, error)
ETSIGetQuantumInterfaces(ctx context.Context, in *ETSIKMSQuantumInterfaceListRequest, opts ...grpc.CallOption) (*ETSIKMSQuantumInterfaceListReply, 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)
ETSIGetEncryptKeys256Bit(ctx context.Context, in *ETSIGetEncryptKeys256BitRequest, opts ...grpc.CallOption) (*ETSIGetEncryptKeys256BitReply, error)
}
......@@ -66,9 +66,9 @@ func (c *kmsETSIClient) ETSIAddKMSPeer(ctx context.Context, in *ETSIKMSPeerReque
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)
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 {
return nil, err
}
......@@ -101,7 +101,7 @@ type KmsETSIServer interface {
ETSICapabilities(context.Context, *ETSICapabilitiesRequest) (*ETSICapabilitiesReply, error)
ETSIGetQuantumInterfaces(context.Context, *ETSIKMSQuantumInterfaceListRequest) (*ETSIKMSQuantumInterfaceListReply, 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)
ETSIGetEncryptKeys256Bit(context.Context, *ETSIGetEncryptKeys256BitRequest) (*ETSIGetEncryptKeys256BitReply, error)
mustEmbedUnimplementedKmsETSIServer()
......@@ -120,8 +120,8 @@ func (UnimplementedKmsETSIServer) ETSIGetQuantumInterfaces(context.Context, *ETS
func (UnimplementedKmsETSIServer) ETSIAddKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIAddKMSPeer not implemented")
}
func (UnimplementedKmsETSIServer) ETSIRemoveKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIRemoveKMSPeer not implemented")
func (UnimplementedKmsETSIServer) ETSIRemovEKMSPeer(context.Context, *ETSIKMSPeerRequest) (*ETSIKMSPeerReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIRemovEKMSPeer not implemented")
}
func (UnimplementedKmsETSIServer) ETSIGetPeerList(context.Context, *ETSIKMSPeerListRequest) (*ETSIKMSPeerListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ETSIGetPeerList not implemented")
......@@ -131,10 +131,10 @@ func (UnimplementedKmsETSIServer) ETSIGetEncryptKeys256Bit(context.Context, *ETS
}
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
// result in compilation errors.
type UnsafeKmsETSIServer interface {
type UnsafEKMSETSIServer interface {
mustEmbedUnimplementedKmsETSIServer()
}
......@@ -196,20 +196,20 @@ func _KmsETSI_ETSIAddKMSPeer_Handler(srv interface{}, ctx context.Context, dec f
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(KmsETSIServer).ETSIRemoveKMSPeer(ctx, in)
return srv.(KmsETSIServer).ETSIRemovEKMSPeer(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/kmsetsiproto.KmsETSI/ETSIRemoveKMSPeer",
FullMethod: "/kmsetsiproto.KmsETSI/ETSIRemovEKMSPeer",
}
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)
}
......@@ -270,8 +270,8 @@ var KmsETSI_ServiceDesc = grpc.ServiceDesc{
Handler: _KmsETSI_ETSIAddKMSPeer_Handler,
},
{
MethodName: "ETSIRemoveKMSPeer",
Handler: _KmsETSI_ETSIRemoveKMSPeer_Handler,
MethodName: "ETSIRemovEKMSPeer",
Handler: _KmsETSI_ETSIRemovEKMSPeer_Handler,
},
{
MethodName: "ETSIGetPeerList",
......
......@@ -63,7 +63,7 @@ func TestMain(m *testing.M) {
func emulatedKMS(myName string, myUDPAddr string, peerUDPAddr string) {
// Attach to eKMS
emuKMS := kms.NeweKMS(myName, uuid.New())
emuKMS := kms.NewEKMS(myName, uuid.New())
// Fire up Quantum LinK
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