pike.git / lib / modules / Crypto.pmod / Password.pmod

version» Context lines:

pike.git/lib/modules/Crypto.pmod/Password.pmod:144:    if ((hash == "") || crypt(password, hash)) return 1;    if (hash[0] != '$') {    if (hash[0] == '_') {    // FIXME: BSDI-style crypt(3C).    }    return 0;    }       // Then try our implementations.    sscanf(hash, "$%s$%s$%s", scheme, string salt, string hash); +  if( !salt || !hash ) return 0;    int rounds = UNDEFINED;    if (has_prefix(salt, "rounds=")) {    sscanf(salt, "rounds=%d", rounds);    sscanf(hash, "%s$%s", salt, hash);    }    switch(scheme) {    case "1": // crypt_md5    return Nettle.crypt_md5(password, salt) == [string(0..255)]hash;       case "2": // Blowfish (obsolete)    case "2a": // Blowfish (possibly weak)    case "2x": // Blowfish (weak)    case "2y": // Blowfish (stronger)    break;       case "3": // MD4 NT LANMANAGER (FreeBSD)    break;    - #if constant(Nettle.SHA256_Info) +     // cf http://www.akkadia.org/drepper/SHA-crypt.txt    case "5": // SHA-256    return Crypto.SHA256.crypt_hash(password, salt, rounds) ==    [string(0..255)]hash; - #endif +    #if constant(Nettle.SHA512_Info)    case "6": // SHA-512    return Crypto.SHA512.crypt_hash(password, salt, rounds) ==    [string(0..255)]hash;   #endif    }    break;    }    return 0;   }
pike.git/lib/modules/Crypto.pmod/Password.pmod:294:    case "{crypt}":    case UNDEFINED:    // FALL_THROUGH   #if constant(Nettle.SHA512_Info)    case "6":    case "$6$":    crypt_hash = Crypto.SHA512.crypt_hash;    scheme = "6";    break;   #endif - #if constant(Nettle.SHA256_Info) +     case "5":    case "$5$":    crypt_hash = Crypto.SHA256.crypt_hash;    scheme = "5";    break; - #endif +     case "1":    case "$1$":    crypt_hash = Crypto.MD5.crypt_hash;    salt_size = 8;    rounds = 1000; // Currently only 1000 rounds is supported.    default_rounds = 1000;    scheme = "1";    break;    case "":    return crypt(password);