diff options
author | Sven Gothel <[email protected]> | 2021-10-29 05:34:55 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-10-29 05:34:55 +0200 |
commit | 30f1f01c1ff567ecf7c24142a1ec8eff9bd7031c (patch) | |
tree | 3b2513b42011c0e8808238eff99f34ee8009e516 /java/jni | |
parent | b01c83eb0102fc81fa03e0cef8adbfbf1bd432b9 (diff) |
Move SMPKeyBin 'apply' to BTDevice, splitting functionality: setting + uploading keys (required for peripheral BTAdapter key management)
SMPKeyBin has the key apply action revoked.
SMPKeyBin is reduced to store keys, address and security settings,
as well adding persistence (read/write to filesystem).
BTDevice::setSMPKeyBin(SMPKeyBin&) shall be used copy the key data over
and BTDevice::uploadKeys() to upload them to the adapter for pre-pairing.
See dbt_scanner10.cpp's use of convenient API (same efficiency as before)
device->uploadKeys(KEY_PATH, req_sec_level, true /* verbose_ */);
BTDevice::setSMPKeyBin(SMPKeyBin&) fully restored BTDevice's PairingData
- keys
- key caps
- user security level and IOCaps
+++
The reduced 'set<Name>Key(..)' methods only
- copy the key to BTDevice's PairingData
- set the KeyType bit for keys_<role>_[init|resp], fully restoring key caps
Diffstat (limited to 'java/jni')
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index f53fba07..73d26a2d 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -477,7 +477,19 @@ jbyte Java_jau_direct_1bt_DBTDevice_getAvailableSMPKeysImpl(JNIEnv *env, jobject BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - return number( device->getAvailableSMPKeys(JNI_TRUE == responder) ); // assign data of new key copy to JNI critical-array + return number( device->getAvailableSMPKeys(JNI_TRUE == responder) ); + } catch(...) { + rethrow_and_raise_java_exception(env); + } + return 0; +} + +jbyte Java_jau_direct_1bt_DBTDevice_uploadKeysImpl(JNIEnv *env, jobject obj) { + try { + BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); + JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); + + return number( device->uploadKeys() ); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -508,7 +520,7 @@ void Java_jau_direct_1bt_DBTDevice_getLongTermKeyImpl(JNIEnv *env, jobject obj, } } -jbyte Java_jau_direct_1bt_DBTDevice_setLongTermKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { +void Java_jau_direct_1bt_DBTDevice_setLongTermKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); @@ -527,12 +539,10 @@ jbyte Java_jau_direct_1bt_DBTDevice_setLongTermKeyImpl(JNIEnv *env, jobject obj, } const SMPLongTermKey& ltk = *reinterpret_cast<SMPLongTermKey *>(source_ptr); - const HCIStatusCode res = device->setLongTermKey(ltk); - return (jbyte) number(res); + device->setLongTermKey(ltk); } catch(...) { rethrow_and_raise_java_exception(env); } - return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE); } void Java_jau_direct_1bt_DBTDevice_getIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { @@ -559,7 +569,7 @@ void Java_jau_direct_1bt_DBTDevice_getIdentityResolvingKeyImpl(JNIEnv *env, jobj } } -jbyte Java_jau_direct_1bt_DBTDevice_setIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { +void Java_jau_direct_1bt_DBTDevice_setIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); @@ -578,12 +588,10 @@ jbyte Java_jau_direct_1bt_DBTDevice_setIdentityResolvingKeyImpl(JNIEnv *env, job } const SMPIdentityResolvingKey& irk = *reinterpret_cast<SMPIdentityResolvingKey *>(source_ptr); - const HCIStatusCode res = device->setIdentityResolvingKey(irk); - return (jbyte) number(res); + device->setIdentityResolvingKey(irk); } catch(...) { rethrow_and_raise_java_exception(env); } - return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE); } void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { @@ -610,7 +618,7 @@ void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyImpl(JNIEnv *env, job } } -jbyte Java_jau_direct_1bt_DBTDevice_setSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { +void Java_jau_direct_1bt_DBTDevice_setSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); @@ -629,12 +637,10 @@ jbyte Java_jau_direct_1bt_DBTDevice_setSignatureResolvingKeyImpl(JNIEnv *env, jo } const SMPSignatureResolvingKey& irk = *reinterpret_cast<SMPSignatureResolvingKey *>(source_ptr); - const HCIStatusCode res = device->setSignatureResolvingKey(irk); - return (jbyte) number(res); + device->setSignatureResolvingKey(irk); } catch(...) { rethrow_and_raise_java_exception(env); } - return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE); } void Java_jau_direct_1bt_DBTDevice_getLinkKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { @@ -661,7 +667,7 @@ void Java_jau_direct_1bt_DBTDevice_getLinkKeyImpl(JNIEnv *env, jobject obj, jboo } } -jbyte Java_jau_direct_1bt_DBTDevice_setLinkKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { +void Java_jau_direct_1bt_DBTDevice_setLinkKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); @@ -680,12 +686,10 @@ jbyte Java_jau_direct_1bt_DBTDevice_setLinkKeyImpl(JNIEnv *env, jobject obj, jby } const SMPLinkKey& lk = *reinterpret_cast<SMPLinkKey *>(source_ptr); - const HCIStatusCode res = device->setLinkKey(lk); - return (jbyte) number(res); + device->setLinkKey(lk); } catch(...) { rethrow_and_raise_java_exception(env); } - return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE); } jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj) { |