Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix build by changing computePaseVerifier to take device pointer #10672

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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