indexedDb

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher interface {
	// Encrypt encrypts the raw data. The returned ciphertext is encoded and
	// includes the nonce (24 bytes) and the encrypted plaintext
	// (with possible padding, if needed).
	//
	// Prior to encrypting the plaintext, a padding will be appended if it is
	// shorter than the pre-defined block size passed into NewCipher.
	//
	// If the plaintext is longer than the block size, then Encrypt will return
	// an error.
	Encrypt(plainText []byte) (cipherText string, err error)

	// Decrypt decrypts the given encoded ciphertext and returns the plaintext.
	// Any padding added to the plaintext during encryption is stripped.
	Decrypt(cipherText string) (plainText []byte, err error)

	// Marshaler marshals the cryptographic information in the cypher for
	// sending over the wire.
	json.Marshaler

	// Unmarshaler does not transfer the internal RNG. Use NewCipherFromJSON to
	// properly reconstruct a cipher from JSON.
	json.Unmarshaler
}

Cipher manages the encryption and decryption of channel messages that are inserted into or read from the database.

func NewCipher

func NewCipher(internalPassword, salt []byte, plaintextBlockSize int,
	csprng io.Reader) (Cipher, error)

NewCipher generates a new Cipher from a password and salt.

plaintextBlockSize is the maximum allowed length of any encrypted plaintext.

func NewCipherFromJSON

func NewCipherFromJSON(data []byte, csprng io.Reader) (Cipher, error)

NewCipherFromJSON generates a new Cipher from its marshalled JSON and a CSPRNG.

Jump to

Keyboard shortcuts

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