Documentation ¶
Index ¶
- Constants
- func AesDecrypt(ciphertext []byte, key []byte) ([]byte, error)
- func AesEncrypt(plaintext []byte, key []byte) ([]byte, error)
- func ExportRsaPrivateKey(prvKey *rsa.PrivateKey, keyPath string, password []byte) error
- func ExportRsaPub(pubKey *rsa.PublicKey) []byte
- func GenAesKey() []byte
- func GenNonce() []byte
- func GenerateRsaKeys(keyPath string, password []byte) error
- func HashKey(password []byte, salt []byte, rounds int) []byte
- func ImportRsa(keyPath string, password []byte) (rsa.PrivateKey, rsa.PublicKey, error)
- func ImportRsaPrivateKey(keyPath string, password []byte) (*rsa.PrivateKey, error)
- func ImportRsaPub(pemStr []byte) (rsa.PublicKey, error)
- func RsaDecrypt(prvKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
- func RsaEncrypt(pubKey *rsa.PublicKey, plaintext []byte) ([]byte, error)
- func RsaSign(prvKey rsa.PrivateKey, plaintext []byte) ([]byte, error)
- func RsaVerify(pubKey rsa.PublicKey, plaintext []byte, signature []byte) bool
- func StripZeroes(slice []byte) []byte
Constants ¶
const ( AES_KEY_SIZE = 32 AES_MIN_CIPHERTEXT_SIZE = aes.BlockSize + 12 )
const ( RSA_KEY_SIZE = 4096 SIGNATURE_SIZE = 512 SALT_SIZE = 16 )
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
decrypts a ciphertext encrypted with AesEncrypt
func AesEncrypt ¶
encrypts a provided plaintext with AES256 in GCM mode, and appends a nonce to the start of the ciphertext
func ExportRsaPrivateKey ¶ added in v0.1.2
func ExportRsaPrivateKey(prvKey *rsa.PrivateKey, keyPath string, password []byte) error
func ExportRsaPub ¶
exports the pem-encoded byte array of a given RSA key
func GenerateRsaKeys ¶
generates a pair of RSA keys and saves them to the provided path
func HashKey ¶ added in v0.1.1
generates an AES key from a password, by hashing it with a salt repeatedly
func ImportRsaPrivateKey ¶ added in v0.1.2
func ImportRsaPrivateKey(keyPath string, password []byte) (*rsa.PrivateKey, error)
func ImportRsaPub ¶
imports an RSA public key from a byte string of the pem-encoded key
func RsaDecrypt ¶
func RsaDecrypt(prvKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
decrypts a given plaintext with the provided private key
func RsaEncrypt ¶
encrypts a given plaintext with the provided public key
func StripZeroes ¶ added in v0.1.2
a helper function to strip zeroes from the beginning of a byte slice this isn't necessarily related to AES inherently, however there isn't really a better place to put this function
Types ¶
This section is empty.