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
80e9d9ca
Commit
80e9d9ca
authored
1 year ago
by
Martin Stiemerling
Browse files
Options
Downloads
Patches
Plain Diff
can be powered on and off
parent
fac33b3a
No related branches found
No related tags found
1 merge request
!9
First working draft version
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
kms/kms.go
+2
-1
2 additions, 1 deletion
kms/kms.go
quantumlayer/quantumlayer-emu-prng.go
+45
-30
45 additions, 30 deletions
quantumlayer/quantumlayer-emu-prng.go
quantumlayer/quantumlayer.go
+2
-1
2 additions, 1 deletion
quantumlayer/quantumlayer.go
with
49 additions
and
32 deletions
kms/kms.go
+
2
−
1
View file @
80e9d9ca
...
...
@@ -69,7 +69,8 @@ func (kms *EKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement {
//Get an emulated Quantumlayer
ql
:=
quantumlayer
.
NewQuantumlayerEmuPRNG
()
ql
.
PowerOn
(
kmsUDPAddrr
)
ql
.
Configure
(
kmsUDPAddrr
)
ql
.
PowerOn
()
ksl
:=
kmsKeyStore
{
keyStore
:
make
(
map
[
string
]
kmsKSElement
),
...
...
This diff is collapsed.
Click to expand it.
quantumlayer/quantumlayer-emu-prng.go
+
45
−
30
View file @
80e9d9ca
...
...
@@ -29,11 +29,13 @@ type QuantumPayloadElement struct {
}
type
QuantumlayerEmuPRNG
struct
{
configured
bool
poweron
bool
incomingRandNums
chan
QuantumPayloadElement
outgoingRandNums
chan
QuantumPayloadElement
peerNumbers
*
NumberStore
myNumbers
*
NumberStore
localQLAddress
string
udpSrvConn
*
net
.
UDPConn
qlPeer
string
qlPeerCancel
context
.
CancelFunc
...
...
@@ -43,6 +45,7 @@ type QuantumlayerEmuPRNG struct {
func
NewQuantumlayerEmuPRNG
()
(
newql
*
QuantumlayerEmuPRNG
)
{
return
&
QuantumlayerEmuPRNG
{
configured
:
false
,
poweron
:
false
,
incomingRandNums
:
make
(
chan
QuantumPayloadElement
),
outgoingRandNums
:
make
(
chan
QuantumPayloadElement
),
...
...
@@ -52,31 +55,41 @@ func NewQuantumlayerEmuPRNG() (newql *QuantumlayerEmuPRNG) {
}
}
// Power on the quantum layer, i.e., open up the communication ports for the
// other quantum module
func
(
qlemuprng
*
QuantumlayerEmuPRNG
)
PowerOn
(
localQLAddress
...
string
)
{
qlemuprng
.
poweron
=
false
log
.
Println
(
"QuantumlayerEmuPRNG is powering on...charging."
)
// Configure the quantum emulation, but do not start if yet
func
(
qlemuprng
*
QuantumlayerEmuPRNG
)
Configure
(
localQLAddress
...
string
)
{
// Start receiving numberstores
go
qlemuprng
.
peerNumbers
.
receiveNumbers
(
qlemuprng
.
incomingRandNums
)
go
qlemuprng
.
myNumbers
.
receiveNumbers
(
qlemuprng
.
outgoingRandNums
)
// Determine if a local UDP address should be used or not
if
len
(
localQLAddress
)
==
0
{
// No input
qlemuprng
.
localQLAddress
=
":0"
}
else
{
qlemuprng
.
localQLAddress
=
localQLAddress
[
0
]
}
qlemuprng
.
configured
=
true
}
// Power on the quantum layer, i.e., open up the communication ports for the
// other quantum module
func
(
qlemuprng
*
QuantumlayerEmuPRNG
)
PowerOn
()
{
if
qlemuprng
.
configured
==
false
{
// nothing do here move on
log
.
Printf
(
"Sorry, the quantum layer is not configured for action. You've missed Configure()"
)
return
}
qlemuprng
.
poweron
=
false
log
.
Println
(
"QuantumlayerEmuPRNG is powering on...charging."
)
// serve UDP incoming
go
func
()
{
// Get UDP server part going...
// Determine if a local UDP address should be used or not
var
udpAddrString
string
if
len
(
localQLAddress
)
==
0
{
// No input
udpAddrString
=
":0"
}
else
{
udpAddrString
=
localQLAddress
[
0
]
}
log
.
Printf
(
"localQLAddress is %s"
,
localQLAddress
[
0
])
log
.
Printf
(
"localQLAddress is %s"
,
qlemuprng
.
localQLAddress
)
// This reads random numbers from other Quantum end
udpSrvPort
,
err
:=
net
.
ResolveUDPAddr
(
"udp"
,
udpAddrString
)
udpSrvPort
,
err
:=
net
.
ResolveUDPAddr
(
"udp"
,
qlemuprng
.
localQLAddress
)
if
err
!=
nil
{
log
.
Fatalf
(
"QuantumlayerEmuPRNG UDP failure: %s"
,
err
)
return
...
...
@@ -158,23 +171,25 @@ func (qlemuprng *QuantumlayerEmuPRNG) AddPeer(addr net.UDPAddr) {
case
<-
ctx
.
Done
()
:
return
default
:
// retrieve a new back of random numbers
newNumberBatch
:=
qlemuprng
.
GenerateRandomNumbers
()
// TODO: Replace this by some generic encapsulation reader and not just JSON
//Get JSON for transmission ready
qpe
:=
QuantumPayloadElement
{
time
.
Now
()
.
UnixNano
(),
len
(
newNumberBatch
),
&
newNumberBatch
}
// XXX/TODO: error must be handled
jsonPayload
,
err
:=
json
.
Marshal
(
qpe
)
if
err
!=
nil
{
log
.
Printf
(
"json.Marshal error %s"
,
err
)
}
if
qlemuprng
.
poweron
==
true
{
// retrieve a new back of random numbers
newNumberBatch
:=
qlemuprng
.
GenerateRandomNumbers
()
// TODO: Replace this by some generic encapsulation reader and not just JSON
//Get JSON for transmission ready
qpe
:=
QuantumPayloadElement
{
time
.
Now
()
.
UnixNano
(),
len
(
newNumberBatch
),
&
newNumberBatch
}
// XXX/TODO: error must be handled
jsonPayload
,
err
:=
json
.
Marshal
(
qpe
)
if
err
!=
nil
{
log
.
Printf
(
"json.Marshal error %s"
,
err
)
}
_
,
_
,
err
=
qlemuprng
.
udpSrvConn
.
WriteMsgUDPAddrPort
(
jsonPayload
,
nil
,
addr
.
AddrPort
())
if
err
!=
nil
{
log
.
Fatalf
(
"WriteMsgUDPAddrPort failed: %s"
,
err
)
_
,
_
,
err
=
qlemuprng
.
udpSrvConn
.
WriteMsgUDPAddrPort
(
jsonPayload
,
nil
,
addr
.
AddrPort
())
if
err
!=
nil
{
log
.
Fatalf
(
"WriteMsgUDPAddrPort failed: %s"
,
err
)
}
qlemuprng
.
outgoingRandNums
<-
qpe
}
qlemuprng
.
outgoingRandNums
<-
qpe
time
.
Sleep
(
5
*
time
.
Second
)
}
}
...
...
This diff is collapsed.
Click to expand it.
quantumlayer/quantumlayer.go
+
2
−
1
View file @
80e9d9ca
...
...
@@ -11,7 +11,8 @@ type QuantumLayerBulkKey struct {
}
type
QuantumLayer
interface
{
PowerOn
(
...
string
)
// switch on the quantum layer element
Configure
(
...
string
)
// configure the interface, e.g., used IP/Port config if emulated
PowerOn
()
// switch on the quantum layer element
PowerOff
()
// switch off the quantum layer element
AddPeer
()
// Adds a Quantum Layer Peer to the peer list
RemovePeer
()
// Remmoves a Quantum Layer Peer to the peer list
...
...
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