use openssl
This commit is contained in:
parent
ed4f06ae90
commit
e864041b8d
@ -18,6 +18,7 @@ android {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags '-std=c++17'
|
||||
arguments "-DANDROID_STL=c++_shared"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,6 +46,7 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
prefab true
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,4 +59,5 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation 'com.android.ndk.thirdparty:openssl:1.1.1q-beta-1'
|
||||
}
|
@ -27,9 +27,7 @@ add_library( # Sets the name of the library.
|
||||
consts.h
|
||||
utils.h
|
||||
des.h
|
||||
des.cpp
|
||||
sha1.cpp
|
||||
sha1.h)
|
||||
des.cpp)
|
||||
|
||||
|
||||
set_property(TARGET cccc PROPERTY CXX_STANDARD 17)
|
||||
@ -48,6 +46,8 @@ find_library( # Sets the name of the path variable.
|
||||
# you want CMake to locate.
|
||||
log)
|
||||
|
||||
find_package(openssl REQUIRED CONFIG)
|
||||
|
||||
# Specifies libraries CMake should link to your target library. You
|
||||
# can link multiple libraries, such as libraries you define in this
|
||||
# build script, prebuilt third-party libraries, or system libraries.
|
||||
@ -58,4 +58,5 @@ target_link_libraries( # Specifies the target library.
|
||||
# Links the target library to the log library
|
||||
# included in the NDK.
|
||||
android
|
||||
${log-lib})
|
||||
${log-lib}
|
||||
openssl::crypto)
|
@ -3,8 +3,9 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include "des.h"
|
||||
#include "sha1.h"
|
||||
|
||||
/*
|
||||
* The DES function
|
||||
@ -123,10 +124,10 @@ uint64_t des(uint64_t input, uint64_t key, char mode) {
|
||||
// 00 00 1000 0100 00 00 00 00 00 row mask
|
||||
// 00 00 0111 1000 00 00 00 00 00 column mask
|
||||
|
||||
row = (char) ((s_input & (0x0000840000000000 >> 6*j)) >> 42-6*j);
|
||||
row = (char) ((s_input & (0x0000840000000000 >> 6*j)) >> (42-6*j));
|
||||
row = (row >> 4) | row & 0x01;
|
||||
|
||||
column = (char) ((s_input & (0x0000780000000000 >> 6*j)) >> 43-6*j);
|
||||
column = (char) ((s_input & (0x0000780000000000 >> 6*j)) >> (43-6*j));
|
||||
|
||||
s_output <<= 4;
|
||||
s_output |= (uint32_t) (S[j][16*row + column] & 0x0f);
|
||||
@ -262,7 +263,7 @@ bytes KDF(bytes keyseed, int32_t count) {
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
msg.push_back(b[3 - i]);
|
||||
}
|
||||
SHA1((char*)hash.data(), (const char*)msg.data(), msg.size());
|
||||
SHA1(msg.data(), msg.size(), hash.data());
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ void SHA1Final(
|
||||
memset(&finalcount, '\0', sizeof(finalcount));
|
||||
}
|
||||
|
||||
void SHA1(
|
||||
void SHA1_bruh(
|
||||
char *hash_out,
|
||||
const char *str,
|
||||
uint32_t len)
|
||||
|
@ -45,7 +45,7 @@ void SHA1Final(
|
||||
SHA1_CTX * context
|
||||
);
|
||||
|
||||
void SHA1(
|
||||
void SHA1_bruh(
|
||||
char *hash_out,
|
||||
const char *str,
|
||||
uint32_t len);
|
||||
|
Loading…
Reference in New Issue
Block a user