Documentation
¶
Index ¶
- func Decrypt(publicKey *ecdh.PublicKey, privateKey *ecdh.PrivateKey, ciphertext []byte) ([]byte, error)
- func DecryptStream(reader io.Reader, writer io.WriteCloser, key string) error
- func EncodePrivateKeyToPEM(privateKey *ecdh.PrivateKey) ([]byte, error)
- func EncodePublicKeyToPEM(publicKey *ecdh.PublicKey) ([]byte, error)
- func Encrypt(publicKey *ecdh.PublicKey, privateKey *ecdh.PrivateKey, plaintext []byte) ([]byte, error)
- func EncryptStream(reader io.Reader, writer io.WriteCloser, key string) error
- func ReadPrivateKey(privateKey []byte) (*ecdh.PrivateKey, error)
- func ReadPrivateKeyFromFile(privateKeyPath string) (*ecdh.PrivateKey, error)
- func ReadPublicKey(publicKey []byte) (*ecdh.PublicKey, error)
- func ReadPublicKeyFromFile(publicKeyPath string) (*ecdh.PublicKey, error)
- func WriteKeyPairToFiles(keyPair *KeyPair, privateKeyPath, publicKeyPath string) error
- type KeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶ added in v1.0.5
func Decrypt(publicKey *ecdh.PublicKey, privateKey *ecdh.PrivateKey, ciphertext []byte) ([]byte, error)
Decrypt decrypts data using AES-GCM with a shared secret derived from ECDH
func DecryptStream ¶ added in v1.0.13
DecryptStream decrypts data from a reader (like an HTTP response body) using a chunked approach where each chunk has its own nonce and authentication tag. This is secure for large files and streaming data sources. The format of each chunk is: [4-byte chunk size][nonce][encrypted data][tag]
func EncodePrivateKeyToPEM ¶
func EncodePrivateKeyToPEM(privateKey *ecdh.PrivateKey) ([]byte, error)
EncodePrivateKeyToPEM converts an ECDH private key to PEM format using PKCS#8
func EncodePublicKeyToPEM ¶
EncodePublicKeyToPEM converts an ECDH public key to PEM format using PKIX
func Encrypt ¶ added in v1.0.5
func Encrypt(publicKey *ecdh.PublicKey, privateKey *ecdh.PrivateKey, plaintext []byte) ([]byte, error)
Encrypt encrypts data using AES-GCM with a shared secret derived from ECDH
func EncryptStream ¶ added in v1.0.13
EncryptStream encrypts data from a reader using a chunked approach where each chunk has its own nonce and authentication tag. This is secure for large files and streaming data sources. The format of each chunk is: [4-byte chunk size][nonce][encrypted data][tag]
func ReadPrivateKey ¶ added in v1.0.7
func ReadPrivateKey(privateKey []byte) (*ecdh.PrivateKey, error)
ReadPrivateKey reads and parses an ECDH private key from pem encoded bytes
func ReadPrivateKeyFromFile ¶
func ReadPrivateKeyFromFile(privateKeyPath string) (*ecdh.PrivateKey, error)
ReadPrivateKeyFromFile reads and parses an ECDH private key from a file
func ReadPublicKey ¶ added in v1.0.7
ReadPublicKey reads and parses an ECDH public key from pem encoded bytes
func ReadPublicKeyFromFile ¶
ReadPublicKeyFromFile reads and parses an ECDH public key from a file
func WriteKeyPairToFiles ¶
WriteKeyPairToFiles writes ECDH key pair to files with specified permissions
Types ¶
type KeyPair ¶ added in v1.0.5
type KeyPair struct {
PrivateKey *ecdh.PrivateKey
PublicKey *ecdh.PublicKey
}
KeyPair represents an ECDH key pair
func GenerateKeyPair ¶ added in v1.0.5
GenerateKeyPair generates a new ECDH key pair using P-256