diff --git a/src/controller/CHIPDevice.h b/src/controller/CHIPDevice.h index 85f7803fd8cb02..4e7301e14b5f54 100644 --- a/src/controller/CHIPDevice.h +++ b/src/controller/CHIPDevice.h @@ -309,8 +309,6 @@ class DLL_EXPORT Device : public Messaging::ExchangeDelegate, public SessionEsta void SetActive(bool active) { mActive = active; } - bool IsCSRNonceProvided() const {return mCSRNonceProvided; } - bool IsSecureConnected() const { return IsActive() && mState == ConnectionState::SecureConnected; } void Reset(); @@ -353,9 +351,15 @@ class DLL_EXPORT Device : public Messaging::ExchangeDelegate, public SessionEsta CHIP_ERROR SetCSRNonce(ByteSpan csrNonce) { - memcpy(mCSRNonce, csrNonce.data(), csrNonce.size()); - mCSRNonceProvided = true; - return CHIP_NO_ERROR; + if(csrNonce.size() == sizeof(mCSRNonce)) + { + memcpy(mCSRNonce, csrNonce.data(), csrNonce.size()); + mCSRNonceProvided = true; + return CHIP_NO_ERROR; + } + else { + return CHIP_ERROR_INCORRECT_STATE; + } } ByteSpan GetCSRNonce() const { return ByteSpan(mCSRNonce, sizeof(mCSRNonce)); } diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index da23a38fad6f93..3462e6236de116 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -150,6 +150,7 @@ void AndroidDeviceControllerWrapper::OnPairingDeleted(CHIP_ERROR error) CallJavaMethod("onPairingDeleted", static_cast(error)); } + // TODO Refactor this API to match latest spec, so that GenerateNodeOperationalCertificate receives the full CSR Elements data payload. CHIP_ERROR AndroidDeviceControllerWrapper::GenerateNodeOperationalCertificate(const chip::PeerId & peerId, const chip::ByteSpan & csr, int64_t serialNumber, uint8_t * certBuf, uint32_t certBufSize, uint32_t & outCertLen) diff --git a/src/controller/java/JniReferences.cpp b/src/controller/java/JniReferences.cpp index 6ab7082f094cdb..e3768f7977d2a6 100644 --- a/src/controller/java/JniReferences.cpp +++ b/src/controller/java/JniReferences.cpp @@ -83,7 +83,7 @@ CHIP_ERROR N2J_ByteArray(JNIEnv * env, const uint8_t * inArray, uint32_t inArray CHIP_ERROR err = CHIP_NO_ERROR; outArray = env->NewByteArray((int) inArrayLen); - VerifyOrExit(outArray != NULL, err = CHIP_ERROR_NO_MEMORY); + VerifyOrReturnError(outArray != NULL, CHIP_ERROR_NO_MEMORY); env->ExceptionClear(); env->SetByteArrayRegion(outArray, 0, inArrayLen, (jbyte *) inArray);