Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proto Kms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
Proto Kms
Commits
c15cc8c3
Commit
c15cc8c3
authored
1 year ago
by
Martin Stiemerling
Browse files
Options
Downloads
Patches
Plain Diff
Removing stupid mistakes in scoping.
parent
0e7b5d2d
Branches
Branches containing commit
No related tags found
1 merge request
!9
First working draft version
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
kms/kms.go
+9
-9
9 additions, 9 deletions
kms/kms.go
kms/kmsetsi.go
+2
-2
2 additions, 2 deletions
kms/kmsetsi.go
kmsetsiproto/kmsetsiproto_grpc.pb.go
+14
-14
14 additions, 14 deletions
kmsetsiproto/kmsetsiproto_grpc.pb.go
main_test.go
+1
-1
1 addition, 1 deletion
main_test.go
with
26 additions
and
26 deletions
kms/kms.go
+
9
−
9
View file @
c15cc8c3
...
...
@@ -28,7 +28,7 @@ type qlElementId uint64
type
qlElementLinkID
int
// The general emulated KMS
type
e
KMS
struct
{
type
E
KMS
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
e
KMS is talking to
// Will keep information about the quantum elements that this
E
KMS 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
New
e
KMS
(
kmsName
string
,
kmsUUID
uuid
.
UUID
)
(
new
ekms
*
e
KMS
)
{
func
New
E
KMS
(
kmsName
string
,
kmsUUID
uuid
.
UUID
)
(
new
EKMS
*
E
KMS
)
{
return
&
e
KMS
{
return
&
E
KMS
{
kmsName
:
kmsName
,
kmsUUID
:
kmsUUID
,
QuantumElements
:
make
(
map
[
qlElementId
]
*
QuantumElement
),
...
...
@@ -59,7 +59,7 @@ func NeweKMS(kmsName string, kmsUUID uuid.UUID) (newekms *eKMS) {
}
}
func
(
kms
*
e
KMS
)
AddQuantumElement
(
kmsUDPAddrr
string
)
*
QuantumElement
{
func
(
kms
*
E
KMS
)
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
*
e
KMS
)
GlobalKeyHandler
(
waitTime
time
.
Duration
)
error
{
func
(
kms
*
E
KMS
)
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
*
e
KMS
)
GenerateNewQleID
()
(
qlElementId
,
error
)
{
func
(
kms
*
E
KMS
)
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
*
e
KMS
)
AddPeer
(
kmsPeerSocket
string
,
servingQLE
*
QuantumElement
)
{
func
(
kms
*
E
KMS
)
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
*
e
KMS
)
RemovePeer
(
kmsPeerSocket
string
)
{
func
(
kms
*
E
KMS
)
RemovePeer
(
kmsPeerSocket
string
)
{
}
This diff is collapsed.
Click to expand it.
kms/kmsetsi.go
+
2
−
2
View file @
c15cc8c3
...
...
@@ -18,7 +18,7 @@ var (
type
etsiServer
struct
{
pb
.
UnimplementedKmsETSIServer
handlingEkms
*
e
KMS
handlingEkms
*
E
KMS
}
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
*
e
KMS
)
{
func
StartETSI
(
listenAddr
string
,
callingKMS
*
E
KMS
)
{
flag
.
Parse
()
//lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *etsiPort))
...
...
This diff is collapsed.
Click to expand it.
kmsetsiproto/kmsetsiproto_grpc.pb.go
+
14
−
14
View file @
c15cc8c3
...
...
@@ -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
)
ETSIRemov
e
KMSPeer
(
ctx
context
.
Context
,
in
*
ETSIKMSPeerRequest
,
opts
...
grpc
.
CallOption
)
(
*
ETSIKMSPeerReply
,
error
)
ETSIRemov
E
KMSPeer
(
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
)
ETSIRemov
e
KMSPeer
(
ctx
context
.
Context
,
in
*
ETSIKMSPeerRequest
,
opts
...
grpc
.
CallOption
)
(
*
ETSIKMSPeerReply
,
error
)
{
func
(
c
*
kmsETSIClient
)
ETSIRemov
E
KMSPeer
(
ctx
context
.
Context
,
in
*
ETSIKMSPeerRequest
,
opts
...
grpc
.
CallOption
)
(
*
ETSIKMSPeerReply
,
error
)
{
out
:=
new
(
ETSIKMSPeerReply
)
err
:=
c
.
cc
.
Invoke
(
ctx
,
"/kmsetsiproto.KmsETSI/ETSIRemov
e
KMSPeer"
,
in
,
out
,
opts
...
)
err
:=
c
.
cc
.
Invoke
(
ctx
,
"/kmsetsiproto.KmsETSI/ETSIRemov
E
KMSPeer"
,
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
)
ETSIRemov
e
KMSPeer
(
context
.
Context
,
*
ETSIKMSPeerRequest
)
(
*
ETSIKMSPeerReply
,
error
)
ETSIRemov
E
KMSPeer
(
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
)
ETSIRemov
e
KMSPeer
(
context
.
Context
,
*
ETSIKMSPeerRequest
)
(
*
ETSIKMSPeerReply
,
error
)
{
return
nil
,
status
.
Errorf
(
codes
.
Unimplemented
,
"method ETSIRemov
e
KMSPeer not implemented"
)
func
(
UnimplementedKmsETSIServer
)
ETSIRemov
E
KMSPeer
(
context
.
Context
,
*
ETSIKMSPeerRequest
)
(
*
ETSIKMSPeerReply
,
error
)
{
return
nil
,
status
.
Errorf
(
codes
.
Unimplemented
,
"method ETSIRemov
E
KMSPeer 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
()
{}
// Unsaf
eKms
ETSIServer may be embedded to opt out of forward compatibility for this service.
// Unsaf
EKMS
ETSIServer 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
Unsaf
eKms
ETSIServer
interface
{
type
Unsaf
EKMS
ETSIServer
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_ETSIRemov
e
KMSPeer_Handler
(
srv
interface
{},
ctx
context
.
Context
,
dec
func
(
interface
{})
error
,
interceptor
grpc
.
UnaryServerInterceptor
)
(
interface
{},
error
)
{
func
_KmsETSI_ETSIRemov
E
KMSPeer_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
)
.
ETSIRemov
e
KMSPeer
(
ctx
,
in
)
return
srv
.
(
KmsETSIServer
)
.
ETSIRemov
E
KMSPeer
(
ctx
,
in
)
}
info
:=
&
grpc
.
UnaryServerInfo
{
Server
:
srv
,
FullMethod
:
"/kmsetsiproto.KmsETSI/ETSIRemov
e
KMSPeer"
,
FullMethod
:
"/kmsetsiproto.KmsETSI/ETSIRemov
E
KMSPeer"
,
}
handler
:=
func
(
ctx
context
.
Context
,
req
interface
{})
(
interface
{},
error
)
{
return
srv
.
(
KmsETSIServer
)
.
ETSIRemov
e
KMSPeer
(
ctx
,
req
.
(
*
ETSIKMSPeerRequest
))
return
srv
.
(
KmsETSIServer
)
.
ETSIRemov
E
KMSPeer
(
ctx
,
req
.
(
*
ETSIKMSPeerRequest
))
}
return
interceptor
(
ctx
,
in
,
info
,
handler
)
}
...
...
@@ -270,8 +270,8 @@ var KmsETSI_ServiceDesc = grpc.ServiceDesc{
Handler
:
_KmsETSI_ETSIAddKMSPeer_Handler
,
},
{
MethodName
:
"ETSIRemov
e
KMSPeer"
,
Handler
:
_KmsETSI_ETSIRemov
e
KMSPeer_Handler
,
MethodName
:
"ETSIRemov
E
KMSPeer"
,
Handler
:
_KmsETSI_ETSIRemov
E
KMSPeer_Handler
,
},
{
MethodName
:
"ETSIGetPeerList"
,
...
...
This diff is collapsed.
Click to expand it.
main_test.go
+
1
−
1
View file @
c15cc8c3
...
...
@@ -63,7 +63,7 @@ func TestMain(m *testing.M) {
func
emulatedKMS
(
myName
string
,
myUDPAddr
string
,
peerUDPAddr
string
)
{
// Attach to eKMS
emuKMS
:=
kms
.
New
e
KMS
(
myName
,
uuid
.
New
())
emuKMS
:=
kms
.
New
E
KMS
(
myName
,
uuid
.
New
())
// Fire up Quantum LinK
myQL
:=
emuKMS
.
AddQuantumElement
(
myUDPAddr
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment