Skip to content

Commit 2f3234c

Browse files
authored
std.crypto: add AES-CCM and CBC-MAC (#25526)
* std.crypto: add AES-CCM and CBC-MAC Add AES-CCM (Counter with CBC-MAC) authenticated encryption and CBC-MAC message authentication code implementations to the standard library. AES-CCM combines CTR mode encryption with CBC-MAC authentication as specified in NIST SP 800-38C and RFC 3610. It provides authenticated encryption with support for additional authenticated data (AAD). CBC-MAC is a simple MAC construction used internally by CCM, specified in FIPS 113 and ISO/IEC 9797-1. Includes comprehensive test vectors from RFC 3610 and NIST SP 800-38C. * std.crypto: add CCM* (encryption-only) support to AES-CCM Implements CCM* mode per IEEE 802.15.4 specification, extending AES-CCM to support encryption-only mode when tag_len=0. This is required by protocols like ZigBee, Thread, and WirelessHART. Changes: - Allow tag_len=0 for encryption-only mode (no authentication) - Skip CBC-MAC computation when tag_len=0 in encrypt/decrypt - Correctly encode M'=0 in B0 block for CCM* mode - Add Aes128Ccm0 and Aes256Ccm0 convenience instances - Add IEEE 802.15.4 test vectors and CCM* tests * std.crypto: add doc comments for AES-CCM variants
1 parent 958faa7 commit 2f3234c

File tree

3 files changed

+1031
-0
lines changed

3 files changed

+1031
-0
lines changed

lib/std/crypto.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub const aead = struct {
4646
pub const Aes256Ocb = @import("crypto/aes_ocb.zig").Aes256Ocb;
4747
};
4848

49+
pub const aes_ccm = @import("crypto/aes_ccm.zig");
50+
4951
pub const ascon = struct {
5052
pub const AsconAead128 = @import("crypto/ascon.zig").AsconAead128;
5153
};
@@ -89,6 +91,7 @@ pub const auth = struct {
8991
pub const Aegis256Mac_128 = variants.Aegis256Mac_128;
9092
};
9193
pub const cmac = @import("crypto/cmac.zig");
94+
pub const cbc_mac = @import("crypto/cbc_mac.zig");
9295
};
9396

9497
/// Core functions, that should rarely be used directly by applications.

0 commit comments

Comments
 (0)