MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ACLCheckPasswordHash

Function ACLCheckPasswordHash

src/acl.cpp:182–197  ·  view source on GitHub ↗

Given a hash and the hash length, returns C_OK if it is a valid password * hash, or C_ERR otherwise. */

Source from the content-addressed store, hash-verified

180/* Given a hash and the hash length, returns C_OK if it is a valid password
181 * hash, or C_ERR otherwise. */
182int 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

Callers 1

ACLSetUserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected