Skip to main content

Module symmetric

Module symmetric 

Source
Expand description

COSE symmetric encryption โ€” the middle layer of the three-layer stack:

  • Lowest: Hazmat primitive (crate::hazmat::symmetric_encryption)
  • Mid: COSE framing (this module)
  • High: Consumer (crate::safe, EncString)

Enumsยง

CoseContentEncryptionAlgorithm ๐Ÿ”’
The content-encryption algorithms that can seal the body of a COSE message.

Constantsยง

TEXT_PAD_BLOCK_SIZE ๐Ÿ”’

Traitsยง

CoseEncryptCipher ๐Ÿ”’
Encrypts and decrypts the content of COSE [CoseEncrypt]/[CoseEncrypt0] messages with an Aead cipher, using the cipherโ€™s key as the content-encryption key (CEK).

Functionsยง

algorithm_from_header ๐Ÿ”’
Recovers the content-encryption algorithm declared in a messageโ€™s protected header, falling back to default_algorithm when the header omits one.
decrypt_cose ๐Ÿ”’
Authenticates and decrypts a multi-recipient COSE [CoseEncrypt] message, dispatching to the CoseEncryptCipher indicated by the content-encryption algorithm declared in the messageโ€™s protected header.
decrypt_cose0 ๐Ÿ”’
Authenticates and decrypts a single-recipient COSE [CoseEncrypt0] message, dispatching to the CoseEncryptCipher indicated by the content-encryption algorithm declared in the messageโ€™s protected header.
decrypt_xchacha20_poly1305 ๐Ÿ”’
Decrypts a COSE Encrypt0 message using a XChaCha20Poly1305 key.
encrypt_cose ๐Ÿ”’
Encrypts plaintext into a multi-recipient COSE [CoseEncrypt] message, dispatching to the CoseEncryptCipher selected by algorithm.
encrypt_cose0 ๐Ÿ”’
Encrypts plaintext into a single-recipient COSE [CoseEncrypt0] message, dispatching to the CoseEncryptCipher selected by algorithm.
encrypt_xchacha20_poly1305 ๐Ÿ”’
Encrypts a plaintext message using XChaCha20Poly1305 and returns a COSE Encrypt0 message.
ensure_algorithm_matches ๐Ÿ”’
Validates that, if the protected header declares a content-encryption algorithm, it matches Cโ€™s.
should_pad_content ๐Ÿ”’