crypto

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

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 EncodePrivateKeyToPEM

func EncodePrivateKeyToPEM(privateKey *ecdh.PrivateKey) []byte

EncodePrivateKeyToPEM converts an ECDH private key to PEM format using PKCS#8

func EncodePublicKeyToPEM

func EncodePublicKeyToPEM(publicKey *ecdh.PublicKey) []byte

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 ReadPrivateKeyFromFile

func ReadPrivateKeyFromFile(privateKeyPath string) (*ecdh.PrivateKey, error)

ReadPrivateKeyFromFile reads and parses an ECDH private key from a file

func ReadPublicKeyFromFile

func ReadPublicKeyFromFile(publicKeyPath string) (*ecdh.PublicKey, error)

ReadPublicKeyFromFile reads and parses an ECDH public key from a file

func WriteKeyPairToFiles

func WriteKeyPairToFiles(keyPair *KeyPair, privateKeyPath, publicKeyPath string) error

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

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair generates a new ECDH key pair using P-256

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL