Skip to main content

Module cose

Module cose 

Source
Expand description

This file contains private-use constants for COSE encoded key types and algorithms. Standardized values from https://www.iana.org/assignments/cose/cose.xhtml should always be preferred unless there is a a clear benefit, such as a clear cryptographic benefit, which MUST be documented publicly.

StructsΒ§

DecryptFailed

EnumsΒ§

CoseExtractError πŸ”’
SafeObjectNamespace πŸ”’

ConstantsΒ§

ALG_ARGON2ID13 πŸ”’
ARGON2_ITERATIONS πŸ”’
ARGON2_MEMORY πŸ”’
ARGON2_PARALLELISM πŸ”’
ARGON2_SALT πŸ”’
CONTAINED_KEY_ID πŸ”’
Indicates for any object containing a key (wrapped key, password protected key envelope) which key ID that contained key has
CONTENT_TYPE_BITWARDEN_LEGACY_KEY πŸ”’
CONTENT_TYPE_PADDED_CBOR πŸ”’
CONTENT_TYPE_PADDED_UTF8 πŸ”’
CONTENT_TYPE_SPKI_PUBLIC_KEY πŸ”’
SAFE_CONTENT_NAMESPACE πŸ”’
Each type of object has it’s own namespace for strong domain separation to eliminate attacks which attempt to confuse object types. For signatures, this refers to signature namespaces, for data envelopes to data envelope namespaces and so on.
SAFE_OBJECT_NAMESPACE πŸ”’
MUST be placed in the protected header of cose objects
SIGNING_NAMESPACE πŸ”’
The label used for the namespace ensuring strong domain separation when using signatures.
SYMMETRIC_KEY πŸ”’
XCHACHA20_POLY1305 πŸ”’
XChaCha20 https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha-03 is used over ChaCha20 to be able to randomly generate nonces, and to not have to worry about key wearout. Since the draft was never published as an RFC, we use a private-use value for the algorithm.
XCHACHA20_TEXT_PAD_BLOCK_SIZE πŸ”’

TraitsΒ§

ContentNamespace πŸ”’
CoseSerializable
Trait for structs that are serializable to COSE objects.

FunctionsΒ§

debug_key_operation πŸ”’
Helper function to convert a COSE KeyOperation to a debug string
decrypt_cose πŸ”’
Decrypt a CoseEncrypt0 message with a CoseKey
decrypt_xchacha20_poly1305 πŸ”’
Decrypts a COSE Encrypt0 message, using a XChaCha20Poly1305 key
encrypt_cose πŸ”’
Encrypt a plaintext message with a given key
encrypt_xchacha20_poly1305 πŸ”’
Encrypts a plaintext message using XChaCha20Poly1305 and returns a COSE Encrypt0 message
extract_bytes πŸ”’
extract_integer πŸ”’
should_pad_content πŸ”’