Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AES engine failing for plaintext shorter than 16 bytes #1

Open
malishav opened this issue Mar 31, 2022 · 0 comments
Open

AES engine failing for plaintext shorter than 16 bytes #1

malishav opened this issue Mar 31, 2022 · 0 comments

Comments

@malishav
Copy link

Branch: crypto

I am getting all-zero ciphertext when invoking the CCM routine on a plaintext that is less than 16 bytes. Looking at the CCM specification, it seems that padding needs to take place to round the lenght of the plaintext to 16-byte blocks. However, this seems to be working for plaintext sizes larger than 16 bytes. I couldn't find the place in the code where this is being done (possibly hardware is handling it?) so am opening this issue for reference.

Here is my minimal code snippet, excluding the boilerplate code:


    const P_3_TV:[u8; 10] = [0x2b, 0x48, 0x4c, 0xd5, 0x3d, 0x74, 0xf0, 0xa6, 0xed, 0x8b];
    let nonce = [
        0x00, 0x00, 0xf0, 0xe0, 0xd0, 0xc0, 0xb0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x05,
    ];
    let mut data_out = [0; 10];
    let mut tag = [0; 16];

    let ccm_info = AesCcmInfo::new(0, 2, 0).with_added_auth_data(&[]);
    aes_crypto.ccm_encrypt(
        &ccm_info,
        &IV_3_TV,
        &P_3_TV,
        &mut data_out[..],
        &mut tag[..],
    );

    rprintln!("data out: {:0x?}", data_out);

which gives the following output

data out: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant