crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key []byte, data []byte, nonce []byte) ([]byte, error)

func DecryptAESCBC

func DecryptAESCBC(key []byte, data []byte) []byte

func Encrypt

func Encrypt(key []byte, data []byte) ([]byte, []byte, error)

func EncryptAESCBC

func EncryptAESCBC(key []byte, data []byte) []byte

func HashSHA256

func HashSHA256(bytes []byte) []byte

func Open

func Open(key []byte, box EncryptedBox) []byte

func RandomBytes

func RandomBytes(length int) []byte

func Sign

func Sign(key *ecdsa.PrivateKey, data []byte) []byte

func Verify

func Verify(key *ecdsa.PublicKey, data []byte, signature []byte) bool

Types

type ECDHKey

type ECDHKey struct {
	Priv []byte
	X, Y *big.Int
}

Note: This should be replaced once crypto/ecdh gets released (Go 1.20?)

func GenerateECDHKey

func GenerateECDHKey() *ECDHKey

func (*ECDHKey) ECDH

func (key *ECDHKey) ECDH(remoteX, remoteY *big.Int) []byte

func (*ECDHKey) PublicKeyBytes

func (key *ECDHKey) PublicKeyBytes() []byte

type EncryptedBox

type EncryptedBox struct {
	Data []byte `cbor:"1,keyasint"`
	IV   []byte `cbor:"2,keyasint"`
}

func Seal

func Seal(key []byte, data []byte) EncryptedBox

Jump to

Keyboard shortcuts

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