encryption

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptAESGCM

func DecryptAESGCM(ciphertext, key, nonce []byte) ([]byte, error)

func DecryptAESGCMWithNonceEmbed added in v0.3.2

func DecryptAESGCMWithNonceEmbed(data, key []byte) ([]byte, error)

DecryptAESGCMWithNonceEmbed decrypts ciphertext where the nonce is embedded at the start of the slice.

func EncryptAESGCM

func EncryptAESGCM(plain, key []byte) (ciphertext, nonce []byte, err error)

func EncryptAESGCMWithNonceEmbed added in v0.3.2

func EncryptAESGCMWithNonceEmbed(plaintext, key []byte) ([]byte, error)

EncryptAESGCMWithNonceEmbed encrypts plaintext and embeds the nonce at the start of the returned slice.

func MarshalP256PublicKey added in v0.3.2

func MarshalP256PublicKey(publicKey *ecdsa.PublicKey) ([]byte, error)

MarshalP256PublicKey marshals a P256 public key to DER format

func ParseEd25519PublicKeyFromHex added in v0.3.2

func ParseEd25519PublicKeyFromHex(hexKey string) ([]byte, error)

ParseEd25519PublicKeyFromHex parses a hex-encoded Ed25519 public key and validates it. Returns the public key as []byte and an error if invalid.

func ParseP256PrivateKey added in v0.3.2

func ParseP256PrivateKey(keyData []byte) (*ecdsa.PrivateKey, error)

ParseP256PrivateKey parses a P256 private key from either DER or hex format

func ParseP256PublicKeyFromBase64 added in v0.3.2

func ParseP256PublicKeyFromBase64(base64String string) (*ecdsa.PublicKey, error)

ParseP256PublicKeyFromBase64 parses a P-256 public key from base64 string

func ParseP256PublicKeyFromBytes added in v0.3.2

func ParseP256PublicKeyFromBytes(keyBytes []byte) (*ecdsa.PublicKey, error)

func ParseP256PublicKeyFromHex added in v0.3.2

func ParseP256PublicKeyFromHex(hexString string) (*ecdsa.PublicKey, error)

ParseP256PublicKeyFromHex parses a P-256 public key from hex string

func SignWithP256 added in v0.3.2

func SignWithP256(privateKey *ecdsa.PrivateKey, data []byte) ([]byte, error)

SignWithP256 signs data using a P256 private key

func ValidateEd25519PublicKey added in v0.3.2

func ValidateEd25519PublicKey(keyBytes []byte) error

ValidateEd25519PublicKey validates an existing byte slice as a valid Ed25519 public key

func ValidateP256PublicKey added in v0.3.2

func ValidateP256PublicKey(publicKey *ecdsa.PublicKey) error

ValidateP256PublicKey validates that a public key is P-256

func VerifyP256Signature added in v0.3.2

func VerifyP256Signature(publicKey *ecdsa.PublicKey, data []byte, signature []byte) error

VerifyP256Signature verifies a P256 signature

Types

type KeyData added in v0.3.2

type KeyData struct {
	PublicKeyHex  string
	PrivateKeyHex string
}

func GenerateEd25519Keys added in v0.3.2

func GenerateEd25519Keys() (KeyData, error)

generateEd25519Keys generates Ed25519 keypair

func GenerateP256Keys added in v0.3.2

func GenerateP256Keys() (KeyData, error)

Jump to

Keyboard shortcuts

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