security

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package security provides cryptographic utilities for cloop's data integrity.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("state file signature mismatch: file may have been tampered with")

ErrInvalidSignature is returned when HMAC verification fails.

Functions

func RedactAPIKey

func RedactAPIKey(s string) string

RedactAPIKey masks all but the first 4 and last 4 characters of a secret. Values of 8 or fewer characters are fully masked as "****". Used to ensure sensitive values are never logged in plaintext.

func Sign

func Sign(key string, data []byte) string

Sign computes HMAC-SHA256 of data using key and returns the hex-encoded digest.

func SigningKey

func SigningKey() string

SigningKey returns the HMAC key from the environment variable CLOOP_STATE_HMAC_KEY. Returns an empty string when the variable is not set (signing disabled).

func Verify

func Verify(key string, data []byte, sig string) error

Verify returns nil when the provided sig matches HMAC-SHA256(key, data). Returns ErrInvalidSignature otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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