Skip to content

Commit bd89bd6

Browse files
jedisct1andrewrk
authored andcommitted
Revamp crypto/aes
* Reorganize crypto/aes in order to separate parameters, implementations and modes. * Add a zero-cost abstraction over the internal representation of a block, so that blocks can be kept in vector registers in optimized implementations. * Add architecture-independent aesenc/aesdec/aesenclast/aesdeclast operations, so that any AES-based primitive can be implemented, including these that don't use the original key schedule (AES-PRF, AEGIS, MeowHash...) * Add support for parallelization/wide blocks to take advantage of hardware implementations. * Align T-tables to cache lines in the software implementations to slightly reduce side channels. * Add an optimized implementation for modern Intel CPUs with AES-NI. * Add new tests (AES256 key expansion). * Reimplement the counter mode to work with any block cipher, any endianness and to take advantage of wide blocks. * Add benchmarks for AES.
1 parent bba4576 commit bd89bd6

File tree

6 files changed

+1363
-643
lines changed

6 files changed

+1363
-643
lines changed

lib/std/crypto.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ pub const pwhash = struct {
5959
pub const core = struct {
6060
pub const aes = @import("crypto/aes.zig");
6161
pub const Gimli = @import("crypto/gimli.zig").State;
62+
63+
/// Modes are generic compositions to construct encryption/decryption functions from block ciphers and permutations.
64+
///
65+
/// These modes are designed to be building blocks for higher-level constructions, and should generally not be used directly by applications, as they may not provide the expected properties and security guarantees.
66+
///
67+
/// Most applications may want to use AEADs instead.
68+
pub const modes = @import("crypto/modes.zig");
6269
};
6370

6471
/// Elliptic-curve arithmetic.
@@ -111,6 +118,7 @@ test "crypto" {
111118
_ = @import("crypto/gimli.zig");
112119
_ = @import("crypto/hmac.zig");
113120
_ = @import("crypto/md5.zig");
121+
_ = @import("crypto/modes.zig");
114122
_ = @import("crypto/pbkdf2.zig");
115123
_ = @import("crypto/poly1305.zig");
116124
_ = @import("crypto/sha1.zig");

0 commit comments

Comments
 (0)