server

package
v0.0.0-...-eab8366 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const MIN_SESSION_KEY_BYTE_LEN = 24

MIN_SESSION_KEY_BYTE_LEN represents the minimal allowed length of the session key in bytes, for security reasons.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmmyServer

EmmyServer is an interface composed of all the auto-generated server interfaces that declare gRPC handler functions for emmy protocols and schemes.

type RandSessionKeyGen

type RandSessionKeyGen struct {
	// contains filtered or unexported fields
}

RandSessionKeyGen generates session keys of the desired byte length from random bytes.

func NewRandSessionKeyGen

func NewRandSessionKeyGen(byteLen int) (*RandSessionKeyGen, error)

NewRandSessionKeyGen creates a new RandSessionKeyGen instance. The new instance will be configured to generate session keys with exactly byteLen bytes. For security reasons, the function checks the byteLen against the value of MIN_SESSION_KEY_BYTE_LEN. If the provided byteLen is smaller than MIN_SESSION_KEY_BYTE_LEN, an error is set and the returned RandSessionKeyGen is configured to use MIN_SESSION_KEY_BYTE_LEN instead of the provided byteLen.

func (*RandSessionKeyGen) GenerateSessionKey

func (m *RandSessionKeyGen) GenerateSessionKey() (*string, error)

GenerateSessionKey produces a secure random session key and returns its base64-encoded representation that is URL-safe. It reports an error in case random byte sequence could not be generated.

type RedisClient

type RedisClient struct {
	*redis.Client
}

func NewRedisClient

func NewRedisClient(c *redis.Client) *RedisClient

func (*RedisClient) CheckRegistrationKey

func (c *RedisClient) CheckRegistrationKey(key string) (bool, error)

CheckRegistrationKey checks whether provided key is present in registration database and deletes it, preventing another registration with the same key. Returns true if key was present (registration allowed), false otherwise.

type RegistrationManager

type RegistrationManager interface {
	CheckRegistrationKey(string) (bool, error)
}

RegistrationManager checks for the presence of a registration key, removing it in case it exists. The bolean return argument indicates success (registration key present and subsequently deleted) or failure (absence of registration key).

type Server

type Server struct {
	GrpcServer *grpc.Server
	Logger     log.Logger
	SessionManager
	RegistrationManager
	// contains filtered or unexported fields
}

func NewServer

func NewServer(certFile, keyFile string, regMgr RegistrationManager,
	recMgr cl.ReceiverRecordManager, logger log.Logger) (*Server, error)

NewServer initializes an instance of the Server struct and returns a pointer. It performs some default configuration (tracing of gRPC communication and interceptors) and registers RPC server handlers with gRPC server. It requires TLS cert and keyfile in order to establish a secure channel with clients.

func (*Server) EnableTracing

func (s *Server) EnableTracing()

EnableTracing instructs the gRPC framework to enable its tracing capability, which is mainly used for debugging purposes. Although this function does not explicitly affect the Server struct, it is wired to Server in order to provide a nicer API when setting up the server.

func (*Server) GenerateCertificate

func (s *Server) GenerateCertificate(stream pb.PseudonymSystemCA_GenerateCertificateServer) error

func (*Server) GenerateCertificate_EC

func (s *Server) GenerateCertificate_EC(stream pb.PseudonymSystemCA_GenerateCertificate_ECServer) error

func (*Server) GenerateNym

func (s *Server) GenerateNym(stream pb.PseudonymSystem_GenerateNymServer) error

func (*Server) GenerateNym_EC

func (s *Server) GenerateNym_EC(stream pb.PseudonymSystem_GenerateNym_ECServer) error

func (*Server) GetAcceptableCredentials

func (s *Server) GetAcceptableCredentials(ctx context.Context, _ *empty.Empty) (*pb.AcceptableCreds, error)

func (*Server) GetCredentialStructure

func (s *Server) GetCredentialStructure(ctx context.Context, _ *empty.Empty) (*pb.CredStructure, error)

func (*Server) GetServiceInfo

func (s *Server) GetServiceInfo(ctx context.Context, _ *empty.Empty) (*pb.ServiceInfo, error)

func (*Server) IssueCredential

func (s *Server) IssueCredential(stream pb.CL_IssueCredentialServer) error

func (*Server) ObtainCredential

func (s *Server) ObtainCredential(stream pb.PseudonymSystem_ObtainCredentialServer) error

func (*Server) ObtainCredential_EC

func (s *Server) ObtainCredential_EC(stream pb.PseudonymSystem_ObtainCredential_ECServer) error

func (*Server) ProveCredential

func (s *Server) ProveCredential(stream pb.CL_ProveCredentialServer) error

func (*Server) Start

func (s *Server) Start(port int) error

Start configures and starts the protocol server at the requested port.

func (*Server) Teardown

func (s *Server) Teardown()

Teardown stops the protocol server by gracefully stopping enclosed gRPC server.

func (*Server) TransferCredential

func (s *Server) TransferCredential(stream pb.PseudonymSystem_TransferCredentialServer) error

func (*Server) TransferCredential_EC

func (s *Server) TransferCredential_EC(stream pb.PseudonymSystem_TransferCredential_ECServer) error

func (*Server) UpdateCredential

func (s *Server) UpdateCredential(stream pb.CL_UpdateCredentialServer) error

type SessionManager

type SessionManager interface {
	GenerateSessionKey() (*string, error)
}

SessionManager generates a new session key. It returns a string containing the generated session key or an error in case session key could not be generated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL