cipher

package
Version: v0.0.78 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cipher collects common cryptographic constants and interfaces.

Index

Constants

View Source
const (
	// NoOperation identified for Encrypt and Decrypter in noop package.
	NoOperation byte = 0x20

	// NACLECDH identified for Encrypt and Decrypter in nacl package using ECDH
	// for key exchange and share secret generation.
	NACLECDH byte = 0x2a

	// AES256CBC identified for Encrypt and Decrypter in aes256cbc package.
	AES256CBC byte = 0x2e
)

Variables

View Source
var (
	// ErrEncrypt returns the error message if encryption failed
	//
	ErrEncrypt = errors.New("cipher: encryption failed") //nolint:gochecknoglobals
	// ErrDecrypt returns the error message if decryption failed
	//
	ErrDecrypt = errors.New("cipher: decryption failed") //nolint:gochecknoglobals
)

Functions

This section is empty.

Types

type Decrypter

type Decrypter interface {
	Decrypt(EncryptedContent) (PlainContent, error)
}

A Decrypter uses the PrivateKey to decrypt the supplied data.

The decryption method used is dependant on the implementation and must check that the data can be decrypted before continuing. Returned data should be the plain bytes that were supplied originally to the Encrypter.

type EncryptedContent

type EncryptedContent []byte

EncryptedContent typed version of byte array that holds encrypted data.

Encrypt method returns the encrypted contents as EncryptedContent. Decrypt method accepts EncryptedContent as the encrypted contents to decrypt.

type Encrypter

type Encrypter interface {
	Encrypt(PlainContent) (EncryptedContent, error)
}

An Encrypter uses the PublicKey to encrypt the supplied data.

The encryption method used is dependant on the implementation and must be included in the response. Returned encrypted data must include what encryption method was used as the first byte. The data can be decrypted using the corresponding PrivateKey and Decrypter method.

type KeyExchange added in v0.0.43

type KeyExchange interface {
	// EphemeralKey generates a private/public key pair.
	EphemeralKey() (private crypto.PrivateKey, err error)

	// SharedSecret computes a secret value from a private / public key pair.
	// On sending a message the private key should be an ephemeralKey or generated private key,
	// the public key is the recipient public key.
	// On reading a message the private key is the recipient private key, the public key is the
	// ephemeralKey or generated public key.
	SharedSecret(privateKey crypto.PrivateKey, publicKey crypto.PublicKey) ([]byte, error)
}

KeyExchange agrees on a symmetric keys by performing a key exchange using asymmetric keys.

type PlainContent

type PlainContent []byte

PlainContent typed version of byte array that holds plain data.

Encrypt method returns the encrypted contents as EncryptedContent. Decrypt method accepts EncryptedContent as the encrypted contents to decrypt.

Directories

Path Synopsis
Package aes256cbc implements Advanced Encryption Standard with a 256 bit key length, using Chain Block Cipher mode (AES-256-CBC).
Package aes256cbc implements Advanced Encryption Standard with a 256 bit key length, using Chain Block Cipher mode (AES-256-CBC).
Package ciphertest is a generated GoMock package.
Package ciphertest is a generated GoMock package.
Package ecdh has implementations for different asymmetric key exchange.
Package ecdh has implementations for different asymmetric key exchange.
Package noop is a no operation encryption algorithm for use when the message is intended to be publically readable.
Package noop is a no operation encryption algorithm for use when the message is intended to be publically readable.

Jump to

Keyboard shortcuts

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