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 213070 2010-09-23 11:58:36Z 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 and AES-XTS support. |
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("null-cbc", name) == 0) 298 return (CRYPTO_NULL_CBC); |
299 else if (strcasecmp("aes", name) == 0) |
300 return (CRYPTO_AES_XTS); 301 else if (strcasecmp("aes-cbc", name) == 0) |
302 return (CRYPTO_AES_CBC); |
303 else if (strcasecmp("aes-xts", name) == 0) 304 return (CRYPTO_AES_XTS); |
305 else if (strcasecmp("blowfish", name) == 0) 306 return (CRYPTO_BLF_CBC); |
307 else if (strcasecmp("blowfish-cbc", name) == 0) 308 return (CRYPTO_BLF_CBC); |
309 else if (strcasecmp("camellia", name) == 0) 310 return (CRYPTO_CAMELLIA_CBC); |
311 else if (strcasecmp("camellia-cbc", name) == 0) 312 return (CRYPTO_CAMELLIA_CBC); |
313 else if (strcasecmp("3des", name) == 0) 314 return (CRYPTO_3DES_CBC); |
315 else if (strcasecmp("3des-cbc", name) == 0) 316 return (CRYPTO_3DES_CBC); |
317 return (CRYPTO_ALGORITHM_MIN - 1); 318} 319 320static __inline u_int 321g_eli_str2aalgo(const char *name) 322{ 323 324 if (strcasecmp("hmac/md5", name) == 0) --- 15 unchanged lines hidden (view full) --- 340g_eli_algo2str(u_int algo) 341{ 342 343 switch (algo) { 344 case CRYPTO_NULL_CBC: 345 return ("NULL"); 346 case CRYPTO_AES_CBC: 347 return ("AES-CBC"); |
348 case CRYPTO_AES_XTS: 349 return ("AES-XTS"); |
350 case CRYPTO_BLF_CBC: 351 return ("Blowfish-CBC"); 352 case CRYPTO_CAMELLIA_CBC: 353 return ("CAMELLIA-CBC"); 354 case CRYPTO_3DES_CBC: 355 return ("3DES-CBC"); 356 case CRYPTO_MD5_HMAC: 357 return ("HMAC/MD5"); --- 69 unchanged lines hidden (view full) --- 427 return (128); 428 case 128: 429 case 192: 430 case 256: 431 return (keylen); 432 default: 433 return (0); 434 } |
435 case CRYPTO_AES_XTS: 436 switch (keylen) { 437 case 0: 438 return (128); 439 case 128: 440 case 256: 441 return (keylen); 442 default: 443 return (0); 444 } |
445 case CRYPTO_BLF_CBC: 446 if (keylen == 0) 447 return (128); 448 if (keylen < 128 || keylen > 448) 449 return (0); 450 if ((keylen % 32) != 0) 451 return (0); 452 return (keylen); --- 82 unchanged lines hidden --- |