category
block_cipher_modes_common
Shared validation, block, XOR, and PKCS#7 predicates for block cipher modes.
Availability:
logtalk_load(block_ciphers(loader))Author: Paulo Moura
Version: 1:0:0
Date: 2026-08-08
Compilation flags:
staticRemarks:
(none)
Inherited public predicates:
(none)
Public predicates
(no local declarations; see entity ancestors if any)
Protected predicates
prepare_cipher/4
Validates a cipher object, queries its block size, and prepares a key.
Compilation flags:
staticTemplate:
prepare_cipher(Cipher,Key,BlockSize,PreparedKey)Mode and number of proofs:
prepare_cipher(+object_identifier,+list(byte),--positive_integer,--compound) - one_or_errorExceptions:
Cipher is a variable:instantiation_errorCipher is not a variable but does not implement the prepared-key block cipher protocol:domain_error(block_cipher,Cipher)Cipher implements he prepared-key block cipher protocol but reports an invalid block size:domain_error(block_cipher_block_size,BlockSize)Key is invalid for Cipher:type_error(list(byte,KeySize),Key)check_bytes/1
Checks a list of bytes.
Compilation flags:
staticTemplate:
check_bytes(Bytes)Mode and number of proofs:
check_bytes(+list(byte)) - one_or_errorExceptions:
Bytes is a variable or a partial list:instantiation_errorBytes is neither a partial list nor a list:type_error(list,Bytes)An element
Byte of the Bytes list is neither a variable nor an integer:type_error(integer,Byte)An element
Byte of the Bytes list is an integer but not a valid byte:domain_error(byte,Byte)check_block/2
Checks a byte list whose length is exactly one block.
Compilation flags:
staticTemplate:
check_block(BlockSize,Block)Mode and number of proofs:
check_block(+positive_integer,+list(byte)) - one_or_errorExceptions:
BlockSize is a variable:instantiation_errorBlockSize is neither a variable nor an integer:type_error(integer,BlockSize)BlockSize is an integer but not a positive integer:domain_error(positive_integer,BlockSize)Block is a variable or a partial list:instantiation_errorBlock is not a list of exactly BlockSize bytes:type_error(list(byte,BlockSize),Block)An element
Byte of the Block` list is neither a variable nor an integer:type_error(integer,Byte)An element
Byte of the Block list is an integer but not a valid byte:domain_error(byte,Byte)check_aligned/2
Checks that a byte-list length is a multiple of the block size.
Compilation flags:
staticTemplate:
check_aligned(BlockSize,Bytes)Mode and number of proofs:
check_aligned(+positive_integer,+list(byte)) - one_or_errorExceptions:
BlockSize is a variable:instantiation_errorBlockSize is neither a variable nor an integer:type_error(integer,BlockSize)BlockSize is an integer but not a positive integer:domain_error(positive_integer,BlockSize)Bytes length is not a multiple of BlockSize:domain_error(block_aligned_byte_length(BlockSize),Bytes)blocks/3
Splits an aligned byte list into blocks.
Compilation flags:
staticTemplate:
blocks(BlockSize,Bytes,Blocks)Mode and number of proofs:
blocks(+positive_integer,+list(byte),--list(list(byte))) - onexor_bytes/3
XORs equal-length byte lists.
Compilation flags:
staticTemplate:
xor_bytes(Bytes1,Bytes2,Bytes)Mode and number of proofs:
xor_bytes(+list(byte),+list(byte),--list(byte)) - onepkcs7_pad/3
Pads bytes using PKCS#7.
Compilation flags:
staticTemplate:
pkcs7_pad(BlockSize,Bytes,PaddedBytes)Mode and number of proofs:
pkcs7_pad(+positive_integer,+list(byte),--list(byte)) - one_or_errorExceptions:
BlockSize exceeds the maximum PKCS#7 block size:domain_error(pkcs7_block_size,BlockSize)pkcs7_unpad/4
Validates and removes PKCS#7 padding, reporting the supplied error value when padding is invalid.
Compilation flags:
staticTemplate:
pkcs7_unpad(BlockSize,PaddedBytes,ErrorValue,Bytes)Mode and number of proofs:
pkcs7_unpad(+positive_integer,+list(byte),+term,--list(byte)) - one_or_errorExceptions:
BlockSize exceeds the maximum PKCS#7 block size:domain_error(pkcs7_block_size,BlockSize)PaddedBytes does not contain valid PKCS#7 padding:domain_error(pkcs7_padding,ErrorValue)Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)