crypto

package
v0.0.0-...-d0512a4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyTypeEcdsaP256 = "ECDSAP256"
	KeyTypeRsa4096   = "RSA4096"
	KeyTypeAESGCM256 = "AESGCM256"
)
View Source
const AES_KEY_SIZE = 32
View Source
const ITER_COUNT = 10
View Source
const NONCE_SIZE = 12

Variables

View Source
var KeyTypeEncrypt = KeyTypeAESGCM256
View Source
var KeyTypeOcicrypt = KeyTypeEcdsaP256

Functions

func DecryptWithAES

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

func DecryptWithKey

func DecryptWithKey(key *pb.Key, ciphertext []byte) ([]byte, error)

func DeriveAesKey

func DeriveAesKey(password []byte, salt []byte) []byte

could drive a nonce or a symmetric key, both are []byte

func EncryptWithAES

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

func EncryptWithKey

func EncryptWithKey(key *pb.Key, plaintext []byte) ([]byte, error)

func GenerateAESKey

func GenerateAESKey(random io.Reader) ([]byte, error)

Generate a AES_KEY_SIZE-byte random key

func GenerateNonce

func GenerateNonce() ([]byte, error)

Generate a NONCE_SIZE-byte random nonce

func GetCryptoConfigKey

func GetCryptoConfigKey(key *pb.Key) (encconfig.CryptoConfig, error)

func NewKey

func NewKey(keyType string) (*pb.Key, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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