salted_sha_pw_enc() provides this much space for the hash value: char hash[ MAX_SHA_HASH_SIZE + SHA_SALT_LENGTH ]; that is, it wants hash to contain the hashed value + the salt. But when it actually generates the hash /* hash the user's key */ if ( sha_salted_hash( hash, pwd, &saltval, secOID ) != SECSuccess ) { return( NULL ); } the length of hash is always the length the hash algorithm produces - SHA1_LENGTH, SHA256_LENGTH, etc. - even though salt is passed in, and added to the hash value, it is not appended to the hash. salted_sha_pw_enc() allocates space for the password hash plus the salt if (( enc = slapi_ch_malloc( 3 + schemeNameLen + LDIF_BASE64_LEN(shaLen + SHA_SALT_LENGTH))) == NULL ) { return( NULL ); } however, it never actually writes the salt value into enc - it only writes the first shaLen bytes from hash, plus SHA_SALT_LENGTH bytes of garbage. I think the assumption was that calling sha_salted_hash() would append the salt value to the end of hash, but this is not done. I think the fix is to have sha_salted_hash() do something like this, after generating the hash: memcpy(hash_out + outLen, salt.bv_val, salt.bv_len);
never mind