Given a hash and the hash length, returns C_OK if it is a valid password * hash, or C_ERR otherwise. */
| 180 | /* Given a hash and the hash length, returns C_OK if it is a valid password |
| 181 | * hash, or C_ERR otherwise. */ |
| 182 | int ACLCheckPasswordHash(unsigned char *hash, int hashlen) { |
| 183 | if (hashlen != HASH_PASSWORD_LEN) { |
| 184 | return C_ERR; |
| 185 | } |
| 186 | |
| 187 | /* Password hashes can only be characters that represent |
| 188 | * hexadecimal values, which are numbers and lowercase |
| 189 | * characters 'a' through 'f'. */ |
| 190 | for(int i = 0; i < HASH_PASSWORD_LEN; i++) { |
| 191 | char c = hash[i]; |
| 192 | if ((c < 'a' || c > 'f') && (c < '0' || c > '9')) { |
| 193 | return C_ERR; |
| 194 | } |
| 195 | } |
| 196 | return C_OK; |
| 197 | } |
| 198 | |
| 199 | /* ============================================================================= |
| 200 | * Low level ACL API |