Documentation
¶
Overview ¶
Package crypto provides cryptographic primitives for cryptkey: HKDF-SHA256 key derivation and AES-256-GCM authenticated encryption of Shamir shares.
Index ¶
- func ConfigHMAC(masterKey, data []byte) ([]byte, error)
- func DecryptShare(providerSecret, aad []byte, es *EncryptedShare) ([]byte, error)
- func DeriveOutputKey(masterKey, salt []byte, info string, length int) ([]byte, error)
- func VerifyConfigHMAC(masterKey, data, expected []byte) (bool, error)
- func WipeBytes(b []byte)
- type EncryptedShare
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigHMAC ¶
ConfigHMAC computes an HMAC-SHA256 over data using a key derived from the master key. Used to detect config tampering without storing the master key.
func DecryptShare ¶
func DecryptShare(providerSecret, aad []byte, es *EncryptedShare) ([]byte, error)
DecryptShare decrypts a Shamir share using a provider's 32-byte secret. The aad must match the value used during encryption.
func DeriveOutputKey ¶
DeriveOutputKey stretches a reconstructed master key through HKDF-SHA256 into a final output key of the requested length. salt and info provide per-profile domain separation.
func VerifyConfigHMAC ¶
VerifyConfigHMAC checks a config HMAC against expected.
func WipeBytes ¶
func WipeBytes(b []byte)
WipeBytes zeroes a byte slice and uses runtime.KeepAlive to discourage the compiler from optimizing the zeroing away. This is a best-effort mitigation: Go's garbage collector may copy heap objects during compaction, leaving prior copies in freed pages that are not wiped. For true memory-forensic resistance, an mlock/madvise approach or a non-GC language would be required. Use this for all secret material cleanup regardless — it raises the bar meaningfully.
Types ¶
type EncryptedShare ¶
type EncryptedShare struct {
}
EncryptedShare holds the ciphertext and parameters needed to decrypt a Shamir share given the originating provider's 32-byte secret.
func EncryptShare ¶
func EncryptShare(providerSecret, share, aad []byte) (*EncryptedShare, error)
EncryptShare encrypts a Shamir share using a provider's 32-byte secret. The aad parameter binds the ciphertext to context (e.g. provider type and ID).
Flow: HKDF-SHA256(secret, random_salt, info) → 32-byte AES key → AES-256-GCM(share, aad).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package hkdfinfo is the central registry of HKDF info strings used throughout cryptkey.
|
Package hkdfinfo is the central registry of HKDF info strings used throughout cryptkey. |
|
Package keyformat converts raw 32-byte derived keys into structured cryptographic key formats (age identities, OpenSSH ed25519 keys).
|
Package keyformat converts raw 32-byte derived keys into structured cryptographic key formats (age identities, OpenSSH ed25519 keys). |
|
Package shamir implements Shamir's Secret Sharing over GF(256).
|
Package shamir implements Shamir's Secret Sharing over GF(256). |