Skip to content

Commit

Permalink
[Android] Fix build by changing computePaseVerifier to take device po…
Browse files Browse the repository at this point in the history
…inter (#10672)

* Change computePaseVerifier to take device pointer

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
austinh0 and restyled-commits authored Oct 20, 2021
1 parent 4efc582 commit d68adb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,22 +442,23 @@ JNI_METHOD(void, deleteDeviceController)(JNIEnv * env, jobject self, jlong handl
}

JNI_METHOD(jobject, computePaseVerifier)
(JNIEnv * env, jobject self, jlong handle, jlong deviceId, jlong setupPincode, jint iterations, jbyteArray salt)
(JNIEnv * env, jobject self, jlong handle, jlong devicePtr, jlong setupPincode, jint iterations, jbyteArray salt)
{
chip::DeviceLayer::StackLock lock;
Device * chipDevice = nullptr;

ChipLogProgress(Controller, "computePaseVerifier() called");
GetCHIPDevice(env, handle, deviceId, &chipDevice);

CHIP_ERROR err = CHIP_NO_ERROR;
Device * chipDevice = nullptr;
CHIP_ERROR err = CHIP_NO_ERROR;
jobject params;
jbyteArray verifierBytes;
uint32_t passcodeId;
PASEVerifier verifier;

JniByteArray jniSalt(env, salt);

ChipLogProgress(Controller, "computePaseVerifier() called");

chipDevice = reinterpret_cast<Device *>(devicePtr);
VerifyOrExit(chipDevice != nullptr, err = CHIP_ERROR_INCORRECT_STATE);

err = chipDevice->ComputePASEVerifier(iterations, setupPincode, jniSalt.byteSpan(), verifier, passcodeId);
SuccessOrExit(err);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,18 @@ public boolean isActive(long deviceId) {
/**
* Generates a new PASE verifier and passcode ID for the given setup PIN code.
*
* @param deviceId the ID of the device for which to generate the PASE verifier
* @param devicePtr a pointer to the device object for which to generate the PASE verifier
* @param setupPincode the PIN code to use
* @param iterations the number of iterations for computing the verifier
* @param salt the 16-byte salt
*/
public PaseVerifierParams computePaseVerifier(
long deviceId, long setupPincode, int iterations, byte[] salt) {
return computePaseVerifier(deviceControllerPtr, deviceId, setupPincode, iterations, salt);
long devicePtr, long setupPincode, int iterations, byte[] salt) {
return computePaseVerifier(deviceControllerPtr, devicePtr, setupPincode, iterations, salt);
}

private native PaseVerifierParams computePaseVerifier(
long deviceControllerPtr, long deviceId, long setupPincode, int iterations, byte[] salt);
long deviceControllerPtr, long devicePtr, long setupPincode, int iterations, byte[] salt);

private native long newDeviceController();

Expand Down

0 comments on commit d68adb5

Please sign in to comment.