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

Fix broken PaseVerifier codepath and add test #20969

Merged
merged 3 commits into from
Jul 20, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.google.chip.chiptool;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import android.content.Context;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import chip.devicecontroller.ChipDeviceController;
import chip.devicecontroller.PaseVerifierParams;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class CHIPDeviceControllerTest {
@Test
public void PaseVerifierTest() {
long deviceId = 123L;
long setupPincode = 808080L;
long iterations = 1000L;
byte[] randomSalt = "hEvzbU:%h)?aB,h7+9fn[Lf[BhYB!=TA".getBytes();

Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
ChipDeviceController chipDeviceController = ChipClient.INSTANCE.getDeviceController(appContext);

PaseVerifierParams params =
chipDeviceController.computePaseVerifier(deviceId, setupPincode, iterations, randomSalt);

assertNotNull(params);
assertEquals(params.getSetupPincode(), setupPincode);
assertNotNull(params.getPakeVerifier());
}
}
1 change: 1 addition & 0 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
initParams.bleLayer = DeviceLayer::ConnectivityMgr().GetBleLayer();
#endif
initParams.listenPort = listenPort;
setupParams.controllerVendorId = VendorId::NotSpecified;
setupParams.pairingDelegate = wrapper.get();
setupParams.operationalCredentialsDelegate = opCredsIssuer;
initParams.fabricIndependentStorage = wrapperStorage;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ CHIP_ERROR N2J_PaseVerifierParams(JNIEnv * env, jlong setupPincode, jbyteArray p
SuccessOrExit(err);

env->ExceptionClear();
constructor = env->GetMethodID(paramsClass, "<init>", "(JI[B)V");
constructor = env->GetMethodID(paramsClass, "<init>", "(J[B)V");
VerifyOrExit(constructor != nullptr, err = CHIP_JNI_ERROR_METHOD_NOT_FOUND);

outParams = (jobject) env->NewObject(paramsClass, constructor, setupPincode, paseVerifier);
Expand Down