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