encrypted

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: BSD-3-Clause Imports: 7 Imported by: 10 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package encrypted provides a simple, secure system for encrypting data symmetrically with a passphrase.

It uses scrypt derive a key from the passphrase and the NaCl secret box cipher for authenticated encryption.

Deprecated: The encrypted package from go-tuf is already moved to https://github.com/secure-systems-lab/go-securesystemslib and will be deprecated here. Use github.com/secure-systems-lab/go-securesystemslib/encrypted instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext, passphrase []byte) ([]byte, error)

Decrypt takes a JSON-encoded ciphertext object encrypted using Encrypt and tries to decrypt it using passphrase. If successful, it returns the plaintext.

func Encrypt

func Encrypt(plaintext, passphrase []byte) ([]byte, error)

Encrypt takes a passphrase and plaintext, and returns a JSON object containing ciphertext and the details necessary to decrypt it.

func EncryptWithCustomKDFParameters added in v0.6.0

func EncryptWithCustomKDFParameters(plaintext, passphrase []byte, kdfLevel KDFParameterStrength) ([]byte, error)

EncryptWithCustomKDFParameters takes a passphrase, the plaintext and a KDF parameter level (Legacy, Standard, or OWASP), and returns a JSON object containing ciphertext and the details necessary to decrypt it.

func Marshal

func Marshal(v interface{}, passphrase []byte) ([]byte, error)

Marshal encrypts the JSON encoding of v using passphrase.

func MarshalWithCustomKDFParameters added in v0.6.0

func MarshalWithCustomKDFParameters(v interface{}, passphrase []byte, kdfLevel KDFParameterStrength) ([]byte, error)

MarshalWithCustomKDFParameters encrypts the JSON encoding of v using passphrase.

func Unmarshal

func Unmarshal(data []byte, v interface{}, passphrase []byte) error

Unmarshal decrypts the data using passphrase and unmarshals the resulting plaintext into the value pointed to by v.

Types

type KDFParameterStrength added in v0.6.0

type KDFParameterStrength uint8

KDFParameterStrength defines the KDF parameter strength level to be used for encryption key derivation.

const (
	// Legacy defines legacy scrypt parameters (N:2^15, r:8, p:1)
	Legacy KDFParameterStrength = iota + 1
	// Standard defines standard scrypt parameters which is focusing 100ms of computation (N:2^16, r:8, p:1)
	Standard
	// OWASP defines OWASP recommended scrypt parameters (N:2^17, r:8, p:1)
	OWASP
)

Jump to

Keyboard shortcuts

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