encryption

package
v0.0.0-...-c01ef8f Latest Latest
Warning

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

Go to latest
Published: Oct 26, 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

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

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

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

func MarshalP256PublicKey

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

MarshalP256PublicKey marshals a P256 public key to DER format

func ParseEd25519PublicKeyFromHex

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

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

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

func ParseP256PublicKeyFromBase64

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

ParseP256PublicKeyFromBase64 parses a P-256 public key from base64 string

func ParseP256PublicKeyFromBytes

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

func ParseP256PublicKeyFromHex

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

ParseP256PublicKeyFromHex parses a P-256 public key from hex string

func SignWithP256

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

SignWithP256 signs data using a P256 private key

func ValidateEd25519PublicKey

func ValidateEd25519PublicKey(keyBytes []byte) error

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

func ValidateP256PublicKey

func ValidateP256PublicKey(publicKey *ecdsa.PublicKey) error

ValidateP256PublicKey validates that a public key is P-256

func VerifyP256Signature

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

VerifyP256Signature verifies a P256 signature

Types

type KeyData

type KeyData struct {
	PublicKeyHex  string
	PrivateKeyHex string
}

func GenerateEd25519Keys

func GenerateEd25519Keys() (KeyData, error)

generateEd25519Keys generates Ed25519 keypair

func GenerateP256Keys

func GenerateP256Keys() (KeyData, error)

Jump to

Keyboard shortcuts

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