Documentation ¶
Index ¶
- Constants
- func Decrypt(key, ciphertext, iv []byte) ([]byte, error)
- func DecryptRSA(key *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
- func Encrypt(key, plaintext []byte) ([]byte, []byte, error)
- func EncryptRSA(key *rsa.PublicKey, plaintext []byte) ([]byte, error)
- func EncryptWithIV(key, plaintext, iv []byte) ([]byte, []byte, error)
- func GenerateKeyPair() (*rsa.PrivateKey, error)
- func GenerateSessionKey(key *rsa.PublicKey) ([]byte, []byte, error)
- func GobDecodePublicKey(b []byte) (*rsa.PublicKey, error)
- func GobEncodePublicKey(pub *rsa.PublicKey) ([]byte, error)
- func ReadKeypairAsPem(r io.Reader) (*rsa.PrivateKey, error)
- func ReadPublicKeyAsPem(r io.Reader) (rsa.PublicKey, error)
- func Sign(key *rsa.PrivateKey, message []byte) ([]byte, error)
- func Verify(key *rsa.PublicKey, signature, message []byte) error
- func WritePrivateKeyAsPem(w io.Writer, key *rsa.PrivateKey) error
- func WritePublicKeyAsPem(w io.Writer, key *rsa.PublicKey) error
Constants ¶
const RSAKeySize int = 2048
Variables ¶
This section is empty.
Functions ¶
func DecryptRSA ¶
func DecryptRSA(key *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
DecryptRSA - Decrypt using RSA Private Key
func EncryptRSA ¶
EncryptRSA - Encrypt using RSA Public Key
func EncryptWithIV ¶
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 ¶
GenerateSessionKey - helper that will return a random session id, in both plaintext and encrypted form
func GobDecodePublicKey ¶
GobDecodePublicKey - decode the public key from gob formatting.
func GobEncodePublicKey ¶
GobEncodePublicKey - encode the public key to gob formatting.
func ReadKeypairAsPem ¶
func ReadKeypairAsPem(r io.Reader) (*rsa.PrivateKey, 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 ¶
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.
Types ¶
This section is empty.