cryptography

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: GPL-3.0 Imports: 7 Imported by: 8

README

Cryptography

Wrappers around Go cryptographic functions, you should avoid using any cryptographic primitives that are not from this package.

Documentation

Index

Constants

View Source
const (
	// AESKeySize - Always use 256 bit keys
	AESKeySize = 16

	// GCMNonceSize - 96 bit nonces for GCM
	GCMNonceSize = 12
)

Variables

View Source
var (
	// ErrInvalidKeyLength - Invalid key length
	ErrInvalidKeyLength = errors.New("Invalid length")
)

Functions

func GCMDecrypt

func GCMDecrypt(key AESKey, ciphertext []byte) ([]byte, error)

GCMDecrypt - Decrypt GCM ciphertext

func GCMEncrypt

func GCMEncrypt(key AESKey, plaintext []byte) ([]byte, error)

GCMEncrypt - Encrypt using AES GCM

func RSADecrypt

func RSADecrypt(ciphertext []byte, privateKey *rsa.PrivateKey) ([]byte, error)

RSADecrypt - Decrypt ciphertext with rsa private key

func RSAEncrypt

func RSAEncrypt(msg []byte, pub *rsa.PublicKey) ([]byte, error)

RSAEncrypt - Encrypt a msg with a public rsa key

Types

type AESIV

type AESIV [aes.BlockSize]byte

AESIV - 128 bit IV

func RandomAESIV

func RandomAESIV() AESIV

RandomAESIV - 128 bit Random IV

type AESKey

type AESKey [AESKeySize]byte

AESKey - 256 bit key

func AESKeyFromBytes

func AESKeyFromBytes(data []byte) (AESKey, error)

AESKeyFromBytes - Convert byte slice to AESKey

func RandomAESKey

func RandomAESKey() AESKey

RandomAESKey - Generate random ID of randomIDSize bytes

Jump to

Keyboard shortcuts

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