server

package
v0.0.0-...-ed623c1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrBadRouting is returned when an expected path variable is missing, which is always programmer error.
	ErrBadRouting = fmt.Errorf("inconsistent mapping between route and handler, %s", bugReportHelp)
	ErrFoundABug  = fmt.Errorf("snuck into machine with err == nil, %s", bugReportHelp)
)
View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
)

Functions

func DecryptData

func DecryptData(params UnifiedParams) (string, error)

func DecryptPin

func DecryptPin(params UnifiedParams) (string, error)

func EncryptData

func EncryptData(params UnifiedParams) (string, error)

func EncryptPin

func EncryptPin(params UnifiedParams) (string, error)

func GenerateMac

func GenerateMac(params UnifiedParams) (string, error)

func InitialKey

func InitialKey(params UnifiedParams) (string, error)

func MakeHTTPHandler

func MakeHTTPHandler(s Service) http.Handler

func TransactionKey

func TransactionKey(params UnifiedParams) (string, error)

Types

type BaseKey

type BaseKey struct {
	Algorithm         string
	AlgorithmKey      string
	BaseDerivativeKey string
	KeySerialNumber   string
}

type Machine

type Machine struct {
	BaseKey
	InitialKey     string
	CurrentKSN     string
	TransactionKey string
	CreatedAt      time.Time
}

func NewMachine

func NewMachine(b BaseKey) *Machine

type Repository

type Repository interface {
	StoreMachine(m *Machine) error
	FindMachine(ik string) (*Machine, error)
	FindAllMachines() []*Machine
	DeleteMachine(ik string) error
}

Repository is the Service storage mechanism abstraction

func NewRepositoryInMemory

func NewRepositoryInMemory(logger log.Logger) Repository

NewRepositoryInMemory is an in memory ach storage repository for machines

type Service

type Service interface {
	CreateMachine(m *Machine) error
	GetMachine(ik string) (*Machine, error)
	GetMachines() []*Machine
	MakeNextKSN(ik string) (*Machine, error)
	DeleteMachine(ik string) error
	EncryptPin(ik, pin, pan, format string) (string, error)
	DecryptPin(ik, ciphertext, pan, format string) (string, error)
	GenerateMac(ik, data, action, macType string) (string, error)
	EncryptData(ik, data, action, iv string) (string, error)
	DecryptData(ik, ciphertext, action, iv string) (string, error)
}

Service is a REST interface for interacting with machine structures

func NewService

func NewService(r Repository) Service

NewService creates a new concrete service

type UnifiedParams

type UnifiedParams struct {
	Algorithm    string
	AlgorithmKey string
	BKD          string
	KSN          string
	IK           string
	TK           string
	PIN          string
	PAN          string
	Format       string
	MacType      string
	Plaintext    string
	Ciphertext   string
	Action       string
	IV           string
}

func (UnifiedParams) ValidateAlgorithm

func (p UnifiedParams) ValidateAlgorithm() error

type WrapperCall

type WrapperCall func(params UnifiedParams) (string, error)

Jump to

Keyboard shortcuts

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