security

package
v0.0.1-96 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: MIT Imports: 13 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 (
	ErrEncrypt              = errors.New("Failed to Encrypt")
	ErrOperationNotPermited = errors.New("Operation Not Permited")
	ErrSignature            = errors.New("Failed to Sign message")
	ErrNotSigned            = errors.New("Message Not Signed")
	ErrVerifyFailed         = errors.New("Fail to verify signature")
)
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")
)
View Source
var (
	DefaultAlphabet = base58.BitcoinAlphabet
)

Functions

func DecryptFrom

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

func DecryptMessageFrom

func DecryptMessageFrom(ctx context.Context, to *Key, from EncryptionPublicKey, message *bank.Message) 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 EncryptMessageFor

func EncryptMessageFor(ctx context.Context, from *Key, to EncryptionPublicKey, message *bank.Message) error

func GenerateNonce

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

func GenerateSeed

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

func NewHasherWorker

func NewHasherWorker(ctx context.Context, time, memory, thread int) bank.Worker

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 SignMessage

func SignMessage(ctx context.Context, key *Key, message *bank.Message) error

func VerifyMessageAuthentication

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

func VerifyMessageSignature

func VerifyMessageSignature(key SignaturePublicKey, message *bank.Message) (bool, error)

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 (*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 SecretKey

type SecretKey [SignatureSecretKeySize]byte

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