1/*-
2 * Copyright (c) 2005-2006 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
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/sys/geom/eli/g_eli.h 213067 2010-09-23 11:49:47Z pjd $
27 */
28
29#ifndef _G_ELI_H_
30#define _G_ELI_H_
31
32#include <sys/endian.h>
33#include <sys/errno.h>
34#include <sys/malloc.h>
--- 20 unchanged lines hidden (view full) ---
55 * Version history:
56 * 0 - Initial version number.
57 * 1 - Added data authentication support (md_aalgo field and
58 * G_ELI_FLAG_AUTH flag).
59 * 2 - Added G_ELI_FLAG_READONLY.
60 * 3 - Added 'configure' subcommand.
61 * 4 - IV is generated from offset converted to little-endian
62 * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions).
63 * 5 - Added multiple encrypton keys.
64 */
65#define G_ELI_VERSION 5
66
67/* ON DISK FLAGS. */
68/* Use random, onetime keys. */
69#define G_ELI_FLAG_ONETIME 0x00000001
70/* Ask for the passphrase from the kernel, before mounting root. */
71#define G_ELI_FLAG_BOOT 0x00000002
--- 217 unchanged lines hidden (view full) ---
289#endif /* !_OpenSSL */
290
291static __inline u_int
292g_eli_str2ealgo(const char *name)
293{
294
295 if (strcasecmp("null", name) == 0)
296 return (CRYPTO_NULL_CBC);
297 else if (strcasecmp("aes", name) == 0)
298 return (CRYPTO_AES_CBC);
299 else if (strcasecmp("blowfish", name) == 0)
300 return (CRYPTO_BLF_CBC);
301 else if (strcasecmp("camellia", name) == 0)
302 return (CRYPTO_CAMELLIA_CBC);
303 else if (strcasecmp("3des", name) == 0)
304 return (CRYPTO_3DES_CBC);
305 return (CRYPTO_ALGORITHM_MIN - 1);
306}
307
308static __inline u_int
309g_eli_str2aalgo(const char *name)
310{
311
312 if (strcasecmp("hmac/md5", name) == 0)
--- 15 unchanged lines hidden (view full) ---
328g_eli_algo2str(u_int algo)
329{
330
331 switch (algo) {
332 case CRYPTO_NULL_CBC:
333 return ("NULL");
334 case CRYPTO_AES_CBC:
335 return ("AES-CBC");
336 case CRYPTO_BLF_CBC:
337 return ("Blowfish-CBC");
338 case CRYPTO_CAMELLIA_CBC:
339 return ("CAMELLIA-CBC");
340 case CRYPTO_3DES_CBC:
341 return ("3DES-CBC");
342 case CRYPTO_MD5_HMAC:
343 return ("HMAC/MD5");
--- 69 unchanged lines hidden (view full) ---
413 return (128);
414 case 128:
415 case 192:
416 case 256:
417 return (keylen);
418 default:
419 return (0);
420 }
421 case CRYPTO_BLF_CBC:
422 if (keylen == 0)
423 return (128);
424 if (keylen < 128 || keylen > 448)
425 return (0);
426 if ((keylen % 32) != 0)
427 return (0);
428 return (keylen);
--- 82 unchanged lines hidden ---
2 * Copyright (c) 2005-2006 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
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/sys/geom/eli/g_eli.h 213067 2010-09-23 11:49:47Z pjd $
27 */
28
29#ifndef _G_ELI_H_
30#define _G_ELI_H_
31
32#include <sys/endian.h>
33#include <sys/errno.h>
34#include <sys/malloc.h>
--- 20 unchanged lines hidden (view full) ---
55 * Version history:
56 * 0 - Initial version number.
57 * 1 - Added data authentication support (md_aalgo field and
58 * G_ELI_FLAG_AUTH flag).
59 * 2 - Added G_ELI_FLAG_READONLY.
60 * 3 - Added 'configure' subcommand.
61 * 4 - IV is generated from offset converted to little-endian
62 * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions).
63 * 5 - Added multiple encrypton keys.
64 */
65#define G_ELI_VERSION 5
66
67/* ON DISK FLAGS. */
68/* Use random, onetime keys. */
69#define G_ELI_FLAG_ONETIME 0x00000001
70/* Ask for the passphrase from the kernel, before mounting root. */
71#define G_ELI_FLAG_BOOT 0x00000002
--- 217 unchanged lines hidden (view full) ---
289#endif /* !_OpenSSL */
290
291static __inline u_int
292g_eli_str2ealgo(const char *name)
293{
294
295 if (strcasecmp("null", name) == 0)
296 return (CRYPTO_NULL_CBC);
297 else if (strcasecmp("aes", name) == 0)
298 return (CRYPTO_AES_CBC);
299 else if (strcasecmp("blowfish", name) == 0)
300 return (CRYPTO_BLF_CBC);
301 else if (strcasecmp("camellia", name) == 0)
302 return (CRYPTO_CAMELLIA_CBC);
303 else if (strcasecmp("3des", name) == 0)
304 return (CRYPTO_3DES_CBC);
305 return (CRYPTO_ALGORITHM_MIN - 1);
306}
307
308static __inline u_int
309g_eli_str2aalgo(const char *name)
310{
311
312 if (strcasecmp("hmac/md5", name) == 0)
--- 15 unchanged lines hidden (view full) ---
328g_eli_algo2str(u_int algo)
329{
330
331 switch (algo) {
332 case CRYPTO_NULL_CBC:
333 return ("NULL");
334 case CRYPTO_AES_CBC:
335 return ("AES-CBC");
336 case CRYPTO_BLF_CBC:
337 return ("Blowfish-CBC");
338 case CRYPTO_CAMELLIA_CBC:
339 return ("CAMELLIA-CBC");
340 case CRYPTO_3DES_CBC:
341 return ("3DES-CBC");
342 case CRYPTO_MD5_HMAC:
343 return ("HMAC/MD5");
--- 69 unchanged lines hidden (view full) ---
413 return (128);
414 case 128:
415 case 192:
416 case 256:
417 return (keylen);
418 default:
419 return (0);
420 }
421 case CRYPTO_BLF_CBC:
422 if (keylen == 0)
423 return (128);
424 if (keylen < 128 || keylen > 448)
425 return (0);
426 if ((keylen % 32) != 0)
427 return (0);
428 return (keylen);
--- 82 unchanged lines hidden ---