├── .gitignore ├── DemoEccdh ├── DemoEccdh.sln └── DemoEccdh │ ├── DemoEccdh.cpp │ ├── DemoEccdh.vcxproj │ ├── DemoEccdh.vcxproj.filters │ ├── DemoEccdh.vcxproj.user │ ├── pch.cpp │ └── pch.h ├── DemoEcdhClient ├── .gitignore ├── .idea │ ├── caches │ │ └── build_file_checksums.ser │ ├── gradle.xml │ └── misc.xml ├── app │ ├── .gitignore │ ├── CMakeLists.txt │ ├── build.gradle │ ├── debug │ │ ├── app-debug.apk │ │ └── output.json │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── shanling │ │ │ └── demo │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ │ ├── native-lib.cpp │ │ │ ├── openssl │ │ │ │ ├── aes.h │ │ │ │ ├── asn1.h │ │ │ │ ├── asn1_mac.h │ │ │ │ ├── asn1t.h │ │ │ │ ├── async.h │ │ │ │ ├── bio.h │ │ │ │ ├── blowfish.h │ │ │ │ ├── bn.h │ │ │ │ ├── buffer.h │ │ │ │ ├── camellia.h │ │ │ │ ├── cast.h │ │ │ │ ├── cmac.h │ │ │ │ ├── cms.h │ │ │ │ ├── comp.h │ │ │ │ ├── conf.h │ │ │ │ ├── conf_api.h │ │ │ │ ├── crypto.h │ │ │ │ ├── ct.h │ │ │ │ ├── des.h │ │ │ │ ├── dh.h │ │ │ │ ├── dsa.h │ │ │ │ ├── dtls1.h │ │ │ │ ├── e_os2.h │ │ │ │ ├── ebcdic.h │ │ │ │ ├── ec.h │ │ │ │ ├── ecdh.h │ │ │ │ ├── ecdsa.h │ │ │ │ ├── engine.h │ │ │ │ ├── err.h │ │ │ │ ├── evp.h │ │ │ │ ├── hmac.h │ │ │ │ ├── idea.h │ │ │ │ ├── kdf.h │ │ │ │ ├── lhash.h │ │ │ │ ├── md2.h │ │ │ │ ├── md4.h │ │ │ │ ├── md5.h │ │ │ │ ├── mdc2.h │ │ │ │ ├── modes.h │ │ │ │ ├── obj_mac.h │ │ │ │ ├── objects.h │ │ │ │ ├── ocsp.h │ │ │ │ ├── opensslconf.h │ │ │ │ ├── opensslv.h │ │ │ │ ├── ossl_typ.h │ │ │ │ ├── pem.h │ │ │ │ ├── pem2.h │ │ │ │ ├── pkcs12.h │ │ │ │ ├── pkcs7.h │ │ │ │ ├── rand.h │ │ │ │ ├── rc2.h │ │ │ │ ├── rc4.h │ │ │ │ ├── rc5.h │ │ │ │ ├── ripemd.h │ │ │ │ ├── rsa.h │ │ │ │ ├── safestack.h │ │ │ │ ├── seed.h │ │ │ │ ├── sha.h │ │ │ │ ├── srp.h │ │ │ │ ├── srtp.h │ │ │ │ ├── ssl.h │ │ │ │ ├── ssl2.h │ │ │ │ ├── ssl3.h │ │ │ │ ├── stack.h │ │ │ │ ├── symhacks.h │ │ │ │ ├── tls1.h │ │ │ │ ├── ts.h │ │ │ │ ├── txt_db.h │ │ │ │ ├── ui.h │ │ │ │ ├── whrlpool.h │ │ │ │ ├── x509.h │ │ │ │ ├── x509_vfy.h │ │ │ │ └── x509v3.h │ │ │ ├── util.cpp │ │ │ └── wap-ecdh.cpp │ │ ├── java │ │ │ └── com │ │ │ │ └── shanling │ │ │ │ └── demo │ │ │ │ ├── AppEcdh.java │ │ │ │ ├── MainActivity.java │ │ │ │ └── util.java │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ └── activity_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 │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── shanling │ │ └── demo │ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── DemoServiceEccDh ├── DemoServiceEccDh.sln └── DemoServiceEccDh │ ├── DemoServiceEccDh.cpp │ ├── DemoServiceEccDh.vcxproj │ ├── DemoServiceEccDh.vcxproj.filters │ ├── DemoServiceEccDh.vcxproj.user │ ├── pch.cpp │ └── pch.h ├── DemoWapServiceEccDh ├── DemoWapServiceEccDh.sln └── DemoWapServiceEccDh │ ├── DemoWapServiceEccDh.cpp │ ├── DemoWapServiceEccDh.vcxproj │ ├── DemoWapServiceEccDh.vcxproj.filters │ ├── DemoWapServiceEccDh.vcxproj.user │ ├── pch.cpp │ └── pch.h ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2003 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DemoEccdh", "DemoEccdh\DemoEccdh.vcxproj", "{2F767A64-7F83-4FDA-BF55-15621F39E86C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Debug|x64.ActiveCfg = Debug|x64 17 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Debug|x64.Build.0 = Debug|x64 18 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Debug|x86.Build.0 = Debug|Win32 20 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Release|x64.ActiveCfg = Release|x64 21 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Release|x64.Build.0 = Release|x64 22 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Release|x86.ActiveCfg = Release|Win32 23 | {2F767A64-7F83-4FDA-BF55-15621F39E86C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {0EFB0B6C-FD6A-48B6-B6C9-09EBB27A4E9D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh/DemoEccdh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziweni/Ecdh/71592f71af97a8e561df1967b433650ecb7f2483/DemoEccdh/DemoEccdh/DemoEccdh.cpp -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh/DemoEccdh.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {2F767A64-7F83-4FDA-BF55-15621F39E86C} 24 | Win32Proj 25 | DemoEccdh 26 | 10.0.17134.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v141 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v141 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v141 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v141 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(ReferencePath) 76 | 77 | 78 | true 79 | 80 | 81 | false 82 | $(ReferencePath) 83 | 84 | 85 | false 86 | 87 | 88 | 89 | NotUsing 90 | Level3 91 | Disabled 92 | true 93 | WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 94 | true 95 | pch.h 96 | F:\openssl-1.0.2n\inc32; 97 | 98 | 99 | Console 100 | true 101 | F:\openssl-1.0.2n\out32.bak;%(AdditionalLibraryDirectories) 102 | libeay32.lib;%(AdditionalDependencies) 103 | 104 | 105 | 106 | 107 | Use 108 | Level3 109 | Disabled 110 | true 111 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 112 | true 113 | pch.h 114 | 115 | 116 | Console 117 | true 118 | 119 | 120 | 121 | 122 | NotUsing 123 | Level3 124 | MaxSpeed 125 | true 126 | true 127 | true 128 | WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 129 | true 130 | pch.h 131 | F:\openssl-1.0.2n\inc32; 132 | 133 | 134 | Console 135 | true 136 | true 137 | true 138 | F:\openssl-1.0.2n\out32.bak;%(AdditionalLibraryDirectories) 139 | libeay32.lib;%(AdditionalDependencies) 140 | 141 | 142 | 143 | 144 | Use 145 | Level3 146 | MaxSpeed 147 | true 148 | true 149 | true 150 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 151 | true 152 | pch.h 153 | 154 | 155 | Console 156 | true 157 | true 158 | true 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | Create 168 | Create 169 | Create 170 | Create 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh/DemoEccdh.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 23 | 24 | 源文件 25 | 26 | 27 | 源文件 28 | 29 | 30 | -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh/DemoEccdh.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh/pch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziweni/Ecdh/71592f71af97a8e561df1967b433650ecb7f2483/DemoEccdh/DemoEccdh/pch.cpp -------------------------------------------------------------------------------- /DemoEccdh/DemoEccdh/pch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziweni/Ecdh/71592f71af97a8e561df1967b433650ecb7f2483/DemoEccdh/DemoEccdh/pch.h -------------------------------------------------------------------------------- /DemoEcdhClient/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /DemoEcdhClient/.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziweni/Ecdh/71592f71af97a8e561df1967b433650ecb7f2483/DemoEcdhClient/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /DemoEcdhClient/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | -------------------------------------------------------------------------------- /DemoEcdhClient/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about using CMake with Android Studio, read the 2 | # documentation: https://d.android.com/studio/projects/add-native-code.html 3 | 4 | # Sets the minimum version of CMake required to build the native library. 5 | 6 | cmake_minimum_required(VERSION 3.4.1) 7 | 8 | # Creates and names a library, sets it as either STATIC 9 | # or SHARED, and provides the relative paths to its source code. 10 | # You can define multiple libraries, and CMake builds them for you. 11 | # Gradle automatically packages shared libraries with your APK. 12 | 13 | add_library( # Sets the name of the library. 14 | native-lib 15 | 16 | # Sets the library as a shared library. 17 | SHARED 18 | 19 | # Provides a relative path to your source file(s). 20 | src/main/cpp/native-lib.cpp ) 21 | 22 | add_library( wap-ecdh 23 | SHARED 24 | src/main/cpp/wap-ecdh.cpp ) 25 | 26 | # Searches for a specified prebuilt library and stores the path as a 27 | # variable. Because CMake includes system libraries in the search path by 28 | # default, you only need to specify the name of the public NDK library 29 | # you want to add. CMake verifies that the library exists before 30 | # completing its build. 31 | 32 | find_library( # Sets the name of the path variable. 33 | log-lib 34 | 35 | # Specifies the name of the NDK library that 36 | # you want CMake to locate. 37 | log ) 38 | 39 | # Specifies libraries CMake should link to your target library. You 40 | # can link multiple libraries, such as libraries you define in this 41 | # build script, prebuilt third-party libraries, or system libraries. 42 | 43 | target_link_libraries( # Specifies the target library. 44 | wap-ecdh native-lib 45 | openssl-crypto 46 | openssl-ssl 47 | # Links the target library to the log library 48 | # included in the NDK. 49 | ${log-lib}) 50 | 51 | # 表示把src/main/cpp加入include目录,这样在代码中,使用:#include <...>就能访问到头文件 52 | include_directories(src/main/cpp) 53 | 54 | # 添加两个预编译库 55 | add_library(openssl-crypto 56 | STATIC 57 | IMPORTED) 58 | 59 | set_target_properties(openssl-crypto 60 | PROPERTIES IMPORTED_LOCATION 61 | ${CMAKE_SOURCE_DIR}/libs/libcrypto.a ) 62 | 63 | add_library(openssl-ssl 64 | STATIC 65 | IMPORTED) 66 | 67 | set_target_properties(openssl-ssl 68 | PROPERTIES IMPORTED_LOCATION 69 | ${CMAKE_SOURCE_DIR}/libs/libssl.a ) -------------------------------------------------------------------------------- /DemoEcdhClient/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.shanling.demo" 7 | minSdkVersion 21 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | externalNativeBuild { 13 | cmake { 14 | cppFlags "-std=c++11 -frtti -fexceptions" 15 | // 下面这样是增加的 16 | arguments "-DANDROID_ABI=armeabi-v7a" 17 | } 18 | } 19 | ndk { 20 | abiFilters "armeabi-v7a" 21 | ldLibs "log", "z", "m" 22 | } 23 | } 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | externalNativeBuild { 31 | cmake { 32 | path "CMakeLists.txt" 33 | } 34 | } 35 | } 36 | 37 | dependencies { 38 | implementation fileTree(dir: 'libs', include: ['*.jar']) 39 | implementation 'com.android.support:appcompat-v7:28.0.0' 40 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 41 | testImplementation 'junit:junit:4.12' 42 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 43 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 44 | } 45 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/debug/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziweni/Ecdh/71592f71af97a8e561df1967b433650ecb7f2483/DemoEcdhClient/app/debug/app-debug.apk -------------------------------------------------------------------------------- /DemoEcdhClient/app/debug/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-debug.apk","fullName":"debug","baseName":"debug"},"path":"app-debug.apk","properties":{}}] -------------------------------------------------------------------------------- /DemoEcdhClient/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/androidTest/java/com/shanling/demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.shanling.demo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.shanling.demo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | extern "C" JNIEXPORT jstring JNICALL 6 | Java_com_shanling_demo_MainActivity_stringFromJNI( 7 | JNIEnv* env, 8 | jobject /* this */) { 9 | std::string hello = "Hello from C++"; 10 | // EC_KEY * ec_key = EC_KEY_new(); 11 | // return env->NewStringUTF(OpenSSL_version(OPENSSL_VERSION)); 12 | return env->NewStringUTF(hello.c_str()); 13 | } 14 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/aes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_AES_H 11 | # define HEADER_AES_H 12 | 13 | # include 14 | 15 | # include 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | # define AES_ENCRYPT 1 21 | # define AES_DECRYPT 0 22 | 23 | /* 24 | * Because array size can't be a const in C, the following two are macros. 25 | * Both sizes are in bytes. 26 | */ 27 | # define AES_MAXNR 14 28 | # define AES_BLOCK_SIZE 16 29 | 30 | /* This should be a hidden type, but EVP requires that the size be known */ 31 | struct aes_key_st { 32 | # ifdef AES_LONG 33 | unsigned long rd_key[4 * (AES_MAXNR + 1)]; 34 | # else 35 | unsigned int rd_key[4 * (AES_MAXNR + 1)]; 36 | # endif 37 | int rounds; 38 | }; 39 | typedef struct aes_key_st AES_KEY; 40 | 41 | const char *AES_options(void); 42 | 43 | int AES_set_encrypt_key(const unsigned char *userKey, const int bits, 44 | AES_KEY *key); 45 | int AES_set_decrypt_key(const unsigned char *userKey, const int bits, 46 | AES_KEY *key); 47 | 48 | void AES_encrypt(const unsigned char *in, unsigned char *out, 49 | const AES_KEY *key); 50 | void AES_decrypt(const unsigned char *in, unsigned char *out, 51 | const AES_KEY *key); 52 | 53 | void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, 54 | const AES_KEY *key, const int enc); 55 | void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 56 | size_t length, const AES_KEY *key, 57 | unsigned char *ivec, const int enc); 58 | void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, 59 | size_t length, const AES_KEY *key, 60 | unsigned char *ivec, int *num, const int enc); 61 | void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, 62 | size_t length, const AES_KEY *key, 63 | unsigned char *ivec, int *num, const int enc); 64 | void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, 65 | size_t length, const AES_KEY *key, 66 | unsigned char *ivec, int *num, const int enc); 67 | void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, 68 | size_t length, const AES_KEY *key, 69 | unsigned char *ivec, int *num); 70 | /* NB: the IV is _two_ blocks long */ 71 | void AES_ige_encrypt(const unsigned char *in, unsigned char *out, 72 | size_t length, const AES_KEY *key, 73 | unsigned char *ivec, const int enc); 74 | /* NB: the IV is _four_ blocks long */ 75 | void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, 76 | size_t length, const AES_KEY *key, 77 | const AES_KEY *key2, const unsigned char *ivec, 78 | const int enc); 79 | 80 | int AES_wrap_key(AES_KEY *key, const unsigned char *iv, 81 | unsigned char *out, 82 | const unsigned char *in, unsigned int inlen); 83 | int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, 84 | unsigned char *out, 85 | const unsigned char *in, unsigned int inlen); 86 | 87 | 88 | # ifdef __cplusplus 89 | } 90 | # endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/asn1_mac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #error "This file is obsolete; please update your software." 11 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/async.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | 12 | #ifndef HEADER_ASYNC_H 13 | # define HEADER_ASYNC_H 14 | 15 | #if defined(_WIN32) 16 | # if defined(BASETYPES) || defined(_WINDEF_H) 17 | /* application has to include to use this */ 18 | #define OSSL_ASYNC_FD HANDLE 19 | #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE 20 | # endif 21 | #else 22 | #define OSSL_ASYNC_FD int 23 | #define OSSL_BAD_ASYNC_FD -1 24 | #endif 25 | 26 | 27 | # ifdef __cplusplus 28 | extern "C" { 29 | # endif 30 | 31 | typedef struct async_job_st ASYNC_JOB; 32 | typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; 33 | 34 | #define ASYNC_ERR 0 35 | #define ASYNC_NO_JOBS 1 36 | #define ASYNC_PAUSE 2 37 | #define ASYNC_FINISH 3 38 | 39 | int ASYNC_init_thread(size_t max_size, size_t init_size); 40 | void ASYNC_cleanup_thread(void); 41 | 42 | #ifdef OSSL_ASYNC_FD 43 | ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); 44 | void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); 45 | int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, 46 | OSSL_ASYNC_FD fd, 47 | void *custom_data, 48 | void (*cleanup)(ASYNC_WAIT_CTX *, const void *, 49 | OSSL_ASYNC_FD, void *)); 50 | int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, 51 | OSSL_ASYNC_FD *fd, void **custom_data); 52 | int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, 53 | size_t *numfds); 54 | int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, 55 | size_t *numaddfds, OSSL_ASYNC_FD *delfd, 56 | size_t *numdelfds); 57 | int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); 58 | #endif 59 | 60 | int ASYNC_is_capable(void); 61 | 62 | int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, 63 | int (*func)(void *), void *args, size_t size); 64 | int ASYNC_pause_job(void); 65 | 66 | ASYNC_JOB *ASYNC_get_current_job(void); 67 | ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); 68 | void ASYNC_block_pause(void); 69 | void ASYNC_unblock_pause(void); 70 | 71 | /* BEGIN ERROR CODES */ 72 | /* 73 | * The following lines are auto generated by the script mkerr.pl. Any changes 74 | * made after this point may be overwritten when the script is next run. 75 | */ 76 | 77 | int ERR_load_ASYNC_strings(void); 78 | 79 | /* Error codes for the ASYNC functions. */ 80 | 81 | /* Function codes. */ 82 | # define ASYNC_F_ASYNC_CTX_NEW 100 83 | # define ASYNC_F_ASYNC_INIT_THREAD 101 84 | # define ASYNC_F_ASYNC_JOB_NEW 102 85 | # define ASYNC_F_ASYNC_PAUSE_JOB 103 86 | # define ASYNC_F_ASYNC_START_FUNC 104 87 | # define ASYNC_F_ASYNC_START_JOB 105 88 | 89 | /* Reason codes. */ 90 | # define ASYNC_R_FAILED_TO_SET_POOL 101 91 | # define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 92 | # define ASYNC_R_INIT_FAILED 105 93 | # define ASYNC_R_INVALID_POOL_SIZE 103 94 | 95 | # ifdef __cplusplus 96 | } 97 | # endif 98 | #endif 99 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/blowfish.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_BLOWFISH_H 11 | # define HEADER_BLOWFISH_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_BF 16 | # include 17 | # ifdef __cplusplus 18 | extern "C" { 19 | # endif 20 | 21 | # define BF_ENCRYPT 1 22 | # define BF_DECRYPT 0 23 | 24 | /*- 25 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 26 | * ! BF_LONG has to be at least 32 bits wide. ! 27 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 28 | */ 29 | # define BF_LONG unsigned int 30 | 31 | # define BF_ROUNDS 16 32 | # define BF_BLOCK 8 33 | 34 | typedef struct bf_key_st { 35 | BF_LONG P[BF_ROUNDS + 2]; 36 | BF_LONG S[4 * 256]; 37 | } BF_KEY; 38 | 39 | void BF_set_key(BF_KEY *key, int len, const unsigned char *data); 40 | 41 | void BF_encrypt(BF_LONG *data, const BF_KEY *key); 42 | void BF_decrypt(BF_LONG *data, const BF_KEY *key); 43 | 44 | void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, 45 | const BF_KEY *key, int enc); 46 | void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 47 | const BF_KEY *schedule, unsigned char *ivec, int enc); 48 | void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, 49 | long length, const BF_KEY *schedule, 50 | unsigned char *ivec, int *num, int enc); 51 | void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, 52 | long length, const BF_KEY *schedule, 53 | unsigned char *ivec, int *num); 54 | const char *BF_options(void); 55 | 56 | # ifdef __cplusplus 57 | } 58 | # endif 59 | # endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_BUFFER_H 11 | # define HEADER_BUFFER_H 12 | 13 | # include 14 | # ifndef HEADER_CRYPTO_H 15 | # include 16 | # endif 17 | 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | # include 24 | 25 | # if !defined(NO_SYS_TYPES_H) 26 | # include 27 | # endif 28 | 29 | /* 30 | * These names are outdated as of OpenSSL 1.1; a future release 31 | * will move them to be deprecated. 32 | */ 33 | # define BUF_strdup(s) OPENSSL_strdup(s) 34 | # define BUF_strndup(s, size) OPENSSL_strndup(s, size) 35 | # define BUF_memdup(data, size) OPENSSL_memdup(data, size) 36 | # define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) 37 | # define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) 38 | # define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) 39 | 40 | struct buf_mem_st { 41 | size_t length; /* current number of bytes */ 42 | char *data; 43 | size_t max; /* size of buffer */ 44 | unsigned long flags; 45 | }; 46 | 47 | # define BUF_MEM_FLAG_SECURE 0x01 48 | 49 | BUF_MEM *BUF_MEM_new(void); 50 | BUF_MEM *BUF_MEM_new_ex(unsigned long flags); 51 | void BUF_MEM_free(BUF_MEM *a); 52 | size_t BUF_MEM_grow(BUF_MEM *str, size_t len); 53 | size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); 54 | void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); 55 | 56 | /* BEGIN ERROR CODES */ 57 | /* 58 | * The following lines are auto generated by the script mkerr.pl. Any changes 59 | * made after this point may be overwritten when the script is next run. 60 | */ 61 | 62 | int ERR_load_BUF_strings(void); 63 | 64 | /* Error codes for the BUF functions. */ 65 | 66 | /* Function codes. */ 67 | # define BUF_F_BUF_MEM_GROW 100 68 | # define BUF_F_BUF_MEM_GROW_CLEAN 105 69 | # define BUF_F_BUF_MEM_NEW 101 70 | 71 | /* Reason codes. */ 72 | 73 | # ifdef __cplusplus 74 | } 75 | # endif 76 | #endif 77 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/camellia.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CAMELLIA_H 11 | # define HEADER_CAMELLIA_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_CAMELLIA 16 | # include 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | # define CAMELLIA_ENCRYPT 1 22 | # define CAMELLIA_DECRYPT 0 23 | 24 | /* 25 | * Because array size can't be a const in C, the following two are macros. 26 | * Both sizes are in bytes. 27 | */ 28 | 29 | /* This should be a hidden type, but EVP requires that the size be known */ 30 | 31 | # define CAMELLIA_BLOCK_SIZE 16 32 | # define CAMELLIA_TABLE_BYTE_LEN 272 33 | # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) 34 | 35 | typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match 36 | * with WORD */ 37 | 38 | struct camellia_key_st { 39 | union { 40 | double d; /* ensures 64-bit align */ 41 | KEY_TABLE_TYPE rd_key; 42 | } u; 43 | int grand_rounds; 44 | }; 45 | typedef struct camellia_key_st CAMELLIA_KEY; 46 | 47 | int Camellia_set_key(const unsigned char *userKey, const int bits, 48 | CAMELLIA_KEY *key); 49 | 50 | void Camellia_encrypt(const unsigned char *in, unsigned char *out, 51 | const CAMELLIA_KEY *key); 52 | void Camellia_decrypt(const unsigned char *in, unsigned char *out, 53 | const CAMELLIA_KEY *key); 54 | 55 | void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, 56 | const CAMELLIA_KEY *key, const int enc); 57 | void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, 58 | size_t length, const CAMELLIA_KEY *key, 59 | unsigned char *ivec, const int enc); 60 | void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, 61 | size_t length, const CAMELLIA_KEY *key, 62 | unsigned char *ivec, int *num, const int enc); 63 | void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, 64 | size_t length, const CAMELLIA_KEY *key, 65 | unsigned char *ivec, int *num, const int enc); 66 | void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, 67 | size_t length, const CAMELLIA_KEY *key, 68 | unsigned char *ivec, int *num, const int enc); 69 | void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, 70 | size_t length, const CAMELLIA_KEY *key, 71 | unsigned char *ivec, int *num); 72 | void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, 73 | size_t length, const CAMELLIA_KEY *key, 74 | unsigned char ivec[CAMELLIA_BLOCK_SIZE], 75 | unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], 76 | unsigned int *num); 77 | 78 | # ifdef __cplusplus 79 | } 80 | # endif 81 | # endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/cast.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CAST_H 11 | # define HEADER_CAST_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_CAST 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | # define CAST_ENCRYPT 1 21 | # define CAST_DECRYPT 0 22 | 23 | # define CAST_LONG unsigned int 24 | 25 | # define CAST_BLOCK 8 26 | # define CAST_KEY_LENGTH 16 27 | 28 | typedef struct cast_key_st { 29 | CAST_LONG data[32]; 30 | int short_key; /* Use reduced rounds for short key */ 31 | } CAST_KEY; 32 | 33 | void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); 34 | void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, 35 | const CAST_KEY *key, int enc); 36 | void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); 37 | void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); 38 | void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, 39 | long length, const CAST_KEY *ks, unsigned char *iv, 40 | int enc); 41 | void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, 42 | long length, const CAST_KEY *schedule, 43 | unsigned char *ivec, int *num, int enc); 44 | void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, 45 | long length, const CAST_KEY *schedule, 46 | unsigned char *ivec, int *num); 47 | 48 | # ifdef __cplusplus 49 | } 50 | # endif 51 | # endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/cmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CMAC_H 11 | # define HEADER_CMAC_H 12 | 13 | # ifndef OPENSSL_NO_CMAC 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | # include 20 | 21 | /* Opaque */ 22 | typedef struct CMAC_CTX_st CMAC_CTX; 23 | 24 | CMAC_CTX *CMAC_CTX_new(void); 25 | void CMAC_CTX_cleanup(CMAC_CTX *ctx); 26 | void CMAC_CTX_free(CMAC_CTX *ctx); 27 | EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 28 | int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 29 | 30 | int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 31 | const EVP_CIPHER *cipher, ENGINE *impl); 32 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 33 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 34 | int CMAC_resume(CMAC_CTX *ctx); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | # endif 41 | #endif 42 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/comp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_COMP_H 11 | # define HEADER_COMP_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_COMP 16 | # include 17 | # ifdef __cplusplus 18 | extern "C" { 19 | # endif 20 | 21 | 22 | 23 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 24 | const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); 25 | int COMP_CTX_get_type(const COMP_CTX* comp); 26 | int COMP_get_type(const COMP_METHOD *meth); 27 | const char *COMP_get_name(const COMP_METHOD *meth); 28 | void COMP_CTX_free(COMP_CTX *ctx); 29 | 30 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 31 | unsigned char *in, int ilen); 32 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 33 | unsigned char *in, int ilen); 34 | 35 | COMP_METHOD *COMP_zlib(void); 36 | 37 | #if OPENSSL_API_COMPAT < 0x10100000L 38 | #define COMP_zlib_cleanup() while(0) continue 39 | #endif 40 | 41 | # ifdef HEADER_BIO_H 42 | # ifdef ZLIB 43 | const BIO_METHOD *BIO_f_zlib(void); 44 | # endif 45 | # endif 46 | 47 | /* BEGIN ERROR CODES */ 48 | /* 49 | * The following lines are auto generated by the script mkerr.pl. Any changes 50 | * made after this point may be overwritten when the script is next run. 51 | */ 52 | 53 | int ERR_load_COMP_strings(void); 54 | 55 | /* Error codes for the COMP functions. */ 56 | 57 | /* Function codes. */ 58 | # define COMP_F_BIO_ZLIB_FLUSH 99 59 | # define COMP_F_BIO_ZLIB_NEW 100 60 | # define COMP_F_BIO_ZLIB_READ 101 61 | # define COMP_F_BIO_ZLIB_WRITE 102 62 | 63 | /* Reason codes. */ 64 | # define COMP_R_ZLIB_DEFLATE_ERROR 99 65 | # define COMP_R_ZLIB_INFLATE_ERROR 100 66 | # define COMP_R_ZLIB_NOT_SUPPORTED 101 67 | 68 | # ifdef __cplusplus 69 | } 70 | # endif 71 | # endif 72 | #endif 73 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CONF_H 11 | # define HEADER_CONF_H 12 | 13 | # include 14 | # include 15 | # include 16 | # include 17 | # include 18 | 19 | # include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct { 26 | char *section; 27 | char *name; 28 | char *value; 29 | } CONF_VALUE; 30 | 31 | DEFINE_STACK_OF(CONF_VALUE) 32 | DEFINE_LHASH_OF(CONF_VALUE); 33 | 34 | struct conf_st; 35 | struct conf_method_st; 36 | typedef struct conf_method_st CONF_METHOD; 37 | 38 | struct conf_method_st { 39 | const char *name; 40 | CONF *(*create) (CONF_METHOD *meth); 41 | int (*init) (CONF *conf); 42 | int (*destroy) (CONF *conf); 43 | int (*destroy_data) (CONF *conf); 44 | int (*load_bio) (CONF *conf, BIO *bp, long *eline); 45 | int (*dump) (const CONF *conf, BIO *bp); 46 | int (*is_number) (const CONF *conf, char c); 47 | int (*to_int) (const CONF *conf, char c); 48 | int (*load) (CONF *conf, const char *name, long *eline); 49 | }; 50 | 51 | /* Module definitions */ 52 | 53 | typedef struct conf_imodule_st CONF_IMODULE; 54 | typedef struct conf_module_st CONF_MODULE; 55 | 56 | DEFINE_STACK_OF(CONF_MODULE) 57 | DEFINE_STACK_OF(CONF_IMODULE) 58 | 59 | /* DSO module function typedefs */ 60 | typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); 61 | typedef void conf_finish_func (CONF_IMODULE *md); 62 | 63 | # define CONF_MFLAGS_IGNORE_ERRORS 0x1 64 | # define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 65 | # define CONF_MFLAGS_SILENT 0x4 66 | # define CONF_MFLAGS_NO_DSO 0x8 67 | # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 68 | # define CONF_MFLAGS_DEFAULT_SECTION 0x20 69 | 70 | int CONF_set_default_method(CONF_METHOD *meth); 71 | void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); 72 | LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, 73 | long *eline); 74 | # ifndef OPENSSL_NO_STDIO 75 | LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, 76 | long *eline); 77 | # endif 78 | LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, 79 | long *eline); 80 | STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, 81 | const char *section); 82 | char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, 83 | const char *name); 84 | long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, 85 | const char *name); 86 | void CONF_free(LHASH_OF(CONF_VALUE) *conf); 87 | #ifndef OPENSSL_NO_STDIO 88 | int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); 89 | #endif 90 | int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); 91 | 92 | DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) 93 | 94 | #if OPENSSL_API_COMPAT < 0x10100000L 95 | # define OPENSSL_no_config() \ 96 | OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) 97 | #endif 98 | 99 | /* 100 | * New conf code. The semantics are different from the functions above. If 101 | * that wasn't the case, the above functions would have been replaced 102 | */ 103 | 104 | struct conf_st { 105 | CONF_METHOD *meth; 106 | void *meth_data; 107 | LHASH_OF(CONF_VALUE) *data; 108 | }; 109 | 110 | CONF *NCONF_new(CONF_METHOD *meth); 111 | CONF_METHOD *NCONF_default(void); 112 | CONF_METHOD *NCONF_WIN32(void); 113 | void NCONF_free(CONF *conf); 114 | void NCONF_free_data(CONF *conf); 115 | 116 | int NCONF_load(CONF *conf, const char *file, long *eline); 117 | # ifndef OPENSSL_NO_STDIO 118 | int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); 119 | # endif 120 | int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); 121 | STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, 122 | const char *section); 123 | char *NCONF_get_string(const CONF *conf, const char *group, const char *name); 124 | int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, 125 | long *result); 126 | #ifndef OPENSSL_NO_STDIO 127 | int NCONF_dump_fp(const CONF *conf, FILE *out); 128 | #endif 129 | int NCONF_dump_bio(const CONF *conf, BIO *out); 130 | 131 | #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) 132 | 133 | /* Module functions */ 134 | 135 | int CONF_modules_load(const CONF *cnf, const char *appname, 136 | unsigned long flags); 137 | int CONF_modules_load_file(const char *filename, const char *appname, 138 | unsigned long flags); 139 | void CONF_modules_unload(int all); 140 | void CONF_modules_finish(void); 141 | #if OPENSSL_API_COMPAT < 0x10100000L 142 | # define CONF_modules_free() while(0) continue 143 | #endif 144 | int CONF_module_add(const char *name, conf_init_func *ifunc, 145 | conf_finish_func *ffunc); 146 | 147 | const char *CONF_imodule_get_name(const CONF_IMODULE *md); 148 | const char *CONF_imodule_get_value(const CONF_IMODULE *md); 149 | void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); 150 | void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); 151 | CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); 152 | unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); 153 | void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); 154 | void *CONF_module_get_usr_data(CONF_MODULE *pmod); 155 | void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); 156 | 157 | char *CONF_get1_default_config_file(void); 158 | 159 | int CONF_parse_list(const char *list, int sep, int nospc, 160 | int (*list_cb) (const char *elem, int len, void *usr), 161 | void *arg); 162 | 163 | void OPENSSL_load_builtin_modules(void); 164 | 165 | /* BEGIN ERROR CODES */ 166 | /* 167 | * The following lines are auto generated by the script mkerr.pl. Any changes 168 | * made after this point may be overwritten when the script is next run. 169 | */ 170 | 171 | int ERR_load_CONF_strings(void); 172 | 173 | /* Error codes for the CONF functions. */ 174 | 175 | /* Function codes. */ 176 | # define CONF_F_CONF_DUMP_FP 104 177 | # define CONF_F_CONF_LOAD 100 178 | # define CONF_F_CONF_LOAD_FP 103 179 | # define CONF_F_CONF_PARSE_LIST 119 180 | # define CONF_F_DEF_LOAD 120 181 | # define CONF_F_DEF_LOAD_BIO 121 182 | # define CONF_F_MODULE_INIT 115 183 | # define CONF_F_MODULE_LOAD_DSO 117 184 | # define CONF_F_MODULE_RUN 118 185 | # define CONF_F_NCONF_DUMP_BIO 105 186 | # define CONF_F_NCONF_DUMP_FP 106 187 | # define CONF_F_NCONF_GET_NUMBER_E 112 188 | # define CONF_F_NCONF_GET_SECTION 108 189 | # define CONF_F_NCONF_GET_STRING 109 190 | # define CONF_F_NCONF_LOAD 113 191 | # define CONF_F_NCONF_LOAD_BIO 110 192 | # define CONF_F_NCONF_LOAD_FP 114 193 | # define CONF_F_NCONF_NEW 111 194 | # define CONF_F_STR_COPY 101 195 | 196 | /* Reason codes. */ 197 | # define CONF_R_ERROR_LOADING_DSO 110 198 | # define CONF_R_LIST_CANNOT_BE_NULL 115 199 | # define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 200 | # define CONF_R_MISSING_EQUAL_SIGN 101 201 | # define CONF_R_MISSING_INIT_FUNCTION 112 202 | # define CONF_R_MODULE_INITIALIZATION_ERROR 109 203 | # define CONF_R_NO_CLOSE_BRACE 102 204 | # define CONF_R_NO_CONF 105 205 | # define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 206 | # define CONF_R_NO_SECTION 107 207 | # define CONF_R_NO_SUCH_FILE 114 208 | # define CONF_R_NO_VALUE 108 209 | # define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 210 | # define CONF_R_UNKNOWN_MODULE_NAME 113 211 | # define CONF_R_VARIABLE_EXPANSION_TOO_LONG 116 212 | # define CONF_R_VARIABLE_HAS_NO_VALUE 104 213 | 214 | # ifdef __cplusplus 215 | } 216 | # endif 217 | #endif 218 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/conf_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_CONF_API_H 11 | # define HEADER_CONF_API_H 12 | 13 | # include 14 | # include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Up until OpenSSL 0.9.5a, this was new_section */ 21 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); 22 | /* Up until OpenSSL 0.9.5a, this was get_section */ 23 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); 24 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ 25 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, 26 | const char *section); 27 | 28 | int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); 29 | char *_CONF_get_string(const CONF *conf, const char *section, 30 | const char *name); 31 | long _CONF_get_number(const CONF *conf, const char *section, 32 | const char *name); 33 | 34 | int _CONF_new_data(CONF *conf); 35 | void _CONF_free_data(CONF *conf); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif 41 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/des.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_DES_H 11 | # define HEADER_DES_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_DES 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | # include 20 | 21 | typedef unsigned int DES_LONG; 22 | 23 | # ifdef OPENSSL_BUILD_SHLIBCRYPTO 24 | # undef OPENSSL_EXTERN 25 | # define OPENSSL_EXTERN OPENSSL_EXPORT 26 | # endif 27 | 28 | typedef unsigned char DES_cblock[8]; 29 | typedef /* const */ unsigned char const_DES_cblock[8]; 30 | /* 31 | * With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and 32 | * const_DES_cblock * are incompatible pointer types. 33 | */ 34 | 35 | typedef struct DES_ks { 36 | union { 37 | DES_cblock cblock; 38 | /* 39 | * make sure things are correct size on machines with 8 byte longs 40 | */ 41 | DES_LONG deslong[2]; 42 | } ks[16]; 43 | } DES_key_schedule; 44 | 45 | # define DES_KEY_SZ (sizeof(DES_cblock)) 46 | # define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) 47 | 48 | # define DES_ENCRYPT 1 49 | # define DES_DECRYPT 0 50 | 51 | # define DES_CBC_MODE 0 52 | # define DES_PCBC_MODE 1 53 | 54 | # define DES_ecb2_encrypt(i,o,k1,k2,e) \ 55 | DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) 56 | 57 | # define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ 58 | DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) 59 | 60 | # define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ 61 | DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) 62 | 63 | # define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ 64 | DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) 65 | 66 | OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */ 67 | # define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) 68 | 69 | const char *DES_options(void); 70 | void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, 71 | DES_key_schedule *ks1, DES_key_schedule *ks2, 72 | DES_key_schedule *ks3, int enc); 73 | DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, 74 | long length, DES_key_schedule *schedule, 75 | const_DES_cblock *ivec); 76 | /* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ 77 | void DES_cbc_encrypt(const unsigned char *input, unsigned char *output, 78 | long length, DES_key_schedule *schedule, 79 | DES_cblock *ivec, int enc); 80 | void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, 81 | long length, DES_key_schedule *schedule, 82 | DES_cblock *ivec, int enc); 83 | void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, 84 | long length, DES_key_schedule *schedule, 85 | DES_cblock *ivec, const_DES_cblock *inw, 86 | const_DES_cblock *outw, int enc); 87 | void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, 88 | long length, DES_key_schedule *schedule, 89 | DES_cblock *ivec, int enc); 90 | void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, 91 | DES_key_schedule *ks, int enc); 92 | 93 | /* 94 | * This is the DES encryption function that gets called by just about every 95 | * other DES routine in the library. You should not use this function except 96 | * to implement 'modes' of DES. I say this because the functions that call 97 | * this routine do the conversion from 'char *' to long, and this needs to be 98 | * done to make sure 'non-aligned' memory access do not occur. The 99 | * characters are loaded 'little endian'. Data is a pointer to 2 unsigned 100 | * long's and ks is the DES_key_schedule to use. enc, is non zero specifies 101 | * encryption, zero if decryption. 102 | */ 103 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc); 104 | 105 | /* 106 | * This functions is the same as DES_encrypt1() except that the DES initial 107 | * permutation (IP) and final permutation (FP) have been left out. As for 108 | * DES_encrypt1(), you should not use this function. It is used by the 109 | * routines in the library that implement triple DES. IP() DES_encrypt2() 110 | * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1() 111 | * DES_encrypt1() DES_encrypt1() except faster :-). 112 | */ 113 | void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc); 114 | 115 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, 116 | DES_key_schedule *ks2, DES_key_schedule *ks3); 117 | void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, 118 | DES_key_schedule *ks2, DES_key_schedule *ks3); 119 | void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, 120 | long length, 121 | DES_key_schedule *ks1, DES_key_schedule *ks2, 122 | DES_key_schedule *ks3, DES_cblock *ivec, int enc); 123 | void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, 124 | long length, DES_key_schedule *ks1, 125 | DES_key_schedule *ks2, DES_key_schedule *ks3, 126 | DES_cblock *ivec, int *num, int enc); 127 | void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, 128 | int numbits, long length, DES_key_schedule *ks1, 129 | DES_key_schedule *ks2, DES_key_schedule *ks3, 130 | DES_cblock *ivec, int enc); 131 | void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, 132 | long length, DES_key_schedule *ks1, 133 | DES_key_schedule *ks2, DES_key_schedule *ks3, 134 | DES_cblock *ivec, int *num); 135 | char *DES_fcrypt(const char *buf, const char *salt, char *ret); 136 | char *DES_crypt(const char *buf, const char *salt); 137 | void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, 138 | long length, DES_key_schedule *schedule, 139 | DES_cblock *ivec); 140 | void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, 141 | long length, DES_key_schedule *schedule, 142 | DES_cblock *ivec, int enc); 143 | DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], 144 | long length, int out_count, DES_cblock *seed); 145 | int DES_random_key(DES_cblock *ret); 146 | void DES_set_odd_parity(DES_cblock *key); 147 | int DES_check_key_parity(const_DES_cblock *key); 148 | int DES_is_weak_key(const_DES_cblock *key); 149 | /* 150 | * DES_set_key (= set_key = DES_key_sched = key_sched) calls 151 | * DES_set_key_checked if global variable DES_check_key is set, 152 | * DES_set_key_unchecked otherwise. 153 | */ 154 | int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); 155 | int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); 156 | int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule); 157 | void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule); 158 | void DES_string_to_key(const char *str, DES_cblock *key); 159 | void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2); 160 | void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, 161 | long length, DES_key_schedule *schedule, 162 | DES_cblock *ivec, int *num, int enc); 163 | void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, 164 | long length, DES_key_schedule *schedule, 165 | DES_cblock *ivec, int *num); 166 | 167 | # define DES_fixup_key_parity DES_set_odd_parity 168 | 169 | # ifdef __cplusplus 170 | } 171 | # endif 172 | # endif 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/dtls1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_DTLS1_H 11 | # define HEADER_DTLS1_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define DTLS1_VERSION 0xFEFF 18 | # define DTLS1_2_VERSION 0xFEFD 19 | # define DTLS_MIN_VERSION DTLS1_VERSION 20 | # define DTLS_MAX_VERSION DTLS1_2_VERSION 21 | # define DTLS1_VERSION_MAJOR 0xFE 22 | 23 | # define DTLS1_BAD_VER 0x0100 24 | 25 | /* Special value for method supporting multiple versions */ 26 | # define DTLS_ANY_VERSION 0x1FFFF 27 | 28 | /* lengths of messages */ 29 | # define DTLS1_COOKIE_LENGTH 256 30 | 31 | # define DTLS1_RT_HEADER_LENGTH 13 32 | 33 | # define DTLS1_HM_HEADER_LENGTH 12 34 | 35 | # define DTLS1_HM_BAD_FRAGMENT -2 36 | # define DTLS1_HM_FRAGMENT_RETRY -3 37 | 38 | # define DTLS1_CCS_HEADER_LENGTH 1 39 | 40 | # ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 41 | # define DTLS1_AL_HEADER_LENGTH 7 42 | # else 43 | # define DTLS1_AL_HEADER_LENGTH 2 44 | # endif 45 | 46 | 47 | /* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ 48 | # define DTLS1_TMO_READ_COUNT 2 49 | # define DTLS1_TMO_WRITE_COUNT 2 50 | 51 | # define DTLS1_TMO_ALERT_COUNT 12 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/ebcdic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_EBCDIC_H 11 | # define HEADER_EBCDIC_H 12 | 13 | # include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Avoid name clashes with other applications */ 20 | # define os_toascii _openssl_os_toascii 21 | # define os_toebcdic _openssl_os_toebcdic 22 | # define ebcdic2ascii _openssl_ebcdic2ascii 23 | # define ascii2ebcdic _openssl_ascii2ebcdic 24 | 25 | extern const unsigned char os_toascii[256]; 26 | extern const unsigned char os_toebcdic[256]; 27 | void *ebcdic2ascii(void *dest, const void *srce, size_t count); 28 | void *ascii2ebcdic(void *dest, const void *srce, size_t count); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/ecdh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/ecdsa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/hmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_HMAC_H 11 | # define HEADER_HMAC_H 12 | 13 | # include 14 | 15 | # include 16 | 17 | # define HMAC_MAX_MD_CBLOCK 128/* largest known is SHA512 */ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | size_t HMAC_size(const HMAC_CTX *e); 24 | HMAC_CTX *HMAC_CTX_new(void); 25 | int HMAC_CTX_reset(HMAC_CTX *ctx); 26 | void HMAC_CTX_free(HMAC_CTX *ctx); 27 | 28 | DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 29 | const EVP_MD *md)) 30 | 31 | /*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 32 | const EVP_MD *md, ENGINE *impl); 33 | /*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, 34 | size_t len); 35 | /*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, 36 | unsigned int *len); 37 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 38 | const unsigned char *d, size_t n, unsigned char *md, 39 | unsigned int *md_len); 40 | __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); 41 | 42 | void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); 43 | const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/idea.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_IDEA_H 11 | # define HEADER_IDEA_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_IDEA 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | typedef unsigned int IDEA_INT; 21 | 22 | # define IDEA_ENCRYPT 1 23 | # define IDEA_DECRYPT 0 24 | 25 | # define IDEA_BLOCK 8 26 | # define IDEA_KEY_LENGTH 16 27 | 28 | typedef struct idea_key_st { 29 | IDEA_INT data[9][6]; 30 | } IDEA_KEY_SCHEDULE; 31 | 32 | const char *IDEA_options(void); 33 | void IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out, 34 | IDEA_KEY_SCHEDULE *ks); 35 | void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); 36 | void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); 37 | void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out, 38 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, 39 | int enc); 40 | void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, 41 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, 42 | int *num, int enc); 43 | void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out, 44 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, 45 | int *num); 46 | void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); 47 | 48 | # if OPENSSL_API_COMPAT < 0x10100000L 49 | # define idea_options IDEA_options 50 | # define idea_ecb_encrypt IDEA_ecb_encrypt 51 | # define idea_set_encrypt_key IDEA_set_encrypt_key 52 | # define idea_set_decrypt_key IDEA_set_decrypt_key 53 | # define idea_cbc_encrypt IDEA_cbc_encrypt 54 | # define idea_cfb64_encrypt IDEA_cfb64_encrypt 55 | # define idea_ofb64_encrypt IDEA_ofb64_encrypt 56 | # define idea_encrypt IDEA_encrypt 57 | # endif 58 | 59 | # ifdef __cplusplus 60 | } 61 | # endif 62 | # endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/kdf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_KDF_H 11 | # define HEADER_KDF_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL) 18 | # define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1) 19 | # define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2) 20 | # define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3) 21 | # define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4) 22 | # define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5) 23 | # define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6) 24 | 25 | # define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \ 26 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 27 | EVP_PKEY_CTRL_TLS_MD, 0, (void *)md) 28 | 29 | # define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \ 30 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 31 | EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)sec) 32 | 33 | # define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \ 34 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 35 | EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)seed) 36 | 37 | # define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \ 38 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 39 | EVP_PKEY_CTRL_HKDF_MD, 0, (void *)md) 40 | 41 | # define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \ 42 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 43 | EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)salt) 44 | 45 | # define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \ 46 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 47 | EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)key) 48 | 49 | # define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \ 50 | EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 51 | EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)info) 52 | 53 | /* BEGIN ERROR CODES */ 54 | /* 55 | * The following lines are auto generated by the script mkerr.pl. Any changes 56 | * made after this point may be overwritten when the script is next run. 57 | */ 58 | 59 | int ERR_load_KDF_strings(void); 60 | 61 | /* Error codes for the KDF functions. */ 62 | 63 | /* Function codes. */ 64 | # define KDF_F_PKEY_TLS1_PRF_CTRL_STR 100 65 | # define KDF_F_PKEY_TLS1_PRF_DERIVE 101 66 | 67 | /* Reason codes. */ 68 | # define KDF_R_INVALID_DIGEST 100 69 | # define KDF_R_MISSING_PARAMETER 101 70 | # define KDF_R_VALUE_MISSING 102 71 | 72 | # ifdef __cplusplus 73 | } 74 | # endif 75 | #endif 76 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/lhash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | /* 11 | * Header for dynamic hash table routines Author - Eric Young 12 | */ 13 | 14 | #ifndef HEADER_LHASH_H 15 | # define HEADER_LHASH_H 16 | 17 | # include 18 | # include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct lhash_node_st OPENSSL_LH_NODE; 25 | typedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *); 26 | typedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *); 27 | typedef void (*OPENSSL_LH_DOALL_FUNC) (void *); 28 | typedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *); 29 | typedef struct lhash_st OPENSSL_LHASH; 30 | 31 | /* 32 | * Macros for declaring and implementing type-safe wrappers for LHASH 33 | * callbacks. This way, callbacks can be provided to LHASH structures without 34 | * function pointer casting and the macro-defined callbacks provide 35 | * per-variable casting before deferring to the underlying type-specific 36 | * callbacks. NB: It is possible to place a "static" in front of both the 37 | * DECLARE and IMPLEMENT macros if the functions are strictly internal. 38 | */ 39 | 40 | /* First: "hash" functions */ 41 | # define DECLARE_LHASH_HASH_FN(name, o_type) \ 42 | unsigned long name##_LHASH_HASH(const void *); 43 | # define IMPLEMENT_LHASH_HASH_FN(name, o_type) \ 44 | unsigned long name##_LHASH_HASH(const void *arg) { \ 45 | const o_type *a = arg; \ 46 | return name##_hash(a); } 47 | # define LHASH_HASH_FN(name) name##_LHASH_HASH 48 | 49 | /* Second: "compare" functions */ 50 | # define DECLARE_LHASH_COMP_FN(name, o_type) \ 51 | int name##_LHASH_COMP(const void *, const void *); 52 | # define IMPLEMENT_LHASH_COMP_FN(name, o_type) \ 53 | int name##_LHASH_COMP(const void *arg1, const void *arg2) { \ 54 | const o_type *a = arg1; \ 55 | const o_type *b = arg2; \ 56 | return name##_cmp(a,b); } 57 | # define LHASH_COMP_FN(name) name##_LHASH_COMP 58 | 59 | /* Fourth: "doall_arg" functions */ 60 | # define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ 61 | void name##_LHASH_DOALL_ARG(void *, void *); 62 | # define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ 63 | void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ 64 | o_type *a = arg1; \ 65 | a_type *b = arg2; \ 66 | name##_doall_arg(a, b); } 67 | # define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG 68 | 69 | 70 | # define LH_LOAD_MULT 256 71 | 72 | int OPENSSL_LH_error(OPENSSL_LHASH *lh); 73 | OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c); 74 | void OPENSSL_LH_free(OPENSSL_LHASH *lh); 75 | void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data); 76 | void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data); 77 | void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data); 78 | void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func); 79 | void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg); 80 | unsigned long OPENSSL_LH_strhash(const char *c); 81 | unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh); 82 | unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh); 83 | void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load); 84 | 85 | # ifndef OPENSSL_NO_STDIO 86 | void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp); 87 | void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp); 88 | void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp); 89 | # endif 90 | void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out); 91 | void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out); 92 | void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); 93 | 94 | # if OPENSSL_API_COMPAT < 0x10100000L 95 | # define _LHASH OPENSSL_LHASH 96 | # define LHASH_NODE OPENSSL_LH_NODE 97 | # define lh_error OPENSSL_LH_error 98 | # define lh_new OPENSSL_lh_new 99 | # define lh_free OPENSSL_LH_free 100 | # define lh_insert OPENSSL_LH_insert 101 | # define lh_delete OPENSSL_LH_delete 102 | # define lh_retrieve OPENSSL_LH_retrieve 103 | # define lh_doall OPENSSL_LH_doall 104 | # define lh_doall_arg OPENSSL_LH_doall_arg 105 | # define lh_strhash OPENSSL_LH_strhash 106 | # define lh_num_items OPENSSL_LH_num_items 107 | # ifndef OPENSSL_NO_STDIO 108 | # define lh_stats OPENSSL_LH_stats 109 | # define lh_node_stats OPENSSL_LH_node_stats 110 | # define lh_node_usage_stats OPENSSL_LH_node_usage_stats 111 | # endif 112 | # define lh_stats_bio OPENSSL_LH_stats_bio 113 | # define lh_node_stats_bio OPENSSL_LH_node_stats_bio 114 | # define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio 115 | # endif 116 | 117 | /* Type checking... */ 118 | 119 | # define LHASH_OF(type) struct lhash_st_##type 120 | 121 | # define DEFINE_LHASH_OF(type) \ 122 | LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \ 123 | static ossl_inline LHASH_OF(type) * \ 124 | lh_##type##_new(unsigned long (*hfn)(const type *), \ 125 | int (*cfn)(const type *, const type *)) \ 126 | { \ 127 | return (LHASH_OF(type) *) \ 128 | OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \ 129 | } \ 130 | static ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \ 131 | { \ 132 | OPENSSL_LH_free((OPENSSL_LHASH *)lh); \ 133 | } \ 134 | static ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \ 135 | { \ 136 | return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \ 137 | } \ 138 | static ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \ 139 | { \ 140 | return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \ 141 | } \ 142 | static ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \ 143 | { \ 144 | return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \ 145 | } \ 146 | static ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \ 147 | { \ 148 | return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \ 149 | } \ 150 | static ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \ 151 | { \ 152 | return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \ 153 | } \ 154 | static ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ 155 | { \ 156 | OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ 157 | } \ 158 | static ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ 159 | { \ 160 | OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ 161 | } \ 162 | static ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ 163 | { \ 164 | OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ 165 | } \ 166 | static ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \ 167 | { \ 168 | return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \ 169 | } \ 170 | static ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \ 171 | { \ 172 | OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \ 173 | } \ 174 | static ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \ 175 | void (*doall)(type *)) \ 176 | { \ 177 | OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \ 178 | } \ 179 | LHASH_OF(type) 180 | 181 | #define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \ 182 | int_implement_lhash_doall(type, argtype, const type) 183 | 184 | #define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \ 185 | int_implement_lhash_doall(type, argtype, type) 186 | 187 | #define int_implement_lhash_doall(type, argtype, cbargtype) \ 188 | static ossl_inline void \ 189 | lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \ 190 | void (*fn)(cbargtype *, argtype *), \ 191 | argtype *arg) \ 192 | { \ 193 | OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \ 194 | } \ 195 | LHASH_OF(type) 196 | 197 | DEFINE_LHASH_OF(OPENSSL_STRING); 198 | # ifdef _MSC_VER 199 | /* 200 | * push and pop this warning: 201 | * warning C4090: 'function': different 'const' qualifiers 202 | */ 203 | # pragma warning (push) 204 | # pragma warning (disable: 4090) 205 | # endif 206 | 207 | DEFINE_LHASH_OF(OPENSSL_CSTRING); 208 | 209 | # ifdef _MSC_VER 210 | # pragma warning (pop) 211 | # endif 212 | 213 | #ifdef __cplusplus 214 | } 215 | #endif 216 | 217 | #endif 218 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/md2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MD2_H 11 | # define HEADER_MD2_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_MD2 16 | # include 17 | # ifdef __cplusplus 18 | extern "C" { 19 | # endif 20 | 21 | typedef unsigned char MD2_INT; 22 | 23 | # define MD2_DIGEST_LENGTH 16 24 | # define MD2_BLOCK 16 25 | 26 | typedef struct MD2state_st { 27 | unsigned int num; 28 | unsigned char data[MD2_BLOCK]; 29 | MD2_INT cksm[MD2_BLOCK]; 30 | MD2_INT state[MD2_BLOCK]; 31 | } MD2_CTX; 32 | 33 | const char *MD2_options(void); 34 | int MD2_Init(MD2_CTX *c); 35 | int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); 36 | int MD2_Final(unsigned char *md, MD2_CTX *c); 37 | unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md); 38 | 39 | # ifdef __cplusplus 40 | } 41 | # endif 42 | # endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/md4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MD4_H 11 | # define HEADER_MD4_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_MD4 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | /*- 23 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | * ! MD4_LONG has to be at least 32 bits wide. ! 25 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 26 | */ 27 | # define MD4_LONG unsigned int 28 | 29 | # define MD4_CBLOCK 64 30 | # define MD4_LBLOCK (MD4_CBLOCK/4) 31 | # define MD4_DIGEST_LENGTH 16 32 | 33 | typedef struct MD4state_st { 34 | MD4_LONG A, B, C, D; 35 | MD4_LONG Nl, Nh; 36 | MD4_LONG data[MD4_LBLOCK]; 37 | unsigned int num; 38 | } MD4_CTX; 39 | 40 | int MD4_Init(MD4_CTX *c); 41 | int MD4_Update(MD4_CTX *c, const void *data, size_t len); 42 | int MD4_Final(unsigned char *md, MD4_CTX *c); 43 | unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); 44 | void MD4_Transform(MD4_CTX *c, const unsigned char *b); 45 | 46 | # ifdef __cplusplus 47 | } 48 | # endif 49 | # endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MD5_H 11 | # define HEADER_MD5_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_MD5 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | /* 23 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | * ! MD5_LONG has to be at least 32 bits wide. ! 25 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 26 | */ 27 | # define MD5_LONG unsigned int 28 | 29 | # define MD5_CBLOCK 64 30 | # define MD5_LBLOCK (MD5_CBLOCK/4) 31 | # define MD5_DIGEST_LENGTH 16 32 | 33 | typedef struct MD5state_st { 34 | MD5_LONG A, B, C, D; 35 | MD5_LONG Nl, Nh; 36 | MD5_LONG data[MD5_LBLOCK]; 37 | unsigned int num; 38 | } MD5_CTX; 39 | 40 | int MD5_Init(MD5_CTX *c); 41 | int MD5_Update(MD5_CTX *c, const void *data, size_t len); 42 | int MD5_Final(unsigned char *md, MD5_CTX *c); 43 | unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); 44 | void MD5_Transform(MD5_CTX *c, const unsigned char *b); 45 | # ifdef __cplusplus 46 | } 47 | # endif 48 | # endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/mdc2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_MDC2_H 11 | # define HEADER_MDC2_H 12 | 13 | # include 14 | 15 | #ifndef OPENSSL_NO_MDC2 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | # define MDC2_BLOCK 8 23 | # define MDC2_DIGEST_LENGTH 16 24 | 25 | typedef struct mdc2_ctx_st { 26 | unsigned int num; 27 | unsigned char data[MDC2_BLOCK]; 28 | DES_cblock h, hh; 29 | int pad_type; /* either 1 or 2, default 1 */ 30 | } MDC2_CTX; 31 | 32 | int MDC2_Init(MDC2_CTX *c); 33 | int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); 34 | int MDC2_Final(unsigned char *md, MDC2_CTX *c); 35 | unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); 36 | 37 | # ifdef __cplusplus 38 | } 39 | # endif 40 | # endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/opensslconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WARNING: do not edit! 3 | * Generated by Makefile from include/openssl/opensslconf.h.in 4 | * 5 | * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. 6 | * 7 | * Licensed under the OpenSSL license (the "License"). You may not use 8 | * this file except in compliance with the License. You can obtain a copy 9 | * in the file LICENSE in the source distribution or at 10 | * https://www.openssl.org/source/license.html 11 | */ 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #ifdef OPENSSL_ALGORITHM_DEFINES 18 | # error OPENSSL_ALGORITHM_DEFINES no longer supported 19 | #endif 20 | 21 | /* 22 | * OpenSSL was configured with the following options: 23 | */ 24 | 25 | #ifndef OPENSSL_NO_COMP 26 | # define OPENSSL_NO_COMP 27 | #endif 28 | #ifndef OPENSSL_NO_MD2 29 | # define OPENSSL_NO_MD2 30 | #endif 31 | #ifndef OPENSSL_NO_RC5 32 | # define OPENSSL_NO_RC5 33 | #endif 34 | #ifndef OPENSSL_THREADS 35 | # define OPENSSL_THREADS 36 | #endif 37 | #ifndef OPENSSL_NO_ASAN 38 | # define OPENSSL_NO_ASAN 39 | #endif 40 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG 41 | # define OPENSSL_NO_CRYPTO_MDEBUG 42 | #endif 43 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE 44 | # define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE 45 | #endif 46 | #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 47 | # define OPENSSL_NO_EC_NISTP_64_GCC_128 48 | #endif 49 | #ifndef OPENSSL_NO_FUZZ_AFL 50 | # define OPENSSL_NO_FUZZ_AFL 51 | #endif 52 | #ifndef OPENSSL_NO_FUZZ_LIBFUZZER 53 | # define OPENSSL_NO_FUZZ_LIBFUZZER 54 | #endif 55 | #ifndef OPENSSL_NO_HEARTBEATS 56 | # define OPENSSL_NO_HEARTBEATS 57 | #endif 58 | #ifndef OPENSSL_NO_HW 59 | # define OPENSSL_NO_HW 60 | #endif 61 | #ifndef OPENSSL_NO_MSAN 62 | # define OPENSSL_NO_MSAN 63 | #endif 64 | #ifndef OPENSSL_NO_SCTP 65 | # define OPENSSL_NO_SCTP 66 | #endif 67 | #ifndef OPENSSL_NO_SSL_TRACE 68 | # define OPENSSL_NO_SSL_TRACE 69 | #endif 70 | #ifndef OPENSSL_NO_SSL3 71 | # define OPENSSL_NO_SSL3 72 | #endif 73 | #ifndef OPENSSL_NO_SSL3_METHOD 74 | # define OPENSSL_NO_SSL3_METHOD 75 | #endif 76 | #ifndef OPENSSL_NO_UBSAN 77 | # define OPENSSL_NO_UBSAN 78 | #endif 79 | #ifndef OPENSSL_NO_UNIT_TEST 80 | # define OPENSSL_NO_UNIT_TEST 81 | #endif 82 | #ifndef OPENSSL_NO_WEAK_SSL_CIPHERS 83 | # define OPENSSL_NO_WEAK_SSL_CIPHERS 84 | #endif 85 | #ifndef OPENSSL_NO_AFALGENG 86 | # define OPENSSL_NO_AFALGENG 87 | #endif 88 | 89 | 90 | /* 91 | * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers 92 | * don't like that. This will hopefully silence them. 93 | */ 94 | #define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy; 95 | 96 | /* 97 | * Applications should use -DOPENSSL_API_COMPAT= to suppress the 98 | * declarations of functions deprecated in or before . Otherwise, they 99 | * still won't see them if the library has been built to disable deprecated 100 | * functions. 101 | */ 102 | #if defined(OPENSSL_NO_DEPRECATED) 103 | # define DECLARE_DEPRECATED(f) 104 | #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) 105 | # define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated)); 106 | #else 107 | # define DECLARE_DEPRECATED(f) f; 108 | #endif 109 | 110 | #ifndef OPENSSL_FILE 111 | # ifdef OPENSSL_NO_FILENAMES 112 | # define OPENSSL_FILE "" 113 | # define OPENSSL_LINE 0 114 | # else 115 | # define OPENSSL_FILE __FILE__ 116 | # define OPENSSL_LINE __LINE__ 117 | # endif 118 | #endif 119 | 120 | #ifndef OPENSSL_MIN_API 121 | # define OPENSSL_MIN_API 0 122 | #endif 123 | 124 | #if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API 125 | # undef OPENSSL_API_COMPAT 126 | # define OPENSSL_API_COMPAT OPENSSL_MIN_API 127 | #endif 128 | 129 | #if OPENSSL_API_COMPAT < 0x10100000L 130 | # define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f) 131 | #else 132 | # define DEPRECATEDIN_1_1_0(f) 133 | #endif 134 | 135 | #if OPENSSL_API_COMPAT < 0x10000000L 136 | # define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f) 137 | #else 138 | # define DEPRECATEDIN_1_0_0(f) 139 | #endif 140 | 141 | #if OPENSSL_API_COMPAT < 0x00908000L 142 | # define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f) 143 | #else 144 | # define DEPRECATEDIN_0_9_8(f) 145 | #endif 146 | 147 | #define OPENSSL_CPUID_OBJ 148 | 149 | /* Generate 80386 code? */ 150 | #undef I386_ONLY 151 | 152 | #undef OPENSSL_UNISTD 153 | #define OPENSSL_UNISTD 154 | 155 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION 156 | 157 | /* 158 | * The following are cipher-specific, but are part of the public API. 159 | */ 160 | #if !defined(OPENSSL_SYS_UEFI) 161 | # define BN_LLONG 162 | /* Only one for the following should be defined */ 163 | # undef SIXTY_FOUR_BIT_LONG 164 | # undef SIXTY_FOUR_BIT 165 | # define THIRTY_TWO_BIT 166 | #endif 167 | 168 | #define RC4_INT unsigned char 169 | 170 | #ifdef __cplusplus 171 | } 172 | #endif 173 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/opensslv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_OPENSSLV_H 11 | # define HEADER_OPENSSLV_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /*- 18 | * Numeric release version identifier: 19 | * MNNFFPPS: major minor fix patch status 20 | * The status nibble has one of the values 0 for development, 1 to e for betas 21 | * 1 to 14, and f for release. The patch level is exactly that. 22 | * For example: 23 | * 0.9.3-dev 0x00903000 24 | * 0.9.3-beta1 0x00903001 25 | * 0.9.3-beta2-dev 0x00903002 26 | * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) 27 | * 0.9.3 0x0090300f 28 | * 0.9.3a 0x0090301f 29 | * 0.9.4 0x0090400f 30 | * 1.2.3z 0x102031af 31 | * 32 | * For continuity reasons (because 0.9.5 is already out, and is coded 33 | * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level 34 | * part is slightly different, by setting the highest bit. This means 35 | * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start 36 | * with 0x0090600S... 37 | * 38 | * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) 39 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 40 | * major minor fix final patch/beta) 41 | */ 42 | # define OPENSSL_VERSION_NUMBER 0x1010006fL 43 | # ifdef OPENSSL_FIPS 44 | # define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0f-fips 25 May 2017" 45 | # else 46 | # define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0f 25 May 2017" 47 | # endif 48 | 49 | /*- 50 | * The macros below are to be used for shared library (.so, .dll, ...) 51 | * versioning. That kind of versioning works a bit differently between 52 | * operating systems. The most usual scheme is to set a major and a minor 53 | * number, and have the runtime loader check that the major number is equal 54 | * to what it was at application link time, while the minor number has to 55 | * be greater or equal to what it was at application link time. With this 56 | * scheme, the version number is usually part of the file name, like this: 57 | * 58 | * libcrypto.so.0.9 59 | * 60 | * Some unixen also make a softlink with the major version number only: 61 | * 62 | * libcrypto.so.0 63 | * 64 | * On Tru64 and IRIX 6.x it works a little bit differently. There, the 65 | * shared library version is stored in the file, and is actually a series 66 | * of versions, separated by colons. The rightmost version present in the 67 | * library when linking an application is stored in the application to be 68 | * matched at run time. When the application is run, a check is done to 69 | * see if the library version stored in the application matches any of the 70 | * versions in the version string of the library itself. 71 | * This version string can be constructed in any way, depending on what 72 | * kind of matching is desired. However, to implement the same scheme as 73 | * the one used in the other unixen, all compatible versions, from lowest 74 | * to highest, should be part of the string. Consecutive builds would 75 | * give the following versions strings: 76 | * 77 | * 3.0 78 | * 3.0:3.1 79 | * 3.0:3.1:3.2 80 | * 4.0 81 | * 4.0:4.1 82 | * 83 | * Notice how version 4 is completely incompatible with version, and 84 | * therefore give the breach you can see. 85 | * 86 | * There may be other schemes as well that I haven't yet discovered. 87 | * 88 | * So, here's the way it works here: first of all, the library version 89 | * number doesn't need at all to match the overall OpenSSL version. 90 | * However, it's nice and more understandable if it actually does. 91 | * The current library version is stored in the macro SHLIB_VERSION_NUMBER, 92 | * which is just a piece of text in the format "M.m.e" (Major, minor, edit). 93 | * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, 94 | * we need to keep a history of version numbers, which is done in the 95 | * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and 96 | * should only keep the versions that are binary compatible with the current. 97 | */ 98 | # define SHLIB_VERSION_HISTORY "" 99 | # define SHLIB_VERSION_NUMBER "1.1" 100 | 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | #endif /* HEADER_OPENSSLV_H */ 106 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/ossl_typ.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_OPENSSL_TYPES_H 11 | # define HEADER_OPENSSL_TYPES_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | # include 20 | 21 | # ifdef NO_ASN1_TYPEDEFS 22 | # define ASN1_INTEGER ASN1_STRING 23 | # define ASN1_ENUMERATED ASN1_STRING 24 | # define ASN1_BIT_STRING ASN1_STRING 25 | # define ASN1_OCTET_STRING ASN1_STRING 26 | # define ASN1_PRINTABLESTRING ASN1_STRING 27 | # define ASN1_T61STRING ASN1_STRING 28 | # define ASN1_IA5STRING ASN1_STRING 29 | # define ASN1_UTCTIME ASN1_STRING 30 | # define ASN1_GENERALIZEDTIME ASN1_STRING 31 | # define ASN1_TIME ASN1_STRING 32 | # define ASN1_GENERALSTRING ASN1_STRING 33 | # define ASN1_UNIVERSALSTRING ASN1_STRING 34 | # define ASN1_BMPSTRING ASN1_STRING 35 | # define ASN1_VISIBLESTRING ASN1_STRING 36 | # define ASN1_UTF8STRING ASN1_STRING 37 | # define ASN1_BOOLEAN int 38 | # define ASN1_NULL int 39 | # else 40 | typedef struct asn1_string_st ASN1_INTEGER; 41 | typedef struct asn1_string_st ASN1_ENUMERATED; 42 | typedef struct asn1_string_st ASN1_BIT_STRING; 43 | typedef struct asn1_string_st ASN1_OCTET_STRING; 44 | typedef struct asn1_string_st ASN1_PRINTABLESTRING; 45 | typedef struct asn1_string_st ASN1_T61STRING; 46 | typedef struct asn1_string_st ASN1_IA5STRING; 47 | typedef struct asn1_string_st ASN1_GENERALSTRING; 48 | typedef struct asn1_string_st ASN1_UNIVERSALSTRING; 49 | typedef struct asn1_string_st ASN1_BMPSTRING; 50 | typedef struct asn1_string_st ASN1_UTCTIME; 51 | typedef struct asn1_string_st ASN1_TIME; 52 | typedef struct asn1_string_st ASN1_GENERALIZEDTIME; 53 | typedef struct asn1_string_st ASN1_VISIBLESTRING; 54 | typedef struct asn1_string_st ASN1_UTF8STRING; 55 | typedef struct asn1_string_st ASN1_STRING; 56 | typedef int ASN1_BOOLEAN; 57 | typedef int ASN1_NULL; 58 | # endif 59 | 60 | typedef struct asn1_object_st ASN1_OBJECT; 61 | 62 | typedef struct ASN1_ITEM_st ASN1_ITEM; 63 | typedef struct asn1_pctx_st ASN1_PCTX; 64 | typedef struct asn1_sctx_st ASN1_SCTX; 65 | 66 | # ifdef _WIN32 67 | # undef X509_NAME 68 | # undef X509_EXTENSIONS 69 | # undef PKCS7_ISSUER_AND_SERIAL 70 | # undef PKCS7_SIGNER_INFO 71 | # undef OCSP_REQUEST 72 | # undef OCSP_RESPONSE 73 | # endif 74 | 75 | # ifdef BIGNUM 76 | # undef BIGNUM 77 | # endif 78 | struct dane_st; 79 | typedef struct bio_st BIO; 80 | typedef struct bignum_st BIGNUM; 81 | typedef struct bignum_ctx BN_CTX; 82 | typedef struct bn_blinding_st BN_BLINDING; 83 | typedef struct bn_mont_ctx_st BN_MONT_CTX; 84 | typedef struct bn_recp_ctx_st BN_RECP_CTX; 85 | typedef struct bn_gencb_st BN_GENCB; 86 | 87 | typedef struct buf_mem_st BUF_MEM; 88 | 89 | typedef struct evp_cipher_st EVP_CIPHER; 90 | typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; 91 | typedef struct evp_md_st EVP_MD; 92 | typedef struct evp_md_ctx_st EVP_MD_CTX; 93 | typedef struct evp_pkey_st EVP_PKEY; 94 | 95 | typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD; 96 | 97 | typedef struct evp_pkey_method_st EVP_PKEY_METHOD; 98 | typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; 99 | 100 | typedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX; 101 | 102 | typedef struct hmac_ctx_st HMAC_CTX; 103 | 104 | typedef struct dh_st DH; 105 | typedef struct dh_method DH_METHOD; 106 | 107 | typedef struct dsa_st DSA; 108 | typedef struct dsa_method DSA_METHOD; 109 | 110 | typedef struct rsa_st RSA; 111 | typedef struct rsa_meth_st RSA_METHOD; 112 | 113 | typedef struct ec_key_st EC_KEY; 114 | typedef struct ec_key_method_st EC_KEY_METHOD; 115 | 116 | typedef struct rand_meth_st RAND_METHOD; 117 | 118 | typedef struct ssl_dane_st SSL_DANE; 119 | typedef struct x509_st X509; 120 | typedef struct X509_algor_st X509_ALGOR; 121 | typedef struct X509_crl_st X509_CRL; 122 | typedef struct x509_crl_method_st X509_CRL_METHOD; 123 | typedef struct x509_revoked_st X509_REVOKED; 124 | typedef struct X509_name_st X509_NAME; 125 | typedef struct X509_pubkey_st X509_PUBKEY; 126 | typedef struct x509_store_st X509_STORE; 127 | typedef struct x509_store_ctx_st X509_STORE_CTX; 128 | 129 | typedef struct x509_object_st X509_OBJECT; 130 | typedef struct x509_lookup_st X509_LOOKUP; 131 | typedef struct x509_lookup_method_st X509_LOOKUP_METHOD; 132 | typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM; 133 | 134 | typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; 135 | 136 | typedef struct v3_ext_ctx X509V3_CTX; 137 | typedef struct conf_st CONF; 138 | typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS; 139 | 140 | typedef struct ui_st UI; 141 | typedef struct ui_method_st UI_METHOD; 142 | 143 | typedef struct engine_st ENGINE; 144 | typedef struct ssl_st SSL; 145 | typedef struct ssl_ctx_st SSL_CTX; 146 | 147 | typedef struct comp_ctx_st COMP_CTX; 148 | typedef struct comp_method_st COMP_METHOD; 149 | 150 | typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; 151 | typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; 152 | typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; 153 | typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; 154 | 155 | typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID; 156 | typedef struct DIST_POINT_st DIST_POINT; 157 | typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; 158 | typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; 159 | 160 | typedef struct crypto_ex_data_st CRYPTO_EX_DATA; 161 | 162 | typedef struct ocsp_req_ctx_st OCSP_REQ_CTX; 163 | typedef struct ocsp_response_st OCSP_RESPONSE; 164 | typedef struct ocsp_responder_id_st OCSP_RESPID; 165 | 166 | typedef struct sct_st SCT; 167 | typedef struct sct_ctx_st SCT_CTX; 168 | typedef struct ctlog_st CTLOG; 169 | typedef struct ctlog_store_st CTLOG_STORE; 170 | typedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX; 171 | 172 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ 173 | defined(INTMAX_MAX) && defined(UINTMAX_MAX) 174 | typedef intmax_t ossl_intmax_t; 175 | typedef uintmax_t ossl_uintmax_t; 176 | #else 177 | /* 178 | * Not long long, because the C-library can only be expected to provide 179 | * strtoll(), strtoull() at the same time as intmax_t and strtoimax(), 180 | * strtoumax(). Since we use these for parsing arguments, we need the 181 | * conversion functions, not just the sizes. 182 | */ 183 | typedef long ossl_intmax_t; 184 | typedef unsigned long ossl_uintmax_t; 185 | #endif 186 | 187 | #ifdef __cplusplus 188 | } 189 | #endif 190 | #endif /* def HEADER_OPENSSL_TYPES_H */ 191 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/pem2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef HEADER_PEM_H 15 | int ERR_load_PEM_strings(void); 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/rand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RAND_H 11 | # define HEADER_RAND_H 12 | 13 | # include 14 | # include 15 | # include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /* Already defined in ossl_typ.h */ 22 | /* typedef struct rand_meth_st RAND_METHOD; */ 23 | 24 | struct rand_meth_st { 25 | int (*seed) (const void *buf, int num); 26 | int (*bytes) (unsigned char *buf, int num); 27 | void (*cleanup) (void); 28 | int (*add) (const void *buf, int num, double entropy); 29 | int (*pseudorand) (unsigned char *buf, int num); 30 | int (*status) (void); 31 | }; 32 | 33 | # ifdef BN_DEBUG 34 | extern int rand_predictable; 35 | # endif 36 | 37 | int RAND_set_rand_method(const RAND_METHOD *meth); 38 | const RAND_METHOD *RAND_get_rand_method(void); 39 | # ifndef OPENSSL_NO_ENGINE 40 | int RAND_set_rand_engine(ENGINE *engine); 41 | # endif 42 | RAND_METHOD *RAND_OpenSSL(void); 43 | #if OPENSSL_API_COMPAT < 0x10100000L 44 | # define RAND_cleanup() while(0) continue 45 | #endif 46 | int RAND_bytes(unsigned char *buf, int num); 47 | DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num)) 48 | void RAND_seed(const void *buf, int num); 49 | #if defined(__ANDROID__) && defined(__NDK_FPABI__) 50 | __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */ 51 | #endif 52 | void RAND_add(const void *buf, int num, double entropy); 53 | int RAND_load_file(const char *file, long max_bytes); 54 | int RAND_write_file(const char *file); 55 | const char *RAND_file_name(char *file, size_t num); 56 | int RAND_status(void); 57 | # ifndef OPENSSL_NO_EGD 58 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); 59 | int RAND_egd(const char *path); 60 | int RAND_egd_bytes(const char *path, int bytes); 61 | # endif 62 | int RAND_poll(void); 63 | 64 | #if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) 65 | /* application has to include in order to use these */ 66 | DEPRECATEDIN_1_1_0(void RAND_screen(void)) 67 | DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM)) 68 | #endif 69 | 70 | /* BEGIN ERROR CODES */ 71 | /* 72 | * The following lines are auto generated by the script mkerr.pl. Any changes 73 | * made after this point may be overwritten when the script is next run. 74 | */ 75 | 76 | int ERR_load_RAND_strings(void); 77 | 78 | /* Error codes for the RAND functions. */ 79 | 80 | /* Function codes. */ 81 | # define RAND_F_RAND_BYTES 100 82 | 83 | /* Reason codes. */ 84 | # define RAND_R_PRNG_NOT_SEEDED 100 85 | 86 | # ifdef __cplusplus 87 | } 88 | # endif 89 | #endif 90 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/rc2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RC2_H 11 | # define HEADER_RC2_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_RC2 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | typedef unsigned int RC2_INT; 21 | 22 | # define RC2_ENCRYPT 1 23 | # define RC2_DECRYPT 0 24 | 25 | # define RC2_BLOCK 8 26 | # define RC2_KEY_LENGTH 16 27 | 28 | typedef struct rc2_key_st { 29 | RC2_INT data[64]; 30 | } RC2_KEY; 31 | 32 | void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits); 33 | void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, 34 | RC2_KEY *key, int enc); 35 | void RC2_encrypt(unsigned long *data, RC2_KEY *key); 36 | void RC2_decrypt(unsigned long *data, RC2_KEY *key); 37 | void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 38 | RC2_KEY *ks, unsigned char *iv, int enc); 39 | void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, 40 | long length, RC2_KEY *schedule, unsigned char *ivec, 41 | int *num, int enc); 42 | void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, 43 | long length, RC2_KEY *schedule, unsigned char *ivec, 44 | int *num); 45 | 46 | # ifdef __cplusplus 47 | } 48 | # endif 49 | # endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/rc4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RC4_H 11 | # define HEADER_RC4_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_RC4 16 | # include 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | typedef struct rc4_key_st { 22 | RC4_INT x, y; 23 | RC4_INT data[256]; 24 | } RC4_KEY; 25 | 26 | const char *RC4_options(void); 27 | void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 28 | void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, 29 | unsigned char *outdata); 30 | 31 | # ifdef __cplusplus 32 | } 33 | # endif 34 | # endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/rc5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RC5_H 11 | # define HEADER_RC5_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_RC5 16 | # ifdef __cplusplus 17 | extern "C" { 18 | # endif 19 | 20 | # define RC5_ENCRYPT 1 21 | # define RC5_DECRYPT 0 22 | 23 | # define RC5_32_INT unsigned int 24 | 25 | # define RC5_32_BLOCK 8 26 | # define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */ 27 | 28 | /* 29 | * This are the only values supported. Tweak the code if you want more The 30 | * most supported modes will be RC5-32/12/16 RC5-32/16/8 31 | */ 32 | # define RC5_8_ROUNDS 8 33 | # define RC5_12_ROUNDS 12 34 | # define RC5_16_ROUNDS 16 35 | 36 | typedef struct rc5_key_st { 37 | /* Number of rounds */ 38 | int rounds; 39 | RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; 40 | } RC5_32_KEY; 41 | 42 | void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, 43 | int rounds); 44 | void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, 45 | RC5_32_KEY *key, int enc); 46 | void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); 47 | void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); 48 | void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, 49 | long length, RC5_32_KEY *ks, unsigned char *iv, 50 | int enc); 51 | void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, 52 | long length, RC5_32_KEY *schedule, 53 | unsigned char *ivec, int *num, int enc); 54 | void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, 55 | long length, RC5_32_KEY *schedule, 56 | unsigned char *ivec, int *num); 57 | 58 | # ifdef __cplusplus 59 | } 60 | # endif 61 | # endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/ripemd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RIPEMD_H 11 | # define HEADER_RIPEMD_H 12 | 13 | # include 14 | 15 | #ifndef OPENSSL_NO_RMD160 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | # define RIPEMD160_LONG unsigned int 23 | 24 | # define RIPEMD160_CBLOCK 64 25 | # define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) 26 | # define RIPEMD160_DIGEST_LENGTH 20 27 | 28 | typedef struct RIPEMD160state_st { 29 | RIPEMD160_LONG A, B, C, D, E; 30 | RIPEMD160_LONG Nl, Nh; 31 | RIPEMD160_LONG data[RIPEMD160_LBLOCK]; 32 | unsigned int num; 33 | } RIPEMD160_CTX; 34 | 35 | int RIPEMD160_Init(RIPEMD160_CTX *c); 36 | int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); 37 | int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 38 | unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md); 39 | void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); 40 | 41 | # ifdef __cplusplus 42 | } 43 | # endif 44 | # endif 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/safestack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SAFESTACK_H 11 | # define HEADER_SAFESTACK_H 12 | 13 | # include 14 | # include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | # define STACK_OF(type) struct stack_st_##type 21 | 22 | # define SKM_DEFINE_STACK_OF(t1, t2, t3) \ 23 | STACK_OF(t1); \ 24 | typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \ 25 | typedef void (*sk_##t1##_freefunc)(t3 *a); \ 26 | typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \ 27 | static ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \ 28 | { \ 29 | return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ 30 | } \ 31 | static ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \ 32 | { \ 33 | return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \ 34 | } \ 35 | static ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \ 36 | { \ 37 | return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \ 38 | } \ 39 | static ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \ 40 | { \ 41 | return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \ 42 | } \ 43 | static ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \ 44 | { \ 45 | OPENSSL_sk_free((OPENSSL_STACK *)sk); \ 46 | } \ 47 | static ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \ 48 | { \ 49 | OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ 50 | } \ 51 | static ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \ 52 | { \ 53 | return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \ 54 | } \ 55 | static ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \ 56 | { \ 57 | return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ 58 | (const void *)ptr); \ 59 | } \ 60 | static ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \ 61 | { \ 62 | return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \ 63 | } \ 64 | static ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \ 65 | { \ 66 | return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \ 67 | } \ 68 | static ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \ 69 | { \ 70 | return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ 71 | } \ 72 | static ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \ 73 | { \ 74 | return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ 75 | } \ 76 | static ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \ 77 | { \ 78 | OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \ 79 | } \ 80 | static ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \ 81 | { \ 82 | return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \ 83 | } \ 84 | static ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \ 85 | { \ 86 | return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \ 87 | } \ 88 | static ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \ 89 | { \ 90 | return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ 91 | } \ 92 | static ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \ 93 | { \ 94 | return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ 95 | } \ 96 | static ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \ 97 | { \ 98 | OPENSSL_sk_sort((OPENSSL_STACK *)sk); \ 99 | } \ 100 | static ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \ 101 | { \ 102 | return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ 103 | } \ 104 | static ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \ 105 | { \ 106 | return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ 107 | } \ 108 | static ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \ 109 | sk_##t1##_copyfunc copyfunc, \ 110 | sk_##t1##_freefunc freefunc) \ 111 | { \ 112 | return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \ 113 | (OPENSSL_sk_copyfunc)copyfunc, \ 114 | (OPENSSL_sk_freefunc)freefunc); \ 115 | } \ 116 | static ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \ 117 | { \ 118 | return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \ 119 | } 120 | 121 | # define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2) 122 | # define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t) 123 | # define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \ 124 | SKM_DEFINE_STACK_OF(t1, const t2, t2) 125 | # define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t) 126 | 127 | /*- 128 | * Strings are special: normally an lhash entry will point to a single 129 | * (somewhat) mutable object. In the case of strings: 130 | * 131 | * a) Instead of a single char, there is an array of chars, NUL-terminated. 132 | * b) The string may have be immutable. 133 | * 134 | * So, they need their own declarations. Especially important for 135 | * type-checking tools, such as Deputy. 136 | * 137 | * In practice, however, it appears to be hard to have a const 138 | * string. For now, I'm settling for dealing with the fact it is a 139 | * string at all. 140 | */ 141 | typedef char *OPENSSL_STRING; 142 | typedef const char *OPENSSL_CSTRING; 143 | 144 | /*- 145 | * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but 146 | * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned 147 | * above, instead of a single char each entry is a NUL-terminated array of 148 | * chars. So, we have to implement STRING specially for STACK_OF. This is 149 | * dealt with in the autogenerated macros below. 150 | */ 151 | DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char) 152 | DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char) 153 | 154 | /* 155 | * Similarly, we sometimes use a block of characters, NOT nul-terminated. 156 | * These should also be distinguished from "normal" stacks. 157 | */ 158 | typedef void *OPENSSL_BLOCK; 159 | DEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void) 160 | 161 | # ifdef __cplusplus 162 | } 163 | # endif 164 | #endif 165 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/seed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | /* 11 | * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Neither the name of author nor the names of its contributors may 19 | * be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef HEADER_SEED_H 36 | # define HEADER_SEED_H 37 | 38 | # include 39 | 40 | # ifndef OPENSSL_NO_SEED 41 | # include 42 | # include 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* look whether we need 'long' to get 32 bits */ 49 | # ifdef AES_LONG 50 | # ifndef SEED_LONG 51 | # define SEED_LONG 1 52 | # endif 53 | # endif 54 | 55 | # if !defined(NO_SYS_TYPES_H) 56 | # include 57 | # endif 58 | 59 | # define SEED_BLOCK_SIZE 16 60 | # define SEED_KEY_LENGTH 16 61 | 62 | typedef struct seed_key_st { 63 | # ifdef SEED_LONG 64 | unsigned long data[32]; 65 | # else 66 | unsigned int data[32]; 67 | # endif 68 | } SEED_KEY_SCHEDULE; 69 | 70 | void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], 71 | SEED_KEY_SCHEDULE *ks); 72 | 73 | void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], 74 | unsigned char d[SEED_BLOCK_SIZE], 75 | const SEED_KEY_SCHEDULE *ks); 76 | void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], 77 | unsigned char d[SEED_BLOCK_SIZE], 78 | const SEED_KEY_SCHEDULE *ks); 79 | 80 | void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, 81 | const SEED_KEY_SCHEDULE *ks, int enc); 82 | void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, 83 | const SEED_KEY_SCHEDULE *ks, 84 | unsigned char ivec[SEED_BLOCK_SIZE], int enc); 85 | void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, 86 | size_t len, const SEED_KEY_SCHEDULE *ks, 87 | unsigned char ivec[SEED_BLOCK_SIZE], int *num, 88 | int enc); 89 | void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, 90 | size_t len, const SEED_KEY_SCHEDULE *ks, 91 | unsigned char ivec[SEED_BLOCK_SIZE], int *num); 92 | 93 | # ifdef __cplusplus 94 | } 95 | # endif 96 | # endif 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/sha.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SHA_H 11 | # define HEADER_SHA_H 12 | 13 | # include 14 | # include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /*- 21 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 22 | * ! SHA_LONG has to be at least 32 bits wide. ! 23 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | */ 25 | # define SHA_LONG unsigned int 26 | 27 | # define SHA_LBLOCK 16 28 | # define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a 29 | * contiguous array of 32 bit wide 30 | * big-endian values. */ 31 | # define SHA_LAST_BLOCK (SHA_CBLOCK-8) 32 | # define SHA_DIGEST_LENGTH 20 33 | 34 | typedef struct SHAstate_st { 35 | SHA_LONG h0, h1, h2, h3, h4; 36 | SHA_LONG Nl, Nh; 37 | SHA_LONG data[SHA_LBLOCK]; 38 | unsigned int num; 39 | } SHA_CTX; 40 | 41 | int SHA1_Init(SHA_CTX *c); 42 | int SHA1_Update(SHA_CTX *c, const void *data, size_t len); 43 | int SHA1_Final(unsigned char *md, SHA_CTX *c); 44 | unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); 45 | void SHA1_Transform(SHA_CTX *c, const unsigned char *data); 46 | 47 | # define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a 48 | * contiguous array of 32 bit wide 49 | * big-endian values. */ 50 | 51 | typedef struct SHA256state_st { 52 | SHA_LONG h[8]; 53 | SHA_LONG Nl, Nh; 54 | SHA_LONG data[SHA_LBLOCK]; 55 | unsigned int num, md_len; 56 | } SHA256_CTX; 57 | 58 | int SHA224_Init(SHA256_CTX *c); 59 | int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); 60 | int SHA224_Final(unsigned char *md, SHA256_CTX *c); 61 | unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md); 62 | int SHA256_Init(SHA256_CTX *c); 63 | int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); 64 | int SHA256_Final(unsigned char *md, SHA256_CTX *c); 65 | unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md); 66 | void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); 67 | 68 | # define SHA224_DIGEST_LENGTH 28 69 | # define SHA256_DIGEST_LENGTH 32 70 | # define SHA384_DIGEST_LENGTH 48 71 | # define SHA512_DIGEST_LENGTH 64 72 | 73 | /* 74 | * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 75 | * being exactly 64-bit wide. See Implementation Notes in sha512.c 76 | * for further details. 77 | */ 78 | /* 79 | * SHA-512 treats input data as a 80 | * contiguous array of 64 bit 81 | * wide big-endian values. 82 | */ 83 | # define SHA512_CBLOCK (SHA_LBLOCK*8) 84 | # if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) 85 | # define SHA_LONG64 unsigned __int64 86 | # define U64(C) C##UI64 87 | # elif defined(__arch64__) 88 | # define SHA_LONG64 unsigned long 89 | # define U64(C) C##UL 90 | # else 91 | # define SHA_LONG64 unsigned long long 92 | # define U64(C) C##ULL 93 | # endif 94 | 95 | typedef struct SHA512state_st { 96 | SHA_LONG64 h[8]; 97 | SHA_LONG64 Nl, Nh; 98 | union { 99 | SHA_LONG64 d[SHA_LBLOCK]; 100 | unsigned char p[SHA512_CBLOCK]; 101 | } u; 102 | unsigned int num, md_len; 103 | } SHA512_CTX; 104 | 105 | int SHA384_Init(SHA512_CTX *c); 106 | int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); 107 | int SHA384_Final(unsigned char *md, SHA512_CTX *c); 108 | unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md); 109 | int SHA512_Init(SHA512_CTX *c); 110 | int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); 111 | int SHA512_Final(unsigned char *md, SHA512_CTX *c); 112 | unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md); 113 | void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/srp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SRP_H 11 | # define HEADER_SRP_H 12 | 13 | #include 14 | 15 | #ifndef OPENSSL_NO_SRP 16 | # include 17 | # include 18 | # include 19 | # include 20 | # include 21 | 22 | # ifdef __cplusplus 23 | extern "C" { 24 | # endif 25 | 26 | typedef struct SRP_gN_cache_st { 27 | char *b64_bn; 28 | BIGNUM *bn; 29 | } SRP_gN_cache; 30 | 31 | 32 | DEFINE_STACK_OF(SRP_gN_cache) 33 | 34 | typedef struct SRP_user_pwd_st { 35 | /* Owned by us. */ 36 | char *id; 37 | BIGNUM *s; 38 | BIGNUM *v; 39 | /* Not owned by us. */ 40 | const BIGNUM *g; 41 | const BIGNUM *N; 42 | /* Owned by us. */ 43 | char *info; 44 | } SRP_user_pwd; 45 | 46 | void SRP_user_pwd_free(SRP_user_pwd *user_pwd); 47 | 48 | DEFINE_STACK_OF(SRP_user_pwd) 49 | 50 | typedef struct SRP_VBASE_st { 51 | STACK_OF(SRP_user_pwd) *users_pwd; 52 | STACK_OF(SRP_gN_cache) *gN_cache; 53 | /* to simulate a user */ 54 | char *seed_key; 55 | const BIGNUM *default_g; 56 | const BIGNUM *default_N; 57 | } SRP_VBASE; 58 | 59 | /* 60 | * Internal structure storing N and g pair 61 | */ 62 | typedef struct SRP_gN_st { 63 | char *id; 64 | const BIGNUM *g; 65 | const BIGNUM *N; 66 | } SRP_gN; 67 | 68 | DEFINE_STACK_OF(SRP_gN) 69 | 70 | SRP_VBASE *SRP_VBASE_new(char *seed_key); 71 | void SRP_VBASE_free(SRP_VBASE *vb); 72 | int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); 73 | 74 | /* This method ignores the configured seed and fails for an unknown user. */ 75 | DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)) 76 | /* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/ 77 | SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); 78 | 79 | char *SRP_create_verifier(const char *user, const char *pass, char **salt, 80 | char **verifier, const char *N, const char *g); 81 | int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, 82 | BIGNUM **verifier, const BIGNUM *N, 83 | const BIGNUM *g); 84 | 85 | # define SRP_NO_ERROR 0 86 | # define SRP_ERR_VBASE_INCOMPLETE_FILE 1 87 | # define SRP_ERR_VBASE_BN_LIB 2 88 | # define SRP_ERR_OPEN_FILE 3 89 | # define SRP_ERR_MEMORY 4 90 | 91 | # define DB_srptype 0 92 | # define DB_srpverifier 1 93 | # define DB_srpsalt 2 94 | # define DB_srpid 3 95 | # define DB_srpgN 4 96 | # define DB_srpinfo 5 97 | # undef DB_NUMBER 98 | # define DB_NUMBER 6 99 | 100 | # define DB_SRP_INDEX 'I' 101 | # define DB_SRP_VALID 'V' 102 | # define DB_SRP_REVOKED 'R' 103 | # define DB_SRP_MODIF 'v' 104 | 105 | /* see srp.c */ 106 | char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N); 107 | SRP_gN *SRP_get_default_gN(const char *id); 108 | 109 | /* server side .... */ 110 | BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u, 111 | const BIGNUM *b, const BIGNUM *N); 112 | BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, 113 | const BIGNUM *v); 114 | int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N); 115 | BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N); 116 | 117 | /* client side .... */ 118 | BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass); 119 | BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g); 120 | BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, 121 | const BIGNUM *x, const BIGNUM *a, const BIGNUM *u); 122 | int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N); 123 | 124 | # define SRP_MINIMAL_N 1024 125 | 126 | # ifdef __cplusplus 127 | } 128 | # endif 129 | # endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/srtp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | /* 11 | * DTLS code by Eric Rescorla 12 | * 13 | * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc. 14 | */ 15 | 16 | #ifndef HEADER_D1_SRTP_H 17 | # define HEADER_D1_SRTP_H 18 | 19 | # include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | # define SRTP_AES128_CM_SHA1_80 0x0001 26 | # define SRTP_AES128_CM_SHA1_32 0x0002 27 | # define SRTP_AES128_F8_SHA1_80 0x0003 28 | # define SRTP_AES128_F8_SHA1_32 0x0004 29 | # define SRTP_NULL_SHA1_80 0x0005 30 | # define SRTP_NULL_SHA1_32 0x0006 31 | 32 | /* AEAD SRTP protection profiles from RFC 7714 */ 33 | # define SRTP_AEAD_AES_128_GCM 0x0007 34 | # define SRTP_AEAD_AES_256_GCM 0x0008 35 | 36 | # ifndef OPENSSL_NO_SRTP 37 | 38 | __owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); 39 | __owur int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles); 40 | 41 | __owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); 42 | __owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); 43 | 44 | # endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/ssl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SSL2_H 11 | # define HEADER_SSL2_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define SSL2_VERSION 0x0002 18 | 19 | # define SSL2_MT_CLIENT_HELLO 1 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_STACK_H 11 | # define HEADER_STACK_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */ 18 | 19 | typedef int (*OPENSSL_sk_compfunc)(const void *, const void *); 20 | typedef void (*OPENSSL_sk_freefunc)(void *); 21 | typedef void *(*OPENSSL_sk_copyfunc)(const void *); 22 | 23 | int OPENSSL_sk_num(const OPENSSL_STACK *); 24 | void *OPENSSL_sk_value(const OPENSSL_STACK *, int); 25 | 26 | void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data); 27 | 28 | OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp); 29 | OPENSSL_STACK *OPENSSL_sk_new_null(void); 30 | void OPENSSL_sk_free(OPENSSL_STACK *); 31 | void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *)); 32 | OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, OPENSSL_sk_copyfunc c, OPENSSL_sk_freefunc f); 33 | int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where); 34 | void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); 35 | void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p); 36 | int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data); 37 | int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data); 38 | int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data); 39 | int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data); 40 | void *OPENSSL_sk_shift(OPENSSL_STACK *st); 41 | void *OPENSSL_sk_pop(OPENSSL_STACK *st); 42 | void OPENSSL_sk_zero(OPENSSL_STACK *st); 43 | OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, OPENSSL_sk_compfunc cmp); 44 | OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st); 45 | void OPENSSL_sk_sort(OPENSSL_STACK *st); 46 | int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st); 47 | 48 | # if OPENSSL_API_COMPAT < 0x10100000L 49 | # define _STACK OPENSSL_STACK 50 | # define sk_num OPENSSL_sk_num 51 | # define sk_value OPENSSL_sk_value 52 | # define sk_set OPENSSL_sk_set 53 | # define sk_new OPENSSL_sk_new 54 | # define sk_new_null OPENSSL_sk_new_null 55 | # define sk_free OPENSSL_sk_free 56 | # define sk_pop_free OPENSSL_sk_pop_free 57 | # define sk_deep_copy OPENSSL_sk_deep_copy 58 | # define sk_insert OPENSSL_sk_insert 59 | # define sk_delete OPENSSL_sk_delete 60 | # define sk_delete_ptr OPENSSL_sk_delete_ptr 61 | # define sk_find OPENSSL_sk_find 62 | # define sk_find_ex OPENSSL_sk_find_ex 63 | # define sk_push OPENSSL_sk_push 64 | # define sk_unshift OPENSSL_sk_unshift 65 | # define sk_shift OPENSSL_sk_shift 66 | # define sk_pop OPENSSL_sk_pop 67 | # define sk_zero OPENSSL_sk_zero 68 | # define sk_set_cmp_func OPENSSL_sk_set_cmp_func 69 | # define sk_dup OPENSSL_sk_dup 70 | # define sk_sort OPENSSL_sk_sort 71 | # define sk_is_sorted OPENSSL_sk_is_sorted 72 | # endif 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/symhacks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SYMHACKS_H 11 | # define HEADER_SYMHACKS_H 12 | 13 | # include 14 | 15 | /* Case insensitive linking causes problems.... */ 16 | # if defined(OPENSSL_SYS_VMS) 17 | # undef ERR_load_CRYPTO_strings 18 | # define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings 19 | # undef OCSP_crlID_new 20 | # define OCSP_crlID_new OCSP_crlID2_new 21 | 22 | # undef d2i_ECPARAMETERS 23 | # define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS 24 | # undef i2d_ECPARAMETERS 25 | # define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS 26 | # undef d2i_ECPKPARAMETERS 27 | # define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS 28 | # undef i2d_ECPKPARAMETERS 29 | # define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS 30 | 31 | /* 32 | * These functions do not seem to exist! However, I'm paranoid... Original 33 | * command in x509v3.h: These functions are being redefined in another 34 | * directory, and clash when the linker is case-insensitive, so let's hide 35 | * them a little, by giving them an extra 'o' at the beginning of the name... 36 | */ 37 | # undef X509v3_cleanup_extensions 38 | # define X509v3_cleanup_extensions oX509v3_cleanup_extensions 39 | # undef X509v3_add_extension 40 | # define X509v3_add_extension oX509v3_add_extension 41 | # undef X509v3_add_netscape_extensions 42 | # define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions 43 | # undef X509v3_add_standard_extensions 44 | # define X509v3_add_standard_extensions oX509v3_add_standard_extensions 45 | 46 | /* This one clashes with CMS_data_create */ 47 | # undef cms_Data_create 48 | # define cms_Data_create priv_cms_Data_create 49 | 50 | # endif 51 | 52 | #endif /* ! defined HEADER_VMS_IDHACKS_H */ 53 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/txt_db.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_TXT_DB_H 11 | # define HEADER_TXT_DB_H 12 | 13 | # include 14 | # include 15 | # include 16 | # include 17 | 18 | # define DB_ERROR_OK 0 19 | # define DB_ERROR_MALLOC 1 20 | # define DB_ERROR_INDEX_CLASH 2 21 | # define DB_ERROR_INDEX_OUT_OF_RANGE 3 22 | # define DB_ERROR_NO_INDEX 4 23 | # define DB_ERROR_INSERT_INDEX_CLASH 5 24 | # define DB_ERROR_WRONG_NUM_FIELDS 6 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef OPENSSL_STRING *OPENSSL_PSTRING; 31 | DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING) 32 | 33 | typedef struct txt_db_st { 34 | int num_fields; 35 | STACK_OF(OPENSSL_PSTRING) *data; 36 | LHASH_OF(OPENSSL_STRING) **index; 37 | int (**qual) (OPENSSL_STRING *); 38 | long error; 39 | long arg1; 40 | long arg2; 41 | OPENSSL_STRING *arg_row; 42 | } TXT_DB; 43 | 44 | TXT_DB *TXT_DB_read(BIO *in, int num); 45 | long TXT_DB_write(BIO *out, TXT_DB *db); 46 | int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), 47 | OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp); 48 | void TXT_DB_free(TXT_DB *db); 49 | OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, 50 | OPENSSL_STRING *value); 51 | int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/openssl/whrlpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_WHRLPOOL_H 11 | # define HEADER_WHRLPOOL_H 12 | 13 | #include 14 | 15 | # ifndef OPENSSL_NO_WHIRLPOOL 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | # define WHIRLPOOL_DIGEST_LENGTH (512/8) 23 | # define WHIRLPOOL_BBLOCK 512 24 | # define WHIRLPOOL_COUNTER (256/8) 25 | 26 | typedef struct { 27 | union { 28 | unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; 29 | /* double q is here to ensure 64-bit alignment */ 30 | double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; 31 | } H; 32 | unsigned char data[WHIRLPOOL_BBLOCK / 8]; 33 | unsigned int bitoff; 34 | size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; 35 | } WHIRLPOOL_CTX; 36 | 37 | int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); 38 | int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes); 39 | void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits); 40 | int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); 41 | unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md); 42 | 43 | # ifdef __cplusplus 44 | } 45 | # endif 46 | # endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/util.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | #define MALLOC_SIZE 0x400u 6 | 7 | char* JString2Char(JNIEnv* env, jstring jstr) { 8 | char* rtn = NULL; 9 | jclass clsstring = env->FindClass("java/lang/String"); 10 | jstring strencode = env->NewStringUTF("GB2312"); 11 | jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B"); 12 | jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode); 13 | jsize alen = env->GetArrayLength(barr); 14 | jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE); 15 | if (alen > 0) { 16 | rtn = (char*) malloc(alen + 1); 17 | memcpy(rtn, ba, alen); 18 | rtn[alen] = 0; 19 | } 20 | env->ReleaseByteArrayElements(barr, ba, 0); 21 | if(!rtn) return (char*)""; 22 | return rtn; 23 | } 24 | 25 | /*hex转bin*/ 26 | int String2Buffer(unsigned char* src, int srclen, unsigned char* dest) { 27 | int i = 0; 28 | if (srclen % 2 != 0) return 0; 29 | for (i = 0; i < srclen / 2; i++) 30 | { 31 | char tmp[3]; 32 | tmp[0] = *(src + 2 * i); 33 | tmp[1] = *(src + 2 * i + 1); 34 | tmp[2] = 0; 35 | int out = 0; 36 | sscanf(tmp, "%x", &out); 37 | unsigned char ch = (unsigned char)out; 38 | *(dest + i) = ch; 39 | } 40 | return i; 41 | } 42 | 43 | /*bin转hex*/ 44 | int Buffer2String(unsigned char* src, int srclen, unsigned char* dest) { 45 | int i; 46 | for (i = 0; i < srclen; i++) 47 | { 48 | char tmp[3] = { 0 }; 49 | sprintf(tmp, "%x", *(src + i)); 50 | if (strlen(tmp) == 1) { 51 | strcat((char*)dest, "0"); 52 | strncat((char*)dest, tmp, 1); 53 | } 54 | else if (strlen(tmp) == 2) { 55 | strncat((char*)dest, tmp, 2); 56 | } 57 | else { 58 | strcat((char*)dest, "00"); 59 | } 60 | } 61 | return i * 2; 62 | } -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/cpp/wap-ecdh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "openssl/crypto.h" 6 | #include "openssl/ssl.h" 7 | #include "openssl/md5.h" 8 | #include "openssl/bn.h" 9 | #include "util.cpp" 10 | 11 | #define ECDH_SIZE 67 12 | #define MALLOC_SIZE 0x400u 13 | #define LOG_TAG "C_TAG" 14 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, __VA_ARGS__) 15 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, __VA_ARGS__) 16 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, __VA_ARGS__) 17 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, __VA_ARGS__) 18 | 19 | /* s1 : 生成(1)/协商(2) s2 :_s_pub_key s3 :_c_pub_key s4 :_c_pri_key */ 20 | int GenECDHKey(JNIEnv* env, jobject obj, char * s2, char * s3, char * s4){ 21 | char* p1 = s2; 22 | char* p2 = s3; 23 | char* p3 = s4; 24 | if(strlen(p1) == 0) return -0x10; 25 | EC_KEY * ec_key = EC_KEY_new(); 26 | ec_key = EC_KEY_new_by_curve_name(NID_secp192k1);//711 27 | if(!ec_key) return -0x07; 28 | if(strlen(s4) > 0){ 29 | BIGNUM *big = BN_new(); 30 | if(!big) return -0x05; 31 | unsigned char *sout3 = (unsigned char*)malloc(MALLOC_SIZE);memset(sout3, 0, MALLOC_SIZE); 32 | int len3 = String2Buffer((unsigned char*)p3, strlen(p3), sout3); 33 | BN_mpi2bn(sout3, len3, big); 34 | if(!big) return -0x06; 35 | char *p = BN_bn2hex(big); 36 | if (p){ 37 | OPENSSL_free(p);//释放p 38 | free(sout3);//释放 sout3 39 | } 40 | int r = EC_KEY_set_private_key(ec_key, big); 41 | BN_free(big);//释放 42 | if(r != 1) return -0x01; 43 | const EC_GROUP *group = EC_KEY_get0_group(ec_key); 44 | EC_POINT *point = EC_POINT_new(group); 45 | if(strlen(p2) > 0){ 46 | unsigned char *str2bin = (unsigned char*)malloc(MALLOC_SIZE); memset(str2bin, 0, MALLOC_SIZE); 47 | int len22 = String2Buffer((unsigned char*)p2, strlen(p2), str2bin); 48 | int r1 = EC_POINT_oct2point(group, point, str2bin, len22, NULL); 49 | free(str2bin); 50 | if (r1 != 1) return -0x11; 51 | }else{ 52 | int r2 = EC_POINT_mul(group, point, NULL, NULL, NULL, NULL); 53 | if (r2 != 1) return -0x02; 54 | } 55 | int r3 = EC_KEY_set_public_key(ec_key, point); 56 | if (r3 != 1) return -0x03; 57 | }else{ 58 | int r5 = EC_KEY_generate_key(ec_key); 59 | if (!r5) return -0x55; 60 | } 61 | const EC_GROUP *group1 = EC_KEY_get0_group(ec_key); 62 | const EC_POINT *point1 = EC_KEY_get0_public_key(ec_key); 63 | //get pubkey 64 | unsigned char *pubkey = (unsigned char*)malloc(MALLOC_SIZE); 65 | memset(pubkey, 0, MALLOC_SIZE); 66 | int publen = EC_POINT_point2oct(group1, point1, POINT_CONVERSION_COMPRESSED, pubkey, ECDH_SIZE, NULL); 67 | // 此处赋值pubkey 68 | jclass dpclazz = env->GetObjectClass(obj); if(!dpclazz) return -0x80; 69 | jmethodID methodID1 = env->GetMethodID(dpclazz,"set_c_pub_key", "([B)V"); if(!methodID1) return -0x81; 70 | jbyteArray para1 = env->NewByteArray(publen); 71 | env->SetByteArrayRegion(para1, 0, publen, (jbyte *)pubkey); 72 | env->CallVoidMethod(obj, methodID1, para1); 73 | free(pubkey);//释放pubkey 74 | 75 | //get privatekey 76 | const BIGNUM *pribig = EC_KEY_get0_private_key(ec_key); 77 | unsigned char *pout = (unsigned char*)malloc(MALLOC_SIZE); memset(pout, 0, MALLOC_SIZE); 78 | int lenpri = BN_bn2mpi(pribig, pout); 79 | // 此处赋值prikey 80 | jmethodID methodID2 = env->GetMethodID(dpclazz,"set_c_pri_key", "([B)V"); if(!methodID2) return -0x82; 81 | jbyteArray para2 = env->NewByteArray(lenpri); 82 | env->SetByteArrayRegion(para2, 0, lenpri, (jbyte *)pout); 83 | env->CallVoidMethod(obj, methodID2, para2); 84 | free(pout);//释放prikey 85 | 86 | //set p1 87 | unsigned char *str1bin = (unsigned char*)malloc(MALLOC_SIZE); 88 | memset(str1bin, 0, MALLOC_SIZE); 89 | int len11 = String2Buffer((unsigned char*)p1, strlen(p1), str1bin); 90 | EC_POINT *point2 = EC_POINT_new(group1); 91 | int r4 = EC_POINT_oct2point(group1, point2, str1bin, len11, NULL); 92 | free(str1bin);//释放str1bin 93 | if (r4 != 1) return -0x04; 94 | 95 | //get sharedkey 96 | unsigned char *shared = (unsigned char *)malloc(MALLOC_SIZE); 97 | memset(shared, 0, MALLOC_SIZE); 98 | int len = ECDH_compute_key(shared, 512, point2, ec_key, NULL); 99 | if (len <= 0) return -0x09; 100 | unsigned char md5share[MD5_DIGEST_LENGTH]; 101 | MD5(shared, len, md5share); 102 | // 此处赋值sharekey 103 | jmethodID methodID3 = env->GetMethodID(dpclazz,"set_g_share_key", "([B)V"); if(!methodID3) return -0x83; 104 | jbyteArray para3 = env->NewByteArray(MD5_DIGEST_LENGTH); 105 | env->SetByteArrayRegion(para3, 0, MD5_DIGEST_LENGTH, (jbyte *)md5share); 106 | env->CallVoidMethod(obj, methodID3, para3); 107 | free(shared);//释放shaedkey 108 | //free(md5share); 109 | EC_KEY_free(ec_key);//释放eckey 110 | return 1; 111 | } 112 | 113 | extern "C" JNIEXPORT jint JNICALL 114 | Java_com_shanling_demo_AppEcdh_GenECDHKeyEx(JNIEnv* env, jobject obj, jstring s1, jstring s2, jstring s3, jstring s4, jstring s5) { 115 | return GenECDHKey(env, obj, JString2Char(env, s1), JString2Char(env, s2), JString2Char(env, s3)); 116 | } 117 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/java/com/shanling/demo/AppEcdh.java: -------------------------------------------------------------------------------- 1 | package com.shanling.demo; 2 | 3 | import android.util.Log; 4 | 5 | public class AppEcdh { 6 | static { 7 | System.loadLibrary("wap-ecdh"); 8 | } 9 | 10 | public static final String S_PUB_KEY = "04af8efd25576ed8ab550b5d65e0ad36916566708cbe5a3ad54e127ae42951d09212fc04a1ac463aff66d3dbf5ac6f46a1"; 11 | public static byte[] _c_pri_key = new byte[0]; 12 | public static byte[] _c_pub_key = new byte[0]; 13 | private static byte[] _g_share_key = new byte[0]; 14 | private static boolean userOpenSSLLib = true; 15 | /*** 16 | * 调用 So 库里的函数 17 | * @param str1 S_PUB_KEY 服务器初始公钥 18 | * @param str2 _c_pub_key 客户生成的公钥 19 | * @param str3 _c_pri_key 客户生成的私钥 20 | * @return 返回:1 :表示成功 21 | */ 22 | public native int GenECDHKeyEx(String str1, String str2, String str3); 23 | 24 | public int GenereateKey(){ 25 | try { 26 | int GenECDHKeyEx; 27 | synchronized (AppEcdh.class) { 28 | GenECDHKeyEx = GenECDHKeyEx(S_PUB_KEY, "", ""); 29 | } 30 | return GenECDHKeyEx; 31 | } catch (UnsatisfiedLinkError e) { 32 | // util.LOGI("GenereateKey failed " + e.getMessage(), ""); 33 | Log.i("TAG","GenereateKey failed " + e.getMessage()); 34 | return -1; 35 | } 36 | } 37 | 38 | public byte[] calShareKeyMd5ByPeerPublicKey(byte[] bArr) { 39 | // Log.i("TAG", "userOpenSSLLib " + userOpenSSLLib + " peerRawPublicKey " + util.buf_to_string(bArr)); 40 | if (true == userOpenSSLLib) { 41 | return calShareKeyByOpenSSL(util.buf_to_string(_c_pri_key), util.buf_to_string(_c_pub_key), util.buf_to_string(bArr)); 42 | } 43 | return null; 44 | } 45 | 46 | private byte[] calShareKeyByOpenSSL(String str, String str2, String str3) { 47 | // Log.i("TAG", "calShareKeyByOpenSSL publickey " + str2); 48 | if (GenECDHKeyEx(str3, str2, str) == 1) { 49 | return _g_share_key; 50 | } 51 | // t.al.attr_api(2461268); 52 | return null; 53 | } 54 | 55 | public byte[] get_c_pub_key() { 56 | return (byte[]) _c_pub_key.clone(); 57 | } 58 | 59 | public void set_c_pub_key(byte[] bArr) { 60 | if (bArr != null) { 61 | _c_pub_key = (byte[]) bArr.clone(); 62 | } else { 63 | _c_pub_key = new byte[0]; 64 | } 65 | } 66 | 67 | public void set_c_pri_key(byte[] bArr) { 68 | if (bArr != null) { 69 | _c_pri_key = (byte[]) bArr.clone(); 70 | } else { 71 | _c_pri_key = new byte[0]; 72 | } 73 | } 74 | 75 | public byte[] get_g_share_key() { 76 | return (byte[]) _g_share_key.clone(); 77 | } 78 | 79 | public void set_g_share_key(byte[] bArr) { 80 | if (bArr != null) { 81 | _g_share_key = (byte[]) bArr.clone(); 82 | } else { 83 | _g_share_key = new byte[0]; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/java/com/shanling/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.shanling.demo; 2 | 3 | import android.content.ClipboardManager; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.support.v7.app.AlertDialog; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.os.Bundle; 9 | import android.util.Log; 10 | import android.view.View; 11 | import android.widget.Button; 12 | import android.widget.EditText; 13 | import android.widget.TextView; 14 | import android.widget.Toast; 15 | 16 | public class MainActivity extends AppCompatActivity { 17 | 18 | static { 19 | System.loadLibrary("native-lib"); 20 | } 21 | 22 | public native String stringFromJNI(); 23 | 24 | AppEcdh Ecc = new AppEcdh(); 25 | 26 | private TextView s_sha_key; 27 | private TextView c_sha_key; 28 | private TextView Text_Info; 29 | 30 | private EditText s_pub_key; 31 | private EditText c_pub_key; 32 | 33 | private Button CopyButt; 34 | private Button OkButt; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_main); 40 | 41 | // 对组件进行实例化 42 | Text_Info = (TextView) findViewById(R.id.Text_Info); 43 | s_sha_key = (TextView) findViewById(R.id.s_sha_key); 44 | c_sha_key = (TextView) findViewById(R.id.c_sha_key); 45 | s_pub_key = (EditText) findViewById(R.id.s_pub_key); 46 | c_pub_key = (EditText) findViewById(R.id.c_pub_key); 47 | CopyButt = (Button) findViewById(R.id.copy_button); 48 | OkButt = (Button) findViewById(R.id.ok_button); 49 | 50 | Text_Info.setText(stringFromJNI()); 51 | 52 | if(Ecc.GenereateKey() == 1){ 53 | c_pub_key.setText(util.buf_to_string(Ecc.get_c_pub_key())); 54 | c_sha_key.setText(util.buf_to_string(Ecc.get_g_share_key())); 55 | }; 56 | 57 | CopyButt.setOnClickListener(new View.OnClickListener() { 58 | @Override 59 | public void onClick(View v) { 60 | // 从API11开始android推荐使用android.content.ClipboardManager 61 | // 为了兼容低版本我们这里使用旧版的android.text.ClipboardManager,虽然提示deprecated,但不影响使用。 62 | ((ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE)).setText(c_pub_key.getText()); 63 | Toast.makeText(MainActivity.this, "已复制到剪辑版!", Toast.LENGTH_LONG).show(); 64 | } 65 | }); 66 | } 67 | 68 | public void OnClick(View v) { 69 | byte[] _s_Share_key, _s_Pub_key = util.string_to_buf(s_pub_key.getText().toString()); 70 | if(_s_Pub_key.length == 0 || _s_Pub_key.length != 49) { 71 | new AlertDialog.Builder(this).setTitle("错误:").setMessage("_s_Pub_key 为空或格式不正确!").setPositiveButton("确定", new DialogInterface.OnClickListener() { 72 | @Override 73 | public void onClick(DialogInterface dialog, int which) { 74 | } 75 | }).show(); 76 | return; 77 | } 78 | if((_s_Share_key = Ecc.calShareKeyMd5ByPeerPublicKey(_s_Pub_key)) == null) 79 | { 80 | s_sha_key.setText("协商失败!"); 81 | }else{ 82 | s_sha_key.setText(util.buf_to_string(Ecc.get_g_share_key())); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/java/com/shanling/demo/util.java: -------------------------------------------------------------------------------- 1 | package com.shanling.demo; 2 | 3 | public class util { 4 | /*** 5 | * 字节数组转到 Hex 十六进制文本 6 | * @param bArr 7 | * @return 8 | */ 9 | public static String buf_to_string(byte[] bArr) { 10 | if (bArr == null) { 11 | return ""; 12 | } 13 | String str = ""; 14 | for (int i = 0; i < bArr.length; i++) { 15 | str = (str + Integer.toHexString((bArr[i] >> 4) & 15)) + Integer.toHexString(bArr[i] & 15); 16 | } 17 | return str; 18 | } 19 | 20 | public static byte get_char(byte b) { 21 | if (b >= (byte) 48 && b <= (byte) 57) { 22 | return (byte) (b - 48); 23 | } 24 | if (b >= (byte) 97 && b <= (byte) 102) { 25 | return (byte) ((b - 97) + 10); 26 | } 27 | if (b < (byte) 65 || b > (byte) 70) { 28 | return (byte) 0; 29 | } 30 | return (byte) ((b - 65) + 10); 31 | } 32 | 33 | /*** 34 | * Hex 十六进制文本转到字节数组 35 | * @param str 36 | * @return 37 | */ 38 | public static byte[] string_to_buf(String str) { 39 | int i = 0; 40 | if (str == null) { 41 | return new byte[0]; 42 | } 43 | byte[] bArr = new byte[(str.length() / 2)]; 44 | while (i < str.length() / 2) { 45 | bArr[i] = (byte) ((get_char((byte) str.charAt(i * 2)) << 4) + get_char((byte) str.charAt((i * 2) + 1))); 46 | i++; 47 | } 48 | return bArr; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /DemoEcdhClient/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 17 | 18 |