package
1.0.1
Repository: https://github.com/terramate-io/opentofulib.git
Documentation: pkg.go.dev

# README

Encryption methods

[!WARNING] This file is not an end-user documentation, it is intended for developers. Please follow the user documentation on the OpenTofu website unless you want to work on the encryption code.

This folder contains the implementations for the encryption methods used in OpenTofu. Encryption methods determine how exactly data is encrypted, but they do not determine what exactly is encrypted.

Implementing a method

When you implement a method, take a look at the aesgcm method as a template.

Testing your method (do this first!)

Before you even go about writing a method, please set up the compliance tests. You can create a single test case that calls compliancetest.ComplianceTest. This test suite will run your key provider through all important compliance tests and will make sure that you are not missing anything during the implementation.

Implementing the descriptor

The descriptor is very simple, you need to implement the Descriptor interface in a type. (It does not have to be a struct.) However, make sure that the ConfigStruct always returns a struct with hcl tags on it. For more information on the hcl tags, see the gohcl documentation.

The config struct

Next, you need to create a config structure. This structure should hold all the fields you expect a user to fill out. This must be a struct, and you must add hcl tags to each field you expect the user to fill out.

If the config structure needs input from key providers, it should declare one HCL-tagged field with the type of keyprovider.Output to receive the encryption and decryption key. Note, that the decryption key is not always available.

Additionally, you must implement the Build function described in the Config interface. You can take a look at aesgcm/config.go for an example on implementing this.

The method

The heart of your method is... well, your method. It has the Encrypt() and Decrypt() methods, which should perform the named tasks. If no decryption key is available, the method should refuse to decrypt data. The method should under no circumstances pass through unencrypted data if it fails to decrypt the data.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewAddr creates a new Addr type from the provider and name supplied.

# Structs

ErrCryptoFailure indicates a generic cryptographic failure.
ErrDecryptionFailed indicates that decrypting a set of data failed.
ErrDecryptionKeyUnavailable indicates that no decryption key is available.
ErrEncryptionFailed indicates that encrypting a set of data failed.
ErrInvalidConfiguration indicates that the method configuration is incorrect.

# Interfaces

Config describes a configuration struct for setting up an encryption Method.
Descriptor contains the details on an encryption method and produces a configuration structure with default values.
Method is a low-level encryption method interface that is responsible for encrypting a binary blob of data.

# Type aliases

Addr is a type-alias for method address strings that identify a specific encryption method configuration.
ID is a type alias to make passing the wrong ID into a method ID harder.