Documentation
¶
Index ¶
- func AesGcmDecrypt(encryptedData []byte, specs CipherKeySpecs) ([]byte, error)
- func AesGcmEncrypt(plainData []byte, specs CipherKeySpecs) ([]byte, error)
- func ChaChaDecrypt(encryptedData []byte, specs CipherKeySpecs) ([]byte, error)
- func ChaChaEncrypt(plainData []byte, specs CipherKeySpecs) ([]byte, error)
- func ComputeAESSharedSecret(specs CipherKeySpecs) (sharedSecret []byte, err error)
- func ComputeChaChaSharedSecret(specs CipherKeySpecs) (sharedSecret []byte, err error)
- func ComputeX25519SharedKey(SharedPublicKey, PrivateKey string) (sharedSecret []byte, err error)
- func GenerateSalt() (string, error)
- func ParsePBKDF2Iterations(iterations string) int
- func SafeStringToInt(s string) (int, error)
- type AlgoMethod
- type CipherKeySpecs
- type X25519KeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesGcmDecrypt ¶
func AesGcmDecrypt(encryptedData []byte, specs CipherKeySpecs) ([]byte, error)
AesGcmDecrypt decrypts the given data using AES-GCM.
func AesGcmEncrypt ¶
func AesGcmEncrypt(plainData []byte, specs CipherKeySpecs) ([]byte, error)
AesGcmEncrypt encrypts the plainData using the AES-GCM AEAD cipher
func ChaChaDecrypt ¶
func ChaChaDecrypt(encryptedData []byte, specs CipherKeySpecs) ([]byte, error)
ChaChaDecrypt decrypts the encryptedData using the ChaCha20-Poly1305 AEAD cipher
func ChaChaEncrypt ¶
func ChaChaEncrypt(plainData []byte, specs CipherKeySpecs) ([]byte, error)
ChaChaEncrypt encrypts the plainData using the ChaCha20-Poly1305 AEAD cipher
func ComputeAESSharedSecret ¶
func ComputeAESSharedSecret(specs CipherKeySpecs) (sharedSecret []byte, err error)
ComputeAESSharedSecret computes the shared secret using elliptic curve Diffie-Hellman
func ComputeChaChaSharedSecret ¶
func ComputeChaChaSharedSecret(specs CipherKeySpecs) (sharedSecret []byte, err error)
ComputeChaChaSharedSecret computes the shared secret using elliptic curve Diffie-Hellman
func ComputeX25519SharedKey ¶ added in v0.1.4
ComputeX25519SharedKey computes the shared secret using elliptic curve Diffie-Hellman SharedPublicKey and PrivateKey must be hex encoded as strings Returns the shared secret as a byte slice
func GenerateSalt ¶ added in v0.1.4
GenerateSalt generates a random salt Returns the salt as a hex encoded string
func ParsePBKDF2Iterations ¶ added in v0.1.4
ParsePBKDF2Iterations parses the PBKDF2 iterations Returns the iterations as an int
func SafeStringToInt ¶ added in v0.1.4
SafeStringToInt converts a string to an int Returns an error if the string cannot be converted to an int
Types ¶
type AlgoMethod ¶
type AlgoMethod string
const ( XChaCha20_Poly1305_PBKDF2_Curve25519 AlgoMethod = "XChaCha20_Poly1305_PBKDF2_Curve25519" AES256_GCM_PBKDF2_Curve25519 AlgoMethod = "AES256_GCM_PBKDF2_Curve25519" )
type CipherKeySpecs ¶
type CipherKeySpecs struct { Salt string `json:"salt"` Iterations string `json:"iterations"` PrivateKey string `json:"privateKey"` Algo AlgoMethod `json:"algo"` }
type X25519KeyPair ¶
type X25519KeyPair struct { PublicKey string `json:"public_key"` PrivateKey string `json:"private_key"` }
func GenerateKeyPair ¶
func GenerateKeyPair() (keyPair X25519KeyPair, err error)
GenerateKeyPair generates a new X25519 key pair.