From 57a3abcb99ad9d9278547096544ec2329bb493a3 Mon Sep 17 00:00:00 2001 From: Berend Sliedrecht Date: Fri, 23 Feb 2024 16:00:07 +0100 Subject: [PATCH] chore: use stable rust Signed-off-by: Berend Sliedrecht --- .github/workflows/ci.yml | 2 +- Cargo.toml | 1 + examples/android/Cargo.lock | 235 +++++++++++------------------------- src/android.rs | 43 ++++--- src/lib.rs | 2 - 5 files changed, 100 insertions(+), 183 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8124f1..3e77f98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: - main env: - RUST_VERSION: "nightly" + RUST_VERSION: "1.69" jobs: format: diff --git a/Cargo.toml b/Cargo.toml index f85f5f8..d08a661 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ android-activity = { version = "0.5.0", features = ["native-activity"] } jni = { version = "0.21.1", features = ["invocation"] } lazy_static = "1.4.0" ndk-context = "0.1.1" +paste = "1.0.14" [dependencies] thiserror = "1.0.50" diff --git a/examples/android/Cargo.lock b/examples/android/Cargo.lock index ea252e1..c2949ee 100644 --- a/examples/android/Cargo.lock +++ b/examples/android/Cargo.lock @@ -61,12 +61,12 @@ dependencies = [ [[package]] name = "android-activity" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052ad56e336bcc615a214bffbeca6c181ee9550acec193f0327e0b103b033a4d" +checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", - "bitflags 2.4.1", + "bitflags 2.4.2", "cc", "cesu8", "jni", @@ -105,20 +105,6 @@ dependencies = [ ] [[package]] -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -======= -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] ->>>>>>> 318f114 (feat(ios): get keypair by id) -======= ->>>>>>> d3d4576 (fix(ios): disable macos) -======= name = "askar-crypto" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -156,7 +142,6 @@ dependencies = [ ] [[package]] ->>>>>>> ac6a119 (tests: improve and unified mobile testing) name = "base16ct" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -182,9 +167,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "blake2" @@ -249,11 +234,10 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" dependencies = [ - "jobserver", "libc", ] @@ -316,15 +300,15 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -332,15 +316,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -516,9 +500,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "log", "regex", @@ -559,9 +543,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -597,9 +581,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hkdf" @@ -621,9 +605,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown", @@ -673,15 +657,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -[[package]] -name = "jobserver" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" -dependencies = [ - "libc", -] - [[package]] name = "k256" version = "0.13.3" @@ -702,9 +677,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" @@ -724,9 +699,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mobile_tests" @@ -744,12 +719,11 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "jni-sys", "log", "ndk-sys", "num_enum", - "raw-window-handle", "thiserror", ] @@ -769,54 +743,19 @@ dependencies = [ ] [[package]] -<<<<<<< HEAD -<<<<<<< HEAD -======= -name = "num-bigint" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" -dependencies = [ - "autocfg", -] - -[[package]] ->>>>>>> 318f114 (feat(ios): get keypair by id) -======= ->>>>>>> d3d4576 (fix(ios): disable macos) name = "num_enum" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -826,9 +765,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -860,6 +799,12 @@ dependencies = [ "sha2", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -925,27 +870,27 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -980,17 +925,11 @@ dependencies = [ "getrandom", ] -[[package]] -name = "raw-window-handle" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" - [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -1000,9 +939,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -1036,9 +975,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "salsa20" @@ -1081,6 +1020,7 @@ dependencies = [ "lazy_static", "ndk-context", "p256", + "paste", "security-framework", "thiserror", ] @@ -1088,54 +1028,21 @@ dependencies = [ [[package]] name = "security-framework" version = "2.9.2" -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -source = "git+https://github.com/berendsliedrecht/rust-security-framework?branch=main#53e05311f7ff7a7cfae4ff38f7f22452407684fc" -======= -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" ->>>>>>> 318f114 (feat(ios): get keypair by id) -======= -source = "git+https://github.com/berendsliedrecht/rust-security-framework?branch=main#53e05311f7ff7a7cfae4ff38f7f22452407684fc" ->>>>>>> d3d4576 (fix(ios): disable macos) -======= source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" ->>>>>>> ac6a119 (tests: improve and unified mobile testing) dependencies = [ "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", -<<<<<<< HEAD -<<<<<<< HEAD -======= - "num-bigint", ->>>>>>> 318f114 (feat(ios): get keypair by id) -======= ->>>>>>> d3d4576 (fix(ios): disable macos) "security-framework-sys", ] [[package]] name = "security-framework-sys" version = "2.9.1" -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -source = "git+https://github.com/berendsliedrecht/rust-security-framework?branch=main#53e05311f7ff7a7cfae4ff38f7f22452407684fc" -======= -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" ->>>>>>> 318f114 (feat(ios): get keypair by id) -======= -source = "git+https://github.com/berendsliedrecht/rust-security-framework?branch=main#53e05311f7ff7a7cfae4ff38f7f22452407684fc" ->>>>>>> d3d4576 (fix(ios): disable macos) -======= source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" ->>>>>>> ac6a119 (tests: improve and unified mobile testing) dependencies = [ "core-foundation-sys", "libc", @@ -1143,15 +1050,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1168,9 +1075,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", @@ -1200,9 +1107,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -1216,9 +1123,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", @@ -1227,18 +1134,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -1253,9 +1160,9 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.20.7" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", @@ -1415,9 +1322,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winnow" -version = "0.5.19" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] diff --git a/src/android.rs b/src/android.rs index 435c92c..444e6bc 100644 --- a/src/android.rs +++ b/src/android.rs @@ -4,6 +4,7 @@ use crate::{ KeyOps, SecureEnvironmentOps, }; use jni::objects::{JByteArray, JObject, JValue}; +use paste::paste; lazy_static::lazy_static! { pub static ref JAVA_VM: jni::JavaVM = @@ -44,7 +45,8 @@ macro_rules! jni_handle_error { macro_rules! jni_call_method { ($env:expr, $cls:expr, $method:ident, $args:expr, $ret_typ:ident, $err:ident) => { - $env.call_method($cls, $method, concat_idents!($method, _SIG), $args) + paste! { + $env.call_method($cls, $method, [<$method _SIG>], $args) .map_err(|e| $crate::error::SecureEnvError::$err(Some(e.to_string()))) .and_then(|v| { jni_handle_error!($env, $err); @@ -52,6 +54,7 @@ macro_rules! jni_call_method { v.$ret_typ() .map_err(|e| $crate::error::SecureEnvError::$err(Some(e.to_string()))) }) + } }; ($env:expr, $cls:expr, $method:ident, $ret_typ:ident, $err:ident) => { @@ -60,12 +63,13 @@ macro_rules! jni_call_method { } macro_rules! jni_call_static_method { - ($env:expr, $cls:ident, $method:ident, $args:expr, $ret_typ:ident, $err:ident) => {{ + ($env:expr, $cls:ident, $method:ident, $args:expr, $ret_typ:ident, $err:ident) => { + paste! {{ let res = $env .call_static_method( - concat_idents!($cls, _CLS), + [<$cls _CLS>], $method, - concat_idents!($method, _SIG), + [<$method _SIG>], $args, ) .map_err(|e| $crate::error::SecureEnvError::$err(Some(e.to_string()))) @@ -79,7 +83,8 @@ macro_rules! jni_call_static_method { jni_handle_error!($env, $err); res - }}; + }} + }; ($env:expr, $cls:ident, $method:ident, $ret_typ:ident, $err:ident) => { jni_call_static_method!($env, $cls, $method, &[], $ret_typ, $err) @@ -87,9 +92,10 @@ macro_rules! jni_call_static_method { } macro_rules! jni_get_static_field { - ($env:expr, $cls:expr, $method:ident, $ret_typ:ident, $err:ident) => {{ + ($env:expr, $cls:expr, $method:ident, $ret_typ:ident, $err:ident) => { + paste! {{ let field = $env - .get_static_field($cls, $method, concat_idents!($method, _SIG)) + .get_static_field($cls, $method, [<$method _SIG>]) .map_err(|e| $crate::error::SecureEnvError::$err(Some(e.to_string()))) .and_then(|v| { jni_handle_error!($env, $err); @@ -101,15 +107,17 @@ macro_rules! jni_get_static_field { jni_handle_error!($env, $err); field - }}; + }} + }; } macro_rules! jni_new_object { - ($env:expr, $cls:ident, $args:expr, $err:ident) => {{ + ($env:expr, $cls:ident, $args:expr, $err:ident) => { + paste! {{ let obj = $env .new_object( - concat_idents!($cls, _CLS), - concat_idents!($cls, _CTOR_SIG), + [<$cls _CLS>], + [<$cls _CTOR_SIG>], $args, ) .map_err(|e| $crate::error::SecureEnvError::$err(Some(e.to_string()))); @@ -117,19 +125,22 @@ macro_rules! jni_new_object { jni_handle_error!($env, $err); obj - }}; + }} + }; } macro_rules! jni_find_class { - ($env:expr, $cls:ident, $err:ident) => {{ + ($env:expr, $cls:ident, $err:ident) => { + paste! {{ let cls = $env - .find_class(concat_idents!($cls, _CLS)) + .find_class([<$cls _CLS>]) .map_err(|e| $crate::error::SecureEnvError::$err(Some(e.to_string()))); jni_handle_error!($env, $err); cls - }}; + }} + }; } #[derive(Debug)] @@ -142,7 +153,7 @@ impl SecureEnvironmentOps for SecureEnvironment { .map_err(SecureEnvError::UnableToAttachJVMToThread)?; let ctx = ndk_context::android_context().context() as jni::sys::jobject; - if ctx.is_null() || !ctx.is_aligned() { + if ctx.is_null() { return Err(SecureEnvError::UnableToGenerateKey(Some( "Could not acquire context. Null, or unaligned pointer, was found".to_owned(), ))); diff --git a/src/lib.rs b/src/lib.rs index 2461ff2..0baa913 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(concat_idents, pointer_is_aligned)] - #[cfg(not(any(target_os = "android", target_os = "ios")))] compile_error!("Only Android and iOS are supported targets");