Exemplo n.º 1
0
BlowfishContext *bcrypt_setup(const unsigned char *key, int keybytes,
                              const unsigned char *salt, int saltbytes)
{
    int i;
    BlowfishContext *ctx;

    ctx = blowfish_make_context();
    blowfish_initkey(ctx);
    blowfish_expandkey(ctx, key, keybytes, salt, saltbytes);

    /* Original bcrypt replaces this fixed loop count with the
     * variable cost. OpenSSH instead iterates the whole thing more
     * than once if it wants extra rounds. */
    for (i = 0; i < 64; i++) {
        blowfish_expandkey(ctx, salt, saltbytes, NULL, 0);
        blowfish_expandkey(ctx, key, keybytes, NULL, 0);
    }

    return ctx;
}
Exemplo n.º 2
0
static void blowfish_setkey(BlowfishContext *ctx,
                            const unsigned char *key, short keybytes)
{
    blowfish_initkey(ctx);
    blowfish_expandkey(ctx, key, keybytes, NULL, 0);
}