Bug 509030 - salted password encoding writes garbage to salt part
Summary: salted password encoding writes garbage to salt part
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: 389
Classification: Retired
Component: Security - Password Policy
Version: 1.2.1
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Rich Megginson
QA Contact: Chandrasekar Kannan
URL:
Whiteboard:
Depends On:
Blocks: 434915 389_1.3.0
TreeView+ depends on / blocked
 
Reported: 2009-06-30 22:34 UTC by Rich Megginson
Modified: 2015-01-04 23:39 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-06-30 23:29:48 UTC
Embargoed:


Attachments (Terms of Use)

Description Rich Megginson 2009-06-30 22:34:42 UTC
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);

Comment 1 Rich Megginson 2009-06-30 23:29:48 UTC
never mind


Note You need to log in before you can comment on or make changes to this bug.