@@ -67,29 +67,34 @@ bool AccessManager<CRED_BIT_MASK>::ValidatePIN(const Optional<ByteSpan> &pinCode
67
67
68
68
/* Check the PIN code */
69
69
for (size_t index = 1 ; index <= CONFIG_LOCK_MAX_NUM_CREDENTIALS_PER_TYPE; ++index ) {
70
- if (CHIP_NO_ERROR == mCredentials .GetCredentials (CredentialTypeEnum::kPin , credential, index )) {
71
- if (credential.status == DlCredentialStatus::kAvailable ) {
72
- continue ;
73
- }
74
-
75
- if (credential.credentialData .data_equal (pinCode.Value ())) {
76
- uint32_t credentialUserId;
77
- if (GetCredentialUserId (index , CredentialTypeEnum::kPin , credentialUserId) ==
78
- CHIP_NO_ERROR) {
79
- result = ValidatePINResult{
80
- .userId = static_cast <uint16_t >(credentialUserId),
81
- .credential = LockOpCredentials{ CredentialTypeEnum::kPin ,
82
- static_cast <uint16_t >(index ) },
83
- };
84
- } else {
85
- result = {};
86
- }
87
-
88
- LOG_DBG (" Valid lock PIN code provided" );
89
- return true ;
90
- }
70
+ if (CHIP_NO_ERROR != mCredentials .GetCredentials (CredentialTypeEnum::kPin , credential, index )) {
71
+ err = OperationErrorEnum::kInvalidCredential ;
72
+ continue ;
91
73
}
92
- err = OperationErrorEnum::kInvalidCredential ;
74
+
75
+ if (credential.status == DlCredentialStatus::kAvailable ) {
76
+ continue ;
77
+ }
78
+
79
+ if (!credential.credentialData .data_equal (pinCode.Value ())) {
80
+ err = OperationErrorEnum::kInvalidCredential ;
81
+ continue ;
82
+ }
83
+
84
+ uint32_t credentialUserId;
85
+ if (GetCredentialUserId (index , CredentialTypeEnum::kPin , credentialUserId) == CHIP_NO_ERROR) {
86
+ result = ValidatePINResult{
87
+ .userId = static_cast <uint16_t >(credentialUserId),
88
+ .credential =
89
+ LockOpCredentials{ CredentialTypeEnum::kPin , static_cast <uint16_t >(index ) },
90
+ };
91
+ } else {
92
+ result = {};
93
+ }
94
+
95
+ LOG_DBG (" Valid lock PIN code provided" );
96
+ err = OperationErrorEnum::kUnspecified ;
97
+ return true ;
93
98
}
94
99
LOG_DBG (" Invalid lock PIN code provided" );
95
100
return false ;
0 commit comments