Documentation
¶
Index ¶
- func AesGCMDecrypt(key []byte, data []byte) ([]byte, error)
- func AesGCMEncrypt(key []byte, data []byte) ([]byte, error)
- func ChaCha20Decrypt(key, data []byte) ([]byte, error)
- func ChaCha20Encrypt(key, data []byte) ([]byte, error)
- func GenRandKey(size int) ([]byte, error)
- func GeneratePrivateKey(size int) ([]byte, error)
- func LoadPrivatePEMKey(fn io.Reader) (*rsa.PrivateKey, error)
- func LoadPublicPEMKey(fn io.Reader) (*rsa.PublicKey, error)
- func SaveGobKey(fn io.Writer, key interface{}) error
- func SavePrivatePEMKey(fn io.Writer, key *rsa.PrivateKey) error
- func SavePublicPEMKey(fn io.Writer, pubkey rsa.PublicKey) error
- func SignPKCS1v15(r io.Reader, key *rsa.PrivateKey) ([]byte, error)
- func VerifyPKCS1v15(r io.Reader, pubkey *rsa.PublicKey, sig []byte) error
- type KeyPair
- type KeyPairRSA
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesGCMDecrypt ¶
AesGCMDecrypt decrypt with the given 32 byte key the given cipher. GCM Mode use a 96-bit nonce that was preadded to the cipher. This nonce must be uniq
func AesGCMEncrypt ¶
AesGCMEncrypt encrypt with the given 32 byte key the given data. The none will be preadded to the ciphertext
func ChaCha20Decrypt ¶
ChaCha20Decrypt decrypt the given data with given key. nonce was preadded to ciphertext
func ChaCha20Encrypt ¶
ChaCha20Encrypt encrypt the given data with given key nonce will be preadded to ciphertext key should be randomly generated or derived from a function like Argon2. XCHACHA20_NONCE_LENGTH = 24
func GenRandKey ¶
GenRandKey generates a (size) 32 byte random key
func GeneratePrivateKey ¶
GeneratePrivateKey a secure private key from a random source
func LoadPrivatePEMKey ¶
func LoadPrivatePEMKey(fn io.Reader) (*rsa.PrivateKey, error)
LoadPrivatePEMKey load private pem key from file
func LoadPublicPEMKey ¶
LoadPublicPEMKey load public pem key from file
func SaveGobKey ¶
SaveGobKey save rsa key as glob to file to decode the key use the correct struct and gob.NewDecoder(fn).Decode(k)
func SavePrivatePEMKey ¶
func SavePrivatePEMKey(fn io.Writer, key *rsa.PrivateKey) error
SavePrivatePEMKey save private pem key to file
func SavePublicPEMKey ¶
SavePublicPEMKey save public pem key to file
func SignPKCS1v15 ¶
SignPKCS1v15 sign with the in PKCS1v15 standard the given bytes with private key
Types ¶
type KeyPair ¶
KeyPair stores private and public 32 byte keys
func GenKeyX25519 ¶
GenKeyX25519 return a KeyPair generated with X25519
type KeyPairRSA ¶
type KeyPairRSA struct { Pub *rsa.PublicKey Priv *rsa.PrivateKey }
KeyPairRSA to hold rsa private and public key
func GenKeyRSA ¶
func GenKeyRSA() (*KeyPairRSA, error)
GenKeyRSA generate a private public rsa key pair with a size of 4096