crypto

package
v0.0.0-...-544e413 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2016 License: BSD-2-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AES128 = 16
	AES192 = 24
	AES256 = 32
)

AES key sizes

Variables

View Source
var (
	ErrCipherTextSize = errors.New("useless/crypto: ciphertext is not a multiple of the block size")
	ErrKeyBlockSize   = errors.New("useless/crypto: key size is not a multiple of the block size")
	ErrKeySize        = errors.New("useless/crypto: Key size should be either 16, 24, or 32")
)

Errors

Functions

func DecryptBytes

func DecryptBytes(key, ciphertext []byte) (b []byte, err error)

DecryptBytes will attempt to decrypt the ciphertext using the provided AES key. The ciphertext will be unpadded using the pkcs7 padding scheme.

func DecryptFile

func DecryptFile(key []byte, filename string) (err error)

DecryptFile will attempt to copy the contents of the specified file into memory and then decrypt it using the provided key. The orginal file contents is over written with the decrypted bytes in memory.

func EncryptBytes

func EncryptBytes(key, b []byte) (ciphertext []byte, err error)

EncryptBytes will encrypt a byte slice using the provided key. Padding will be added using the pkcs7 padding scheme.

func EncryptFile

func EncryptFile(key []byte, filename string) (err error)

EncryptFile will attempt to copy the contents of the specified file into memory and then encrypt it using the provided key. The orginal file contents is over written with the encrypted bytes in memory.

func EncryptKey

func EncryptKey(pubBytes, key []byte) (ciphertext []byte, err error)

EncryptKey can be used to encrypt a AES key with the provided RSA public key. The ciphertext can only be decrypted using the RSA private key of the public key.

func GenerateKey

func GenerateKey(size int) ([]byte, error)

GenerateKey will attempt to generate a secure aes key of specified size. The aes key can only be 16, 24, or 32 bytes in length.

Types

This section is empty.

Directories

Path Synopsis
Package pkcs7 implements PKCS#7 padding, described at http://tools.ietf.org/html/rfc5652#section-6.3.
Package pkcs7 implements PKCS#7 padding, described at http://tools.ietf.org/html/rfc5652#section-6.3.

Jump to

Keyboard shortcuts

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