kipher

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package kipher implements standard block cipher modes that can be wrapped around low-level block cipher implementations.

See NIST SP 800-38A, NIST SP 800-38B, NIST SP 800-38D

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCBCDecrypter

func NewCBCDecrypter(b cipher.Block, iv []byte) cipher.BlockMode

NewCBCDecrypter returns a BlockMode which decrypts in cipher block chaining mode, using the given Block. The length of iv must be the same as the Block's block size and must match the iv used to encrypt the data.

func NewCBCEncrypter

func NewCBCEncrypter(b cipher.Block, iv []byte) cipher.BlockMode

NewCBCEncrypter returns a BlockMode which encrypts in cipher block chaining mode, using the given Block. The length of iv must be the same as the Block's block size.

func NewCCM

func NewCCM(b cipher.Block, nonceSize, tagSize int) (cipher.AEAD, error)

func NewCFBDecrypter

func NewCFBDecrypter(block cipher.Block, iv []byte) cipher.Stream

NewCFB8Decrypter returns a Stream which decrypts with cipher feedback mode, using the given Block. The iv must be the same length as the Block's block size.

func NewCFBDecrypterWithBlockSize

func NewCFBDecrypterWithBlockSize(block cipher.Block, iv []byte, cfbBlockByteSize int) cipher.Stream

func NewCFBEncrypter

func NewCFBEncrypter(block cipher.Block, iv []byte) cipher.Stream

NewCFBEncrypter returns a Stream which encrypts with cipher feedback mode, using the given Block. The iv must be the same length as the Block's block size.

func NewCFBEncrypterWithBlockSize

func NewCFBEncrypterWithBlockSize(block cipher.Block, iv []byte, cfbBlockByteSize int) cipher.Stream

func NewCTR

func NewCTR(block cipher.Block, iv []byte) cipher.Stream

NewCTR returns a Stream which encrypts/decrypts using the given Block in counter mode. The length of iv must be the same as the Block's block size.

func NewECBDecryptor

func NewECBDecryptor(b cipher.Block) cipher.BlockMode

func NewECBEncryptor

func NewECBEncryptor(b cipher.Block) cipher.BlockMode

func NewGCM

func NewGCM(b cipher.Block) (cipher.AEAD, error)

NewGCM returns the given 128-bit, block cipher wrapped in Galois Counter Mode with the standard nonce length.

In general, the GHASH operation performed by this implementation of GCM is not constant-time. An exception is when the underlying Block was created by aes.NewCipher on systems with hardware support for AES. See the crypto/aes package documentation for details.

func NewGCMWithNonceSize

func NewGCMWithNonceSize(b cipher.Block, size int) (cipher.AEAD, error)

NewGCMWithNonceSize returns the given 128-bit, block cipher wrapped in Galois Counter Mode, which accepts nonces of the given length. The length must not be zero.

Only use this function if you require compatibility with an existing cryptosystem that uses non-standard nonce lengths. All other users should use NewGCM, which is faster and more resistant to misuse.

func NewGCMWithSize

func NewGCMWithSize(b cipher.Block, nonceSize, tagSize int) (cipher.AEAD, error)

NewGCM returns the given 128-bit, block cipher wrapped in Galois Counter Mode with the standard nonce length.

In general, the GHASH operation performed by this implementation of GCM is not constant-time. An exception is when the underlying Block was created by aes.NewCipher on systems with hardware support for AES. See the crypto/aes package documentation for details.

if nonceSize = 0, nonceSize = 12 if tagSize = 0, tagSize = 16

func NewGCMWithTagSize

func NewGCMWithTagSize(b cipher.Block, tagSize int) (cipher.AEAD, error)

NewGCMWithTagSize returns the given 128-bit, block cipher wrapped in Galois Counter Mode, which generates tags with the given length.

Tag sizes between 1 and 16 bytes are allowed.

Only use this function if you require compatibility with an existing cryptosystem that uses non-standard tag lengths. All other users should use NewGCM, which is more resistant to misuse.

func NewOFB

func NewOFB(b cipher.Block, iv []byte) cipher.Stream

NewOFB returns a [Stream] that encrypts or decrypts using the block cipher b in output feedback mode. The initialization vector iv's length must be equal to b's block size.

Types

This section is empty.

Jump to

Keyboard shortcuts

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