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

Implement AES-CCM #1373

Merged
merged 7 commits into from
Jan 12, 2024
Merged

Implement AES-CCM #1373

merged 7 commits into from
Jan 12, 2024

Conversation

geedo0
Copy link
Contributor

@geedo0 geedo0 commented Dec 22, 2023

Issues:

Resolves: CryptoAlg-2085

Description of changes:

Describe AWS-LC’s current behavior and how your code changes that behavior. If there are no issues this pr is resolving, explain why this change is necessary.

This exposes the AES-CCM block cipher algorithm via the EVP_CIPHER API. Currently we only support a limited set of AES-CCM modes via the EVP_AEAD interface for the Bluetooth, Bluetooth-8, and Matter wireless protocols. This PR introduces support for all AES key sizes (128, 192, and 256) as well as the ability to configure arbitrary AES-CCM modes via the M and L parameters.

Call-outs:

  • AES-CCM in OpenSSL has a number of idiosyncrasies. I chose to prefer the behavior of upstream OpenSSL rather than imposing "more consistent" behavior relative to our other AEAD algorithms like AES-GCM and ChaCha20-Poly1305. This approach will improve our OpenSSL compatibility rather than introduce issues in potential consumers in the future.
    • AES-CCM only works in one-shot mode. i.e. incremental updates are not allowed. This is documented in the wiki and inferred from the source
    • Tag validation happens in EVP_Decrypt_Update rather than EVP_Decrypt_Final. This is in-line with the OpenSSL wiki, OpenSSL source, and strongSwan consuming source.
    • The NULL-ness of the in and out parameters going into EVP_Cipher_Update is very important. The unit tests have been updated to ensure that non-NULL pointers are passed in regardless of whether or not the length is 0.
  • We are introducing new to LC CCM operating modes and key sizes for AES-CCM that were not exposed via the EVP_AEAD mode. Please review that the cryptography for these are sound.

Testing:

How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?

  • All the NIST CAVP test vectors have been imported from upstream OpenSSL and run into the EVP_CIPHER test suite.
  • All the existing EVP_AEAD test vectors for Bluetooth, Bluetooth-8, and Matter have been run into the EVP_AEAD test vector runner.
  • All the AES-CCM Wycheproof test vectors were generated using convert_wycheproof.go and run through the test runner developed for ChaCha20-Poly1305.
  • All CI is passing aside from aws-lc-ci-ec2-test-framework which appears universal to all active PRs.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (7226be1) 76.84% compared to head (061ad4f) 76.82%.
Report is 24 commits behind head on main.

Files Patch % Lines
crypto/fipsmodule/cipher/e_aesccm.c 88.37% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1373      +/-   ##
==========================================
- Coverage   76.84%   76.82%   -0.02%     
==========================================
  Files         424      424              
  Lines       71392    71500     +108     
==========================================
+ Hits        54859    54933      +74     
- Misses      16533    16567      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This exposes the AES-CCM block cipher algorithm via the EVP_CIPHER API. Currently we only support a limited set of AES-CCM modes via the EVP_AEAD interface for the Bluetooth, Bluetooth-8, and Matter wireless protocols. This PR introduces support for all AES key sizes (128, 192, and 256) as well as the ability to configure arbitrary AES-CCM modes via the M and L parameters.
@geedo0 geedo0 marked this pull request as ready for review January 2, 2024 17:58
@geedo0 geedo0 requested a review from a team as a code owner January 2, 2024 17:58
include/openssl/cipher.h Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Outdated Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Outdated Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Show resolved Hide resolved
crypto/cipher_extra/cipher_test.cc Show resolved Hide resolved
@torben-hansen torben-hansen self-requested a review January 9, 2024 14:58
- cleanse on other tag failures
- add constant for min tag
crypto/cipher_extra/cipher_test.cc Show resolved Hide resolved
crypto/cipher_extra/cipher_test.cc Show resolved Hide resolved
crypto/cipher_extra/cipher_test.cc Outdated Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Outdated Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Outdated Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Show resolved Hide resolved
- smaller bools
- Fix message truncation
crypto/fipsmodule/cipher/e_aesccm.c Outdated Show resolved Hide resolved
crypto/fipsmodule/cipher/e_aesccm.c Outdated Show resolved Hide resolved
@geedo0 geedo0 merged commit f7798b7 into aws:main Jan 12, 2024
34 of 36 checks passed
dougch pushed a commit to dougch/aws-lc that referenced this pull request Jan 30, 2024
This exposes the AES-CCM block cipher algorithm via the EVP_CIPHER API. Currently we only support a limited set of AES-CCM modes via the EVP_AEAD interface for the Bluetooth, Bluetooth-8, and Matter wireless protocols. This PR introduces support for all AES key sizes (128, 192, and 256) as well as the ability to configure arbitrary AES-CCM modes via the M and L parameters.
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

Successfully merging this pull request may close these issues.

4 participants