Skip to content

Commit

Permalink
Return CHIP_ERROR_INVALID_IPK when providing the invalid IPK from and…
Browse files Browse the repository at this point in the history
…roid application
  • Loading branch information
yunhanw-google committed Jan 17, 2024
1 parent 87e6da0 commit a52f491
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ JNI_METHOD(jint, onNOCChainGeneration)
{
JniByteArray jByteArrayIpk(env, ipk);

VerifyOrReturnValue(jByteArrayIpk.byteSpan().size() == sizeof(ipkValue), CHIP_ERROR_INTERNAL.AsInteger());
if (jByteArrayIpk.byteSpan().size() != sizeof(ipkValue))
{
ChipLogError(Controller, "Invalid IPK size %ld and expect %ld", jByteArrayIpk.byteSpan().size(), sizeof(ipkValue));
return CHIP_ERROR_INVALID_IPK.AsInteger();
}
memcpy(&ipkValue[0], jByteArrayIpk.byteSpan().data(), jByteArrayIpk.byteSpan().size());

ipkOptional.SetValue(ipkTempSpan);
Expand Down
3 changes: 3 additions & 0 deletions src/lib/core/CHIPError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
case CHIP_ERROR_UNINITIALIZED.AsInteger():
desc = "Uninitialized";
break;
case CHIP_ERROR_INVALID_IPK.AsInteger():
desc = "Invalid IPK";
break;
case CHIP_ERROR_INVALID_STRING_LENGTH.AsInteger():
desc = "Invalid string length";
break;
Expand Down
9 changes: 8 additions & 1 deletion src/lib/core/CHIPError.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,14 @@ using CHIP_ERROR = ::chip::ChipError;
*/
#define CHIP_ERROR_UNINITIALIZED CHIP_CORE_ERROR(0x1c)

// AVAILABLE: 0x1d
/**
* @def CHIP_ERROR_INVALID_IPK
*
* @brief
* The IPK is invalid
*
*/
#define CHIP_ERROR_INVALID_IPK CHIP_CORE_ERROR(0x1d)

/**
* @def CHIP_ERROR_INVALID_STRING_LENGTH
Expand Down

0 comments on commit a52f491

Please sign in to comment.