A small crypto package containing some useful utility functions
func GenKeyPair() ([32]byte, [32]byte, error)
Generates a private and public key pair generated with the Curve25519 Diffe-Hellman function. Returns (privateKey, publicKey, error).
func GenSharedSecret(selfPri, otherPub [32]byte) [32]byte
Generates a shared secret with the client's private key and a peers public key using the [Curve25519] Diffie-Hellman function.
func Hash(tag string, data []byte) []byte
Generates an authenticated 256 bit hash with the SHA-2 SHA-512/256 hash function in combination with HMAC.
func Encrypt(plaintext []byte, secret [32]byte) ([]byte, error)
Returns an encrypted version of the provided plaintext using AES.
func Decrypt(ciphertext []byte, secret [32]byte) ([]byte, error)
Returns a decrypted version of the provided ciphertext using AES.
- Curve25519
- Diffie-Hellman Key Exchange - A Non-Mathematician’s Explanation
- George Tankersley - Crypto for Go Developers