Documentation
¶
Index ¶
- Constants
- func AesDecrypt(ciphertext []byte, key []byte) ([]byte, error)
- func AesEncrypt(plaintext []byte, key []byte) ([]byte, error)
- func ExportRsaPub(pubKey *rsa.PublicKey) []byte
- func GenAesKey() []byte
- func GenNonce() []byte
- func GenerateRsaKeys(keyPath string) error
- func HashKey(plaintext []byte, salt []byte) []byte
- func ImportRsa(keyPath string) (rsa.PrivateKey, rsa.PublicKey, 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
Constants ¶
View Source
const ( AES_KEY_SIZE = 32 AES_MIN_CIPHERTEXT_SIZE = aes.BlockSize + 12 )
View Source
const ( RSA_KEY_SIZE = 4096 SIGNATURE_SIZE = 512 )
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 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 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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.