ykksm

package
v0.0.0-...-72724d7 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoOTP is an error returned when no OTP is provided
	ErrNoOTP = errors.New("no OTP provided")
	// ErrInvalidOTP is an error returned when OTP is wrong format
	ErrInvalidOTP = errors.New("invalid OTP format")
	// ErrCorruptOTP is an error returned when OTP is corrupted
	ErrCorruptOTP = errors.New("corrupt OTP")
	// ErrNoYubikey is an error returned when no Yubikey can be found
	ErrNoYubikey = errors.New("no YubiKey found")
)
View Source
var Base64Transformer = TransformerFunc(func(key []byte) ([]byte, error) {
	n, err := base64.StdEncoding.Decode(key, key)
	return key[:n], err
})

Base64Transformer decodes a slice of base64 bytes to a slice of bytes

View Source
var HexTransformer = TransformerFunc(func(key []byte) ([]byte, error) {
	n, err := hex.Decode(key, key)
	return key[:n], err
})

HexTransformer decodes a slice of hexadecimal bytes to a slice of bytes

Functions

func ValidateOTP

func ValidateOTP(otp string) error

ValidateOTP check if the provided string is a proper yubikey token

Types

type Decrypter

type Decrypter interface {
	Decrypt(otp string) (*yubico.Token, error)
}

Decrypter interface abstract the decryption of a token into a Token struct

type DecrypterFactory

type DecrypterFactory func(zerolog.Logger) Decrypter

DecrypterFactory is currying a Decrypter to inject a logger on each request

type DecrypterFunc

type DecrypterFunc func(otp string) (*yubico.Token, error)

DecrypterFunc is a wrapper for a function to implement the Decrypter interface

func (DecrypterFunc) Decrypt

func (df DecrypterFunc) Decrypt(otp string) (*yubico.Token, error)

Decrypt wraps a function to implement Decrypter interface

type Retriever

type Retriever interface {
	Retrieve(pubid []byte) (key []byte, name string, err error)
}

Retriever interface abstract the retrieval of a key from a store

func RetrieveTransformer

func RetrieveTransformer(retriever Retriever, transformers ...Transformer) Retriever

RetrieveTransformer pipes a retrieved key to a list of tranformers and return the result

type RetrieverFunc

type RetrieverFunc func(pubid []byte) (key []byte, name string, err error)

RetrieverFunc is a wrapper for a function to implement the Retriever interface

func (RetrieverFunc) Retrieve

func (rf RetrieverFunc) Retrieve(pubid []byte) ([]byte, string, error)

Retrieve wraps a function to implement the Retrieve interface

type Transformer

type Transformer interface {
	Transform(key []byte) ([]byte, error)
}

Transformer is an interface abstracting the transformations made on a byte slice.

func OAEPTransformer

func OAEPTransformer(private *rsa.PrivateKey) Transformer

OAEPTransformer return a Transformer which decode a slice of byte using a RSA key.

type TransformerFunc

type TransformerFunc func([]byte) ([]byte, error)

TransformerFunc is a wrapper for a function to implement the Tranformer interface

func (TransformerFunc) Transform

func (tf TransformerFunc) Transform(key []byte) ([]byte, error)

Transform wraps a function to implement Transformer interface

type YKKSM

type YKKSM struct {
	Retriever
	zerolog.Logger
}

YKKSM struct handles the features of the yubico KSM module

func NewKSM

func NewKSM(retriever Retriever, options ...func(*YKKSM)) *YKKSM

NewKSM creates a new instance of a YKKSM with sensible defaults

func (YKKSM) Decrypt

func (ykksm YKKSM) Decrypt(otp string) (*yubico.Token, error)

Decrypt implements the Decrypter interface and perform an otp decryption.

Jump to

Keyboard shortcuts

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