CbcMode

Mojo struct 🡭

CbcMode

@memory_only
struct CbcMode[Cipher: BlockCipherDecryptable & BlockCipherEncryptable & Copyable & Deinitable]

CBC block cipher mode of operation.

See NIST SP 800-38A, Section 6.2.

Aliases

  • BLOCK_SIZE = Cipher.BLOCK_SIZE

Parameters

  • Cipher (BlockCipherDecryptable & BlockCipherEncryptable & Copyable & Deinitable)

Implemented traits

AnyType, BlockCipherDecryptable, BlockCipherEncryptable, Copyable, Deinitable, Movable

Methods

__init__

fn def __init__(out self, var cipher: Cipher, var iv: Array[UInt8, Cipher.BLOCK_SIZE])

Args:

  • cipher (Cipher)
  • iv (Array[UInt8, Cipher.BLOCK_SIZE])
  • self (Self)

Returns:

Self

encrypt

fn def encrypt[o: MutOrigin](mut self, data: Span[UInt8, o])

Parameters:

  • o (MutOrigin)

Args:

  • self (Self)
  • data (Span[UInt8, o])

Raises:

decrypt

fn def decrypt[o: MutOrigin](mut self, data: Span[UInt8, o])

Parameters:

  • o (MutOrigin)

Args:

  • self (Self)
  • data (Span[UInt8, o])

Raises: