Deleted Added
full compact
pkcs5v2.c (155174) pkcs5v2.c (293306)
1/*-
2 * Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/geom/eli/pkcs5v2.c 155174 2006-02-01 12:06:01Z pjd $");
28__FBSDID("$FreeBSD: head/sys/geom/eli/pkcs5v2.c 293306 2016-01-07 05:47:34Z allanjude $");
29
30#include <sys/param.h>
31#ifdef _KERNEL
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#else
35#include <sys/resource.h>
36#include <stdint.h>

--- 41 unchanged lines hidden (view full) ---

78 g_eli_crypto_hmac(passphrase, passlen, md, sizeof(md),
79 md, 0);
80 xor(keyp, md, bsize);
81 }
82 }
83}
84
85#ifndef _KERNEL
29
30#include <sys/param.h>
31#ifdef _KERNEL
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#else
35#include <sys/resource.h>
36#include <stdint.h>

--- 41 unchanged lines hidden (view full) ---

78 g_eli_crypto_hmac(passphrase, passlen, md, sizeof(md),
79 md, 0);
80 xor(keyp, md, bsize);
81 }
82 }
83}
84
85#ifndef _KERNEL
86#ifndef _STAND
86/*
87 * Return the number of microseconds needed for 'interations' iterations.
88 */
89static int
90pkcs5v2_probe(int iterations)
91{
92 uint8_t key[G_ELI_USERKEYLEN], salt[G_ELI_SALTLEN];
93 uint8_t passphrase[] = "passphrase";

--- 21 unchanged lines hidden (view full) ---

115
116 for (iterations = 1; ; iterations <<= 1) {
117 v = pkcs5v2_probe(iterations);
118 if (v > 2000000)
119 break;
120 }
121 return (((intmax_t)iterations * (intmax_t)usecs) / v);
122}
87/*
88 * Return the number of microseconds needed for 'interations' iterations.
89 */
90static int
91pkcs5v2_probe(int iterations)
92{
93 uint8_t key[G_ELI_USERKEYLEN], salt[G_ELI_SALTLEN];
94 uint8_t passphrase[] = "passphrase";

--- 21 unchanged lines hidden (view full) ---

116
117 for (iterations = 1; ; iterations <<= 1) {
118 v = pkcs5v2_probe(iterations);
119 if (v > 2000000)
120 break;
121 }
122 return (((intmax_t)iterations * (intmax_t)usecs) / v);
123}
124#endif /* !_STAND */
123#endif /* !_KERNEL */
125#endif /* !_KERNEL */