GpuCtrMode
Mojo struct 🡭
GpuCtrMode
@memory_only
struct GpuCtrMode[C: AsyncBlockCipherDecryptable & AsyncBlockCipherEncryptable & Deinitable & Movable, SIZE: Int = C.BLOCK_SIZE, BIG_ENDIAN: Bool = True]Counter (CTR) block cipher mode over an async (device-backed) cipher.
NIST SP 800-38A, Section 6.5: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf
Each keystream block is produced by its own awaited cipher call. SIZE
and BIG_ENDIAN are as in CtrMode.
Aliases
BLOCK_SIZE = C.BLOCK_SIZE
Parameters
- C (
AsyncBlockCipherDecryptable & AsyncBlockCipherEncryptable & Deinitable & Movable) - SIZE (
Int) - BIG_ENDIAN (
Bool)
Implemented traits
AnyType, AsyncBlockCipherDecryptable, AsyncBlockCipherEncryptable, Deinitable, Movable
Methods
__init__
fn def __init__(out self, var cipher: C, var ctr: Array[UInt8, C.BLOCK_SIZE])Initialize from a fully-assembled initial counter block.
Args:
- cipher (
C) - ctr (
Array[UInt8, C.BLOCK_SIZE]) - self (
Self)
Returns:
Self
encrypt
fn def encrypt[o: MutOrigin](mut self, ctx: Context, data: Span[UInt8, o])Parameters:
- o (
MutOrigin)
Args:
- self (
Self) - ctx (
Context) - data (
Span[UInt8, o])
Raises:
decrypt
fn def decrypt[o: MutOrigin](mut self, ctx: Context, data: Span[UInt8, o])Parameters:
- o (
MutOrigin)
Args:
- self (
Self) - ctx (
Context) - data (
Span[UInt8, o])
Raises: