Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/eli/pkcs5v2.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | for(i = 1; i < iterations; i++) { | ||||
g_eli_crypto_hmac(passphrase, passlen, md, sizeof(md), | g_eli_crypto_hmac(passphrase, passlen, md, sizeof(md), | ||||
md, 0); | md, 0); | ||||
xor(keyp, md, bsize); | xor(keyp, md, bsize); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
#ifndef _KERNEL | #ifndef _KERNEL | ||||
#ifndef _STAND | |||||
/* | /* | ||||
* Return the number of microseconds needed for 'interations' iterations. | * Return the number of microseconds needed for 'interations' iterations. | ||||
*/ | */ | ||||
static int | static int | ||||
pkcs5v2_probe(int iterations) | pkcs5v2_probe(int iterations) | ||||
{ | { | ||||
uint8_t key[G_ELI_USERKEYLEN], salt[G_ELI_SALTLEN]; | uint8_t key[G_ELI_USERKEYLEN], salt[G_ELI_SALTLEN]; | ||||
uint8_t passphrase[] = "passphrase"; | uint8_t passphrase[] = "passphrase"; | ||||
Show All 21 Lines | pkcs5v2_calculate(int usecs) | ||||
for (iterations = 1; ; iterations <<= 1) { | for (iterations = 1; ; iterations <<= 1) { | ||||
v = pkcs5v2_probe(iterations); | v = pkcs5v2_probe(iterations); | ||||
if (v > 2000000) | if (v > 2000000) | ||||
break; | break; | ||||
} | } | ||||
return (((intmax_t)iterations * (intmax_t)usecs) / v); | return (((intmax_t)iterations * (intmax_t)usecs) / v); | ||||
} | } | ||||
#endif /* !_STAND */ | |||||
#endif /* !_KERNEL */ | #endif /* !_KERNEL */ |