Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

tc_cbc_mode_decrypt doc inaccurate #50

@yannroth

Description

@yannroth

The description of the in parameter of tc_cbc_mode_decrypt is misleading. All examples show that in should point on the cipher text offset by the size of the iv (which is a block):
https://github.com/intel/tinycrypt/blob/master/tests/test_cbc_mode.c#L134 :

p = &encrypted[TC_AES_BLOCK_SIZE];
	length = ((unsigned int) sizeof(encrypted));

	if (tc_cbc_mode_decrypt(decrypted, length, p, length, encrypted, &a) == 0) {
...

But both the note and the description of the in param are suggesting that it should point on the cipher text including the IV:
https://github.com/intel/tinycrypt/blob/master/lib/include/tinycrypt/cbc_mode.h#L128 :

* @note Assumes:- in == iv + ciphertext, i.e. the iv and the ciphertext are
 *                contiguous. This allows for a very efficient decryption
 *                algorithm that would not otherwise be possible

* @param in IN -- ciphertext to decrypt, including IV

I'd propose to modify the doc to something like:

* @note Assumes:- the IV and the ciphertext need to be
 *                contiguous. This allows for a very efficient decryption
 *                algorithm that would not otherwise be possible

* @param in IN -- ciphertext to decrypt, not including IV
* @param iv IN -- the IV for the encrypt/decrypt, must be followed by ciphertext

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions