Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This package kms implements a simplistic key managment system (kms) for
// Quantum Key Distribution Networks (QKDN) which is a simple emulated KMS. x
// It relies on the emulated quantum link out of the quantumlayer package
package kms
import (
"code.fbi.h-da.de/m.stiemerling/proto-kms/quantumlayer"
"github.com/google/uuid"
)
type Qkdnkms interface {
AddQuantumElement() *QuantumElement
}
type qlElementId uuid.UUID
type qlElementLinkID int
// The general emulated KMS
type eKMS struct {
QuantumElements map[qlElementId]*QuantumElement
KeyStorages map[qlElementId]map[qlElementLinkID]uint64
}
// Will keep information about the quantum elements that this eKMS is talking to
type QuantumElement struct {
qlElementName string // the name of this Quantum Element
qlElementUUID uuid.UUID // the uuid for this device
QlElement *quantumlayer.QuantumlayerEmuPRNG // the actual quantum element
QuantumElementLinks map[qlElementLinkID]*quantumlayer.QuantumLayer // contains information about the quantum links
}
func NeweKMS() (newekms *eKMS) {
return &eKMS{
QuantumElements: make(map[qlElementId]*QuantumElement),
KeyStorages: make(map[qlElementId]map[qlElementLinkID]uint64),
}
}
func (kms *eKMS) AddQuantumElement(kmsName string, kmsUUID uuid.UUID, kmsUDPAddrr string) *QuantumElement {
//Get an emulated Quantumlayer
ql := quantumlayer.NewQuantumlayerEmuPRNG()
ql.PowerOn(kmsUDPAddrr)
qle := QuantumElement{
qlElementName: kmsName,
qlElementUUID: kmsUUID,
QlElement: ql,
QuantumElementLinks: make(map[qlElementLinkID]*quantumlayer.QuantumLayer),
}
kms.QuantumElements[qlElementId(kmsUUID)] = &qle
return &qle
}