Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and joonhaengHeo committed Feb 2, 2024
1 parent a122f03 commit 61b3225
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2157,26 +2157,30 @@ JNI_METHOD(jobject, computePaseVerifier)
return nullptr;
}

JNI_METHOD(jbyteArray, validateAndExtractCSR)(JNIEnv * env, jclass clazz, jbyteArray jCsrElements, jbyteArray jCsrNonce) {
JNI_METHOD(jbyteArray, validateAndExtractCSR)(JNIEnv * env, jclass clazz, jbyteArray jCsrElements, jbyteArray jCsrNonce)
{

chip::JniByteArray csrElements(env, jCsrElements);
chip::JniByteArray csrNonce(env, jCsrNonce);

chip::ByteSpan csrSpan;
chip::ByteSpan csrNonceSpan;
chip::ByteSpan vendor_reserved1, vendor_reserved2, vendor_reserved3;
CHIP_ERROR err = chip::Credentials::DeconstructNOCSRElements(
csrElements.byteSpan(), csrSpan, csrNonceSpan, vendor_reserved1, vendor_reserved2, vendor_reserved3);
CHIP_ERROR err = chip::Credentials::DeconstructNOCSRElements(csrElements.byteSpan(), csrSpan, csrNonceSpan, vendor_reserved1,
vendor_reserved2, vendor_reserved3);

VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogError(Controller, "CsrElement decoding error: %" CHIP_ERROR_FORMAT, err.Format()));
VerifyOrReturnValue(csrNonceSpan.size() == Controller::kCSRNonceLength, nullptr, ChipLogError(Controller, "csrNonce size is invalid"));
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogError(Controller, "CsrElement decoding error: %" CHIP_ERROR_FORMAT, err.Format()));
VerifyOrReturnValue(csrNonceSpan.size() == Controller::kCSRNonceLength, nullptr,
ChipLogError(Controller, "csrNonce size is invalid"));

// Verify that Nonce matches with what we sent
VerifyOrReturnValue(csrNonceSpan.data_equal(csrNonce.byteSpan()), nullptr, ChipLogError(Controller, "csrNonce is not matched!"));
VerifyOrReturnValue(csrNonceSpan.data_equal(csrNonce.byteSpan()), nullptr,
ChipLogError(Controller, "csrNonce is not matched!"));

jbyteArray javaCsr;
chip::JniReferences::GetInstance().N2J_ByteArray(chip::JniReferences::GetInstance().GetEnvForCurrentThread(), csrSpan.data(),
static_cast<jsize>(csrSpan.size()), javaCsr);
static_cast<jsize>(csrSpan.size()), javaCsr);
return javaCsr;
}

Expand Down

0 comments on commit 61b3225

Please sign in to comment.