crypto

package
v0.0.0-...-81637fe Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SessionKeyBytes defines how many bytes of keying material we derive for each
	// QPP pad direction.
	SessionKeyBytes = 256

	// HmacKeyBytes defines the length of the per-direction integrity key.
	HmacKeyBytes = 32
)
View Source
const (
	// MinPadCount defines the minimum allowed pad count for QPP.
	MinPadCount = 1024

	// MaxPadCount defines the maximum allowed pad count for QPP.
	MaxPadCount = 2048
)
View Source
const (
	// KdfName defines the key derivation function used for encrypting private keys.
	KdfName = "scrypt"

	// ScryptCostN defines the CPU/memory cost parameter for scrypt.
	ScryptCostN = 1 << 15

	// ScryptCostR defines the block size parameter for scrypt.
	ScryptCostR = 8

	// ScryptCostP defines the parallelization parameter for scrypt.
	ScryptCostP = 1

	// EncryptedKeyType defines the format identifier for encrypted private key files.
	EncryptedKeyType = "encrypted-hppk"
)

Variables

This section is empty.

Functions

func DeriveDirectionalMAC

func DeriveDirectionalMAC(master []byte, label string) ([]byte, error)

DeriveDirectionalMAC returns the per-direction MAC key.

func DeriveDirectionalSeed

func DeriveDirectionalSeed(master []byte, label string) ([]byte, error)

DeriveDirectionalSeed deterministically expands the shared master secret per direction.

func FingerprintPublicKey

func FingerprintPublicKey(pub *hppk.PublicKey) (string, error)

FingerprintPublicKey returns a short deterministic fingerprint for display/trust decisions.

func GenerateKeyPair

func GenerateKeyPair(path string, strength int, passphrase *memguard.LockedBuffer) error

GenerateKeyPair creates a new HPPK keypair, optionally encrypts the private key, and persists both halves.

func LoadPrivateKey

func LoadPrivateKey(path string) (*hppk.PrivateKey, error)

LoadPrivateKey reads an HPPK private key and decrypts it if needed.

func LoadPublicKey

func LoadPublicKey(path string) (*hppk.PublicKey, error)

LoadPublicKey reads a JSON-encoded HPPK public key.

func MarshalPublicKey

func MarshalPublicKey(pub *hppk.PublicKey) ([]byte, error)

MarshalPublicKey serializes an HPPK public key using its binary representation.

func PromptPassword

func PromptPassword(prompt string, confirm bool) (*memguard.LockedBuffer, error)

PromptPassword prompts the user for a password, optionally confirming it.

func RandomPrimePadCount

func RandomPrimePadCount() (uint16, error)

RandomPrimePadCount returns a random prime number between MinPadCount and MaxPadCount.

func SignatureFromProto

func SignatureFromProto(msg *protocol.Signature) (*hppk.Signature, error)

SignatureFromProto rebuilds an HPPK signature from protobuf bytes.

func SignatureToProto

func SignatureToProto(sig *hppk.Signature) *protocol.Signature

SignatureToProto converts an HPPK signature into its protobuf equivalent.

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (*hppk.PublicKey, error)

UnmarshalPublicKey decodes an HPPK public key from its binary form.

func ValidatePadCount

func ValidatePadCount(p uint16) bool

ValidatePadCount checks if the given pad count is a prime number within the valid range.

Types

This section is empty.

Jump to

Keyboard shortcuts

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