|
iPXE
|
AES-NI hardware acceleration. More...
Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| static void | aesni_encrypt (struct cipher_algorithm *cipher __unused, void *ctx, const void *src, void *dst, size_t len) |
| Encrypt data. | |
| static void | aesni_decrypt (struct cipher_algorithm *cipher __unused, void *ctx, const void *src, void *dst, size_t len) |
| Decrypt data. | |
| void | aes_accelerate (void) |
| Enable hardware acceleration (if supported). | |
AES-NI hardware acceleration.
The AES-NI instructions use SSE registers. For the sake of not having to think about the possible consequences across all various runtime environments (BIOS/UEFI/Linux), we choose not to enable "-msse" in CFLAGS for this file. We include ".arch" directives to ensure that the assembler knows that it is permitted to emit the SSE2 and AES-NI instructions, and use a fixed "%xmm0" rather than an "x" constraint (which GCC would consider to be impossible without "-msse").
We rely upon the runtime environment to guarantee that using the "%xmm0" register is a safe operation:
We restore the "%xmm0" register after use, to satisfy the constraints of the IA-32 UEFI ABI (which defines all FPU/MMX/SSE registers as callee-saved). This is the most restrictive of the ABIs for which this file can be built:
Definition in file aesni.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
static |
Encrypt data.
| cipher | Cipher algorithm |
| ctx | Context |
| src | Data to encrypt |
| dst | Buffer for encrypted data |
| len | Length of data |
Definition at line 84 of file aesni.c.
References __unused, aes_context(), assert, ctx, aes_context::encrypt, in, aes_round_keys::key, key, len, out, aes_context::rounds, and src.
Referenced by aes_accelerate().
|
static |
Decrypt data.
| cipher | Cipher algorithm |
| ctx | Context |
| src | Data to encrypt |
| dst | Buffer for encrypted data |
| len | Length of data |
Definition at line 150 of file aesni.c.
References __unused, aes_context(), assert, ctx, aes_context::decrypt, in, aes_round_keys::key, key, len, out, aes_context::rounds, and src.
Referenced by aes_accelerate().
| void aes_accelerate | ( | void | ) |
Enable hardware acceleration (if supported).
Definition at line 211 of file aesni.c.
References aes_algorithm, aesni_decrypt(), aesni_encrypt(), CPUID_FEATURES_INTEL_ECX_AESNI, DBGC, features, and x86_features().
Referenced by aes_hw_test_exec(), aes_setkey(), and aes_sw_test_exec().