literals

package
v0.0.0-...-24ce6ba Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestObfuscator string
)

Functions

func AsconDecrypt

func AsconDecrypt(key, nonce, ciphertextAndTag []byte) ([]byte, bool)

AsconDecrypt performs ASCON-128 authenticated decryption Input: ciphertext || tag Returns: plaintext, success (false if authentication fails)

func AsconEncrypt

func AsconEncrypt(key, nonce, plaintext []byte) []byte

AsconEncrypt performs ASCON-128 authenticated encryption Returns: ciphertext || tag (ciphertext length = plaintext length, tag = 16 bytes)

func Obfuscate

func Obfuscate(rand *mathrand.Rand, file *ast.File, info *types.Info, linkStrings map[*types.Var]string, nameFunc NameProviderFunc, cfg BuilderConfig) *ast.File

Obfuscate replaces literals with obfuscated anonymous functions.

func RegisteredStrategyNames

func RegisteredStrategyNames() []string

RegisteredStrategyNames returns the identifiers of all registered literal obfuscation strategies in registration order. It is primarily used by tooling and tests to reference specific strategies without exposing the underlying implementation type.

func SetReversibleMode

func SetReversibleMode(reversible bool)

SetReversibleMode sets the obfuscation mode.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(rand *mathrand.Rand, file *ast.File, nameFunc NameProviderFunc, cfg BuilderConfig) *Builder

func (*Builder) Finalize

func (b *Builder) Finalize(file *ast.File)

func (*Builder) ObfuscateFile

func (b *Builder) ObfuscateFile(file *ast.File, info *types.Info, linkStrings map[*types.Var]string) *ast.File

func (*Builder) ObfuscateStringLiteral

func (b *Builder) ObfuscateStringLiteral(value string, pos token.Pos) ast.Expr

type BuilderConfig

type BuilderConfig struct {
	KeyProvider KeyProvider
}

type KeyProvider

type KeyProvider interface {
	// NextLiteralKeys returns a unique 16-byte key and 16-byte nonce pair for
	// the ASCON literal backend.
	NextLiteralKeys() (key, nonce []byte)

	// NextIrreversibleMaterial returns deterministic pseudorandom bytes for the
	// irreversible literal backend. The caller specifies how many bytes are
	// required for round subkeys or other material.
	NextIrreversibleMaterial(size int) []byte
}

KeyProvider generates per-literal keying material for encryption-based obfuscators.

func NewHKDFKeyProvider

func NewHKDFKeyProvider(masterSecret, packageSalt []byte, fileID string) KeyProvider

NewHKDFKeyProvider constructs a KeyProvider backed by HKDF-SHA256.

masterSecret should come from combineSeedAndNonce(seed, nonce) when a CLI seed is provided; otherwise the package GarbleActionID is used. packageSalt must be a stable, package-unique identifier such as the GarbleActionID. fileID should be a trimmed/relative path that is stable across builds.

type NameProviderFunc

type NameProviderFunc func(rand *mathrand.Rand, baseName string) string

NameProviderFunc defines a function type that generates a string based on a random source and a base name.

Jump to

Keyboard shortcuts

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