Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
9,180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[target.aarch64-linux-android] | ||
ar = "/Users/vladikoff/dev/rust-cjose/android/NDK/arm64/bin/aarch64-linux-android-ar" | ||
linker = "/Users/vladikoff/dev/rust-cjose/android/NDK/arm64/bin/aarch64-linux-android-clang" | ||
|
||
[target.armv7-linux-androideabi] | ||
ar = "/Users/vladikoff/dev/rust-cjose/android/NDK/arm/bin/arm-linux-androideabi-ar" | ||
linker = "/Users/vladikoff/dev/rust-cjose/android/NDK/arm/bin/arm-linux-androideabi-clang" | ||
|
||
[target.i686-linux-android] | ||
ar = "/Users/vladikoff/dev/rust-cjose/android/NDK/x86/bin/i686-linux-android-ar" | ||
linker = "/Users/vladikoff/dev/rust-cjose/android/NDK/x86/bin/i686-linux-android-clang" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target/ | ||
**/*.rs.bk | ||
Cargo.lock | ||
android/NDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "jose_c" | ||
version = "0.1.0" | ||
authors = ["vladikoff <vlad.filippov@gmail.com>"] | ||
|
||
[lib] | ||
name = "jose_c" | ||
path = "src/lib.rs" | ||
crate-type = ["lib", "staticlib", "cdylib"] | ||
#crate-type = ["dylib"] | ||
|
||
[dependencies] | ||
libc = "0.2" | ||
|
||
[build-dependencies] | ||
cc = "1.0" | ||
pkg-config = "0.3.9" | ||
|
||
[target.'cfg(target_os="android")'.dependencies] | ||
jni = { version = "0.5", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Android | ||
|
||
Generate this directory using | ||
|
||
```bash | ||
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch arm64 --install-dir NDK/arm64 | ||
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch arm --install-dir NDK/arm | ||
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch x86 --install-dir NDK/x86 | ||
``` | ||
|
||
|
||
Create a `cargo-config.toml` and move it to your `~/.cargo/config`: | ||
|
||
``` | ||
[target.aarch64-linux-android] | ||
ar = "<project path>/android/NDK/arm64/bin/aarch64-linux-android-ar" | ||
linker = "<project path>/android/NDK/arm64/bin/aarch64-linux-android-clang" | ||
[target.armv7-linux-androideabi] | ||
ar = "<project path>/android/NDK/arm/bin/arm-linux-androideabi-ar" | ||
linker = "<project path>/android/NDK/arm/bin/arm-linux-androideabi-clang" | ||
[target.i686-linux-android] | ||
ar = "<project path>/android/NDK/x86/bin/i686-linux-android-ar" | ||
linker = "<project path>/android/NDK/x86/bin/i686-linux-android-clang" | ||
``` | ||
|
||
Don't forget the thing: | ||
``` | ||
TARGET_AR="/Users/vladikoff/dev/rust-cjose/android/NDK/arm64/bin/aarch64-linux-android-ar" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[target.aarch64-linux-android] | ||
ar = "$PWD/NDK/arm64/bin/aarch64-linux-android-ar" | ||
linker = "$PWD/NDK/arm64/bin/aarch64-linux-android-gcc" | ||
|
||
[target.armv7-linux-androideabi] | ||
ar = "$PWD/NDK/arm/bin/arm-linux-androideabi-ar" | ||
linker = "$PWD/NDK/arm/bin/arm-linux-androideabi-gcc" | ||
|
||
[target.i686-linux-android] | ||
ar = "$PWD/NDK/x86/bin/i686-linux-android-ar" | ||
linker = "$PWD/NDK/x86/bin/i686-linux-android-gcc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#! /bin/bash | ||
|
||
# based on https://github.com/kennytm/rust-ios-android | ||
|
||
set -euo pipefail | ||
|
||
if [ -d NDK ]; then | ||
printf '\e[33;1mStandalone NDK already exists... Delete the NDK folder to make a new one.\e[0m\n\n' | ||
printf '$ rm -rf NDK\n' | ||
exit 0 | ||
fi | ||
|
||
MAKER="$NDK_HOME/build/tools/make_standalone_toolchain.py" | ||
|
||
if [ -x "$MAKER" ]; then | ||
MAKER="$NDK_HOME/build/tools/make_standalone_toolchain.py" | ||
fi | ||
|
||
if [ -x "$MAKER" ]; then | ||
echo 'Creating standalone NDK...' | ||
else | ||
printf '\e[91;1mPlease install `android-ndk`!\e[0m\n\n' | ||
printf '$ brew install android-ndk\n' | ||
exit 1 | ||
fi | ||
|
||
mkdir NDK | ||
cd NDK | ||
|
||
for ARCH in arm64 arm x86; do | ||
echo "($ARCH)..." | ||
"$MAKER" --arch $ARCH --install-dir $ARCH | ||
done | ||
|
||
echo 'Updating ./rust/.cargo/config.toml...' | ||
|
||
cd .. | ||
mkdir -p rust/.cargo | ||
sed 's|$PWD|'"${PWD}"'|g' cargo-config.toml.template > ./rust/.cargo/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use std::env; | ||
|
||
extern crate cc; | ||
extern crate pkg_config; | ||
|
||
|
||
fn main() { | ||
env::set_var("CFLAGS", "-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"); | ||
//env::set_var("CC", "arm-linux-gnueabihf-gcc"); | ||
cc::Build::new() | ||
.file("src/cjose/version.c") | ||
//.shared_flag(true) | ||
//.pic(true) | ||
//.target("aarch64-linux-android") | ||
.target("armv7-linux-androideabi") | ||
// this is the alias for GCC on my computer | ||
//.compiler("gcc") | ||
//.compiler("/Users/vladikoff/dev/rust-cjose/android/NDK/arm64/bin/aarch64-linux-android-gcc") | ||
.compiler("/Users/vladikoff/dev/rust-cjose/android/NDK/arm/bin/arm-linux-androideabi-gcc") | ||
.compile("version.so"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
extern crate jose_c; | ||
|
||
fn main() { | ||
let cjose_version = jose_c::version(); | ||
|
||
println!("cjose version is {}", cjose_version); | ||
|
||
|
||
// let kty = "oct"; | ||
// let k = "lPcH0XzKdjZe5nZ2aRZvpg2PX6tQjd7T-DeLPllm8Fc"; | ||
// let kid = "1521857656-2wUwquQBAEluma_ZtAeKkA"; | ||
// | ||
// let input = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.D0pXfIy0inmvfcpe_QsNkm31Y9rsEUhGmY2p2o67mM4xQAIBP1JWgg.2xdHtQuMWHzREbkb.8nGVFour5PyKttLvzjQvRoDVtlAz226vNcc1PWa8c3hGDbK0ZCD-PnzJ4lSphmCkPrYb_JZxXtNzz4oIegC8WMuEgYDeMSnnFeOBiKt3_pgLcf6E8EQ-C07420UGzZrMYmeBnf1Nfz_90nbLGZKZmyaNkIU3KcFgz9SYjU8duuvZkOg-YuDuLbtZL0iqqXn-w1z-PTX3uprr64OVIPPnOHRW.pYisL1l_6ffPtSgVfbOCfQ"; | ||
|
||
//let x = unsafe { snappy_max_compressed_length(100) }; | ||
// let keystore = jose_c::JWK::asKey(100); | ||
|
||
|
||
|
||
// let decryptor = jose_c::JWE::createDecrypt(keystore); | ||
// let result = decryptor.decrypt(input); | ||
//let result = jose_c::JWE::createDecrypt(keystore, input); | ||
|
||
//println!("Decrypted: {}", result); | ||
} |
Oops, something went wrong.