scrypto

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ed25519                    = "ed25519"
	Curve25519xSalsa20Poly1305 = "curve25519xsalsa20poly1305"
)

Available asymmetric crypto algorithms. The values must be lower case.

View Source
const (
	NaClBoxNonceSize = 24
	NaClBoxKeySize   = 32
)

Constants for nacl/box implementation of Curve25519xSalsa20Poly1305

View Source
const (
	ErrCipherFailure common.ErrMsg = "Unable to initialize AES cipher"
	ErrMacFailure    common.ErrMsg = "Unable to initialize Mac"
)
View Source
const (
	ErrInvalidNonceSize      common.ErrMsg = "Invalid nonce size"
	ErrUnableToGenerateNonce common.ErrMsg = "Unable to generate nonce"
)

Variables

View Source
var (
	ErrInvalidPubKeySize       = serrors.New("Invalid public key size")
	ErrInvalidPrivKeySize      = serrors.New("Invalid private key size")
	ErrInvalidSignatureSize    = serrors.New("Invalid signature size")
	ErrInvalidSignatureFormat  = serrors.New("Invalid signature format: sig[63]&224 should equal 0")
	ErrVerification            = serrors.New("Signature verification failed")
	ErrUnableToGenerateKeyPair = serrors.New("Unable to generate key pair")
	ErrUnableToDecrypt         = serrors.New("Unable to decrypt message")
	ErrUnsupportedAlgo         = serrors.New("Unsupported algorithm")
	ErrUnsupportedSignAlgo     = serrors.New("Unsupported signing algorithm")
	ErrUnsupportedEncAlgo      = serrors.New("Unsupported encryption algorithm")
)

Errors

Functions

func Decrypt

func Decrypt(msg, nonce, pubkey, privkey []byte, algo string) ([]byte, error)

Decrypt decrypts a message for a given nonce and public/private keypair.

func Encrypt

func Encrypt(msg, nonce, pubkey, privkey []byte, algo string) ([]byte, error)

Encrypt takes a message, a nonce and a public/private keypair and returns the encrypted and authenticated message. Note: Nonce must be different for each message that is encrypted with the same key.

func GenKeyPair

func GenKeyPair(algo string) (common.RawBytes, common.RawBytes, error)

GenKeyPair generates a public/private key pair.

func GetPubKey added in v0.4.0

func GetPubKey(privKey []byte, algo string) ([]byte, error)

GetPubKey generates the public key for the provided private key.

func HFMacFactory added in v0.4.0

func HFMacFactory(key []byte) (func() hash.Hash, error)

func InitMac

func InitMac(key []byte) (hash.Hash, error)

func Nonce

func Nonce(l int) (common.RawBytes, error)

Nonce takes an input length and returns a random nonce of the given length.

func RandInt64

func RandInt64() int64

RandInt64 returns a random int64 value. The returned value can be negative.

func RandUint64

func RandUint64() uint64

func Sign

func Sign(sigInput, signKey []byte, signAlgo string) ([]byte, error)

Sign takes a signature input and a signing key to create a signature. Currently only ed25519 is supported.

func Verify

func Verify(sigInput, sig, verifyKey []byte, signAlgo string) error

Verify takes a signature input and a verifying key and returns an error, if the signature does not match. Currently only ed25519 is supported.

Types

type Version added in v0.4.0

type Version uint64

Version identifies the version of a trust file. It cannot be marshalled/unmarshalled to/from LatestVer.

const LatestVer Version = 0

LatestVer is the wildcard version indicating the highest available version when requesting certificate chains and TRCs.

func (Version) IsLatest added in v0.4.0

func (v Version) IsLatest() bool

IsLatest checks if the value is LatestVer

func (Version) String added in v0.5.0

func (v Version) String() string

Directories

Path Synopsis
cms
oid
Package oid contains OID definitions.
Package oid contains OID definitions.
protocol
Package protocol implements low level CMS types, parsing and generation.
Package protocol implements low level CMS types, parsing and generation.

Jump to

Keyboard shortcuts

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