crypto

package
v0.0.0-...-f3f2e11 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const RSAKeySize int = 2048

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key, ciphertext, iv []byte) ([]byte, error)

Decrypt - decrypt with aes256 in cbc mode, returns plaintext and error

func DecryptRSA

func DecryptRSA(key *rsa.PrivateKey, ciphertext []byte) ([]byte, error)

DecryptRSA - Decrypt using RSA Private Key

func Encrypt

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

Encrypt - encrypt encrypts with aes256 in cbc mode, returns ciphertext, iv and error

func EncryptRSA

func EncryptRSA(key *rsa.PublicKey, plaintext []byte) ([]byte, error)

EncryptRSA - Encrypt using RSA Public Key

func EncryptWithIV

func EncryptWithIV(key, plaintext, iv []byte) ([]byte, []byte, error)

EncryptWithIV - encrypt encrypts with aes256 in cbc mode, returns ciphertext, iv and error

func GenerateKeyPair

func GenerateKeyPair() (*rsa.PrivateKey, error)

GenerateKeyPair - generate an RSA keypair

func GenerateSessionKey

func GenerateSessionKey(key *rsa.PublicKey) ([]byte, []byte, error)

GenerateSessionKey - helper that will return a random session id, in both plaintext and encrypted form

func GobDecodePublicKey

func GobDecodePublicKey(b []byte) (*rsa.PublicKey, error)

GobDecodePublicKey - decode the public key from gob formatting.

func GobEncodePublicKey

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

GobEncodePublicKey - encode the public key to gob formatting.

func ReadKeypairAsPem

func ReadKeypairAsPem(r io.Reader) (*rsa.PrivateKey, error)

func ReadPublicKeyAsPem

func ReadPublicKeyAsPem(r io.Reader) (rsa.PublicKey, error)

func Sign

func Sign(key *rsa.PrivateKey, message []byte) ([]byte, error)

Sign - Create a digital signature with the RSA keypair that can be validated. Function will create the hash and then sign

func Verify

func Verify(key *rsa.PublicKey, signature, message []byte) error

Verify - Verify a digitial signature with an RSA Public Key will return error if not able to verify the signature

func WritePrivateKeyAsPem

func WritePrivateKeyAsPem(w io.Writer, key *rsa.PrivateKey) error

WritePrivateKeyAsPem - convert a keypair to PEM formatting for storage. This will be used for storing the keypair to disk.

func WritePublicKeyAsPem

func WritePublicKeyAsPem(w io.Writer, key *rsa.PublicKey) error

WritePublicKeyAsPem - convert a keypair to PEM formatting for storage. This will be used for storing the keypair to disk.

Types

This section is empty.

Jump to

Keyboard shortcuts

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