Skip to content

Commit

Permalink
renamed macro for enabling aes neon instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed Sep 14, 2023
1 parent 4403bb8 commit 6dc0ddc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions AES.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <iostream>

#if defined(USE_ARM_NEON_AES)
#if defined(USE_NEON_AES)
#ifndef HARDWARE_ACCELERATION_ARM_NEON_AES
#define HARDWARE_ACCELERATION_ARM_NEON_AES
#endif
Expand All @@ -30,7 +30,7 @@
#endif

#if (defined(_WIN32) || defined(_WIN64) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__)) && \
!defined(USE_CXX_AES) && !defined(USE_ARM_NEON_AES)
!defined(USE_CXX_AES) && !defined(USE_NEON_AES)
#ifdef _MSC_VER
#include <intrin.h>
#endif
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

![tests](https://github.com/mrdcvlsc/AES/actions/workflows/tests.yml/badge.svg)

This repository contains a **single header file C++ library** that provides AES encryption and decryption functionality. The library _**supports**_ both a **pure C++** implementation and optimized implementations that leverage **hardware acceleration technologies**, such as `AES-NI` for `x86-64` architectures and `ARM NEON` for `ARM` architectures.
This repository contains a **single header file C++** that provides AES encryption and decryption function that _**supports**_ both a **pure C++** implementation and optimized implementations that leverage **hardware acceleration technologies** such as; `AES-NI` for `x86-64` architectures and `ARM NEON` for `ARM` architectures.

**Please note** that this library **focuses solely** on the **encryption** and **decryption** of **AES blocks** and _**does not include padding functions or encryption modes**_. You may need to incorporate additional functions or libraries to handle padding and implement specific encryption modes, such as CBC or CTR.
> [!IMPORTANT]
> This library **focuses solely** on the **encryption** and **decryption** of **AES blocks** and _**does not include padding functions or block cipher encryption modes**_.
>
> You need to code additional functions or incorporate libraries to handle padding and encryption modes such as CBC or CTR.
>
> Here is a [CLI program for File Encryption](https://github.com/mrdcvlsc/bethela/blob/main/main.cpp) that uses some of the modules that I wrote ([AES](https://github.com/mrdcvlsc/AES), [BytePadding](https://github.com/mrdcvlsc/BytePadding), [BlockCipherModes](https://github.com/mrdcvlsc/BlockCipherModes)) which can be used as an example.
-----------

Expand Down Expand Up @@ -38,7 +43,7 @@ To gain a speed-up performance, add the following flag when compiling for **`aar

_e.g. modern android devices_.

**Additional Compiler Flag: `-D USE_ARM_NEON_AES -march=armv8-a+crypto`**
**Additional Compiler Flag: `-D USE_NEON_AES -march=armv8-a+crypto`**

**CMake: `AES_IMPL=neon`**

Expand Down Expand Up @@ -110,7 +115,7 @@ if("${AES_IMPL}" STREQUAL "aesni")
target_compile_options(main PRIVATE -maes)
endif()
elseif("${AES_IMPL}" STREQUAL "neon")
target_compile_definitions(main PUBLIC USE_ARM_NEON_AES)
target_compile_definitions(main PUBLIC USE_NEON_AES)
target_compile_options(main PRIVATE -march=armv8-a+crypto)
elseif("${AES_IMPL}" STREQUAL "portable")
target_compile_definitions(main PUBLIC USE_CXX_AES)
Expand Down Expand Up @@ -146,5 +151,5 @@ The value of `<CHOSEN_AES>` could be `aesni`, `neon` or `portable`, .
3. **comple with [Arm-NEON-AES]**

```
g++ -o sample.exe sample.cpp -D USE_ARM_NEON_AES -march=armv8-a+crypto -O3
g++ -o sample.exe sample.cpp -D USE_NEON_AES -march=armv8-a+crypto -O3
```
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COMPILATION_MSG="compiling AES-NI version"
DFLAGS:=-D USE_INTEL_AESNI -maes
else ifeq ($(VERSION), neon)
COMPILATION_MSG="compiling AES aarch64 neon version"
DFLAGS:=-D USE_ARM_NEON_AES -march=armv8-a+crypto
DFLAGS:=-D USE_NEON_AES -march=armv8-a+crypto
endif

########################## type ##########################
Expand Down

0 comments on commit 6dc0ddc

Please sign in to comment.