Skip to content

Commit 0261045

Browse files
committed
class path variable
1 parent 6199a05 commit 0261045

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/tpm/android/knox/interface.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use robusta_jni::bridge;
22

3+
34
#[bridge]
45
pub mod jni {
56
#[allow(unused_imports)] //the bridge import is marked as unused, but if removed the compiler throws an error
@@ -19,6 +20,8 @@ pub mod jni {
1920

2021
use crate::SecurityModuleError;
2122

23+
const CLASS_SIGNATURE: &str = "com/example/vulcans_limes/RustDef";
24+
2225
/// Contains all methods related to Rust - Java communication and the JNI
2326
#[derive(Signature, TryIntoJavaValue, IntoJavaValue, TryFromJavaValue)]
2427
#[package(com.example.vulcans_1limes)] //the 1 after the "_" is an escape character for the "_"
@@ -27,6 +30,7 @@ pub mod jni {
2730
pub raw: AutoLocal<'env, 'borrow>,
2831
}
2932

33+
3034
/// This Implementation provides the method declarations that are the interface for the JNI.
3135
/// The first part contains Java-methods that can be called from Rust.
3236
/// The second part contains some utility methods.
@@ -63,7 +67,7 @@ pub mod jni {
6367
//This calls a method in Java in the Class RustDef, with the method name "callback"
6468
//and no arguments
6569
environment.call_static_method(
66-
"com/example/vulcans_limes/RustDef", //Class signature
70+
CLASS_SIGNATURE, //Class signature
6771
"callback", //method name signature
6872
"()V", //parameter types of the method
6973
&[], //parameters to be passed to the method
@@ -82,7 +86,7 @@ pub mod jni {
8286
pub fn create_key(environment: &JNIEnv, key_id: String, key_gen_info: String) -> Result<(), SecurityModuleError> {
8387
RustDef::initialize_module(environment)?;
8488
let result = environment.call_static_method(
85-
"com/example/vulcans_limes/RustDef",
89+
CLASS_SIGNATURE,
8690
"create_key",
8791
"(Ljava/lang/String;Ljava/lang/String;)V",
8892
&[JValue::from(environment.new_string(key_id).unwrap()),
@@ -121,7 +125,7 @@ pub mod jni {
121125
pub fn load_key(environment: &JNIEnv, key_id: String) -> Result<(), SecurityModuleError> {
122126
RustDef::initialize_module(environment)?;
123127
let result = environment.call_static_method(
124-
"com/example/vulcans_limes/RustDef",
128+
CLASS_SIGNATURE,
125129
"load_key",
126130
"(Ljava/lang/String;)V",
127131
&[JValue::from(environment.new_string(key_id).unwrap())],
@@ -165,7 +169,7 @@ pub mod jni {
165169
pub fn initialize_module(environment: &JNIEnv)
166170
-> Result<(), SecurityModuleError> {
167171
let result = environment.call_static_method(
168-
"com/example/vulcans_limes/RustDef",
172+
CLASS_SIGNATURE,
169173
"initialize_module",
170174
"()V",
171175
&[],
@@ -202,7 +206,7 @@ pub mod jni {
202206
/// or an `Error` on failure.
203207
pub fn sign_data(environment: &JNIEnv, data: &[u8]) -> Result<Vec<u8>, SecurityModuleError> {
204208
let result = environment.call_static_method(
205-
"com/example/vulcans_limes/RustDef",
209+
CLASS_SIGNATURE,
206210
"sign_data",
207211
"([B)[B",
208212
&[JValue::from(environment.byte_array_from_slice(data).unwrap())],
@@ -253,7 +257,7 @@ pub mod jni {
253257
/// or an `Error` on failure to determine the validity.
254258
pub fn verify_signature(environment: &JNIEnv, data: &[u8], signature: &[u8]) -> Result<bool, SecurityModuleError> {
255259
let result = environment.call_static_method(
256-
"com/example/vulcans_limes/RustDef",
260+
CLASS_SIGNATURE,
257261
"verify_signature",
258262
"([B[B)Z",
259263
&[JValue::from(environment.byte_array_from_slice(data).unwrap()),
@@ -303,7 +307,7 @@ pub mod jni {
303307
/// or an `Error` on failure.
304308
pub fn encrypt_data(environment: &JNIEnv, data: &[u8]) -> Result<Vec<u8>, SecurityModuleError> {
305309
let result = environment.call_static_method(
306-
"com/example/vulcans_limes/RustDef",
310+
CLASS_SIGNATURE,
307311
"encrypt_data",
308312
"([B)[B",
309313
&[JValue::from(environment.byte_array_from_slice(data).unwrap())],
@@ -354,7 +358,7 @@ pub mod jni {
354358
/// or an `Error` on failure.
355359
pub fn decrypt_data(environment: &JNIEnv, data: &[u8]) -> Result<Vec<u8>, SecurityModuleError> {
356360
let result = environment.call_static_method(
357-
"com/example/vulcans_limes/RustDef",
361+
CLASS_SIGNATURE,
358362
"decrypt_data",
359363
"([B)[B",
360364
&[JValue::from(environment.byte_array_from_slice(data).unwrap())],

0 commit comments

Comments
 (0)