Skip to content

Commit 3dbf79a

Browse files
committed
[aes/doc] Document Galois/Counter Mode (GCM) implementation + hardening
Signed-off-by: Pirmin Vogel <[email protected]>
1 parent 205d8e7 commit 3dbf79a

7 files changed

+5136
-390
lines changed

hw/ip/aes/README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ The AES unit supports the following features:
2828
- Electronic Codebook (ECB) mode,
2929
- Cipher Block Chaining (CBC) mode,
3030
- Cipher Feedback (CFB) mode (fixed data segment size of 128 bits, i.e., CFB-128),
31-
- Output Feedback (OFB) mode, and
32-
- Counter (CTR) mode.
31+
- Output Feedback (OFB) mode,
32+
- Counter (CTR) mode, and
33+
- Galois/Counter Mode (GCM) (fixed IV length of 96 bits, fixed tag length of 128 bits) including support for context switching (via saving and restoring).
34+
- Support for GCM can be removed to save area, and is enabled/disabled using a compile-time Verilog parameter
3335
- Support for AES-192 can be removed to save area, and is enabled/disabled using a compile-time Verilog parameter
3436
- First-order masking of the cipher core using domain-oriented masking (DOM) to deter side-channel analysis (SCA), can optionally be disabled using compile-time Verilog parameters (for more details see [Security Hardening](./doc/theory_of_operation.md#side-channel-analysis))
37+
- First-order masking of the GHASH operation involved in GCM (for more details see [Security Hardening](./doc/theory_of_operation.md#side-channel-analysis))
3538
- Latency per 16 byte data block of 12/14/16 clock cycles (unmasked implementation) and 56/66/72 clock cycles (DOM) in AES-128/192/256 mode
3639
- Automatic as well as software-initiated reseeding of internal pseudo-random number generators (PRNGs) with configurable reseeding rate resulting in max entropy consumption rates ranging from 343 Mbit/s to 0.042 Mbit/s (at 100 MHz).
3740
- Countermeasures for deterring fault injection (FI) on the control path (for more details see [Security Hardening](./doc/theory_of_operation.md#fault-injection))
@@ -42,19 +45,19 @@ The AES unit supports the following features:
4245
This AES unit targets medium performance (16 parallel S-Boxes, \~1 cycle per round for the unmasked implementation, \~5 cycles per round for the DOM implementation).
4346
High-speed, single-cycle operation for high-bandwidth data streaming is not required.
4447

45-
Cipher modes other than ECB, CBC, CFB, OFB and CTR are beyond this version of the AES unit but might be supported in future versions.
46-
Galois/Counter Mode (GCM) can be implemented by leveraging [Ibex](../rv_core_ibex/README.md) for the GHASH operation as demonstrated in [OpenTitan's library of cryptographic implementations](https://github.com/lowRISC/opentitan/tree/master/sw/device/lib/crypto).
48+
Cipher modes other than ECB, CBC, CFB, OFB, CTR and GCM are beyond this version of the AES unit but might be supported in future versions.
49+
If hardware support for GCM is disabled, it can be implemented by leveraging [Ibex](../rv_core_ibex/README.md) for the GHASH operation as demonstrated in [OpenTitan's library of cryptographic implementations](https://github.com/lowRISC/opentitan/tree/master/sw/device/lib/crypto).
4750

4851

4952
## Description
5053

5154
The AES unit is a cryptographic accelerator that accepts requests from the processor to encrypt or decrypt 16B blocks of data.
52-
It supports AES-128/192/256 in Electronic Codebook (ECB) mode, Cipher Block Chaining (CBC) mode, Cipher Feedback (CFB) mode (fixed data segment size of 128 bits, i.e., CFB-128), Output Feedback (OFB) mode and Counter (CTR) mode.
55+
It supports AES-128/192/256 in Electronic Codebook (ECB) mode, Cipher Block Chaining (CBC) mode, Cipher Feedback (CFB) mode (fixed data segment size of 128 bits, i.e., CFB-128), Output Feedback (OFB) mode, Counter (CTR) mode and Galois/Counter Mode (GCM) (fixed IV length of 96 bits, fixed tag length of 128 bits).
5356
For more information on these cipher modes, refer to [Recommendation for Block Cipher Modes of Operation](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf).
54-
Galois/Counter Mode (GCM) can be implemented using [Ibex](../rv_core_ibex/README.md) for the GHASH operation as demonstrated in the [OpenTitan Cryptography Library](../../../doc/security/cryptolib/README.md).
55-
To improve the performance of GCM, instructions of the [RISC-V Bit-Manipulation Extension of Ibex](https://ibex-core.readthedocs.io/en/latest/03_reference/instruction_decode_execute.html#arithmetic-logic-unit-alu) can be leveraged.
56-
In particular, carry-less multiply instructions can help to speed up the GHASH operation.
5757
For details on GCM, refer to [Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf).
58+
If hardware support for GCM is disabled, it can be implemented using [Ibex](../rv_core_ibex/README.md) for the GHASH operation as demonstrated in the [OpenTitan Cryptography Library](../../../doc/security/cryptolib/README.md).
59+
To improve the performance of such an implementation, instructions of the [RISC-V Bit-Manipulation Extension of Ibex](https://ibex-core.readthedocs.io/en/latest/03_reference/instruction_decode_execute.html#arithmetic-logic-unit-alu) can be leveraged.
60+
In particular, carry-less multiply instructions can help to speed up the GHASH operation.
5861
Other cipher modes might be added in future versions.
5962

6063
The AES unit is attached to the chip interconnect bus as a peripheral module.

hw/ip/aes/data/aes.hjson

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
one_line_desc: "AES encryption and decryption engine with SCA and FI countermeasures",
1010
one_paragraph_desc: '''
1111
[Advanced Encryption Standard (AES)][nist-aes] is the primary symmetric encryption and decryption mechanism used in OpenTitan protocols.
12-
AES Accelerator supports encryption/decryption using AES-128/192/256 in ECB, CBC, CFB, OFB, and CTR block cipher modes.
12+
AES Accelerator supports encryption/decryption using AES-128/192/256 in ECB, CBC, CFB, OFB, CTR, and GCM block cipher modes.
1313
Its cipher core uses first-order domain-oriented masking (DOM) to deter side-channel analysis (SCA).
1414
To save area, the masking can optionally be disabled using a compile-time Verilog parameter.
1515
In addition, AES Accelerator features several countermeasures to deter fault injection (FI) attacks on the control path.
@@ -50,11 +50,20 @@
5050
local: "false",
5151
expose: "false"
5252
},
53+
{ name: "AESGCMEnable",
54+
type: "bit",
55+
default: "1'b1",
56+
desc: '''
57+
Disable (0) or enable (1) support for Galois/Counter Mode (GCM) in hardware.
58+
'''
59+
local: "false",
60+
expose: "false"
61+
},
5362
{ name: "SecMasking",
5463
type: "bit",
5564
default: "1'b1",
5665
desc: '''
57-
Disable (0) or enable (1) first-order masking of the AES cipher core.
66+
Disable (0) or enable (1) first-order masking of the AES cipher core and the GHASH operation of GCM.
5867
Masking requires the use of a masked S-Box, see SecSBoxImpl parameter.
5968
'''
6069
local: "false",

0 commit comments

Comments
 (0)