Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
kms.go 6.44 KiB
// 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 (
"fmt"
"io"
"net"
"sync"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
pbETSI "code.fbi.h-da.de/danet/proto-kms/api/gen/proto/go/kmsetsi"
pbIC "code.fbi.h-da.de/danet/proto-kms/api/gen/proto/go/kmsintercom"
pbQS "code.fbi.h-da.de/danet/quipsec/gen/go/quipsec"
"github.com/google/uuid"
)
//type Qkdnkms interface {
// //AddExternalNotifierGeneral(chan bool) // used to indicate unspecific changes
// AddExternalNotifierQLE(chan uint32) // used to indicate changes to specific Quantum Link Element (QLE)
// AddExternalNotifierKMSPeer(chan string) // used to indicate changes to specific KMSPeer
// AddQuantumElement() *EmulatedQuantumModule
// GlobalKeyHandler(time.Duration) error
// AddPeer(kmsPeerSocket string, servingQLE *EmulatedQuantumModule)
// RemovePeer(kmsPeerSocket string)
// FindPeerUuid(uuid.UUID) *kmsPeer
//}
type Route struct {
Previous *kmsPeer
Next *kmsPeer
}
type BitKeyLength string
const (
BitKeyLen128 BitKeyLength = "128"
BitKeyLen256 BitKeyLength = "256"
BitKeyLen512 BitKeyLength = "512"
)
// The general emulated KMS
type EKMS struct {
kmsName string
kmsUUID uuid.UUID
interComAddr string
qleMapMutex sync.Mutex
quantumModules map[string]QuantumModule
quantumModulesMutex sync.RWMutex
externalNotifierQLE chan uint32
kmsPeersMutex sync.Mutex
// TODO(maba): find a better name for this
// TODO: add mutex
keysForPathId map[uuid.UUID]string
routingTable map[uuid.UUID]*Route
KmsPeers map[string]*kmsPeer
externalNotifierKMSPeer chan string
pbETSI.UnimplementedKmsETSIServer
pbIC.UnimplementedKmsTalkerServer
supportedKeyLengths map[BitKeyLength]bool
}
// Will keep information about the quantum elements that this EKMS is talking to
// This actually constitutes a quantum element with only a single link