├── .gitignore
├── LICENSE.txt
├── app
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ ├── CMakeLists.txt
│ ├── aescrypt_engine-master
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── dependencies
│ │ │ └── CMakeLists.txt
│ │ ├── include
│ │ │ └── terra
│ │ │ │ └── aescrypt
│ │ │ │ └── engine
│ │ │ │ ├── decryptor.h
│ │ │ │ └── encryptor.h
│ │ ├── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── decryptor.cpp
│ │ │ ├── encryptor.cpp
│ │ │ └── engine_common.h
│ │ ├── stream_format.md
│ │ └── test
│ │ │ ├── CMakeLists.txt
│ │ │ ├── decryption
│ │ │ ├── CMakeLists.txt
│ │ │ ├── test_stream_0.cpp
│ │ │ ├── test_stream_1.cpp
│ │ │ ├── test_stream_2.cpp
│ │ │ └── test_stream_3.cpp
│ │ │ ├── encryption
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_encryption.cpp
│ │ │ └── string_stream_buffer.h
│ ├── androidcrypt.cpp
│ ├── conio-master
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── ansi
│ │ │ ├── CMakeLists.txt
│ │ │ └── ansi.cpp
│ │ ├── dependencies
│ │ │ └── CMakeLists.txt
│ │ ├── include
│ │ │ └── terra
│ │ │ │ └── conio
│ │ │ │ ├── ansi.h
│ │ │ │ ├── ansi_capable.h
│ │ │ │ ├── progress_meter.h
│ │ │ │ └── utilities.h
│ │ ├── show_progress
│ │ │ ├── CMakeLists.txt
│ │ │ └── show_progress.cpp
│ │ ├── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ansi.cpp
│ │ │ ├── ansi_capable.cpp
│ │ │ ├── progress_meter.cpp
│ │ │ └── utilities.cpp
│ │ └── test
│ │ │ ├── CMakeLists.txt
│ │ │ └── ansi_capable
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_ansi_capable.cpp
│ ├── dependencies
│ │ └── CMakeLists.txt
│ ├── libaes-master
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── dependencies
│ │ │ └── CMakeLists.txt
│ │ ├── include
│ │ │ └── terra
│ │ │ │ └── crypto
│ │ │ │ └── cipher
│ │ │ │ ├── aes.h
│ │ │ │ └── aes_key_wrap.h
│ │ ├── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── aes.cpp
│ │ │ ├── aes_intel.cpp
│ │ │ ├── aes_intel.h
│ │ │ ├── aes_key_wrap.cpp
│ │ │ ├── aes_tables.h
│ │ │ ├── aes_unavailable.h
│ │ │ ├── aes_universal.cpp
│ │ │ ├── aes_universal.h
│ │ │ ├── aes_utilities.h
│ │ │ ├── cpu_check.cpp
│ │ │ ├── cpu_check.h
│ │ │ └── intel_intrinsics.h
│ │ ├── technical_notes.md
│ │ └── test
│ │ │ ├── CMakeLists.txt
│ │ │ ├── aes
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_aes.cpp
│ │ │ ├── aes_intel
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_aes_intel.cpp
│ │ │ ├── aes_key_wrap
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_aes_key_wrap.cpp
│ │ │ └── aes_universal
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_aes_universal.cpp
│ ├── libhash-master
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── dependencies
│ │ │ └── CMakeLists.txt
│ │ ├── include
│ │ │ └── terra
│ │ │ │ └── crypto
│ │ │ │ └── hashing
│ │ │ │ ├── hash.h
│ │ │ │ ├── hmac.h
│ │ │ │ ├── sha1.h
│ │ │ │ ├── sha224.h
│ │ │ │ ├── sha256.h
│ │ │ │ ├── sha384.h
│ │ │ │ └── sha512.h
│ │ ├── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── hash.cpp
│ │ │ ├── hmac.cpp
│ │ │ ├── sha1.cpp
│ │ │ ├── sha224.cpp
│ │ │ ├── sha256.cpp
│ │ │ ├── sha384.cpp
│ │ │ └── sha512.cpp
│ │ └── test
│ │ │ ├── CMakeLists.txt
│ │ │ ├── hash
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_hash.cpp
│ │ │ ├── hmac
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_hmac.cpp
│ │ │ ├── sha1
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_sha1.cpp
│ │ │ ├── sha224
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_sha224.cpp
│ │ │ ├── sha256
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_sha256.cpp
│ │ │ ├── sha384
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_sha384.cpp
│ │ │ └── sha512
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_sha512.cpp
│ ├── libkdf-master
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── dependencies
│ │ │ └── CMakeLists.txt
│ │ ├── include
│ │ │ └── terra
│ │ │ │ └── crypto
│ │ │ │ └── kdf
│ │ │ │ ├── hkdf.h
│ │ │ │ ├── kdf_exception.h
│ │ │ │ └── pbkdf.h
│ │ ├── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ackdf.cpp
│ │ │ ├── hkdf.cpp
│ │ │ ├── pbkdf1.cpp
│ │ │ └── pbkdf2.cpp
│ │ └── test
│ │ │ ├── CMakeLists.txt
│ │ │ ├── ackdf
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_ackdf.cpp
│ │ │ ├── hkdf
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_hkdf.cpp
│ │ │ ├── pbkdf1
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_pbkdf1.cpp
│ │ │ └── pbkdf2
│ │ │ ├── CMakeLists.txt
│ │ │ └── test_pbkdf2.cpp
│ └── logger-master
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── dependencies
│ │ └── CMakeLists.txt
│ │ ├── include
│ │ └── terra
│ │ │ └── logger
│ │ │ ├── log_level.h
│ │ │ ├── logger.h
│ │ │ ├── logger_buffer.h
│ │ │ ├── logger_interface.h
│ │ │ ├── logger_macros.h
│ │ │ └── null_ostream.h
│ │ ├── sample
│ │ ├── CMakeLists.txt
│ │ └── src
│ │ │ ├── CMakeLists.txt
│ │ │ └── logger_demo.cpp
│ │ ├── src
│ │ ├── CMakeLists.txt
│ │ └── logger.cpp
│ │ └── test
│ │ ├── CMakeLists.txt
│ │ └── logger
│ │ ├── CMakeLists.txt
│ │ └── test_logger.cpp
│ ├── ic_launcher-web.png
│ ├── java
│ ├── com
│ │ └── dewdrop623
│ │ │ └── androidcrypt
│ │ │ ├── AboutFragment.java
│ │ │ ├── CryptoService.java
│ │ │ ├── CryptoThread.java
│ │ │ ├── FileSelectButton.java
│ │ │ ├── IconAttributionView.java
│ │ │ ├── JNICallbackInterface.java
│ │ │ ├── JNIInterface.java
│ │ │ ├── LogStream.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MainActivityFragment.java
│ │ │ ├── SettingsFragment.java
│ │ │ ├── SettingsHelper.java
│ │ │ └── StorageAccessFrameworkHelper.java
│ └── es
│ │ └── vocali
│ │ └── util
│ │ └── AESCrypt.java
│ └── res
│ ├── anim
│ └── slide_in_right.xml
│ ├── drawable-hdpi
│ ├── ic_lock_png.png
│ └── ic_unlock_png.png
│ ├── drawable-mdpi
│ ├── ic_lock_png.png
│ └── ic_unlock_png.png
│ ├── drawable-xhdpi
│ ├── ic_lock_png.png
│ └── ic_unlock_png.png
│ ├── drawable-xxhdpi
│ ├── ic_lock_png.png
│ └── ic_unlock_png.png
│ ├── drawable
│ ├── file_select_button_selected.xml
│ ├── file_select_button_selector.xml
│ ├── file_select_button_unselected.xml
│ ├── ic_cancel.xml
│ ├── ic_file_search.xml
│ ├── ic_launcher_background.xml
│ ├── ic_launcher_foreground.xml
│ ├── ic_lock.xml
│ ├── ic_unlock.xml
│ ├── operation_mode_button_selected.xml
│ ├── operation_mode_button_selector.xml
│ └── operation_mode_button_unselected.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ ├── fragment_about.xml
│ ├── fragment_main.xml
│ ├── fragment_settings.xml
│ ├── view_file_select_button.xml
│ └── view_icon_attribution.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-es
│ └── strings.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── docs
└── index.html
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/**
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | misc.xml
10 | .idea/vcs.xml
11 | app/build/**
12 | app/debug/**
13 | app/release/**
14 | gitpush.sh
15 | gitcommit.sh
16 | app/.cxx/**
17 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 ndew623
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | namespace "com.dewdrop623.androidcrypt"
5 | defaultConfig {
6 | applicationId "com.dewdrop623.androidcrypt"
7 | minSdkVersion 21
8 | targetSdkVersion 34
9 | compileSdk 34
10 | versionCode 12
11 | versionName "1.9"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | vectorDrawables.useSupportLibrary = true
14 | externalNativeBuild {
15 | cmake {
16 | cppFlags ''
17 | }
18 | }
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | lint {
27 | disable 'MissingTranslation'
28 | }
29 | externalNativeBuild {
30 | cmake {
31 | path 'src/main/cpp/CMakeLists.txt'
32 | version '3.22.1'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation fileTree(dir: 'libs', include: ['*.jar'])
39 | testImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
40 | exclude group: 'com.android.support', module: 'support-annotations'
41 | })
42 | implementation 'com.android.support:appcompat-v7:28.0.0'
43 | implementation 'com.android.support.constraint:constraint-layout:2.0.4'
44 | implementation 'com.android.support:design:28.0.0'
45 | implementation 'com.android.support:support-v4:28.0.0'
46 | implementation 'com.android.support:support-vector-drawable:28.0.0'
47 | testImplementation 'junit:junit:4.12'
48 | }
49 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/nick/Android/Sdk_no-sync/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | # For more information about using CMake with Android Studio, read the
3 | # documentation: https://d.android.com/studio/projects/add-native-code.html.
4 | # For more examples on how to use CMake, see https://github.com/android/ndk-samples.
5 |
6 | # Sets the minimum CMake version required for this project.
7 | cmake_minimum_required(VERSION 3.22.1)
8 |
9 | # Set the C++ standard to C++20
10 | set(CMAKE_CXX_STANDARD 20)
11 | set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce the standard
12 |
13 | # Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
14 | # Since this is the top level CMakeLists.txt, the project name is also accessible
15 | # with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
16 | # build script scope).
17 | project("androidcrypt")
18 |
19 | # Creates and names a library, sets it as either STATIC
20 | # or SHARED, and provides the relative paths to its source code.
21 | # You can define multiple libraries, and CMake builds them for you.
22 | # Gradle automatically packages shared libraries with your APK.
23 | #
24 | # In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
25 | # the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
26 | # is preferred for the same purpose.
27 | #
28 | # In order to load a library into your app from Java/Kotlin, you must call
29 | # System.loadLibrary() and pass the name of the library defined here;
30 | # for GameActivity/NativeActivity derived applications, the same library name must be
31 | # used in the AndroidManifest.xml file.
32 | add_library(${CMAKE_PROJECT_NAME} SHARED
33 | # List C/C++ source files with relative paths to this CMakeLists.txt.
34 | androidcrypt.cpp)
35 |
36 | #AESCrypt
37 | option(aescrypt_engine_INSTALL "Install the AES Crypt Engine" OFF)
38 | option(aescrypt_engine_CLANG_TIDY "Use clang-tidy to perform linting during build" OFF)
39 | option(aescrypt_engine_BUILD_TESTS "Build Tests for the AES Crypt Engine" OFF)
40 |
41 | add_subdirectory(conio-master)
42 | add_subdirectory(logger-master)
43 | add_subdirectory(libaes-master)
44 | add_subdirectory(libhash-master)
45 | add_subdirectory(libkdf-master)
46 | add_subdirectory(dependencies)
47 | add_subdirectory(aescrypt_engine-master)
48 |
49 |
50 | # Specifies libraries CMake should link to your target library. You
51 | # can link libraries from various origins, such as libraries defined in this
52 | # build script, prebuilt third-party libraries, or Android system libraries.
53 | target_link_libraries(${CMAKE_PROJECT_NAME}
54 | PRIVATE
55 | Terra::aescrypt_engine
56 | Terra::secutil
57 | Terra::charutil
58 | Terra::kdf
59 | Terra::random
60 | PUBLIC
61 | android
62 | log
63 | Terra::logger
64 | Terra::libhash)
65 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | v4.0.10
4 |
5 | - Updated the following to the latest library version:
6 | libaes, secutil, libhash, libkdf, and logger.
7 |
8 | v4.0.9
9 |
10 | - Updated libhash and libkdf dependencies
11 |
12 | v4.0.8
13 |
14 | - Changes required to build on FreeBSD
15 |
16 | v4.0.7
17 |
18 | - Updated STF and AES dependencies
19 |
20 | v4.0.6
21 |
22 | - Updated to latest dependencies
23 |
24 | v4.0.5
25 |
26 | - Changed the encryption/decryption cancellation logic for consistency
27 | - Updated dependencies (libaes, secutil)
28 |
29 | v4.0.4
30 |
31 | - Updated to latest dependencies
32 |
33 | v4.0.3
34 |
35 | - Issue initial progress callback before iterating over the entire stream
36 | to facilitate rendering by the called application
37 |
38 | v4.0.2
39 |
40 | - Updated secutil to 1.0.1 for better Linux compatibility
41 | - Updated other library dependencies to align to secutil dependency
42 |
43 | v4.0.1
44 |
45 | - Simplification of CreateComponent() function
46 |
47 | v4.0.0
48 |
49 | - Initial release as a part of AES Crypt v4
50 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.21)
2 |
3 | # Define the AES Crypt Engine project
4 | project(aescrypt_engine
5 | VERSION 4.0.10.0
6 | DESCRIPTION "AES Crypt Engine"
7 | LANGUAGES CXX)
8 |
9 | # Tests are built by default when this is a top-level project
10 | if(PROJECT_IS_TOP_LEVEL)
11 | option(aescrypt_engine_BUILD_TESTS "Build Tests for the AES Crypt Engine" ON)
12 | else()
13 | option(aescrypt_engine_BUILD_TESTS "Build Tests for the AES Crypt Engine" OFF)
14 | endif()
15 |
16 | # Option to control ability to install the library
17 | option(aescrypt_engine_INSTALL "Install the AES Crypt Engine" ON)
18 |
19 | # Determine whether clang-tidy will be performed
20 | option(aescrypt_engine_CLANG_TIDY "Use clang-tidy to perform linting during build" OFF)
21 |
22 | # Add the dependencies and source directories
23 | add_subdirectory(dependencies)
24 | add_subdirectory(src)
25 |
26 | # Include testing support (defines BUILD_TESTING)
27 | include(CTest)
28 |
29 | # Build tests if conditions are met
30 | if(BUILD_TESTING AND aescrypt_engine_BUILD_TESTS)
31 | add_subdirectory(test)
32 | endif()
33 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | ## Acquiring a License
4 |
5 | This is commercial software and a license may be purchased by visiting
6 | [Terrapane](https://www.terrapane.com). You may download the software and try
7 | it to see if it meets your needs, but please purchase a license if you
8 | find the software useful. Your financial support is important so we can
9 | continue to improve and enhance this and our other software products.
10 |
11 | Use of the software implies understanding and acceptance of the warranty
12 | statement.
13 |
14 | ### Individual Use
15 |
16 | Each individual using the software on his or her computer(s) is required to
17 | purchase a license for continued use of the software. An individual may use
18 | his or her license on any number of devices owned and operated by that
19 | individual.
20 |
21 | ### Business, Government, Educational, and Non-Profit Use
22 |
23 | For business, government, educational, non-profits, or other non-human entity,
24 | the entity may acquire and assign a license per machine or per individual.
25 | Licenses acquired for an individual within such an entity may be transferred to
26 | another individual within the same entity (e.g., a license acquired for a first
27 | employee may be transferred to a second employee should the first employee
28 | leave the company or otherwise cease using the software).
29 |
30 | Licenses are not transferrable to another individual or entity, except as
31 | described in the previous paragraph.
32 |
33 | ### Machine Use
34 |
35 | This clause applies only to business, government, educational, non-profits,
36 | or other non-human entities.
37 |
38 | Each computer or machine having no specific human user that uses this software
39 | (e.g., a server or server instance wherein this software is used) must have a
40 | distinct license.
41 |
42 | ## Warranty
43 |
44 | THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED
45 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
46 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE
47 | HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER
48 | DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA
49 | BEING RENDERED INACCURATE.
50 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/dependencies/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Enable fetching content
2 | include(FetchContent)
3 |
4 | # Set the root of the Terrapane source repositories
5 | if(DEFINED ENV{TERRAPANE_SOURCE_URI})
6 | set(TERRAPANE_SOURCE_URI "$ENV{TERRAPANE_SOURCE_URI}")
7 | else()
8 | set(TERRAPANE_SOURCE_URI "https://github.com/terrapane")
9 | endif()
10 |
11 | # Retrieve Simple Test Framework only if building tests
12 | if(aescrypt_engine_BUILD_TESTS)
13 | # Fetch the Simple Test Framework library
14 | FetchContent_Declare(stf
15 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/stf.git
16 | GIT_TAG v1.0.1
17 | GIT_SHALLOW true)
18 |
19 | # It is not necessary to install the STF library
20 | set (stf_INSTALL OFF)
21 |
22 | # Make STF available
23 | FetchContent_MakeAvailable(stf)
24 | endif()
25 |
26 | # Fetch the AES library
27 | #FetchContent_Declare(libaes
28 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libaes.git
29 | #GIT_TAG v1.0.6
30 | #GIT_SHALLOW true)
31 |
32 | # Fetch security utilities library
33 | FetchContent_Declare(secutil
34 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/secutil.git
35 | GIT_TAG v1.0.5
36 | GIT_SHALLOW true)
37 |
38 | # Fetch character-related utilities
39 | FetchContent_Declare(charutil
40 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/charutil.git
41 | GIT_TAG v1.0.2
42 | GIT_SHALLOW true)
43 |
44 | # Fetch the random generator library
45 | FetchContent_Declare(random
46 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/random.git
47 | GIT_TAG v1.0.1
48 | GIT_SHALLOW true)
49 |
50 | # Fetch the hashing library
51 | #FetchContent_Declare(libhash
52 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libhash.git
53 | #GIT_TAG v1.0.6
54 | #GIT_SHALLOW true)
55 |
56 | # Fetch the Key Derivation Function library
57 | #FetchContent_Declare(libkdf
58 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libkdf.git
59 | #GIT_TAG v1.0.6
60 | #GIT_SHALLOW true)
61 |
62 | # Fetch the Logger library
63 | #FetchContent_Declare(logger
64 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/logger.git
65 | #GIT_TAG v1.0.4
66 | #GIT_SHALLOW true)
67 |
68 | # If not installing aescrypt_engine, turn off installation for dependencies
69 | #set(libaes_INSTALL ${aescrypt_engine_INSTALL})
70 | set(secutil_INSTALL ${aescrypt_engine_INSTALL})
71 | set(charutil_INSTALL ${aescrypt_engine_INSTALL})
72 | set(random_INSTALL ${aescrypt_engine_INSTALL})
73 | #set(libhash_INSTALL ${aescrypt_engine_INSTALL})
74 | #set(libkdf_INSTALL ${aescrypt_engine_INSTALL})
75 | #set(logger_INSTALL ${aescrypt_engine_INSTALL})
76 |
77 | # Make dependencies available
78 | #FetchContent_MakeAvailable(libaes secutil charutil random libhash libkdf logger)
79 |
80 | #locally downloaded libs removed
81 | FetchContent_MakeAvailable(secutil charutil random)
82 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Threading support is required
2 | find_package(Threads REQUIRED)
3 |
4 | # Create the library
5 | add_library(aescrypt_engine STATIC decryptor.cpp encryptor.cpp)
6 | add_library(Terra::aescrypt_engine ALIAS aescrypt_engine)
7 |
8 | # Make project include directory available to external projects
9 | target_include_directories(aescrypt_engine
10 | PRIVATE
11 | $
12 | PUBLIC
13 | $)
14 |
15 | # Specify the C++ standard to observe
16 | set_target_properties(aescrypt_engine
17 | PROPERTIES
18 | CXX_STANDARD 20
19 | CXX_STANDARD_REQUIRED ON
20 | CXX_EXTENSIONS OFF)
21 |
22 | # If requesting clang-tidy, try to look for it
23 | if(aescrypt_engine_CLANG_TIDY)
24 | find_program(CLANG_TIDY_COMMAND NAMES "clang-tidy")
25 | if(CLANG_TIDY_COMMAND)
26 | set_target_properties(aescrypt_engine PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
27 | else()
28 | message(WARNING "Could not find clang-tidy")
29 | endif()
30 | endif()
31 |
32 | # Use the following compile options
33 | target_compile_options(aescrypt_engine
34 | PRIVATE
35 | $<$,$,$>:-Wpedantic -Wextra -Wall>
36 | $<$:>)
37 |
38 | # Link against dependencies
39 | target_link_libraries(aescrypt_engine
40 | PRIVATE
41 | Terra::libaes
42 | Terra::secutil
43 | Terra::charutil
44 | Terra::kdf
45 | Terra::random
46 | PUBLIC
47 | Terra::logger)
48 |
49 | # Install target and associated include files
50 | if(aescrypt_engine_INSTALL)
51 | include(GNUInstallDirs)
52 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ TYPE INCLUDE)
53 | install(TARGETS aescrypt_engine EXPORT aescrypt_engineTargets ARCHIVE)
54 | install(EXPORT aescrypt_engineTargets
55 | FILE aescrypt_engineConfig.cmake
56 | NAMESPACE Terra::
57 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/aescrypt_engine)
58 | endif()
59 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/src/engine_common.h:
--------------------------------------------------------------------------------
1 | /*
2 | * engine_common.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines values that are common between the Encryptor and
13 | * Decryptor objects.
14 | *
15 | * Portability Issues:
16 | * None.
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | namespace
27 | {
28 |
29 | // Recommended number of PBKDF2 iterations to employ for AES Crypt stream
30 | // format version 3 for typical passwords
31 | constexpr std::size_t PBKDF2_Iterations = 300'000;
32 |
33 | // Bound the number of iterations to ensure values are valid and does not cause
34 | // the process to hang for an exceedingly long period of time; if the stream
35 | // contains an iteration value beyond PBKDF2_Max_Iterations, it will be treated
36 | // as an error
37 | constexpr std::size_t PBKDF2_Min_Iterations = 1;
38 | constexpr std::size_t PBKDF2_Max_Iterations = 5'000'000;
39 |
40 | // The hashing algorithm to employ with PBKDF2
41 | constexpr Terra::Crypto::Hashing::HashAlgorithm PBKDF2_Hash_Algorithm =
42 | Terra::Crypto::Hashing::HashAlgorithm::SHA512;
43 |
44 | // Indicate the latest defined AES Crypt stream version
45 | constexpr std::uint8_t Latest_AES_Crypt_Stream_Version = 3;
46 |
47 | /*
48 | * CreateComponent()
49 | *
50 | * Description:
51 | * This is a utility function that will create the component string
52 | * used in the construction of the child Logger object.
53 | *
54 | * Parameters:
55 | * component [in]
56 | * The component name.
57 | *
58 | * instance [in]
59 | * The instance string for this component.
60 | *
61 | * Returns:
62 | * The string to use as the component parameter to the Logger.
63 | *
64 | * Comments:
65 | * This can be made constexpr in C++20, but some newish compilers do not
66 | * yet support constexpr string functions like this.
67 | */
68 | static inline std::string CreateComponent(const std::string &component,
69 | const std::string &instance)
70 | {
71 | return instance.empty() ? component : component + ":" + instance;
72 | }
73 |
74 | /*
75 | * XORBlock()
76 | *
77 | * Description:
78 | * This function will the two given spans. This is used as a part of
79 | * the CBC operation.
80 | *
81 | * Parameters:
82 | * a [in]
83 | * This is one of the input spans.
84 | *
85 | * b [in]
86 | * This is one of the input spans.
87 | *
88 | * result [out]
89 | * This is the output span (which may point to the same memory
90 | * location as either a or b).
91 | *
92 | * Returns:
93 | * Nothing, though the result of the XOR operation will be stored in
94 | * the result span.
95 | *
96 | * Comments:
97 | * None.
98 | */
99 | constexpr void XORBlock(const std::span a,
100 | const std::span b,
101 | std::span result)
102 | {
103 | result[0] = a[0] ^ b[0];
104 | result[1] = a[1] ^ b[1];
105 | result[2] = a[2] ^ b[2];
106 | result[3] = a[3] ^ b[3];
107 | result[4] = a[4] ^ b[4];
108 | result[5] = a[5] ^ b[5];
109 | result[6] = a[6] ^ b[6];
110 | result[7] = a[7] ^ b[7];
111 | result[8] = a[8] ^ b[8];
112 | result[9] = a[9] ^ b[9];
113 | result[10] = a[10] ^ b[10];
114 | result[11] = a[11] ^ b[11];
115 | result[12] = a[12] ^ b[12];
116 | result[13] = a[13] ^ b[13];
117 | result[14] = a[14] ^ b[14];
118 | result[15] = a[15] ^ b[15];
119 | }
120 |
121 | } // namespace
122 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(decryption)
2 | add_subdirectory(encryption)
3 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/test/decryption/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the test excutable
2 | add_executable(test_decryption
3 | test_stream_0.cpp
4 | test_stream_1.cpp
5 | test_stream_2.cpp
6 | test_stream_3.cpp)
7 |
8 | # Link to the required libraries
9 | target_link_libraries(test_decryption Terra::aescrypt_engine Terra::stf)
10 |
11 | # Specify the C++ standard to observe
12 | set_target_properties(test_decryption
13 | PROPERTIES
14 | CXX_STANDARD 20
15 | CXX_STANDARD_REQUIRED ON
16 | CXX_EXTENSIONS OFF)
17 |
18 | # Specify the compiler options
19 | target_compile_options(test_decryption
20 | PRIVATE
21 | $<$,$,$>:-Wpedantic -Wextra -Wall>
22 | $<$:>)
23 |
24 | # Ensure CTest can find the test
25 | add_test(NAME test_decryption
26 | COMMAND test_decryption)
27 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/test/encryption/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the test excutable
2 | add_executable(test_encryption test_encryption.cpp)
3 |
4 | # Link to the required libraries
5 | target_link_libraries(test_encryption Terra::aescrypt_engine Terra::stf)
6 |
7 | # Specify the C++ standard to observe
8 | set_target_properties(test_encryption
9 | PROPERTIES
10 | CXX_STANDARD 20
11 | CXX_STANDARD_REQUIRED ON
12 | CXX_EXTENSIONS OFF)
13 |
14 | # Specify the compiler options
15 | target_compile_options(test_encryption
16 | PRIVATE
17 | $<$,$,$>:-Wpedantic -Wextra -Wall>
18 | $<$:>)
19 |
20 | # Ensure CTest can find the test
21 | add_test(NAME test_encryption
22 | COMMAND test_encryption)
23 |
--------------------------------------------------------------------------------
/app/src/main/cpp/aescrypt_engine-master/test/string_stream_buffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * string_stream_buffer.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file implements a simple custom StringStreamBuffer object
13 | * used to facilitate testing. While it is referred to as
14 | * a "string" buffer, it can receive a span of characters or uint8_t.
15 | * The buffer provided must live at least as long as this object.
16 | *
17 | * Portability Issues:
18 | * None.
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | namespace {
29 |
30 | // Define the StringStreamBuffer class
31 | class StringStreamBuffer : public std::streambuf
32 | {
33 | public:
34 | StringStreamBuffer(const std::span(buffer))
35 | {
36 | auto p = const_cast(buffer.data());
37 | setg(p, p, p + buffer.size());
38 | setp(p, p + buffer.size());
39 | }
40 |
41 | StringStreamBuffer(const std::string &buffer) :
42 | StringStreamBuffer(
43 | std::span(buffer.data(), buffer.size()))
44 | {
45 | }
46 | StringStreamBuffer(const std::span(buffer)) :
47 | StringStreamBuffer(std::span(
48 | reinterpret_cast(buffer.data()),
49 | buffer.size()))
50 | {
51 | }
52 | protected:
53 | pos_type seekoff(off_type off,
54 | std::ios_base::seekdir dir,
55 | [[maybe_unused]] std::ios_base::openmode which =
56 | std::ios_base::in | std::ios_base::out) override
57 | {
58 | if (dir == std::ios_base::cur)
59 | {
60 | if (which & std::ios_base::in) gbump(off);
61 | if (which & std::ios_base::out) pbump(off);
62 | }
63 | else if (dir == std::ios_base::end)
64 | {
65 | if (which & std::ios_base::in)
66 | {
67 | setg(eback(), egptr() + off, egptr());
68 | }
69 | if (which & std::ios_base::out)
70 | {
71 | pbump(epptr() - pptr() + off);
72 | }
73 | }
74 | else if (dir == std::ios_base::beg)
75 | {
76 | if (which & std::ios_base::in)
77 | {
78 | setg(eback(), eback() + off, egptr());
79 | }
80 | if (which & std::ios_base::out)
81 | {
82 | pbump(pbase() - pptr() + off);
83 | }
84 | }
85 |
86 | return gptr() - eback();
87 | }
88 |
89 | pos_type seekpos(pos_type pos,
90 | std::ios_base::openmode which =
91 | std::ios_base::in | std::ios_base::out) override
92 | {
93 | return seekoff(pos, std::ios_base::beg, which);
94 | }
95 | };
96 |
97 | } // namespace
98 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | v1.0.2
4 |
5 | - Updated to support builds on FreeBSD
6 |
7 | v1.0.1
8 |
9 | - Updated to the latest Simple Test Framework (STF)
10 |
11 | v1.0.0
12 |
13 | - Initial Release
14 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.21)
2 |
3 | # Define the Console I/O Library Project
4 | project(conio
5 | VERSION 1.0.2.0
6 | DESCRIPTION "Console I/O Library"
7 | LANGUAGES CXX)
8 |
9 | # Set options depending on whether this is a subproject
10 | if(PROJECT_IS_TOP_LEVEL)
11 | # Option to control whether tests are built
12 | option(conio_BUILD_TESTS "Build Tests for the Console I/O Library" ON)
13 | else()
14 | # Option to control whether tests are built
15 | option(conio_BUILD_TESTS "Build Tests for the Console I/O Library" OFF)
16 | endif()
17 |
18 | # Option to control ability to install the library
19 | option(conio_INSTALL "Install the Console I/O Library" ON)
20 |
21 | # Determine whether clang-tidy will be performed
22 | option(conio_CLANG_TIDY "Use clang-tidy to perform linting during build" OFF)
23 |
24 | add_subdirectory(dependencies)
25 | add_subdirectory(src)
26 |
27 | include(CTest)
28 |
29 | if(BUILD_TESTING AND conio_BUILD_TESTS)
30 | add_subdirectory(ansi)
31 | add_subdirectory(show_progress)
32 | add_subdirectory(test)
33 | endif()
34 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | ## Acquiring a License
4 |
5 | This is commercial software and a license may be purchased by visiting
6 | [Terrapane](https://www.terrapane.com). You may download the software and try
7 | it to see if it meets your needs, but please purchase a license if you
8 | find the software useful. Your financial support is important so we can
9 | continue to improve and enhance this and our other software products.
10 |
11 | Use of the software implies understanding and acceptance of the warranty
12 | statement.
13 |
14 | ### Individual Use
15 |
16 | Each individual using the software on his or her computer(s) is required to
17 | purchase a license for continued use of the software. An individual may use
18 | his or her license on any number of devices owned and operated by that
19 | individual.
20 |
21 | ### Business, Government, Educational, and Non-Profit Use
22 |
23 | For business, government, educational, non-profits, or other non-human entity,
24 | the entity may acquire and assign a license per machine or per individual.
25 | Licenses acquired for an individual within such an entity may be transferred to
26 | another individual within the same entity (e.g., a license acquired for a first
27 | employee may be transferred to a second employee should the first employee
28 | leave the company or otherwise cease using the software).
29 |
30 | Licenses are not transferrable to another individual or entity, except as
31 | described in the previous paragraph.
32 |
33 | ### Machine Use
34 |
35 | This clause applies only to business, government, educational, non-profits,
36 | or other non-human entities.
37 |
38 | Each computer or machine having no specific human user that uses this software
39 | (e.g., a server or server instance wherein this software is used) must have a
40 | distinct license.
41 |
42 | ## Warranty
43 |
44 | THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED
45 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
46 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE
47 | HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER
48 | DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA
49 | BEING RENDERED INACCURATE.
50 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/README.md:
--------------------------------------------------------------------------------
1 | Console I/O Library
2 | ===================
3 |
4 | This library contains functions and definitions to facilitate output to
5 | console (terminal) devices.
6 |
7 | These functions include:
8 |
9 | * ANSI escape sequences to control color, cursor appearance, etc.
10 | * Functions to determine if stdout or stderr is to a terminal window
11 | * Functions to determine if a terminal is ANSI-capable
12 | * Functions to determine the terminal size
13 |
14 | Additionally, this repository defines a ProgressMeter object that utilizes
15 | some of the above utility and ANSI-related functions to render a progress
16 | meter in a console application.
17 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/ansi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the ansi executable
2 | add_executable(ansi ansi.cpp)
3 |
4 | # Link against the console I/O library
5 | target_link_libraries(ansi PRIVATE Terra::conio)
6 |
7 | # Make project include directory available to external projects
8 | target_include_directories(ansi
9 | PRIVATE
10 | $
11 | PUBLIC
12 | $)
13 |
14 | # Specify the C++ standard to observe
15 | set_target_properties(ansi
16 | PROPERTIES
17 | CXX_STANDARD 20
18 | CXX_STANDARD_REQUIRED ON
19 | CXX_EXTENSIONS OFF)
20 |
21 | # Use the following compile options
22 | target_compile_options(ansi
23 | PRIVATE
24 | $<$,$,$>: -Wpedantic -Wextra -Wall>
25 | $<$: >)
26 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/dependencies/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if(conio_BUILD_TESTS)
2 | # Enable fetching content
3 | include(FetchContent)
4 |
5 | # Set the root of the Terrapane source repositories
6 | if(DEFINED ENV{TERRAPANE_SOURCE_URI})
7 | set(TERRAPANE_SOURCE_URI "$ENV{TERRAPANE_SOURCE_URI}")
8 | else()
9 | set(TERRAPANE_SOURCE_URI "https://github.com/terrapane")
10 | endif()
11 |
12 | # Fetch the Simple Test Framework library
13 | FetchContent_Declare(stf
14 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/stf.git
15 | GIT_TAG v1.0.1
16 | GIT_SHALLOW true)
17 |
18 | # It is not necessary to install the STF library
19 | set(stf_INSTALL OFF)
20 |
21 | # Make dependencies available
22 | FetchContent_MakeAvailable(stf)
23 | endif()
24 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/include/terra/conio/ansi_capable.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ansi_capable.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines a function to determine if the standard output device
13 | * (stdout) is ANSI-capable.
14 | *
15 | * Portability Issues:
16 | * None.
17 | */
18 |
19 | #pragma once
20 |
21 | namespace Terra::ConIO
22 | {
23 |
24 | /*
25 | * IsANSICapable()
26 | *
27 | * Description:
28 | * This function will determine if it is possible to send ANSI escape
29 | * sequences to the specified output device. This function checks to see
30 | * if the file descriptor is directed to a terminal and, if it is, whether
31 | * or not it's a dumb terminal. On Linux/Unix, anything other than a dumb
32 | * terminal is assumed to be ANSI-capable. This approach may not work for
33 | * legacy devices, but it works for all modern systems when the routine
34 | * was written, including Linux/Unix, Windows, and Mac.
35 | *
36 | * Parameters:
37 | * fd [in]
38 | * The file descriptor to check.
39 | *
40 | * Returns:
41 | * True if ANSI-capable, false if not.
42 | *
43 | * Comments:
44 | * The logic employed is similar to what is used by the GNU grep utility,
45 | * where there are "colorize" files that can be found here:
46 | * https://git.savannah.gnu.org/cgit/grep.git/tree/lib
47 | * And the GNU "ls" command, whose source is here:
48 | * https://github.com/coreutils/coreutils
49 | * There is a check to see if stdout is a TTY device. In the case of
50 | * Linux/Unix/Apple, there is also a check to see if the TTY device is
51 | * something other than a dumb terminal.
52 | *
53 | * On Windows, legacy command-prompt (e.g., cmd.exe) does not support ANSI
54 | * output by default. One must first call EnableStdoutANSIOutput()
55 | * or EnableStderrANSIOutput() to enable virtual terminal processing.
56 | * However, this function can then be used to verify that it is enabled.
57 | */
58 | bool IsANSICapable(int fd);
59 |
60 | /*
61 | * IsStdOutANSICapable()
62 | *
63 | * Description:
64 | * This function calls IsANSICapable() to check to see if the device
65 | * associated with standard output is ANSI-capable.
66 | *
67 | * Parameters:
68 | * None.
69 | *
70 | * Returns:
71 | * True if ANSI-capable, false if not.
72 | *
73 | * Comments:
74 | * None.
75 | */
76 | bool IsStdOutANSICapable();
77 |
78 | /*
79 | * IsStdErrANSICapable()
80 | *
81 | * Description:
82 | * This function calls IsANSICapable() to check to see if the device
83 | * associated with standard error is ANSI-capable.
84 | *
85 | * Parameters:
86 | * None.
87 | *
88 | * Returns:
89 | * True if ANSI-capable, false if not.
90 | *
91 | * Comments:
92 | * None.
93 | */
94 | bool IsStdErrANSICapable();
95 |
96 | /*
97 | * EnableStdOutANSIOutput()
98 | *
99 | * Description:
100 | * Legacy Windows console windows (e.g., cmd.exe) do not have the
101 | * capability to render ANSI control codes, thus are not ANSI-capable.
102 | * However, it can be enabled in Windows 10 TH2 (v1511) and newer systems.
103 | * This function will enable ANSI control codes sent to stdout.
104 | *
105 | * On non-Windows platforms, this function will call the function to see
106 | * if the terminal is ANSI-capable and return that as the result.
107 | *
108 | * Parameters:
109 | * None.
110 | *
111 | * Returns:
112 | * True if successful, false if not.
113 | *
114 | * Comments:
115 | * None.
116 | */
117 | bool EnableStdOutANSIOutput();
118 |
119 | /*
120 | * EnableStderrANSIOutput()
121 | *
122 | * Description:
123 | * Legacy Windows console windows (e.g., cmd.exe) do not have the
124 | * capability to render ANSI control codes, thus are not ANSI-capable.
125 | * However, it can be enabled in Windows 10 TH2 (v1511) and newer systems.
126 | * This function will enable ANSI control codes sent to stderr.
127 | *
128 | * On non-Windows platforms, this function will call the function to see
129 | * if the terminal is ANSI-capable and return that as the result.
130 | *
131 | * Parameters:
132 | * None.
133 | *
134 | * Returns:
135 | * True if successful, false if not.
136 | *
137 | * Comments:
138 | * None.
139 | */
140 | bool EnableStdErrANSIOutput();
141 |
142 | } // namespace Terra::ConIO
143 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/include/terra/conio/progress_meter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * progress_meter.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines an object that renders a progress meter via the
13 | * console. This will only work if stdout is a terminal capable of
14 | * rendering color. If stdout is not a ANSI-capable terminal, then this
15 | * object produces no output.
16 | *
17 | * If the user resizes the terminal, that will be detected the next time
18 | * the progress meter is updated.
19 | *
20 | * To render the progress meter, one creates a ProgressMeter object and
21 | * calls Start(). Update may be called any number of times and the
22 | * progress meter will be updated accordingly. The user may re-size the
23 | * terminal window and, if needed, the progress meter will be re-scaled
24 | * to adjust to the new screen size. Once rendering should stop,
25 | * call the Stop() function or destroy the object (which will call Stop()).
26 | *
27 | * It is assumed that once rendering starts, the ProgressMeter owns the
28 | * current output line. If there is a need to output anything else to
29 | * standard out, the ProgressBar should be stopped. It is possible to
30 | * start it again.
31 | *
32 | * Portability Issues:
33 | * Using a long progress meter presents issues on Windows Terminal when
34 | * attempting to resize the terminal. The issue is that if one reduces the
35 | * window size, the lines wrap and do not clear properly. This results in
36 | * residue appearing on the lines (and multiple lines) Disabling line
37 | * wrapping, both via SetConsoleMode() and via ANSI sequences, did not
38 | * resolve the issue. Further, the same issue is presented when using
39 | * Windows Terminal and using SSH to a remote Linux/Unix machine. In that
40 | * case, SetConsoleMode() would have no effect, anyway. Therefore, it is
41 | * best to just use relatively short progress meters to avoid the wrapping
42 | * issue.
43 | */
44 |
45 | #pragma once
46 |
47 | #include
48 |
49 | namespace Terra::ConIO
50 | {
51 |
52 | class ProgressMeter
53 | {
54 | public:
55 | static constexpr std::size_t Default_Maximum_Width = 50;
56 |
57 | ProgressMeter(std::size_t length,
58 | std::size_t maximum_width = Default_Maximum_Width);
59 | virtual ~ProgressMeter();
60 | bool IsRendering() const noexcept;
61 | void Start();
62 | void Update(std::size_t position);
63 | void Stop();
64 |
65 | protected:
66 | void DrawBlankMeter();
67 | void ClearLine() const;
68 | std::string MeterTip() const;
69 | std::string MeterFill() const;
70 |
71 | bool utf8_capable;
72 | const std::size_t length;
73 | bool render;
74 | bool running;
75 | std::size_t meter_width;
76 | std::size_t maximum_width;
77 | std::size_t last_position;
78 | std::size_t last_location;
79 | };
80 |
81 | } // namespace Terra::ConIO
82 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/include/terra/conio/utilities.h:
--------------------------------------------------------------------------------
1 | /*
2 | * utilities.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines a few utility functions useful for console I/O.
13 | *
14 | * Portability Issues:
15 | * See comments on functions.
16 | */
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | namespace Terra::ConIO
24 | {
25 |
26 | /*
27 | * IsTerminal()
28 | *
29 | * Description:
30 | * This function will determine if the specifed file descriptor is
31 | * associated with a terminal / TTY.
32 | *
33 | * Parameters:
34 | * fd [in]
35 | * The file descriptor to check.
36 | *
37 | * Returns:
38 | * True if the file descriptor is associated with a terminal, false if not.
39 | *
40 | * Comments:
41 | * This will also return false if the platform is not supported. Supported
42 | * platforms include Windows, Linux/Unix, and Mac.
43 | */
44 | bool IsTerminal(int fd);
45 |
46 | /*
47 | * IsStdOutTerminal()
48 | *
49 | * Description:
50 | * This function will determine if stdout is associated with a terminal.
51 | *
52 | * Parameters:
53 | * None.
54 | *
55 | * Returns:
56 | * True if stdout is associated with a terminal, false if not.
57 | *
58 | * Comments:
59 | * This will also return false if the platform is not supported. Supported
60 | * platforms include Windows, Linux/Unix, and Mac.
61 | */
62 | bool IsStdOutTerminal();
63 |
64 | /*
65 | * IsStdErrTerminal()
66 | *
67 | * Description:
68 | * This function will determine if stderr is associated with a terminal.
69 | *
70 | * Parameters:
71 | * None.
72 | *
73 | * Returns:
74 | * True if stderr is associated with a terminal, false if not.
75 | *
76 | * Comments:
77 | * This will also return false if the platform is not supported. Supported
78 | * platforms include Windows, Linux/Unix, and Mac.
79 | */
80 | bool IsStdErrTerminal();
81 |
82 | /*
83 | * GetTerminalDimensions()
84 | *
85 | * Description:
86 | * This function will return the width and height of the terminal window.
87 | * It uses the "standard out" file descriptor / handle to determine the
88 | * screen size.
89 | *
90 | * Parameters:
91 | * None.
92 | *
93 | * Returns:
94 | * A std::pair containing the screen width and height. If the values
95 | * could not be determined or if stdout is not associated with a terminal,
96 | * then the values {0, 0} will be returned.
97 | *
98 | * Comments:
99 | * None.
100 | */
101 | std::pair GetTerminalDimensions();
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/show_progress/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the show_progress executable
2 | add_executable(show_progress show_progress.cpp)
3 |
4 | # Link against the console I/O library
5 | target_link_libraries(show_progress PRIVATE Terra::conio)
6 |
7 | # Make project include directory available to external projects
8 | target_include_directories(show_progress
9 | PRIVATE
10 | $
11 | PUBLIC
12 | $)
13 |
14 | # Specify the C++ standard to observe
15 | set_target_properties(show_progress
16 | PROPERTIES
17 | CXX_STANDARD 20
18 | CXX_STANDARD_REQUIRED ON
19 | CXX_EXTENSIONS OFF)
20 |
21 | # Use the following compile options
22 | target_compile_options(show_progress
23 | PRIVATE
24 | $<$,$,$>: -Wpedantic -Wextra -Wall>
25 | $<$: >)
26 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/show_progress/show_progress.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * show_progress.cpp
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This program shows usage of the ProgressMeter class and is intended
13 | * both for demonstration of use and verification of functionality.
14 | *
15 | * Portability Issues:
16 | * None.
17 | */
18 |
19 | #ifdef _WIN32
20 | #include
21 | #endif
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | namespace
33 | {
34 | std::atomic Terminate = false;
35 | }
36 |
37 | extern "C"
38 | {
39 |
40 | void SignalHandler(int)
41 | {
42 | // Regardless of signal received, signal program termination
43 | Terminate = true;
44 | }
45 |
46 | }
47 |
48 | /*
49 | * InstallSignalHandlers()
50 | *
51 | * Description:
52 | * This function will install signal handlers to ensure a graceful exit.
53 | *
54 | * Parameters:
55 | * None.
56 | *
57 | * Returns:
58 | * Nothing.
59 | *
60 | * Comments:
61 | * None.
62 | */
63 | void InstallSignalHandlers()
64 | {
65 | #ifdef _WIN32
66 | signal(SIGABRT, SignalHandler);
67 | signal(SIGINT, SignalHandler);
68 | signal(SIGTERM, SignalHandler);
69 | #else
70 | struct sigaction sa;
71 |
72 | sa.sa_handler = &SignalHandler; // Specify the signal handler
73 | sa.sa_flags = SA_RESTART; // Restart system calls
74 | sigfillset(&sa.sa_mask); // Block all other signals
75 |
76 | // Signals to handle
77 | sigaction(SIGABRT, &sa, NULL);
78 | sigaction(SIGHUP, &sa, NULL);
79 | sigaction(SIGINT, &sa, NULL);
80 | sigaction(SIGQUIT, &sa, NULL);
81 | sigaction(SIGTERM, &sa, NULL);
82 | #endif
83 | }
84 |
85 | int main()
86 | {
87 | #ifdef _WIN32
88 | // On Windows, use UTF-8 for input/output to console
89 | SetConsoleOutputCP(CP_UTF8);
90 | SetConsoleCP(CP_UTF8);
91 | #else
92 | // Get the user's locale for character classification from the environment
93 | // NOTE: This call is so that the ProgressMeter class can check to see if
94 | // UTF-8 character encoding is used. The progress meter will be
95 | // rendered using nicer Unicode characters if this is called and the
96 | // character encoding is UTF-8. Otherwise, it will render using
97 | // using plain ASCII characters.
98 | std::setlocale(LC_CTYPE, "");
99 | #endif
100 |
101 | // Install the signal handlers
102 | InstallSignalHandlers();
103 |
104 | std::cout << "This program will demonstrate a progress meter render"
105 | << std::endl;
106 |
107 | // Say the "size" is 500, whatever this might be.
108 | Terra::ConIO::ProgressMeter progress_meter(500);
109 |
110 | // Show the terminal window dimensions
111 | auto dimensions = Terra::ConIO::GetTerminalDimensions();
112 | std::cout << "Screen size: " << dimensions.first << " x "
113 | << dimensions.second << std::endl;
114 |
115 | // Start rendering
116 | progress_meter.Start();
117 |
118 | for (std::size_t i = 1; i <= 500; i++)
119 | {
120 | if (Terminate) break;
121 | progress_meter.Update(i);
122 | std::this_thread::sleep_for(std::chrono::milliseconds(10));
123 | }
124 |
125 | if (!Terminate)
126 | {
127 | std::this_thread::sleep_for(std::chrono::seconds(2));
128 | }
129 |
130 | // Stop rendering
131 | progress_meter.Stop();
132 |
133 | std::cout << "Final line replaces the meter" << std::endl;
134 |
135 | // Show the terminal window dimensions (again)
136 | dimensions = Terra::ConIO::GetTerminalDimensions();
137 | std::cout << "Screen size: " << dimensions.first << " x "
138 | << dimensions.second << std::endl;
139 | }
140 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the library
2 | add_library(conio STATIC
3 | utilities.cpp
4 | ansi_capable.cpp
5 | ansi.cpp
6 | progress_meter.cpp)
7 | add_library(Terra::conio ALIAS conio)
8 |
9 | # Make project include directory available to external projects
10 | target_include_directories(conio
11 | PRIVATE
12 | $
13 | PUBLIC
14 | $)
15 |
16 | # Specify the C++ standard to observe
17 | set_target_properties(conio
18 | PROPERTIES
19 | CXX_STANDARD 20
20 | CXX_STANDARD_REQUIRED ON
21 | CXX_EXTENSIONS OFF)
22 |
23 | # If requesting clang-tidy, try to look for it
24 | if(conio_CLANG_TIDY)
25 | find_program(CLANG_TIDY_COMMAND NAMES "clang-tidy")
26 | if(CLANG_TIDY_COMMAND)
27 | set_target_properties(conio PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
28 | else()
29 | message(WARNING "Could not find clang-tidy")
30 | endif()
31 | endif()
32 |
33 | # Use the following compile options
34 | target_compile_options(conio
35 | PRIVATE
36 | $<$,$,$>: -Wpedantic -Wextra -Wall>
37 | $<$: >)
38 |
39 | # Install target and associated include files
40 | if(conio_INSTALL)
41 | include(GNUInstallDirs)
42 | install(TARGETS conio EXPORT conioTargets ARCHIVE)
43 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ TYPE INCLUDE)
44 | install(EXPORT conioTargets
45 | FILE conioConfig.cmake
46 | NAMESPACE Terra::
47 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/conio)
48 | endif()
49 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(ansi_capable)
2 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/test/ansi_capable/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the test excutable
2 | add_executable(test_ansi_capable test_ansi_capable.cpp)
3 |
4 | # Link to the required libraries
5 | target_link_libraries(test_ansi_capable Terra::stf Terra::conio)
6 |
7 | # Specify the C++ standard to observe
8 | set_target_properties(test_ansi_capable
9 | PROPERTIES
10 | CXX_STANDARD 20
11 | CXX_STANDARD_REQUIRED ON
12 | CXX_EXTENSIONS OFF)
13 |
14 | # Specify the compiler options
15 | target_compile_options(test_ansi_capable
16 | PRIVATE
17 | $<$,$,$>: -Wpedantic -Wextra -Wall>
18 | $<$: >)
19 |
20 | # Ensure CTest can find the test
21 | add_test(NAME test_ansi_capable
22 | COMMAND test_ansi_capable)
23 |
--------------------------------------------------------------------------------
/app/src/main/cpp/conio-master/test/ansi_capable/test_ansi_capable.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * test_ansi_capable.cpp
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This module will test the ansi_capable function.
13 | *
14 | * Portability Issues:
15 | * None.
16 | */
17 |
18 | #ifdef _WIN32
19 | #include // For _isatty()
20 | #include // For _fileno()
21 | #elif defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
22 | #include // For isatty()
23 | #include // For getenv()
24 | #include // For strcmp()
25 | #endif
26 | #include
27 | #include
28 |
29 | STF_TEST(ANSICapable, NonExistentANSICapable)
30 | {
31 | // Device descriptor 3 should result in false
32 | STF_ASSERT_FALSE(Terra::ConIO::IsANSICapable(3));
33 | }
34 |
35 | STF_TEST(ANSICapable, StdOutANSICapable)
36 | {
37 | // If running from an actual TTY, then the results should be true, else
38 | // they should be false
39 | bool expected = false;
40 |
41 | #if defined(_WIN32)
42 | // If this is a TTY, then return true
43 | if (_isatty(_fileno(stdout))) expected = true;
44 | #elif defined (__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
45 | // If this is not a TTY, return false
46 | if (isatty(STDOUT_FILENO)) expected = true;
47 | #endif
48 |
49 | // Check the expected results
50 | STF_ASSERT_EQ(expected, Terra::ConIO::IsStdOutANSICapable());
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/cpp/dependencies/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Enable fetching content
2 | include(FetchContent)
3 |
4 | # Set the root of the Terrapane source repositories
5 | if(DEFINED ENV{TERRAPANE_SOURCE_URI})
6 | set(TERRAPANE_SOURCE_URI "$ENV{TERRAPANE_SOURCE_URI}")
7 | else()
8 | set(TERRAPANE_SOURCE_URI "https://github.com/terrapane")
9 | endif()
10 |
11 | # Retrieve STF only if building tests
12 | if(aescrypt_engine_BUILD_TESTS)
13 | # Fetch the Simple Test Framework library
14 | FetchContent_Declare(stf
15 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/stf.git
16 | GIT_TAG master
17 | GIT_SHALLOW true)
18 |
19 | # It is not necessary to install the STF library
20 | set (stf_INSTALL OFF)
21 |
22 | # Make STF available
23 | FetchContent_MakeAvailable(stf)
24 | endif()
25 |
26 | # Fetch the AES Crypt Engine
27 | #FetchContent_Declare(aescrypt_engine
28 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/aescrypt_engine.git
29 | #GIT_TAG master
30 | #GIT_SHALLOW true)
31 |
32 | # Fetch the AES library
33 | #FetchContent_Declare(libaes
34 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libaes.git
35 | #GIT_TAG master
36 | #GIT_SHALLOW true)
37 |
38 | # Fetch security utilities library
39 | FetchContent_Declare(secutil
40 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/secutil.git
41 | GIT_TAG master
42 | GIT_SHALLOW true)
43 |
44 | # Fetch character-related utilities
45 | FetchContent_Declare(charutil
46 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/charutil.git
47 | GIT_TAG master
48 | GIT_SHALLOW true)
49 |
50 | # Fetch the random generator library
51 | FetchContent_Declare(random
52 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/random.git
53 | GIT_TAG master
54 | GIT_SHALLOW true)
55 |
56 | # Fetch the hashing library
57 | #FetchContent_Declare(libhash
58 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libhash.git
59 | #GIT_TAG master
60 | #GIT_SHALLOW true)
61 |
62 | # Fetch the Key Derivation Function library
63 | #FetchContent_Declare(libkdf
64 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libkdf.git
65 | #GIT_TAG master
66 | #GIT_SHALLOW true)
67 |
68 | # Fetch the Logger library
69 | #FetchContent_Declare(logger
70 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/logger.git
71 | #GIT_TAG master
72 | #GIT_SHALLOW true)
73 |
74 | # If not installing aescrypt_engine, turn off installation for dependencies
75 | if(NOT aescrypt_engine_INSTALL)
76 | #set(libaes_INSTALL OFF)
77 | set(secutil_INSTALL OFF)
78 | set(charutil_INSTALL OFF)
79 | set(random_INSTALL OFF)
80 | #set(libhash_INSTALL OFF)
81 | #set(libkdf_INSTALL OFF)
82 | #set(logger_INSTALL OFF)
83 | endif()
84 |
85 | # Make dependencies available
86 | #FetchContent_MakeAvailable(aescrypt_engine libaes secutil charutil random libhash libkdf logger)
87 | #Without libaes, logger, aescrypt_engine
88 | FetchContent_MakeAvailable(secutil charutil random)
89 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | v1.0.6
4 |
5 | - Disable Intel intrinsics if not targeting an Intel processor
6 | - Updated dependencies
7 |
8 | v1.0.5
9 |
10 | - Changes required to build on FreeBSD
11 | - Updated library dependencies
12 |
13 | v1.0.4
14 |
15 | - Changes for Intel-based Mac to support Intel intrinsics
16 |
17 | v1.0.3
18 |
19 | - Updated library dependencies
20 |
21 | v1.0.2
22 |
23 | - Changes to CMake related to use of Intel Intrinsics
24 | - Changes to #ifdef statements to check for AES-NI support
25 | - Updated library dependencies
26 |
27 | v1.0.1
28 |
29 | - Updated secutil to 1.0.1 for better Linux compatibility
30 |
31 | v1.0.0
32 |
33 | - Initial Release
34 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.21)
2 |
3 | # Define the AES Library project
4 | project(libaes
5 | VERSION 1.0.6.0
6 | DESCRIPTION "AES Cryptography Library"
7 | LANGUAGES CXX)
8 |
9 | # Tests are built by default when this is a top-level project
10 | if(PROJECT_IS_TOP_LEVEL)
11 | option(libaes_BUILD_TESTS "Build Tests for the AES Library" ON)
12 | else()
13 | option(libaes_BUILD_TESTS "Build Tests for the AES Library" OFF)
14 | endif()
15 |
16 | # Option to control ability to install the library
17 | option(libaes_INSTALL "Install the AES Library" ON)
18 |
19 | # Determine whether clang-tidy should be used during build
20 | option(libaes_CLANG_TIDY "Use clang-tidy to perform linting during build" OFF)
21 |
22 | # Does the platform potentially support Intel Intrinsics?
23 | set(TERRA_CHECK_INTEL_TARGET OFF)
24 | if(APPLE)
25 | if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR
26 | (NOT CMAKE_OSX_ARCHITECTURES AND CMAKE_SYSTEM_PROCESSOR MATCHES "i386|x86_64"))
27 | set(TERRA_CHECK_INTEL_TARGET ON)
28 | endif()
29 | elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|i386")
30 | set(TERRA_CHECK_INTEL_TARGET ON)
31 | endif()
32 |
33 | # Option to control use of Intel Intrinsics (available only on x86/x64)
34 | option(TERRA_ENABLE_INTEL_INTRINSICS "Enable Intel AES Intrinsics" ${TERRA_CHECK_INTEL_TARGET})
35 |
36 | # Option to enable speed test in the AES engine tests
37 | option(TERRA_ENABLE_AES_SPEED_TESTS "Enable AES Engine Speed Tests" OFF)
38 |
39 | add_subdirectory(dependencies)
40 | add_subdirectory(src)
41 |
42 | include(CTest)
43 |
44 | if(BUILD_TESTING AND libaes_BUILD_TESTS)
45 | add_subdirectory(test)
46 | endif()
47 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | ## Acquiring a License
4 |
5 | This is commercial software and a license may be purchased by visiting
6 | [Terrapane](https://www.terrapane.com). You may download the software and try
7 | it to see if it meets your needs, but please purchase a license if you
8 | find the software useful. Your financial support is important so we can
9 | continue to improve and enhance this and our other software products.
10 |
11 | Use of the software implies understanding and acceptance of the warranty
12 | statement.
13 |
14 | ### Individual Use
15 |
16 | Each individual using the software on his or her computer(s) is required to
17 | purchase a license for continued use of the software. An individual may use
18 | his or her license on any number of devices owned and operated by that
19 | individual.
20 |
21 | ### Business, Government, Educational, and Non-Profit Use
22 |
23 | For business, government, educational, non-profits, or other non-human entity,
24 | the entity may acquire and assign a license per machine or per individual.
25 | Licenses acquired for an individual within such an entity may be transferred to
26 | another individual within the same entity (e.g., a license acquired for a first
27 | employee may be transferred to a second employee should the first employee
28 | leave the company or otherwise cease using the software).
29 |
30 | Licenses are not transferrable to another individual or entity, except as
31 | described in the previous paragraph.
32 |
33 | ### Machine Use
34 |
35 | This clause applies only to business, government, educational, non-profits,
36 | or other non-human entities.
37 |
38 | Each computer or machine having no specific human user that uses this software
39 | (e.g., a server or server instance wherein this software is used) must have a
40 | distinct license.
41 |
42 | ## Warranty
43 |
44 | THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED
45 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
46 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE
47 | HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER
48 | DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA
49 | BEING RENDERED INACCURATE.
50 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/README.md:
--------------------------------------------------------------------------------
1 | # Advanced Encryption Standard Library
2 |
3 | This library implements the AES block cipher (FIPS 197) and AES Key Wrap
4 | (IETF RFC 3394) and AES Key Wrap with Padding (IETF RFC 5649).
5 |
6 | For Intel processors that support the AES-NI instructions, this library will
7 | make use of those instructions for speed benefits.
8 |
9 | ## AES Usage
10 |
11 | To encrypt or decrypt data, one creates an `AES` object and calls functions
12 | to perform those operations. The following is an example of how to encrypt
13 | a block of data:
14 |
15 | ```cpp
16 | // Pass the key of the desired length as an argument to the constructor
17 | AES aes(key);
18 |
19 | // Encrypt data
20 | aes.Encrypt(plaintext, ciphertext);
21 | ```
22 |
23 | AES supports 128, 192, and 256-bit key lengths, all of which are supported
24 | by this library. There are additional functions to set (or re-set) the
25 | encryption key, so it's not required to provide the key exclusively via the
26 | constructor.
27 |
28 | Text is encrypted or decrypted "in place", meaning that the memory pointed
29 | to by the `plaintext` and `ciphertext` arguments in the above
30 | examples _may_ refer to the same memory location.
31 |
32 | ## AESKeyWrap Usage
33 |
34 | The `AESKeyWrap` object implements the specifications that are designed
35 | to allow one to encrypt a key that is subsequently used for encryption.
36 | There are wrapping procedures implemented with and without padding.
37 |
38 | The following is an example of the usage of `AESKeyWrap`:
39 |
40 | ```cpp
41 | // Create AESKeyWrap object using the given key and length
42 | AESKeyWrap aes_kw(key);
43 |
44 | // Perform the AES Key Wrap
45 | aes_kw.Wrap(plaintext, ciphertext);
46 | ```
47 |
48 | The `plaintext` in this example would be the encryption key to wrap and the
49 | `ciphertext` would be the wrapped (encrypted) key. Note that the output of
50 | the wrapping operation will be longer than the original input. This is to
51 | hold integrity data that is used to determine that the wrapped key data was
52 | modified when `Unwrap()` is called. Refer to the `Wrap()` function definition
53 | for more details.
54 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/dependencies/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Enable fetching content
2 | include(FetchContent)
3 |
4 | # Set the root of the Terrapane source repositories
5 | if(DEFINED ENV{TERRAPANE_SOURCE_URI})
6 | set(TERRAPANE_SOURCE_URI "$ENV{TERRAPANE_SOURCE_URI}")
7 | else()
8 | set(TERRAPANE_SOURCE_URI "https://github.com/terrapane")
9 | endif()
10 |
11 | if(libaes_BUILD_TESTS)
12 | # Fetch the Simple Test Framework library
13 | FetchContent_Declare(stf
14 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/stf.git
15 | GIT_TAG v1.0.1
16 | GIT_SHALLOW true)
17 |
18 | # It is not necessary to install the STF library
19 | set(stf_INSTALL OFF)
20 |
21 | # Make STF available
22 | FetchContent_MakeAvailable(stf)
23 | endif()
24 |
25 | # Fetch and make available security-related utility functions
26 | FetchContent_Declare(secutil
27 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/secutil.git
28 | GIT_TAG v1.0.5
29 | GIT_SHALLOW true)
30 |
31 | # Fetch and make available bit-oriented utility functions
32 | FetchContent_Declare(bitutil
33 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/bitutil.git
34 | GIT_TAG v1.0.1
35 | GIT_SHALLOW true)
36 |
37 | # If not installing libaes, turn off installation for dependencies
38 | if(NOT libaes_INSTALL)
39 | set(secutil_INSTALL OFF)
40 | set(bitutil_INSTALL OFF)
41 | endif()
42 |
43 | # Make dependencies available
44 | FetchContent_MakeAvailable(secutil bitutil)
45 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/include/terra/crypto/cipher/aes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aes.h
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines the AES object that performs encryption and
13 | * decryption as specified in FIPS 197 ("Advanced Encryption Standard").
14 | * This object utilizes one of the underlying AES engines to perform
15 | * the actual encryption.
16 | *
17 | * Portability Issues:
18 | * None.
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | namespace Terra::Crypto::Cipher
30 | {
31 |
32 | // Define an exception class for AES-related exceptions
33 | class AESException : public std::runtime_error
34 | {
35 | using std::runtime_error::runtime_error;
36 | };
37 |
38 | // Enum that defines the AES engine types
39 | enum class AESEngineType : std::uint8_t
40 | {
41 | Unavailable,
42 | Universal,
43 | Intel
44 | };
45 |
46 | // Define an interface class to facilitate a plurality of AES implementations
47 | class AESEngine
48 | {
49 | public:
50 | AESEngine() = default;
51 | virtual ~AESEngine() = default;
52 |
53 | virtual AESEngineType GetEngineType() const noexcept = 0;
54 |
55 | virtual void SetKey(const std::span key) = 0;
56 |
57 | virtual void ClearKeyState() = 0;
58 |
59 | virtual void Encrypt(
60 | const std::span plaintext,
61 | std::span ciphertext) noexcept = 0;
62 |
63 | virtual void Decrypt(
64 | const std::span ciphertext,
65 | std::span plaintext) noexcept = 0;
66 | };
67 |
68 | // Define the AES class
69 | class AES
70 | {
71 | public:
72 | AES();
73 | AES(const std::span key);
74 | AES(const AES &other);
75 | AES(AES &&other) noexcept;
76 | ~AES() = default;
77 |
78 | AES &operator=(const AES &other);
79 | AES &operator=(AES &&other) noexcept;
80 |
81 | void SetKey(const std::span key);
82 |
83 | void Encrypt(const std::span plaintext,
84 | std::span ciphertext) noexcept;
85 |
86 | void Decrypt(const std::span ciphertext,
87 | std::span plaintext) noexcept;
88 |
89 | bool operator==(const AES &other) const;
90 | bool operator!=(const AES &other) const;
91 |
92 | protected:
93 | void CreateEngine();
94 |
95 | std::unique_ptr aes_engine; // AES engine
96 | };
97 |
98 | } // namespace Terra::Crypto::Cipher
99 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/include/terra/crypto/cipher/aes_key_wrap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aes_key_wrap.h
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines the AESKeyWrap object that implements AES Key Wrap
13 | * (RFC 3394) and AES Key Wrap with Padding (RFC 5649). This code
14 | * relies on the AES object to actually perform AES encryption and
15 | * decryption. Note that invalid span or key lengths will cause an
16 | * exception to be thrown.
17 | *
18 | * These routines are also documented in NIST Special Publication 800-38F.
19 | *
20 | * Portability Issues:
21 | * None.
22 | */
23 |
24 | #pragma once
25 |
26 | #include
27 | #include
28 | #include
29 | #include "aes.h"
30 |
31 | namespace Terra::Crypto::Cipher
32 | {
33 |
34 | class AESKeyWrap
35 | {
36 | public:
37 | // The default IV per RFC 3394
38 | static constexpr std::uint8_t AES_Key_Wrap_Default_IV[8] =
39 | {
40 | 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6
41 | };
42 |
43 | // AIV per RFC 5649
44 | static constexpr std::uint8_t Alternative_IV[4] =
45 | {
46 | 0xA6, 0x59, 0x59, 0xA6
47 | };
48 |
49 | // The maximum plaintext length for Key Wrap with Padding
50 | static constexpr std::size_t AES_Key_Wrap_with_Padding_Max{0xFFFFFFFF};
51 |
52 | AESKeyWrap();
53 | AESKeyWrap(const std::span key);
54 | ~AESKeyWrap();
55 |
56 | void SetKey(const std::span key);
57 |
58 | void Wrap(const std::span plaintext,
59 | std::span ciphertext,
60 | const std::span alternative_iv = {});
61 | bool Unwrap(const std::span ciphertext,
62 | std::span plaintext,
63 | std::span integrity_data = {},
64 | const std::span alternative_iv = {});
65 |
66 | std::size_t WrapWithPadding(
67 | const std::span plaintext,
68 | std::span ciphertext,
69 | const std::span alternative_iv = {});
70 | std::size_t UnwrapWithPadding(
71 | const std::span ciphertext,
72 | std::span plaintext,
73 | const std::span alternative_iv = {});
74 |
75 | protected:
76 | AES aes; // AES block cipher
77 |
78 | std::size_t i, j, k; // Loop counter
79 | std::size_t n; // Number of 64-bit blocks
80 | std::size_t t, tt; // Step counters
81 | std::uint8_t *A; // Integrity check register
82 | std::uint8_t B[16]; // Buffer to encrypt/decrypt
83 | std::uint8_t *R; // Pointer to register i
84 |
85 | std::uint32_t network_word; // Word in network byte order
86 |
87 | std::size_t padding_length; // Number of padding octets
88 |
89 | std::uint8_t integrity_data[8]; // Integrity data
90 | std::uint32_t message_length_indicator; // Message length indicator
91 | std::uint8_t plaintext_buffer[16]; // Plaintext for one block
92 | };
93 |
94 | } // namespace Terra::Crypto::Cipher
95 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the library
2 | add_library(aes STATIC
3 | aes.cpp
4 | aes_intel.cpp
5 | aes_universal.cpp
6 | aes_key_wrap.cpp
7 | cpu_check.cpp)
8 | add_library(Terra::libaes ALIAS aes)
9 |
10 | # Specify the internal and public include directories
11 | target_include_directories(aes
12 | PRIVATE
13 | $
14 | PUBLIC
15 | $)
16 |
17 | # Specify the C++ standard to observe
18 | set_target_properties(aes
19 | PROPERTIES
20 | CXX_STANDARD 20
21 | CXX_STANDARD_REQUIRED ON
22 | CXX_EXTENSIONS OFF)
23 |
24 | # Use the following compile options
25 | target_compile_options(aes
26 | PRIVATE
27 | $<$,$,$>:-Wpedantic -Wextra -Wall>
28 | $<$:>)
29 |
30 | # Ensure compiler knows if requested to build with Intel Intrinsics
31 | if(TERRA_ENABLE_INTEL_INTRINSICS)
32 | # Set the compiler definition
33 | target_compile_definitions(aes PRIVATE TERRA_ENABLE_INTEL_INTRINSICS)
34 |
35 | # Set compiler options for some platforms to include -maes
36 | if(DEFINED CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
37 | target_compile_options(aes PRIVATE
38 | # On Mac, -maes for explicit single x86_64
39 | $<$,$>:-maes>
40 | # On Mac, -maes and warning suppression for universal with x86_64 (excludes single x86_64)
41 | $<$,$,$>:-maes -Wno-unused-command-line-argument>)
42 | else()
43 | target_compile_options(aes PRIVATE
44 | # On any platform, -maes for system processors x86_64 or i386
45 | $<$,$>:-maes>)
46 | endif()
47 | endif()
48 |
49 | # Link against library dependencies
50 | target_link_libraries(aes PRIVATE Terra::secutil Terra::bitutil)
51 |
52 | # If requesting clang-tidy, try to look for it
53 | if(libaes_CLANG_TIDY)
54 | find_program(CLANG_TIDY_COMMAND NAMES "clang-tidy")
55 | if(CLANG_TIDY_COMMAND)
56 | set_target_properties(aes PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
57 | else()
58 | message(WARNING "Could not find clang-tidy")
59 | endif()
60 | endif()
61 |
62 | # Install target and associated include files
63 | if(libaes_INSTALL)
64 | include(GNUInstallDirs)
65 | install(TARGETS aes EXPORT libaesTargets ARCHIVE)
66 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ TYPE INCLUDE)
67 | install(EXPORT libaesTargets
68 | FILE libaesConfig.cmake
69 | NAMESPACE Terra::
70 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libaes)
71 | endif()
72 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/aes_intel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aes_intel.h
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines the AESIntel object which performs encryption and
13 | * decryption as specified in FIPS 197 ("Advanced Encryption Standard")
14 | * using Intel Intrinsics functions.
15 | *
16 | * Reference implementation code:
17 | * https://www.intel.com/content/dam/doc/white-paper/advanced-encryption-standard-new-instructions-set-paper.pdf
18 | *
19 | * Note that if one attempts to use this AES engine on a processor that
20 | * does not support the AES NI instructions it will not work and will
21 | * likely cause a core dump. One should always call the GetEngineType()
22 | * to ensure that it does not return "AESEngineType::Unavailable" before
23 | * attempting to use any of the functions.
24 | *
25 | * Portability Issues:
26 | * None.
27 | */
28 |
29 | #pragma once
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include "intel_intrinsics.h"
37 | #include "cpu_check.h"
38 | #include "aes_unavailable.h"
39 |
40 | namespace Terra::Crypto::Cipher
41 | {
42 |
43 | #ifdef TERRA_USE_INTEL_INTRINSICS
44 |
45 | // Define the AESIntel class
46 | class AESIntel : public AESEngine
47 | {
48 | protected:
49 | // The block size of the AES cipher is fixed at 16 octets
50 | static constexpr std::size_t AES_Block_Size{16};
51 |
52 | // Number of columns in the State array
53 | static constexpr std::size_t Nb{4};
54 |
55 | // Specify the maximum number of rounds per the standard
56 | static constexpr std::size_t Max_Rounds{14};
57 |
58 | public:
59 | AESIntel() noexcept;
60 | AESIntel(const std::span key);
61 | AESIntel(const AESIntel &other) noexcept;
62 | AESIntel(AESIntel &&other) noexcept;
63 | ~AESIntel();
64 |
65 | AESIntel &operator=(const AESIntel &other);
66 | AESIntel &operator=(AESIntel &&other) noexcept;
67 |
68 | AESEngineType GetEngineType() const noexcept override
69 | {
70 | if (CPUSupportsAES_NI()) return AESEngineType::Intel;
71 |
72 | return AESEngineType::Unavailable;
73 | }
74 |
75 | void SetKey(const std::span key) override;
76 |
77 | void ClearKeyState() override;
78 |
79 | void Encrypt(const std::span plaintext,
80 | std::span ciphertext) noexcept override;
81 |
82 | void Decrypt(const std::span ciphertext,
83 | std::span plaintext) noexcept override;
84 |
85 | bool operator==(const AESIntel &other) const;
86 | bool operator!=(const AESIntel &other) const;
87 |
88 | protected:
89 | // Number of encryption rounds
90 | unsigned Nr;
91 |
92 | // Encryption round key schedule array
93 | __m128i W[Max_Rounds + 1];
94 |
95 | // Decryption round key schedule array
96 | __m128i DW[Max_Rounds + 1];
97 |
98 | // Temporary variables used in key expansion
99 | __m128i T1, T2, T3, T4;
100 | };
101 |
102 | #else // TERRA_USE_INTEL_INTRINSICS
103 |
104 | // If building without Intel Intrinsics, alias this engine type as unavailable
105 |
106 | using AESIntel = AESUnavailable;
107 |
108 | #endif // TERRA_USE_INTEL_INTRINSICS
109 |
110 | } // namespace Terra::Crypto::Cipher
111 |
112 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/aes_unavailable.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aes_unavailable.h
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines the AESUnavailable object which serves as a
13 | * stub for when specific AES engines when they are not available.
14 | * For example, if one builds the code with Intel Intrinsics disabled,
15 | * then the AESIntel object will be an alias of this object.
16 | *
17 | * This helps to simplify code to avoid having conditional compilation
18 | * statements.
19 | *
20 | * Portability Issues:
21 | * None.
22 | */
23 |
24 | #pragma once
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | namespace Terra::Crypto::Cipher
31 | {
32 |
33 | struct AESUnavailable : public AESEngine
34 | {
35 | AESUnavailable() = default;
36 | AESUnavailable(const std::span) {}
37 | ~AESUnavailable() = default;
38 |
39 | AESEngineType GetEngineType() const noexcept override
40 | {
41 | return AESEngineType::Unavailable;
42 | }
43 |
44 | void SetKey(const std::span) override {}
45 |
46 | void ClearKeyState() override {}
47 |
48 | void Encrypt(const std::span,
49 | std::span) noexcept override
50 | {
51 | }
52 |
53 | void Decrypt(const std::span,
54 | std::span) noexcept override
55 | {
56 | }
57 |
58 | bool operator==(const AESUnavailable &) const { return true; }
59 |
60 | bool operator!=(const AESUnavailable &) const { return false; }
61 | };
62 |
63 | } // namespace Terra::Crypto::Cipher
64 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/aes_universal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aes_universal.h
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines the AESUniversal object that performs encryption and
13 | * decryption as specified in FIPS 197 ("Advanced Encryption Standard").
14 | *
15 | * Note that this code does not utilize older C-style macros, instead
16 | * opting for constexpr functions. While this makes the code more
17 | * readable and safe, performance suffers unless this library is built
18 | * with compiler optimizations enabled.
19 | *
20 | * This implementation of AES is called "universal" as it can operate on
21 | * any processor and is not dependent on processor-specific instructions.
22 | *
23 | * Portability Issues:
24 | * None.
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 |
35 | namespace Terra::Crypto::Cipher
36 | {
37 |
38 | // Define the AESUniversal class
39 | class AESUniversal : public AESEngine
40 | {
41 | protected:
42 | // The block size of the AES cipher is fixed at 16 octets
43 | static constexpr std::size_t AES_Block_Size{16};
44 |
45 | // Number of columns in the State array
46 | static constexpr std::size_t Nb{4};
47 |
48 | // Specify the maximum number of rounds per the standard
49 | static constexpr std::size_t Max_Rounds{14};
50 |
51 | public:
52 | AESUniversal() noexcept;
53 | AESUniversal(const std::span key);
54 | AESUniversal(const AESUniversal &other) noexcept;
55 | AESUniversal(AESUniversal &&other) noexcept;
56 | ~AESUniversal();
57 |
58 | AESUniversal &operator=(const AESUniversal &other);
59 | AESUniversal &operator=(AESUniversal &&other) noexcept;
60 |
61 | AESEngineType GetEngineType() const noexcept override
62 | {
63 | return AESEngineType::Universal;
64 | }
65 |
66 | void SetKey(const std::span key) override;
67 |
68 | void ClearKeyState() override;
69 |
70 | void Encrypt(
71 | const std::span plaintext,
72 | std::span ciphertext) noexcept
73 | override;
74 |
75 | void Decrypt(
76 | const std::span ciphertext,
77 | std::span plaintext) noexcept
78 | override;
79 |
80 | bool operator==(const AESUniversal &other) const;
81 | bool operator!=(const AESUniversal &other) const;
82 |
83 | protected:
84 | unsigned Nr; // Number of encryption rounds
85 | unsigned Nk; // 32-bit words in cipher key
86 |
87 | // State array of four columns
88 | std::uint_fast32_t state[4];
89 |
90 | // Alternating state array (temporary use during encryption/decryption)
91 | std::uint_fast32_t alt_state[4];
92 |
93 | // Encryption round key schedule array
94 | std::uint_fast32_t W[Nb * (Max_Rounds + 1)];
95 |
96 | // Decryption round key schedule array
97 | std::uint_fast32_t DW[Nb * (Max_Rounds + 1)];
98 | };
99 |
100 | } // namespace Terra::Crypto::Cipher
101 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/cpu_check.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cpu_check.cpp
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This module defines a function that will verify that the Intel
13 | * processor supports the AES-NI instructions. When calling the cpuid()
14 | * function with function_id 1, bit 25 of the ecx register will contain
15 | * a 1 if the AES-NI instructions are supported. Source:
16 | * https://www.intel.com/content/dam/doc/white-paper/advanced-encryption-standard-new-instructions-set-paper.pdf
17 | *
18 | * Portability Issues:
19 | * None.
20 | */
21 |
22 | #include "intel_intrinsics.h"
23 |
24 | #ifdef TERRA_USE_INTEL_INTRINSICS
25 | #include
26 | #include
27 | #ifdef _WIN32
28 | #include
29 | #include
30 | #endif
31 | #endif
32 |
33 | namespace Terra::Crypto::Cipher
34 | {
35 |
36 | #ifdef TERRA_USE_INTEL_INTRINSICS
37 |
38 | // Set the feature bit representing AES (25th bit) (0x0200'0000)
39 | constexpr std::uint32_t Intel_AES_Bit = 0x0200'0000;
40 |
41 | #ifdef _WIN32
42 |
43 | bool CPUSupportsAES_NI()
44 | {
45 | // Ensure we can query via cpuid
46 | {
47 | std::array cpu_info{};
48 | __cpuid(cpu_info.data(), 0);
49 | if (cpu_info[0] < 1) return false;
50 | }
51 |
52 | std::array cpu_info{};
53 | __cpuid(cpu_info.data(), 1);
54 | return (cpu_info[2] & Intel_AES_Bit) != 0;
55 | }
56 |
57 | #else
58 |
59 | #if defined(__linux__) || defined(__FreeBSD__)
60 |
61 | bool CPUSupportsAES_NI()
62 | {
63 | // Ensure we can query via cpuid
64 | {
65 | std::uint32_t eax{}, ebx{}, ecx{}, edx{};
66 | __cpuid(0, eax, ebx, ecx, edx);
67 | if (eax < 1) return false;
68 | }
69 |
70 | std::uint32_t eax{}, ebx{}, ecx{}, edx{};
71 | __cpuid(1, eax, ebx, ecx, edx);
72 | return (ecx & Intel_AES_Bit) != 0;
73 | }
74 |
75 | #else // defined(__linux__) || defined(__FreeBSD__)
76 |
77 | #define cpuid(function_id, eax, ebx, ecx, edx) \
78 | __asm__ __volatile__ ("cpuid": "=a" (eax), "=b" (ebx), "=c" (ecx), \
79 | "=d" (edx) : "a" (function_id));
80 |
81 | bool CPUSupportsAES_NI()
82 | {
83 | // Ensure we can query via cpuid
84 | {
85 | std::uint32_t eax{}, ebx{}, ecx{}, edx{};
86 | cpuid(0, eax, ebx, ecx, edx);
87 | if (eax < 1) return false;
88 | }
89 |
90 | std::uint32_t eax{}, ebx{}, ecx{}, edx{};
91 | cpuid(1, eax, ebx, ecx, edx);
92 | return (ecx & Intel_AES_Bit) != 0;
93 | }
94 |
95 | #endif // defined(__linux__) || defined(__FreeBSD__)
96 |
97 | #endif // _WIN32
98 |
99 | #else // TERRA_USE_INTEL_INTRINSICS
100 |
101 | bool CPUSupportsAES_NI()
102 | {
103 | return false;
104 | }
105 |
106 | #endif // TERRA_USE_INTEL_INTRINSICS
107 |
108 | } // namespace Terra::Crypto::Cipher
109 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/cpu_check.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cpu_check.cpp
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This module declares a function that will verify that the Intel
13 | * processor supports the AES-NI instructions.
14 | *
15 | * Portability Issues:
16 | * None.
17 | */
18 |
19 | #pragma once
20 |
21 | namespace Terra::Crypto::Cipher
22 | {
23 |
24 | bool CPUSupportsAES_NI();
25 |
26 | } // namespace Terra::Crypto::Cipher
27 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/src/intel_intrinsics.h:
--------------------------------------------------------------------------------
1 | /*
2 | * intel_intrinsics.h
3 | *
4 | * Copyright (C) 2024-2025
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file will check to see if the platform might support Intel
13 | * Intrinsics and set the TERRA_USE_INTEL_INTRINSICS if so, while also
14 | * including the Intel Intrinsics header file. If one wants to disable
15 | * use of Intel Intrinsics, turn off TERRA_ENABLE_INTEL_INTRINSICS.
16 | *
17 | * Portability Issues:
18 | * None.
19 | */
20 |
21 | #pragma once
22 |
23 | #ifdef TERRA_ENABLE_INTEL_INTRINSICS
24 |
25 | #if defined(__AES__) || defined(__AESNI__) || defined(__i386__) || \
26 | defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64)
27 |
28 | #ifndef TERRA_USE_INTEL_INTRINSICS
29 | #define TERRA_USE_INTEL_INTRINSICS 1
30 | #endif
31 |
32 | #include
33 |
34 | #endif // CPU definitions
35 |
36 | #endif // TERRA_ENABLE_INTEL_INTRINSICS
37 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(aes_universal)
2 | if(TERRA_ENABLE_INTEL_INTRINSICS)
3 | add_subdirectory(aes_intel)
4 | endif()
5 | add_subdirectory(aes_key_wrap)
6 | add_subdirectory(aes)
7 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/test/aes/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_aes test_aes.cpp)
2 |
3 | target_link_libraries(test_aes PRIVATE Terra::libaes Terra::stf)
4 |
5 | add_test(NAME test_aes
6 | COMMAND test_aes)
7 |
8 | # Specify the C++ standard to observe
9 | set_target_properties(test_aes
10 | PROPERTIES
11 | CXX_STANDARD 20
12 | CXX_STANDARD_REQUIRED ON
13 | CXX_EXTENSIONS OFF)
14 |
15 | # Specify the compiler options
16 | target_compile_options(test_aes
17 | PRIVATE
18 | $<$,$,$>:-Wpedantic -Wextra -Wall>
19 | $<$:>)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/test/aes_intel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_aes_intel test_aes_intel.cpp)
2 |
3 | target_include_directories(test_aes_intel
4 | PRIVATE
5 | ${PROJECT_SOURCE_DIR}/src)
6 |
7 | target_link_libraries(test_aes_intel PRIVATE Terra::libaes Terra::stf)
8 |
9 | add_test(NAME test_aes_intel
10 | COMMAND test_aes_intel)
11 |
12 | # Specify the C++ standard to observe
13 | set_target_properties(test_aes_intel
14 | PROPERTIES
15 | CXX_STANDARD 20
16 | CXX_STANDARD_REQUIRED ON
17 | CXX_EXTENSIONS OFF)
18 |
19 | # Specify the compiler options
20 | target_compile_options(test_aes_intel
21 | PRIVATE
22 | $<$,$,$>:-Wpedantic -Wextra -Wall>
23 | $<$:>)
24 |
25 | # Ensure compiler knows if requested to build with Intel Intrinsics
26 | if(TERRA_ENABLE_INTEL_INTRINSICS)
27 | target_compile_definitions(test_aes_intel PRIVATE TERRA_ENABLE_INTEL_INTRINSICS)
28 | endif()
29 |
30 | # If speed tests are enabled, pass that to the compiler
31 | if(TERRA_ENABLE_AES_SPEED_TESTS)
32 | target_compile_definitions(test_aes_intel PRIVATE TERRA_ENABLE_AES_SPEED_TESTS)
33 | endif()
34 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/test/aes_key_wrap/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_aes_key_wrap test_aes_key_wrap.cpp)
2 |
3 | target_link_libraries(test_aes_key_wrap PRIVATE Terra::libaes Terra::stf)
4 |
5 | add_test(NAME test_aes_key_wrap
6 | COMMAND test_aes_key_wrap)
7 |
8 | # Specify the C++ standard to observe
9 | set_target_properties(test_aes_key_wrap
10 | PROPERTIES
11 | CXX_STANDARD 20
12 | CXX_STANDARD_REQUIRED ON
13 | CXX_EXTENSIONS OFF)
14 |
15 | # Specify the compiler options
16 | target_compile_options(test_aes_key_wrap
17 | PRIVATE
18 | $<$,$,$>:-Wpedantic -Wextra -Wall>
19 | $<$:>)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libaes-master/test/aes_universal/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_aes_universal test_aes_universal.cpp)
2 |
3 | target_include_directories(test_aes_universal
4 | PRIVATE
5 | ${PROJECT_SOURCE_DIR}/src)
6 |
7 | target_link_libraries(test_aes_universal PRIVATE Terra::libaes Terra::stf)
8 |
9 | add_test(NAME test_aes_universal
10 | COMMAND test_aes_universal)
11 |
12 | # Specify the C++ standard to observe
13 | set_target_properties(test_aes_universal
14 | PROPERTIES
15 | CXX_STANDARD 20
16 | CXX_STANDARD_REQUIRED ON
17 | CXX_EXTENSIONS OFF)
18 |
19 | # Specify the compiler options
20 | target_compile_options(test_aes_universal
21 | PRIVATE
22 | $<$,$,$>:-Wpedantic -Wextra -Wall>
23 | $<$:>)
24 |
25 | # If speed tests are enabled, pass that to the compiler
26 | if(TERRA_ENABLE_AES_SPEED_TESTS)
27 | target_compile_definitions(test_aes_universal PRIVATE TERRA_ENABLE_AES_SPEED_TESTS)
28 | endif()
29 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | .vscode/
3 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | v1.0.7
4 |
5 | - Updated the dependency libraries
6 | - Made warnings stricter
7 |
8 | v1.0.6
9 |
10 | - Updated the security utilities library
11 | - Added a missing #include line
12 |
13 | v1.0.5
14 |
15 | - Added an implementation of SHA-224
16 |
17 | v1.0.4
18 |
19 | - Updated library dependencies for FreeBSD builds
20 |
21 | v1.0.3
22 |
23 | - Updated library dependencies
24 |
25 | v1.0.2
26 |
27 | - Updated library dependencies
28 |
29 | v1.0.1
30 |
31 | - Updated secutil to 1.0.1 for better Linux compatibility
32 |
33 | v1.0.0
34 |
35 | - Initial Release
36 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.21)
2 |
3 | # Define the Cryptographic Hashing project
4 | project(libhash
5 | VERSION 1.0.7.0
6 | DESCRIPTION "Cryptographic Hashing Library"
7 | LANGUAGES CXX)
8 |
9 | # Set options depending on whether this is a subproject
10 | if(PROJECT_IS_TOP_LEVEL)
11 | # Option to control whether tests are built
12 | option(libhash_BUILD_TESTS "Build Tests for Hashing Library" ON)
13 | else()
14 | # Option to control whether tests are built
15 | option(libhash_BUILD_TESTS "Build Tests for Hashing Library" OFF)
16 | endif()
17 |
18 | # Option to control ability to install the library
19 | option(libhash_INSTALL "Install the Hashing Library" ON)
20 |
21 | # Determine whether clang-tidy will be performed
22 | option(libhash_CLANG_TIDY "Use clang-tidy to perform linting during build" OFF)
23 |
24 | add_subdirectory(dependencies)
25 | add_subdirectory(src)
26 |
27 | include(CTest)
28 |
29 | if(BUILD_TESTING AND libhash_BUILD_TESTS)
30 | add_subdirectory(test)
31 | endif()
32 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | ## Acquiring a License
4 |
5 | This is commercial software and a license may be purchased by visiting
6 | [Terrapane](https://www.terrapane.com). You may download the software and try
7 | it to see if it meets your needs, but please purchase a license if you
8 | find the software useful. Your financial support is important so we can
9 | continue to improve and enhance this and our other software products.
10 |
11 | Use of the software implies understanding and acceptance of the warranty
12 | statement.
13 |
14 | ### Individual Use
15 |
16 | Each individual using the software on his or her computer(s) is required to
17 | purchase a license for continued use of the software. An individual may use
18 | his or her license on any number of devices owned and operated by that
19 | individual.
20 |
21 | ### Business, Government, Educational, and Non-Profit Use
22 |
23 | For business, government, educational, non-profits, or other non-human entity,
24 | the entity may acquire and assign a license per machine or per individual.
25 | Licenses acquired for an individual within such an entity may be transferred to
26 | another individual within the same entity (e.g., a license acquired for a first
27 | employee may be transferred to a second employee should the first employee
28 | leave the company or otherwise cease using the software).
29 |
30 | Licenses are not transferrable to another individual or entity, except as
31 | described in the previous paragraph.
32 |
33 | ### Machine Use
34 |
35 | This clause applies only to business, government, educational, non-profits,
36 | or other non-human entities.
37 |
38 | Each computer or machine having no specific human user that uses this software
39 | (e.g., a server or server instance wherein this software is used) must have a
40 | distinct license.
41 |
42 | ## Warranty
43 |
44 | THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED
45 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
46 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE
47 | HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER
48 | DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA
49 | BEING RENDERED INACCURATE.
50 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/README.md:
--------------------------------------------------------------------------------
1 | # Cryptographic Hashing Library
2 |
3 | This library implements various cryptographic hashing algorithms and related
4 | functions. In this context, a hash value is also sometimes called a message
5 | digest.
6 |
7 | The algorithms contained in this library include:
8 |
9 | * SHA-1
10 | * SHA-224
11 | * SHA-256
12 | * SHA-384
13 | * SHA-512
14 | * HMAC (for any of the aforementioned algorithms)
15 |
16 | ## Usage Examples
17 |
18 | Note that for all of the following examples, the hashing related objects are
19 | within the namespace `Terra::Crypto::Hashing`. The namespace is left out for
20 | brevity. In the test code, one will note the use of
21 | `using Terra::Crypto::Hashing` also for brevity. In commercial applications,
22 | it does make sense to retain the namespace or at least some part of it.
23 | Alternatively, one might define a shorter alias (e.g.,
24 | `namespace TCH = Terra::Crypto::Hashing`). The library uses the longer
25 | namespace names to avoid naming conflicts in our own code and third-party
26 | code.
27 |
28 | ### SHA-256 Computation
29 |
30 | If the data for which a hash value it to be competed is contained in a single
31 | string, one may compute the hash by simply doing this:
32 |
33 | ```cpp
34 | // Create the SHA256 object and compute the hash
35 | SHA256 sha256("abc");
36 |
37 | // Retrieve that hash value
38 | std::string result = sha256.Result();
39 | ```
40 |
41 | In this example, the result is returned as a string. The result may also be
42 | returned as a sequence of octets. Refer to the header file for APIs and the
43 | implementation file for more complete documentation.
44 |
45 | Generally, though, one will compute the hash value over data incrementally.
46 | To do that, the code might look something like the following:
47 |
48 | ```cpp
49 | // Creation of the SHA256 object
50 | SHA256 sha256;
51 |
52 | // Examples adding input incrementally
53 | sha256.Input(some_data);
54 | sha256.Input(more_data);
55 |
56 | // Finalize the hash by calling Finalize() once all data is inputted
57 | sha256.Finalize();
58 |
59 | // Get the result, as in the previous example
60 | std::string result = sha256.Result();
61 | ```
62 |
63 | ### Creating a Hash object
64 |
65 | Each of the hashing algorithms is derived from the abstract base class
66 | Hashing::Hash. To create an instance as a unique pointer, one calls the
67 | following function and specifying the algorithm to use:
68 |
69 | ```cpp
70 | HashPointer hash = CreateHashObject(HashAlgorithm::SHA256);
71 | ```
72 |
73 | ### HMAC Example
74 |
75 | One may implement an HMAC object and compute the hash similarly:
76 |
77 | ```cpp
78 | HMAC hmac(HashAlgorithm::SHA256, key);
79 | hmac.Input(input);
80 | hmac.Finalize();
81 |
82 | std::string result = hmac.Result();
83 | ```
84 |
85 | The above example is taken from the `test_hmac.cpp` file. Those tests and
86 | other unit tests provide a number of additional usage examples.
87 |
88 | ## Note on Performance
89 |
90 | Note that this code does not utilize older C-style macros, instead opting for
91 | `constexpr` functions. While this makes the code more readable and safe,
92 | performance suffers unless this library is built with compiler optimizations
93 | enabled. If compiler optimization is not possible for a given platform,
94 | employ C-style macros to replace various utility functions implemented in
95 | the C++ source files to significantly increase performance.
96 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/dependencies/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Enable fetching content
2 | include(FetchContent)
3 |
4 | # Set the root of the Terrapane source repositories
5 | if(DEFINED ENV{TERRAPANE_SOURCE_URI})
6 | set(TERRAPANE_SOURCE_URI "$ENV{TERRAPANE_SOURCE_URI}")
7 | else()
8 | set(TERRAPANE_SOURCE_URI "https://github.com/terrapane")
9 | endif()
10 |
11 | # Get the Simple Test Framework if building tests
12 | if(libhash_BUILD_TESTS)
13 | # Fetch the Simple Test Framework library
14 | FetchContent_Declare(stf
15 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/stf.git
16 | GIT_TAG v1.0.2
17 | GIT_SHALLOW true)
18 |
19 | # It is not necessary to install the STF library
20 | set(stf_INSTALL OFF)
21 |
22 | # Make STF available
23 | FetchContent_MakeAvailable(stf)
24 | endif()
25 |
26 | # Fetch the common security-related utility functions
27 | FetchContent_Declare(secutil
28 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/secutil.git
29 | GIT_TAG v1.0.6
30 | GIT_SHALLOW true)
31 |
32 | # Fetch the bit-related utility functions
33 | FetchContent_Declare(bitutil
34 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/bitutil.git
35 | GIT_TAG v1.0.2
36 | GIT_SHALLOW true)
37 |
38 | # If not installing libhash, turn off installation for dependencies
39 | set(secutil_INSTALL ${libhash_INSTALL})
40 | set(bitutil_INSTALL ${libhash_INSTALL})
41 |
42 | # Make dependencies available
43 | FetchContent_MakeAvailable(secutil bitutil)
44 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/include/terra/crypto/hashing/hmac.h:
--------------------------------------------------------------------------------
1 | /*
2 | * hmac.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines the keyed Hash Message Authentication Code (HMAC)
13 | * logic defined in FIPS 198-1. It is intended for use with the
14 | * hashing functions implemented in this library.
15 | *
16 | * Portability Issues:
17 | * This code assumes the compiler and platform can support 64-bit integers.
18 | */
19 |
20 | #pragma once
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include "hash.h"
28 |
29 | namespace Terra::Crypto::Hashing
30 | {
31 |
32 | // Define the HMAC class
33 | class HMAC
34 | {
35 | protected:
36 | static constexpr std::uint8_t ipad = 0x36;
37 | static constexpr std::uint8_t opad = 0x5c;
38 |
39 | // These two values must be set to the largest possible values
40 | // of any hash functions supported
41 | static constexpr std::size_t Max_Block_Size = 128;
42 | static constexpr std::size_t Max_Digest = 64;
43 |
44 | public:
45 | HMAC(const HashAlgorithm hash_algorithm);
46 | HMAC(const HashAlgorithm hash_algorithm,
47 | const std::span key,
48 | const bool spaces = true);
49 | HMAC(const HashAlgorithm hash_algorithm,
50 | const std::string_view key,
51 | const bool spaces = true);
52 | HMAC(const HMAC &other);
53 | HMAC(HMAC &&other) noexcept;
54 | ~HMAC() noexcept;
55 |
56 | HMAC &operator=(const HMAC &other);
57 | HMAC &operator=(HMAC &&other) noexcept;
58 | bool operator==(const HMAC &other) const noexcept;
59 | bool operator!=(const HMAC &other) const noexcept;
60 |
61 | void Reset();
62 |
63 | void SetKey(const std::span key);
64 | void SetKey(const std::string_view key);
65 |
66 | void Input(const std::span data);
67 | void Input(const std::string_view data);
68 | HMAC &operator<<(const std::string_view data);
69 |
70 | void Finalize();
71 |
72 | std::string Result() const;
73 | std::span Result(std::span result) const;
74 |
75 | std::size_t GetHMACLength() const noexcept
76 | {
77 | return hash ? hash->GetDigestLength() : 0;
78 | }
79 |
80 | bool IsFinalized() const noexcept
81 | {
82 | return hash ? hash->IsFinalized() : false;
83 | }
84 |
85 | bool IsCorrupted() const noexcept
86 | {
87 | return hash ? hash->IsCorrupted() : true;
88 | }
89 |
90 | void SpaceSeparateWords(bool spaces) noexcept
91 | {
92 | space_separate_words = spaces;
93 | if (hash) hash->SpaceSeparateWords(spaces);
94 | }
95 |
96 | protected:
97 | HashAlgorithm hash_algorithm;
98 | std::unique_ptr hash;
99 | bool space_separate_words;
100 | bool keyed;
101 | std::size_t block_size;
102 | std::uint8_t message_digest[Max_Digest];
103 | std::uint8_t K0[Max_Block_Size];
104 | std::uint8_t K0_ipad[Max_Block_Size];
105 | std::uint8_t K0_opad[Max_Block_Size];
106 | };
107 |
108 | // Streaming operator
109 | std::ostream &operator<<(std::ostream &o, const HMAC &hmac);
110 |
111 | } // namespace Terra::Crypto::Hashing
112 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Create the library
2 | add_library(hash STATIC hash.cpp hmac.cpp sha1.cpp sha224.cpp sha256.cpp
3 | sha384.cpp sha512.cpp)
4 | add_library(Terra::libhash ALIAS hash)
5 |
6 | set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
7 |
8 | # Specify the internal and public include directories
9 | target_include_directories(hash
10 | PRIVATE
11 | $
12 | PUBLIC
13 | $)
14 |
15 | # Specify the C++ standard to observe
16 | set_target_properties(hash
17 | PROPERTIES
18 | CXX_STANDARD 20
19 | CXX_STANDARD_REQUIRED ON
20 | CXX_EXTENSIONS OFF)
21 |
22 | # If requesting clang-tidy, try to look for it
23 | if(libhash_CLANG_TIDY)
24 | find_program(CLANG_TIDY_COMMAND NAMES "clang-tidy")
25 | if(CLANG_TIDY_COMMAND)
26 | set_target_properties(hash PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
27 | else()
28 | message(WARNING "Could not find clang-tidy")
29 | endif()
30 | endif()
31 |
32 | # Use the following compile options
33 | #target_compile_options(hash
34 | #PRIVATE
35 | #$<$,$,$>:-Wpedantic -Wextra -Wall -Werror>
36 | #$<$:/W4 /WX>)
37 | target_compile_options(hash
38 | PRIVATE
39 | $<$,$,$>:-Wpedantic -Wextra -Wall>
40 | $<$:/W4 /WX>)
41 |
42 | # Link against library dependencies
43 | target_link_libraries(hash PRIVATE Terra::secutil Terra::bitutil)
44 |
45 | # Install target and associated include files
46 | if(libhash_INSTALL)
47 | include(GNUInstallDirs)
48 | install(TARGETS hash EXPORT libhashTargets ARCHIVE)
49 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ TYPE INCLUDE)
50 | install(EXPORT libhashTargets
51 | FILE libhashConfig.cmake
52 | NAMESPACE Terra::
53 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libhash)
54 | endif()
55 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(hash)
2 | add_subdirectory(hmac)
3 | add_subdirectory(sha1)
4 | add_subdirectory(sha224)
5 | add_subdirectory(sha256)
6 | add_subdirectory(sha384)
7 | add_subdirectory(sha512)
8 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/hash/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_hash test_hash.cpp)
2 |
3 | target_link_libraries(test_hash Terra::libhash Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_hash
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_hash
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_hash
19 | COMMAND test_hash)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/hash/test_hash.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * test_hmac_sha.cpp
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This module will test code defined in the hash.h file.
13 | *
14 | * Portability Issues:
15 | * None.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | using namespace Terra::Crypto::Hashing;
23 |
24 | STF_TEST(HASH, HashDigest)
25 | {
26 | STF_ASSERT_EQ(GetHashDigestLength(HashAlgorithm::SHA1), 20);
27 | STF_ASSERT_EQ(GetHashDigestLength(HashAlgorithm::SHA256), 32);
28 | STF_ASSERT_EQ(GetHashDigestLength(HashAlgorithm::SHA384), 48);
29 | STF_ASSERT_EQ(GetHashDigestLength(HashAlgorithm::SHA512), 64);
30 | STF_ASSERT_EQ(GetHashDigestLength(HashAlgorithm::Unknown), 0);
31 | }
32 |
33 | STF_TEST(HASH, CreateHash)
34 | {
35 | {
36 | auto hash = CreateHashObject(HashAlgorithm::SHA1);
37 | STF_ASSERT_EQ(HashAlgorithm::SHA1, hash->GetHashAlgorithm());
38 | }
39 | {
40 | auto hash = CreateHashObject(HashAlgorithm::SHA256);
41 | STF_ASSERT_EQ(HashAlgorithm::SHA256, hash->GetHashAlgorithm());
42 | }
43 | {
44 | auto hash = CreateHashObject(HashAlgorithm::SHA384);
45 | STF_ASSERT_EQ(HashAlgorithm::SHA384, hash->GetHashAlgorithm());
46 | }
47 | {
48 | auto hash = CreateHashObject(HashAlgorithm::SHA512);
49 | STF_ASSERT_EQ(HashAlgorithm::SHA512, hash->GetHashAlgorithm());
50 | }
51 | }
52 |
53 | STF_TEST(HASH, SHA256Test)
54 | {
55 | auto hash = CreateHashObject(HashAlgorithm::SHA256);
56 | STF_ASSERT_EQ(HashAlgorithm::SHA256, hash->GetHashAlgorithm());
57 |
58 | hash->Input("abc");
59 | hash->Finalize();
60 | std::string result = hash->Result();
61 |
62 | STF_ASSERT_EQ(std::string("ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 "
63 | "96177a9c b410ff61 f20015ad"),
64 | result);
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/hmac/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_hmac test_hmac.cpp)
2 |
3 | target_link_libraries(test_hmac Terra::libhash Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_hmac
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_hmac
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_hmac
19 | COMMAND test_hmac)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/sha1/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_sha1 test_sha1.cpp)
2 |
3 | target_link_libraries(test_sha1 Terra::libhash Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_sha1
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_sha1
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_sha1
19 | COMMAND test_sha1)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/sha224/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_sha224 test_sha224.cpp)
2 |
3 | target_link_libraries(test_sha224 Terra::libhash Terra::bitutil Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_sha224
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_sha224
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_sha224
19 | COMMAND test_sha224)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/sha256/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_sha256 test_sha256.cpp)
2 |
3 | target_link_libraries(test_sha256 Terra::libhash Terra::bitutil Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_sha256
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_sha256
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_sha256
19 | COMMAND test_sha256)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/sha384/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_sha384 test_sha384.cpp)
2 |
3 | target_link_libraries(test_sha384 Terra::libhash Terra::bitutil Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_sha384
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_sha384
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_sha384
19 | COMMAND test_sha384)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libhash-master/test/sha512/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(test_sha512 test_sha512.cpp)
2 |
3 | target_link_libraries(test_sha512 Terra::libhash Terra::bitutil Terra::stf)
4 |
5 | # Specify the C++ standard to observe
6 | set_target_properties(test_sha512
7 | PROPERTIES
8 | CXX_STANDARD 20
9 | CXX_STANDARD_REQUIRED ON
10 | CXX_EXTENSIONS OFF)
11 |
12 | # Use the following compile options
13 | target_compile_options(test_sha512
14 | PRIVATE
15 | $<$,$,$>: -Wpedantic -Wextra -Wall>
16 | $<$: >)
17 |
18 | add_test(NAME test_sha512
19 | COMMAND test_sha512)
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | v1.0.7
4 |
5 | - Updated dependencies
6 | - Enabled stricter compiler warnings
7 |
8 | v1.0.6
9 |
10 | - Updated dependencies
11 |
12 | v1.0.5
13 |
14 | - Updated libhash library to 1.0.5
15 |
16 | v1.0.4
17 |
18 | - Updated dependencies to support FreeBSD builds
19 |
20 | v1.0.3
21 |
22 | - Updated library dependencies (stf, secutil, and libhash)
23 |
24 | v1.0.2
25 |
26 | - Updated dependencies (secutil and libhash)
27 |
28 | v1.0.1
29 |
30 | - Updated secutil to 1.0.1 for better Linux compatibility
31 | - Updated libhash to 1.0.1 to align with same secutil dependency
32 |
33 | v1.0.0
34 |
35 | - Initial Release
36 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.21)
2 |
3 | # Define the Key Derivation Function (KDF) project
4 | project(libkdf
5 | VERSION 1.0.7.0
6 | DESCRIPTION "Key Derivation Function (KDF) Library"
7 | LANGUAGES CXX)
8 |
9 | # Set options depending on whether this is a subproject
10 | if(PROJECT_IS_TOP_LEVEL)
11 | # Option to control whether tests are built
12 | option(libkdf_BUILD_TESTS "Build Tests for the KDF Library" ON)
13 | else()
14 | # Option to control whether tests are built
15 | option(libkdf_BUILD_TESTS "Build Tests for the KDF Library" OFF)
16 | endif()
17 |
18 | # Option to control ability to install the library
19 | option(libkdf_INSTALL "Install the KDF Library" ON)
20 |
21 | # Determine whether clang-tidy will be performed
22 | option(libkdf_CLANG_TIDY "Use clang-tidy to perform linting during build" OFF)
23 |
24 | add_subdirectory(dependencies)
25 | add_subdirectory(src)
26 |
27 | include(CTest)
28 |
29 | if(BUILD_TESTING AND libkdf_BUILD_TESTS)
30 | add_subdirectory(test)
31 | endif()
32 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | ## Acquiring a License
4 |
5 | This is commercial software and a license may be purchased by visiting
6 | [Terrapane](https://www.terrapane.com). You may download the software and try
7 | it to see if it meets your needs, but please purchase a license if you
8 | find the software useful. Your financial support is important so we can
9 | continue to improve and enhance this and our other software products.
10 |
11 | Use of the software implies understanding and acceptance of the warranty
12 | statement.
13 |
14 | ### Individual Use
15 |
16 | Each individual using the software on his or her computer(s) is required to
17 | purchase a license for continued use of the software. An individual may use
18 | his or her license on any number of devices owned and operated by that
19 | individual.
20 |
21 | ### Business, Government, Educational, and Non-Profit Use
22 |
23 | For business, government, educational, non-profits, or other non-human entity,
24 | the entity may acquire and assign a license per machine or per individual.
25 | Licenses acquired for an individual within such an entity may be transferred to
26 | another individual within the same entity (e.g., a license acquired for a first
27 | employee may be transferred to a second employee should the first employee
28 | leave the company or otherwise cease using the software).
29 |
30 | Licenses are not transferrable to another individual or entity, except as
31 | described in the previous paragraph.
32 |
33 | ### Machine Use
34 |
35 | This clause applies only to business, government, educational, non-profits,
36 | or other non-human entities.
37 |
38 | Each computer or machine having no specific human user that uses this software
39 | (e.g., a server or server instance wherein this software is used) must have a
40 | distinct license.
41 |
42 | ## Warranty
43 |
44 | THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED
45 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
46 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE
47 | HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER
48 | DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA
49 | BEING RENDERED INACCURATE.
50 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/README.md:
--------------------------------------------------------------------------------
1 | # Key Derivation Function Library
2 |
3 | This library contains various Key Derivation Functions.
4 |
5 | ## Standalone functions
6 |
7 | Functions implemented in this library:
8 |
9 | * ACKDF - The Password-based KDF implemented for AES Crypt version 0
10 | and used through version 2.
11 | * PBKDF1 - Password-based KDF function 1 as defined in RFC 8018 Section 5.1.
12 | * PBKDF2 - Password-based KDF function 2 as defined in RFC 8018 Section 5.2.
13 |
14 | ## HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
15 |
16 | Additionally, this library implements the "HMAC-based Extract-and-Expand Key
17 | Derivation Function (HKDF)" defined in RFC 5869. This is also referenced
18 | in NIST SP800-56Cr2 as a type of "Key-Derivation Methods in Key-Establishment
19 | Schemes". That logic is implemented in an object called, appropriately, HKDF.
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/dependencies/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Enable fetching content
2 | include(FetchContent)
3 |
4 | # Set the root of the Terrapane source repositories
5 | if(DEFINED ENV{TERRAPANE_SOURCE_URI})
6 | set(TERRAPANE_SOURCE_URI "$ENV{TERRAPANE_SOURCE_URI}")
7 | else()
8 | set(TERRAPANE_SOURCE_URI "https://github.com/terrapane")
9 | endif()
10 |
11 | # Bring in the Simple Test Framework if building tests
12 | if(libkdf_BUILD_TESTS)
13 | # Fetch the Simple Test Framework library
14 | FetchContent_Declare(stf
15 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/stf.git
16 | GIT_TAG v1.0.2
17 | GIT_SHALLOW true)
18 |
19 | # It is not necessary to install the STF library
20 | set(stf_INSTALL OFF)
21 |
22 | # Make STF available
23 | FetchContent_MakeAvailable(stf)
24 | endif()
25 |
26 | # Fetch the Hashing library
27 | #FetchContent_Declare(libhash
28 | #GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/libhash.git
29 | #GIT_TAG v1.0.7
30 | #GIT_SHALLOW true)
31 |
32 | # Fetch the Security Utilities library
33 | FetchContent_Declare(secutil
34 | GIT_REPOSITORY ${TERRAPANE_SOURCE_URI}/secutil.git
35 | GIT_TAG v1.0.6
36 | GIT_SHALLOW true)
37 |
38 | # If not installing libkdf, turn off installation for dependencies
39 | #set(libhash_INSTALL ${libkdf_INSTALL})
40 | set(secutil_INSTALL ${libkdf_INSTALL})
41 |
42 | # Make dependencies available
43 | #FetchContent_MakeAvailable(libhash secutil)
44 | FetchContent_MakeAvailable(secutil)
45 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libkdf-master/include/terra/crypto/kdf/hkdf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * hkdf.h
3 | *
4 | * Copyright (C) 2024
5 | * Terrapane Corporation
6 | * All Rights Reserved
7 | *
8 | * Author:
9 | * Paul E. Jones
10 | *
11 | * Description:
12 | * This file defines an object called HKDF that performs the
13 | * Hash-based Message Authentication Code (HMAC) Key Derivation Function
14 | * (KDF) procedures defined in RFC 5869.
15 | *
16 | * There are two forms of the constructor. The first takes only a
17 | * hashing algorithm, while the second accepts an optional salt value,
18 | * "Input Keying Material" (IKM), and hashing algorithm.
19 | *
20 | * With the first form, the user must call the Extract() function later
21 | * with (optional) salt value and "Input Keying Material" (IKM). Then,
22 | * the user may call Expand() to get additional derived data.
23 | *
24 | * In the second form, the constructor will invoke the Extract() function
25 | * upon construction. As such, the user may immediately call Expand().
26 | *
27 | * At any time, the object may be reinitialized with a new salt and
28 | * IKM by calling Extract().
29 | *
30 | * Portability Issues:
31 | * None.
32 | */
33 |
34 | #pragma once
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | namespace Terra::Crypto::KDF
44 | {
45 |
46 | class HKDF
47 | {
48 | public:
49 | HKDF(Hashing::HashAlgorithm algorithm);
50 | HKDF(Hashing::HashAlgorithm algorithm,
51 | const std::span key,
52 | const std::span