Documentation
¶
Index ¶
- Constants
- Variables
- func CreateTestConfig(t *testing.T, schemes *TestSchemes, geometry *geo.Geometry, ...) *config.Config
- func CreateTestGeometry(schemes *TestSchemes) *geo.Geometry
- func CreateTestGeometryCustom(schemes *TestSchemes, payloadSize, nrHops int) *geo.Geometry
- func CreateTestGeometryECDH(forwardPayloadLength, nrHops int) *geo.Geometry
- func CreateTestPKIDocument(t *testing.T, replicas []*pki.ReplicaDescriptor, ...) *pki.Document
- func CreateTestTempDir(t *testing.T, prefix string) string
- func GenerateTestReplica(t *testing.T, schemes *TestSchemes, index int) *pki.ReplicaDescriptor
- func StoreTestDocument(t *testing.T, pkiWorker *PKIWorker, doc *pki.Document)
- type Connector
- func (co *Connector) CloseAllCh() chan interface{}
- func (co *Connector) ConnectionCount() int
- func (co *Connector) DispatchCommand(cmd commands.Command, idHash *[32]byte)
- func (co *Connector) DispatchReplication(cmd *commands.ReplicaWrite)
- func (co *Connector) ForceUpdate()
- func (co *Connector) Halt()
- func (co *Connector) OnClosedConn(c *outgoingConn)
- func (co *Connector) QueueForRetry(cmd commands.Command, idHash [32]byte)
- func (co *Connector) Server() *Server
- type EnvelopeKeys
- type GenericConnector
- type GenericListener
- type Listener
- type PKIWorker
- type ProxyRequest
- type ProxyRequestManager
- func (p *ProxyRequestManager) CleanupExpiredRequests(timeout time.Duration)
- func (p *ProxyRequestManager) HandleReply(reply *commands.ReplicaMessageReply) bool
- func (p *ProxyRequestManager) RegisterProxyRequest(envelopeHash [32]byte, mkemPrivateKey nike.PrivateKey, ...) chan *commands.ReplicaMessageReply
- func (p *ProxyRequestManager) Shutdown()
- type Server
- type TestKeys
- type TestSchemes
Constants ¶
const ( // GracePeriod is the duration after key expirey that we keep the keys. GracePeriod = 3 * time.Hour )
const (
NumPKIDocsToFetch = 3
)
const PKIDocNum = 3
const ValidEnvelopeEpochWindow uint64 = 1
ValidEnvelopeEpochWindow is the symmetric tolerance the replica applies when decapsulating an inbound MKEM ciphertext. It MUST match the courier's ValidCourierEnvelopeEpochWindow, so any envelope the courier decided to forward has a matching private key to try here.
A window of 1 means three candidate epochs at any moment: {current-1, current, current+1}. See the Pigeonhole specification section "Epoch tolerance for CourierEnvelope" for the reasoning.
Variables ¶
var ( ErrBoxIDNotFound = errors.New("Box ID not found") ErrBoxAlreadyExists = errors.New("BoxID already exists, writes are immutable") ErrFailedDBRead = errors.New("Failed to read from database") ErrFailedToDeserialize = errors.New("Failed to deserialize data from DB") ErrDBClosed = errors.New("DB is closed") )
var ErrGenerateOnly = errors.New("server: GenerateOnly set")
ErrGenerateOnly is the error returned when the server initialization terminates due to the `GenerateOnly` debug config option.
var GitCommit = "unknown"
GitCommit is the git commit hash, set at build time via -ldflags
var (
PublishDeadline = vServer.MixPublishDeadline
)
Functions ¶
func CreateTestConfig ¶
func CreateTestConfig(t *testing.T, schemes *TestSchemes, geometry *geo.Geometry, dataDir, identifier string, addresses []string) *config.Config
CreateTestConfig creates a standard test configuration
func CreateTestGeometry ¶
func CreateTestGeometry(schemes *TestSchemes) *geo.Geometry
CreateTestGeometry creates a standard test geometry
func CreateTestGeometryCustom ¶
func CreateTestGeometryCustom(schemes *TestSchemes, payloadSize, nrHops int) *geo.Geometry
CreateTestGeometryCustom creates a custom test geometry
func CreateTestGeometryECDH ¶
CreateTestGeometryECDH creates a test geometry using ECDH
func CreateTestPKIDocument ¶
func CreateTestPKIDocument(t *testing.T, replicas []*pki.ReplicaDescriptor, serviceNodes []*pki.MixDescriptor) *pki.Document
CreateTestPKIDocument creates a test PKI document
func CreateTestTempDir ¶
CreateTestTempDir creates a temporary directory for tests
func GenerateTestReplica ¶
func GenerateTestReplica(t *testing.T, schemes *TestSchemes, index int) *pki.ReplicaDescriptor
GenerateTestReplica creates a test replica descriptor
Types ¶
type Connector ¶
func (*Connector) CloseAllCh ¶
func (co *Connector) CloseAllCh() chan interface{}
func (*Connector) ConnectionCount ¶ added in v0.0.73
ConnectionCount returns the number of active outgoing connections.
func (*Connector) DispatchCommand ¶
func (*Connector) DispatchReplication ¶
func (co *Connector) DispatchReplication(cmd *commands.ReplicaWrite)
func (*Connector) ForceUpdate ¶
func (co *Connector) ForceUpdate()
func (*Connector) OnClosedConn ¶
func (co *Connector) OnClosedConn(c *outgoingConn)
func (*Connector) QueueForRetry ¶ added in v0.0.73
QueueForRetry adds a command to the retry queue when no connection is available. Dedup is by (destination replica, BoxID): re-queuing the same write collapses and bumps attempts; writes for different boxes to the same peer accumulate as distinct entries. Evicts expired entries and, if at capacity, the oldest entry.
type EnvelopeKeys ¶
func NewEnvelopeKeys ¶
func (*EnvelopeKeys) EnsureKey ¶
func (k *EnvelopeKeys) EnsureKey(replicaEpoch uint64) (*replicaCommon.EnvelopeKey, error)
EnsureKey returns the keypair for replicaEpoch, generating it on demand for the current or a future replica epoch (the PKI publisher's use case). For any replicaEpoch strictly in the past it returns whatever is already cached in memory, or an error — it never fabricates a fresh random keypair for a past epoch, because such a key cannot decrypt ciphertexts that were encrypted to the previously PKI-published public key for that epoch.
func (*EnvelopeKeys) Generate ¶
func (k *EnvelopeKeys) Generate(replicaEpoch uint64) error
func (*EnvelopeKeys) GetKeypair ¶
func (k *EnvelopeKeys) GetKeypair(replicaEpoch uint64) (*replicaCommon.EnvelopeKey, error)
func (*EnvelopeKeys) Prune ¶
func (k *EnvelopeKeys) Prune() bool
type GenericConnector ¶
type GenericConnector interface {
Halt()
Server() *Server
OnClosedConn(conn *outgoingConn)
CloseAllCh() chan interface{}
ForceUpdate()
DispatchCommand(cmd commands.Command, idHash *[32]byte)
DispatchReplication(cmd *commands.ReplicaWrite)
QueueForRetry(cmd commands.Command, idHash [32]byte)
ConnectionCount() int
}
type GenericListener ¶
type GenericListener interface {
Halt()
CloseOldConns(interface{}) error
GetConnIdentities() (map[[constants.RecipientIDLength]byte]interface{}, error)
}
type Listener ¶
func (*Listener) CloseOldConns ¶
func (*Listener) GetConnIdentities ¶
func (l *Listener) GetConnIdentities() (map[[sConstants.RecipientIDLength]byte]interface{}, error)
GetConnIdentities returns a slice of byte slices each corresponding to a currently connected client identity.
type PKIWorker ¶
type PKIWorker struct {
worker.Worker
*pki.WorkerBase
// contains filtered or unexported fields
}
func (*PKIWorker) ForceFetchPKI ¶
ForceFetchPKI forces the PKI worker to fetch a new PKI document for the current epoch. This is useful for integration tests where you want to ensure the replica has the latest PKI document without waiting for the normal fetch cycle.
func (*PKIWorker) HasCurrentPKIDocument ¶
HasCurrentPKIDocument returns true if the replica has a PKI document for the current epoch. This is useful for integration tests to check if the replica is ready.
func (*PKIWorker) PKIDocument ¶
PKIDocument returns the PKI document for the current epoch
func (*PKIWorker) ReplicasCopy ¶
func (p *PKIWorker) ReplicasCopy() map[[32]byte]*pki.ReplicaDescriptor
ReplicasCopy returns a copy of the replicas map
type ProxyRequest ¶ added in v0.0.54
type ProxyRequest struct {
ResponseCh chan *commands.ReplicaMessageReply
MKEMPrivateKey nike.PrivateKey
TargetPublicKey nike.PublicKey
OriginalRequest *commands.ReplicaMessage
Timestamp time.Time
}
ProxyRequest represents a pending proxy request
type ProxyRequestManager ¶ added in v0.0.54
ProxyRequestManager manages pending proxy requests
func NewProxyRequestManager ¶ added in v0.0.54
func NewProxyRequestManager(log *logging.Logger, requestTimeout time.Duration) *ProxyRequestManager
NewProxyRequestManager creates a new proxy request manager
func (*ProxyRequestManager) CleanupExpiredRequests ¶ added in v0.0.54
func (p *ProxyRequestManager) CleanupExpiredRequests(timeout time.Duration)
CleanupExpiredRequests removes requests that have been waiting too long
func (*ProxyRequestManager) HandleReply ¶ added in v0.0.54
func (p *ProxyRequestManager) HandleReply(reply *commands.ReplicaMessageReply) bool
HandleReply processes an incoming reply and routes it to the waiting request
func (*ProxyRequestManager) RegisterProxyRequest ¶ added in v0.0.54
func (p *ProxyRequestManager) RegisterProxyRequest(envelopeHash [32]byte, mkemPrivateKey nike.PrivateKey, targetPublicKey nike.PublicKey, originalRequest *commands.ReplicaMessage) chan *commands.ReplicaMessageReply
RegisterProxyRequest registers a new proxy request and returns a response channel
func (*ProxyRequestManager) Shutdown ¶ added in v0.0.54
func (p *ProxyRequestManager) Shutdown()
Shutdown gracefully shuts down the proxy request manager
type Server ¶
type Server struct {
sync.WaitGroup
PKIWorker *PKIWorker
// contains filtered or unexported fields
}
func CreateTestServer ¶
func CreateTestServer(t *testing.T, cfg *config.Config, keys *TestKeys, logBackend *log.Backend) *Server
CreateTestServer creates a test server with PKI worker
func NewWithPKI ¶
NewWithPKI returns a new Server instance with a custom PKI implementation. If pkiFactory is nil, the default PKI worker is used.
func (*Server) ConnectionCount ¶ added in v0.0.73
ConnectionCount returns the number of active outgoing connections to other replicas. This is useful for testing to verify inter-replica connections are established.
func (*Server) ForceConnectorUpdate ¶ added in v0.0.73
func (s *Server) ForceConnectorUpdate()
ForceConnectorUpdate triggers the connector to rescan PKI and spawn new connections.
func (*Server) LogBackend ¶
func (*Server) ProxyManager ¶ added in v0.0.54
func (s *Server) ProxyManager() *ProxyRequestManager
ProxyManager returns the proxy request manager
func (*Server) RotateLog ¶
func (s *Server) RotateLog()
RotateLog rotates the log file if logging to a file is enabled.
type TestKeys ¶
type TestKeys struct {
IdentityPubKey sign.PublicKey
IdentityPrivKey sign.PrivateKey
IdentityKeyBlob []byte
LinkPubKey kem.PublicKey
LinkPrivKey kem.PrivateKey
LinkKeyBlob []byte
ReplicaPubKey nike.PublicKey
ReplicaPrivKey nike.PrivateKey
ReplicaKeyBlob []byte
}
GenerateTestKeys generates a complete set of test keys
func GenerateTestKeys ¶
func GenerateTestKeys(t *testing.T, schemes *TestSchemes) *TestKeys
GenerateTestKeys creates a complete set of test keys
type TestSchemes ¶
TestSchemes holds the cryptographic schemes used in tests
func NewTestSchemes ¶
func NewTestSchemes() *TestSchemes
NewTestSchemes creates standard test schemes
func NewTestSchemesAdvanced ¶
func NewTestSchemesAdvanced() *TestSchemes
NewTestSchemesAdvanced creates advanced test schemes
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package common contains code that is useful to replicas and couriers.
|
Package common contains code that is useful to replicas and couriers. |