Skip to content
Snippets Groups Projects

Allow to reset key store and stop key fetching

Merged Malte Bauch requested to merge qkdnm-set-key-store into master
Files
7
@@ -22,6 +22,7 @@ type DanetQuantumModule struct {
// QuantumElementLink *quantumlayer.QuantumlayerEmuPRNG // contains information about the quantum links
// key stores of unchopped bulk keys go here
addr string
active bool // determs if the module is active to receive keys
RawBulkKeysMutex sync.Mutex
RawBulkKeys map[int64]*quantumlayer.QuantumLayerBulkKey
keyStore *store.KmsKeyStore // the keys used between two peers.
@@ -35,6 +36,7 @@ func NewDanetQuantumModule(kmsUDPAddr string, kmsId string) *DanetQuantumModule
QlID: uuid.New(),
kmsId: kmsId,
addr: kmsUDPAddr,
active: false,
RawBulkKeys: make(map[int64]*quantumlayer.QuantumLayerBulkKey),
keyStore: store.NewKmsKeyStore(256),
kmsClient: nil,
@@ -48,9 +50,20 @@ func (qm *DanetQuantumModule) ID() uuid.UUID {
}
func (qm *DanetQuantumModule) Initialize() error {
qm.RawBulkKeysMutex.Lock()
defer qm.RawBulkKeysMutex.Unlock()
qm.active = true
return nil
}
func (qm *DanetQuantumModule) Reset() {
qm.RawBulkKeysMutex.Lock()
defer qm.RawBulkKeysMutex.Unlock()
qm.active = false
qm.RawBulkKeys = make(map[int64]*quantumlayer.QuantumLayerBulkKey)
qm.KeyStore().Reset()
}
func (qm *DanetQuantumModule) SetKmsPeerInformation(kmsClient *GRPCClient, kmsEventBus *event.EventBus, kmsTcpSocketStr string) error {
qm.kmsClient = kmsClient
qm.kmsEventBus = kmsEventBus
@@ -62,6 +75,10 @@ func (qm *DanetQuantumModule) Address() string {
return qm.addr
}
func (qm *DanetQuantumModule) IsActive() bool {
return qm.active
}
func (qm *DanetQuantumModule) Sync() error {
rawBulkKeyIds := util.KeysOfMap(qm.RawBulkKeys)
log.Info("Found the following bulk key ids for usage: ", rawBulkKeyIds)
Loading