Date: Sat, 13 Jul 2013 17:47:22 GMT From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254759 - in soc2013/def/crashdump-head/sys: kern sys Message-ID: <201307131747.r6DHlMdJ051183@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: def Date: Sat Jul 13 17:47:22 2013 New Revision: 254759 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254759 Log: Change the dumperinfo structure to store a key, a tweak and their context. Modify kerneldump_crypto_init to set context and mkdumpheader to write data in the new format. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Jul 13 17:42:51 2013 (r254758) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Jul 13 17:47:22 2013 (r254759) @@ -86,7 +86,7 @@ #include <sys/signalvar.h> -#include <crypto/rijndael/rijndael-api-fst.h> +#include <crypto/xts.h> #ifndef PANIC_REBOOT_WAIT_TIME #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ @@ -145,8 +145,8 @@ int dumping; /* system is dumping */ int rebooting; /* system is rebooting */ static struct dumperinfo dumper; /* our selected dumper */ -keyInstance dumper_key; -cipherInstance dumper_cipher; +static rijndael_ctx dumper_tweak_ctx; +static rijndael_ctx dumper_data_ctx; /* Context information for dump-debuggers. */ static struct pcb dumppcb; /* Registers. */ @@ -852,8 +852,6 @@ return (EBUSY); dumper = *di; - dumper.key = &dumper_key; - dumper.cipher = &dumper_cipher; kerneldump_crypto_init(&dumper); wantcopy = strlcpy(dumpdevname, devname, sizeof(dumpdevname)); @@ -884,14 +882,14 @@ void kerneldump_crypto_init(struct dumperinfo *di) { - char keyMaterial[KERNELDUMP_MAX_KEY_SIZE >> 3]; - int i; - - for (i = 0 ; i < KERNELDUMP_MAX_KEY_SIZE >> 3 ; i++) - keyMaterial[i] = i; - - rijndael_makeKey(di->key, DIR_ENCRYPT, KERNELDUMP_MAX_KEY_SIZE, keyMaterial); - rijndael_cipherInit(di->cipher, MODE_ECB, NULL); + /* In the future the tweak will be set via sysctl. */ + arc4rand(kerneldumptweak, KERNELDUMP_TWEAK_SIZE, 0); + di->key = (char *)kerneldumpkey; + di->tweak = kerneldumptweak; + di->tweak_ctx = &dumper_tweak_ctx; + di->data_ctx = &dumper_data_ctx; + rijndael_set_key(di->tweak_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); + rijndael_set_key(di->data_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); } void @@ -911,9 +909,9 @@ strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); - kdh->keyLen = dumper_key.keyLen; - strncpy(kdh->keyMaterial, dumper_key.keyMaterial, kdh->keyLen); - kdh->mode = dumper_cipher.mode; - strncpy(kdh->IV, dumper_cipher.IV, KERNELDUMP_MAX_IV_SIZE); + kdh->keysize = KERNELDUMP_KEY_SIZE; + strncpy(kdh->key, dumper.key, kdh->keysize); + kdh->tweaksize = KERNELDUMP_TWEAK_SIZE; + strncpy(kdh->tweak, dumper.tweak, kdh->tweaksize); kdh->parity = kerneldump_parity(kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Sat Jul 13 17:42:51 2013 (r254758) +++ soc2013/def/crashdump-head/sys/sys/conf.h Sat Jul 13 17:47:22 2013 (r254759) @@ -331,8 +331,10 @@ u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ - void *key; /* Key information. */ - void *cipher; /* Cipher information. */ + char *key; /* Key information. */ + char *tweak; /* Tweak. */ + void *tweak_ctx; + void *data_ctx; }; int set_dumper(struct dumperinfo *, const char *_devname);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307131747.r6DHlMdJ051183>