Skip to main content
Version: 0.1.24

DES / 3DES

DES and 3DES are legacy block ciphers with 8-byte block size. 3DES (EDE) is stronger than single DES but still legacy and slower than modern ciphers.

  • DES: 56-bit effective key (not recommended for new systems).
  • 3DES (2-key/3-key): 112-bit or 168-bit effective key, still considered legacy.

Use these only for interoperability with existing protocols or systems. Prefer AES or ChaCha20-Poly1305 for new designs.

API

des_encrypt_block

noxtls_return_t des_encrypt_block(const uint8_t *key, const uint8_t *data, uint8_t *output);

Encrypt a single 8-byte block with DES.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

des_decrypt_block

noxtls_return_t des_decrypt_block(const uint8_t *key, const uint8_t *data, uint8_t *output);

Decrypt a single 8-byte block with DES.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

des3_encrypt_block

noxtls_return_t des3_encrypt_block(const uint8_t *key, uint32_t key_len, const uint8_t *data, uint8_t *output);

Encrypt a single 8-byte block with 3DES (EDE). key_len is 16 (2-key) or 24 (3-key).

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

des3_decrypt_block

noxtls_return_t des3_decrypt_block(const uint8_t *key, uint32_t key_len, const uint8_t *data, uint8_t *output);

Decrypt a single 8-byte block with 3DES (DED). key_len is 16 (2-key) or 24 (3-key).

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

noxtls_des_encrypt_cbc

noxtls_return_t noxtls_des_encrypt_cbc(const uint8_t *key, const uint8_t *data, uint32_t data_len, const uint8_t *iv, uint8_t *output);

DES CBC encryption. data_len must be a multiple of 8. iv is 8 bytes.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

noxtls_des_decrypt_cbc

noxtls_return_t noxtls_des_decrypt_cbc(const uint8_t *key, const uint8_t *data, uint32_t data_len, const uint8_t *iv, uint8_t *output);

DES CBC decryption. data_len must be a multiple of 8. iv is 8 bytes.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

des3_encrypt_cbc

noxtls_return_t des3_encrypt_cbc(const uint8_t *key, uint32_t key_len, const uint8_t *data, uint32_t data_len, const uint8_t *iv, uint8_t *output);

3DES CBC encryption. key_len is 16 or 24. data_len must be multiple of 8. iv is 8 bytes.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

des3_decrypt_cbc

noxtls_return_t des3_decrypt_cbc(const uint8_t *key, uint32_t key_len, const uint8_t *data, uint32_t data_len, const uint8_t *iv, uint8_t *output);

3DES CBC decryption. key_len is 16 or 24. data_len must be multiple of 8. iv is 8 bytes.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS on success; otherwise a specific return code.

des_self_test

noxtls_return_t des_self_test(void);

Run DES/3DES known-answer self-tests.

Returns: noxtls_return_t: NOXTLS_RETURN_SUCCESS if tests pass; otherwise NOXTLS_RETURN_FAILED.