Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ added some untested gradle scripts to init build of liboqs #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.LibOQSTestApp">
<activity android:name=".MainActivity">
<activity android:name="de.hartz.software.unoffical.liboqstestapp.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.liboqstestapp;
package de.hartz.software.unoffical.liboqstestapp;

import androidx.appcompat.app.AppCompatActivity;

Expand All @@ -11,16 +11,22 @@
import android.widget.EditText;
import android.widget.Spinner;

import com.example.liboqs.Common;
import com.example.liboqs.KEMs;
import com.example.liboqs.KeyEncapsulation;
import com.example.liboqs.Pair;
import org.openquantumsafe.Common;
import org.openquantumsafe.KEMs;
import org.openquantumsafe.KeyEncapsulation;
import org.openquantumsafe.Pair;
import com.example.liboqstestapp.R;
import com.google.android.material.tabs.TabLayout;

import java.io.UnsupportedEncodingException;
import de.hartz.software.unofficial.liboqs.android.CommonAndroid;

public class MainActivity extends AppCompatActivity {

static {
// We need this instead of Common.loadNativeLibrary() as we cannot extract the lib on android.
CommonAndroid.loadNativeLibrary();
}

private static class Client {
KeyEncapsulation kem;
String sharedSecret;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.example.liboqstestapp;
package de.hartz.software.unoffical.liboqstestapp;

import android.util.Base64;

import com.example.liboqs.Common;

import java.nio.charset.Charset;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
tools:context=".MainActivity">
tools:context="de.hartz.software.unoffical.liboqstestapp.MainActivity">

<com.google.android.material.tabs.TabLayout
android:id="@+id/simpleTabLayout"
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ allprojects {
repositories {
google()
jcenter()
maven {
name = 'ajoberstar-backup'
url = 'https://ajoberstar.github.io/bintray-backup/'
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion liboqs-android/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
/prebuild-liboqs
4 changes: 2 additions & 2 deletions liboqs-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {

// https://developer.android.com/ndk/guides/abis#gc
ndk {
// Only support 64 bit systems (as liboqs does not build others)
// Only support 64 bit systems (as liboqs does not build others yet #2 and #3)
abiFilters 'arm64-v8a', 'x86_64'
}
}
Expand All @@ -39,7 +39,7 @@ android {

externalNativeBuild {
ndkBuild {
// Tells Gradle to put outputs from external native
// Tells Gradle to put outputs/logs from external native
// builds in the path specified below.
buildStagingDirectory "./outputs/ndk-build"
path 'jni/Android.mk'
Expand Down
48 changes: 48 additions & 0 deletions liboqs-android/init-prebuilt-liboqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Define paths for copying liboqs-java
jniDir = "jni/jni"
liboqsJavaDir = "liboqs-java"

git clone --recursive -j8 -n https://github.com/open-quantum-safe/liboqs-java.git
cp "{$liboqsJavaDir}/src/main/c/*" $jniDir
cp "{$liboqsJavaDir}/src/main/java/*" "src/main/java/"

# Define Paths looking from root of this project.
prebuiltRoot = "prebuild-liboqs"
liboqsScriptsDir = "${prebuiltRoot}/liboqs/scripts"
liboqsBuildDir = "${prebuiltRoot}/liboqs/build"
ndkPath = "${prebuiltRoot}/android-ndk-r21"
jniLibDir = "jni/jniLibs"
jniIncludeDir = "jni/include/oqs"

# Get sources
cd $prebuiltRoot/liboqs
git clone --recursive -j8 -n https://github.com/open-quantum-safe/liboqs.git

# Get Tools
cd $prebuiltRoot
apt-get update # Not necessary as with docker we are up to date
wget https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip
apt-get install unzip
unzip android-ndk-r21-linux-x86_64.zip
apt-get install -y build-essential cmake libssl-dev

# Build
cd $liboqsScriptsDir

# declare -a arr=("x86" "x86_64" "arm64-v8a" "armeabi-v7a") # 32 Bit is currently not working.
declare -a arr=("x86_64" "arm64-v8a")
sdkVersion = 19

for abi in "${arr[@]}"
do
# turn off errors as different abis might compile differently well.
set -e
build-android.sh $ndkPath -s $sdkVersion -a $abi
liboqsFile = "${liboqsBuildDir}/liboqs.so"
abiFile = "${jniLibDir}/${abi}/liboqs.so"
mv $liboqsFile $abiFile # TODO: Is the order of target and source correct?
done
# TODO: Copy include folder probably we just need to copy include/oqs to include/oqs
cp "{$liboqsBuildDir}/include" $jniIncludeDir

# You can access them using echo "${arr[0]}", "${arr[1]}" also
158 changes: 0 additions & 158 deletions liboqs-android/jni/include/oqs/aes.h

This file was deleted.

Loading