Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
RitikaNanda committed Jun 22, 2021
1 parent 66ce627 commit 2955ad9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/controller/CHIPDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)); }
Expand Down
1 change: 1 addition & 0 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void AndroidDeviceControllerWrapper::OnPairingDeleted(CHIP_ERROR error)
CallJavaMethod("onPairingDeleted", static_cast<jint>(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)
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/JniReferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2955ad9

Please sign in to comment.