Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/eli/pkcs5v2.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
for (; size > 0; size--) | for (; size > 0; size--) | ||||
*dst++ ^= *src++; | *dst++ ^= *src++; | ||||
} | } | ||||
void | void | ||||
pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt, | pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt, | ||||
size_t saltsize, const char *passphrase, u_int iterations) | size_t saltsize, const char passphrase[], u_int iterations) | ||||
{ | { | ||||
uint8_t md[SHA512_MDLEN], saltcount[saltsize + sizeof(uint32_t)]; | uint8_t md[SHA512_MDLEN], saltcount[saltsize + sizeof(uint32_t)]; | ||||
uint8_t *counter, *keyp; | uint8_t *counter, *keyp; | ||||
u_int i, bsize, passlen; | u_int i, bsize, passlen; | ||||
uint32_t count; | uint32_t count; | ||||
struct hmac_ctx startpoint, ctx; | struct hmac_ctx startpoint, ctx; | ||||
passlen = strlen(passphrase); | passlen = strlen(passphrase); | ||||
Show All 28 Lines | |||||
#ifndef _STAND | #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"; | const char passphrase[] = "passphrase"; | ||||
struct rusage start, end; | struct rusage start, end; | ||||
int usecs; | int usecs; | ||||
getrusage(RUSAGE_SELF, &start); | getrusage(RUSAGE_SELF, &start); | ||||
pkcs5v2_genkey(key, sizeof(key), salt, sizeof(salt), passphrase, | pkcs5v2_genkey(key, sizeof(key), salt, sizeof(salt), passphrase, | ||||
iterations); | iterations); | ||||
getrusage(RUSAGE_SELF, &end); | getrusage(RUSAGE_SELF, &end); | ||||
Show All 23 Lines |