Help us shape the future of Go! Take the 2026 Go Developer Survey

crypto

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package crypto provides the integrity and signing primitives gitdr relies on: SHA-256 checksums for every artifact and Ed25519 signatures for the run-manifest.

Index

Constants

View Source
const EncryptionKeySize = 32

EncryptionKeySize is the required KEK length (AES-256).

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(dst io.Writer, src io.Reader, kek []byte) error

Decrypt streams a gitdr envelope-encrypted src to dst.

func DecryptFile

func DecryptFile(srcPath, dstPath string, kek []byte) error

DecryptFile streams an encrypted srcPath to a new plaintext dstPath.

func Encrypt

func Encrypt(dst io.Writer, src io.Reader, kek []byte) error

Encrypt streams src to dst as a gitdr envelope-encrypted stream.

func EncryptFile

func EncryptFile(srcPath, dstPath string, kek []byte) error

EncryptFile streams srcPath to a new encrypted dstPath.

func GenerateKeyPair

func GenerateKeyPair() (pubPEM, privPEM []byte, err error)

GenerateKeyPair creates an Ed25519 keypair and returns PEM-encoded public (PKIX) and private (PKCS#8) keys. Primarily for tests and key bootstrap.

func IsEncrypted

func IsEncrypted(b []byte) bool

IsEncrypted reports whether b begins with the gitdr envelope magic, i.e. it is ciphertext produced by Encrypt/EncryptFile. Used to detect an encrypted artifact when no key was supplied, so restore can fail with a clear message.

func ParseEncryptionKey

func ParseEncryptionKey(data []byte) ([]byte, error)

ParseEncryptionKey accepts a 32-byte key as 64-char hex, base64, or raw bytes.

func ParsePrivateKey

func ParsePrivateKey(data []byte) (ed25519.PrivateKey, error)

ParsePrivateKey decodes an Ed25519 private key from PEM, raw, or base64 input.

func ParsePublicKey

func ParsePublicKey(data []byte) (ed25519.PublicKey, error)

ParsePublicKey decodes an Ed25519 public key from PEM, raw, or base64 input.

func SHA256Bytes

func SHA256Bytes(b []byte) string

SHA256Bytes returns the lowercase hex SHA-256 of b.

func SHA256File

func SHA256File(path string) (string, int64, error)

SHA256File hashes the file at path.

func SHA256Hex

func SHA256Hex(r io.Reader) (string, int64, error)

SHA256Hex streams r through SHA-256 and returns the lowercase hex digest and the number of bytes hashed.

func Sign

func Sign(priv ed25519.PrivateKey, msg []byte) []byte

Sign returns a detached Ed25519 signature over msg.

func Verify

func Verify(pub ed25519.PublicKey, msg, sig []byte) error

Verify checks a detached Ed25519 signature, returning an error on mismatch.

Types

This section is empty.

Jump to

Keyboard shortcuts

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