object

ctr

Generic Counter mode encryption and decryption using a whole-block big-endian counter.

Availability:
logtalk_load(block_ciphers(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-08-08
Compilation flags:
static, context_switching_calls
Imports:
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

crypt/5

Encrypts or decrypts bytes using an explicit initial whole-block big-endian counter. The counter is incremented internally while processing the input but is not returned. The client is responsible for managing initial counters across calls and preventing reuse of a counter sequence with the same key.

Compilation flags:
static
Template:
crypt(Cipher,Key,InitialCounter,Input,Output)
Mode and number of proofs:
crypt(+object_identifier,+list(byte),+list(byte),+list(byte),--list(byte)) - one_or_error
Exceptions:
Cipher is a variable:
instantiation_error
Cipher is neither a variable nor a prepared-key block cipher object:
domain_error(block_cipher,Cipher)
InitialCounter is not a byte list of exactly one block:
type_error(list(byte,BlockSize),InitialCounter)
Input is a variable or a partial list:
instantiation_error
Input is neither a partial list nor a list:
type_error(list,Input)
An element Byte of the Input list is neither a variable nor an integer:
type_error(integer,Byte)
An element Byte of the Input list is an integer but not a valid byte:
domain_error(byte,Byte)

crypt/6

Encrypts or decrypts bytes using an explicit initial whole-block big-endian counter and returns the next unused counter. The final counter equals the initial counter for empty input and is otherwise incremented once per processed input block, modulo the counter width.

Compilation flags:
static
Template:
crypt(Cipher,Key,InitialCounter,Input,FinalCounter,Output)
Mode and number of proofs:
crypt(+object_identifier,+list(byte),+list(byte),+list(byte),--list(byte),--list(byte)) - one_or_error
Exceptions:
Cipher is a variable:
instantiation_error
Cipher is neither a variable nor a prepared-key block cipher object:
domain_error(block_cipher,Cipher)
InitialCounter is not a byte list of exactly one block:
type_error(list(byte,BlockSize),InitialCounter)
Input is a variable or a partial list:
instantiation_error
Input is neither a partial list nor a list:
type_error(list,Input)
An element Byte of the Input list is neither a variable nor an integer:
type_error(integer,Byte)
An element Byte of the Input list is an integer but not a valid byte:
domain_error(byte,Byte)

Protected predicates

(no local declarations; see entity ancestors if any)

Private predicates

(no local declarations; see entity ancestors if any)

Operators

(none)