util

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPEMDecode is used to be propagated up the call stack.
	// It is returned when something goes wrong in the crypt module.
	ErrPEMDecode = fmt.Errorf("failed to decode PEM block containing private key")
)

Functions

func DecodeRSAKey

func DecodeRSAKey(bytes []byte) (*rsa.PrivateKey, error)

DecodeRSAKey decode a slice of bytes into an rsa.PrivateKey. It uses the x509.ParsePKCS1PrivateKey function under the hood

func DecodeRSAOAEP

func DecodeRSAOAEP(key *rsa.PrivateKey, cipher []byte) ([]byte, error)

DecodeRSAOAEP decode a cipher using the rsa private key argument. It uses the rsa.DecryptOAEP function under the hood

func IsSignValid

func IsSignValid(hash, cipher string, key []byte) bool

IsSignValid checks if the signature of a given cipher is valid with the given key

func Nonce

func Nonce(n int) (string, error)

Nonce function creates a random base62 string of size n

func ReadRSAKeyFromFile

func ReadRSAKeyFromFile(path string) (*rsa.PrivateKey, error)

ReadRSAKeyFromFile read a file and decode the content into a rsa.PrivateKey

func Sign

func Sign(cipher, key []byte) []byte

Sign is using HMAC and sha256 to create a signature of a cipher

func SignEncodeBase64

func SignEncodeBase64(cipher, key []byte) string

SignEncodeBase64 sign a cipher and return the base64 signature

Types

type ReaderFunc

type ReaderFunc func(p []byte) (n int, err error)

ReaderFunc is a wrapper for a function to implement the Reader interface

func (ReaderFunc) Read

func (rf ReaderFunc) Read(p []byte) (n int, err error)

Read wraps a function to implement Reader interface

type TokenLog

type TokenLog yubico.Token

TokenLog is mapping yubico.Token to a logger

func (TokenLog) MarshalZerologObject

func (tl TokenLog) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog interface to dump Token in logger

type TokenTSLog

type TokenTSLog yubico.Token

TokenTSLog is mapping yubico.Token timestamp to a logger

func (TokenTSLog) MarshalZerologObject

func (ttl TokenTSLog) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog interface to dump Token timestamp in logger

type ValuesLog

type ValuesLog url.Values

ValuesLog is mapping url.Values to a logger

func (ValuesLog) MarshalZerologObject

func (vl ValuesLog) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog interface to dump values in logger

type WriterFunc

type WriterFunc func(p []byte) (n int, err error)

WriterFunc is a wrapper for a function to implement the Writer interface

func (WriterFunc) Write

func (wf WriterFunc) Write(p []byte) (n int, err error)

Write wraps a function to implement Writer interface

type YubikeyLog

type YubikeyLog yubico.Yubikey

YubikeyLog is mapping yubico.Yubikey to a logger

func (YubikeyLog) MarshalZerologObject

func (yl YubikeyLog) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog interface to dump Yubikey in logger

type YubikeyTSLog

type YubikeyTSLog yubico.Yubikey

YubikeyTSLog is mapping yubico.Yubikey timestamp to a logger

func (YubikeyTSLog) MarshalZerologObject

func (ytl YubikeyTSLog) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog interface to dump Yubikey timestamp in logger

Jump to

Keyboard shortcuts

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