security

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignatureSecretKeySize = ed25519.PrivateKeySize
	SignaturePublicKeySize = ed25519.PublicKeySize

	EncryptionKeySize = sodium.Curve25519Size
	NonceSize         = 24
	MinSaltSize       = 24

	AuthenticationKeySize       = EncryptionKeySize
	AuthenticationKeyDigestSize = EncryptionKeySize

	SeedKeySize     = ed25519.SeedSize
	HashSeedKeySize = 32
)
View Source
const (
	KeyHasherWorker = "Security.KeyHasherWorker"
)
View Source
const (
	KeyPasswordHashSeed = "Security.KeyPasswordHashSeed"
)
View Source
const (
	KeyPrivateKeySalt = "Key.PrivateKeySalt"
)

Variables

View Source
var (
	ErrInvalidKeys        = errors.New("Invalid SecureID Keys")
	InvalidSecureIDString = errors.New("Invalid SecureID String")
)
View Source
var (
	ErrInvalidKey      = errors.New("Invalid key")
	ErrSignMessage     = errors.New("Message Sign Failed")
	ErrVerifySignature = errors.New("Signature verification failed")
	ErrNoSignature     = errors.New("No Signature found")
	ErrNoData          = errors.New("No Data")
)
View Source
var (
	DefaultAlphabet = base58.BitcoinAlphabet
)

Functions

func DecryptFrom

func DecryptFrom(from EncryptionPublicKey, to EncryptionPrivateKey, data []byte) ([]byte, error)

func EncodeAuthenticationDigest

func EncodeAuthenticationDigest(key AuthenticationDigest) string

func EncodeAuthenticationKey

func EncodeAuthenticationKey(key AuthenticationKey) string

func EncodePublicKey

func EncodePublicKey(key EncryptionPublicKey) string

func EncodeSeedKey

func EncodeSeedKey(key SeedKey) string

func EncodeSignatureKey

func EncodeSignatureKey(key SignaturePublicKey) string

func EncryptFor

func EncryptFor(from EncryptionPrivateKey, to EncryptionPublicKey, message []byte) ([]byte, error)

func GenerateNonce

func GenerateNonce() ([NonceSize]byte, error)

func GenerateSeed

func GenerateSeed() ([SeedKeySize]byte, error)

func PasswordHashSeedContext

func PasswordHashSeedContext(ctx context.Context, passwordHashSeed string) context.Context

func SaltedHash

func SaltedHash(ctx context.Context, password []byte) []byte

SaltedHash return argon2 key from salt and input do not store or reuse salt

func SaltedHashVerify

func SaltedHashVerify(ctx context.Context, password []byte, hash []byte) bool

SaltedHashVerify check if hash correspond to argon2 hash from salt and input do not store or reuse salt

func Sign

func Sign(secretKey SignatureSecretKey, data []byte) ([]byte, error)

func VerifyMessageAuthentication

func VerifyMessageAuthentication(authenticateKey AuthenticationKey, digest AuthenticationDigest, message []byte) bool

func VerifySignature

func VerifySignature(publicKey SignaturePublicKey, signedMessage []byte) (bool, error)

Types

type AuthenticationDigest

type AuthenticationDigest [AuthenticationKeyDigestSize]byte

func AuthenticateMessage

func AuthenticateMessage(authenticateKey AuthenticationKey, message []byte) AuthenticationDigest

func DecodeAuthenticationDigest

func DecodeAuthenticationDigest(encoded string) (AuthenticationDigest, error)

type AuthenticationKey

type AuthenticationKey [AuthenticationKeySize]byte

func DecodeAuthenticationKey

func DecodeAuthenticationKey(encoded string) (AuthenticationKey, error)

type EncryptionPrivateKey

type EncryptionPrivateKey [EncryptionKeySize]byte

type EncryptionPublicKey

type EncryptionPublicKey [EncryptionKeySize]byte

func DecodePublicKey

func DecodePublicKey(encoded string) (EncryptionPublicKey, error)

type HashSeed

type HashSeed struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type HashSeedKey

type HashSeedKey [HashSeedKeySize]byte

func PasswordHashSalt

func PasswordHashSalt(ctx context.Context) HashSeedKey

type HasherWorker

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

func NewHasherWorker

func NewHasherWorker(ctx context.Context, time, memory, thread int) *HasherWorker

func (*HasherWorker) Run

func (p *HasherWorker) Run(ctx context.Context, numWorkers int)

type Key

type Key struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func FromSeed

func FromSeed(ctx context.Context, seed SeedKey) *Key

func NewKey

func NewKey(ctx context.Context) *Key

func (*Key) AuthenticationKey

func (p *Key) AuthenticationKey(ctx context.Context) AuthenticationKey

func (*Key) DecryptFrom

func (p *Key) DecryptFrom(ctx context.Context, from EncryptionPublicKey, data []byte) ([]byte, error)

func (*Key) EncryptFor

func (p *Key) EncryptFor(ctx context.Context, to EncryptionPublicKey, data []byte) ([]byte, error)

func (*Key) Public

func (p *Key) Public(ctx context.Context) EncryptionPublicKey

func (*Key) SignMessage

func (p *Key) SignMessage(ctx context.Context, message []byte) ([]byte, error)

func (*Key) SignPublicKey

func (p *Key) SignPublicKey(ctx context.Context) SignaturePublicKey

func (*Key) Wipe

func (p *Key) Wipe()

type KeysMap added in v0.1.0

type KeysMap map[string]*secureid.Keys

type Options added in v0.1.0

type Options struct {
	Seed    string `json:"seed"`
	Context string `json:"context"`
	KeyID   uint   `json:"keyId"`
}

type SecretKey

type SecretKey [SignatureSecretKeySize]byte

type SecureID added in v0.1.0

type SecureID interface {
	ToSecureID(context string, value secureid.Value) (secureid.SecureID, error)
	FromSecureID(context string, secureID secureid.SecureID) (secureid.Value, error)

	ToString(secureID secureid.SecureID) string
	Parse(secureID string) secureid.SecureID
}

func FromOptions added in v0.1.0

func FromOptions(options Options) SecureID

func New added in v0.1.0

func New(info secureid.SecureInfo, keyID secureid.KeyID) SecureID

func SecureIDFromFile added in v0.1.0

func SecureIDFromFile(filename string) SecureID

type SecureIDKeys added in v0.1.0

type SecureIDKeys struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*SecureIDKeys) FromSecureID added in v0.1.0

func (p *SecureIDKeys) FromSecureID(context string, secureID secureid.SecureID) (secureid.Value, error)

func (*SecureIDKeys) Parse added in v0.1.0

func (p *SecureIDKeys) Parse(secureID string) secureid.SecureID

func (*SecureIDKeys) SubKey added in v0.1.0

func (p *SecureIDKeys) SubKey(context string) *secureid.Keys

func (*SecureIDKeys) ToSecureID added in v0.1.0

func (p *SecureIDKeys) ToSecureID(context string, value secureid.Value) (secureid.SecureID, error)

func (*SecureIDKeys) ToString added in v0.1.0

func (p *SecureIDKeys) ToString(secureID secureid.SecureID) string

type SeedKey

type SeedKey [SeedKeySize]byte

func DecodeSeedKey

func DecodeSeedKey(encoded string) (SeedKey, error)

func NewSeed

func NewSeed() SeedKey

type SignaturePublicKey

type SignaturePublicKey [SignaturePublicKeySize]byte

func DecodeSignatureKey

func DecodeSignatureKey(encoded string) (SignaturePublicKey, error)

type SignatureSecretKey

type SignatureSecretKey [SignatureSecretKeySize]byte

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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