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

[Android]Return CHIP_ERROR_INVALID_IPK when providing the invalid IPK from and… #31491

Merged
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
1 change: 1 addition & 0 deletions docs/ERROR_CODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This file was **AUTOMATICALLY** generated by
| 26 | 0x1A | `CHIP_ERROR_DUPLICATE_KEY_ID` |
| 27 | 0x1B | `CHIP_ERROR_WRONG_KEY_TYPE` |
| 28 | 0x1C | `CHIP_ERROR_UNINITIALIZED` |
| 29 | 0x1D | `CHIP_ERROR_INVALID_IPK` |
| 30 | 0x1E | `CHIP_ERROR_INVALID_STRING_LENGTH` |
| 31 | 0x1F | `CHIP_ERROR_INVALID_LIST_LENGTH` |
| 33 | 0x21 | `CHIP_ERROR_END_OF_TLV` |
Expand Down
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
Loading