summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-04-18 16:57:49 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-04-18 16:57:49 +0000
commit310f8e3fef7ed53e2b94a247b2a7dbbfe88f67d9 (patch)
tree44118a9d86a50260ae7a5dbd84d0945b1bba8237
parent17e4ae72a78d51c260502f7562f5e3e51ea465c5 (diff)
Make key disks use their own optional metadata type, rather than reusing
crypto optional metadata. ok marco@
-rw-r--r--sys/dev/softraid_crypto.c16
-rw-r--r--sys/dev/softraidvar.h8
2 files changed, 18 insertions, 6 deletions
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index d202e9e21bb..970584f54f4 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.50 2010/03/28 16:38:57 jsing Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.51 2010/04/18 16:57:48 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -767,10 +767,10 @@ sr_crypto_create_key_disk(struct sr_discipline *sd, dev_t dev)
sm->ssdi.ssd_opt_no = 1;
omi = malloc(sizeof(struct sr_meta_opt_item), M_DEVBUF,
M_WAITOK | M_ZERO);
- omi->omi_om.somi.som_type = SR_OPT_CRYPTO;
+ omi->omi_om.somi.som_type = SR_OPT_KEYDISK;
bcopy(sd->mds.mdd_crypto.scr_maskkey,
- &omi->omi_om.somi.som_meta.smm_crypto,
- sizeof(sd->mds.mdd_crypto.scr_maskkey));
+ omi->omi_om.somi.som_meta.smm_keydisk.skm_maskkey,
+ sizeof(omi->omi_om.somi.som_meta.smm_keydisk.skm_maskkey));
SLIST_INSERT_HEAD(&fakesd->sd_meta_opt, omi, omi_link);
/* Save metadata. */
@@ -906,10 +906,16 @@ sr_crypto_read_key_disk(struct sr_discipline *sd, dev_t dev)
om = (struct sr_meta_opt *)((u_int8_t *)(sm + 1) +
sizeof(struct sr_meta_chunk) * sm->ssdi.ssd_chunk_no);
for (c = 0; c < sm->ssdi.ssd_opt_no; c++) {
- if (om->somi.som_type == SR_OPT_CRYPTO) {
+ if (om->somi.som_type == SR_OPT_KEYDISK) {
+ bcopy(&om->somi.som_meta.smm_keydisk.skm_maskkey,
+ sd->mds.mdd_crypto.scr_maskkey,
+ sizeof(sd->mds.mdd_crypto.scr_maskkey));
+ break;
+ } else if (om->somi.som_type == SR_OPT_CRYPTO) {
bcopy(&om->somi.som_meta.smm_crypto,
sd->mds.mdd_crypto.scr_maskkey,
sizeof(sd->mds.mdd_crypto.scr_maskkey));
+ break;
}
om++;
}
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index 29da6f46d21..e699954e69c 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.91 2010/03/28 16:38:57 jsing Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.92 2010/04/18 16:57:48 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -152,16 +152,22 @@ struct sr_meta_boot {
u_int32_t sbm_bootldr_size;
} __packed;
+struct sr_meta_keydisk {
+ u_int8_t skm_maskkey[SR_CRYPTO_MAXKEYBYTES];
+} __packed;
+
struct sr_meta_opt {
struct sr_meta_opt_invariant {
u_int32_t som_type; /* optional type */
#define SR_OPT_INVALID 0x00
#define SR_OPT_CRYPTO 0x01
#define SR_OPT_BOOT 0x02
+#define SR_OPT_KEYDISK 0x03
u_int32_t som_pad;
union {
struct sr_meta_crypto smm_crypto;
struct sr_meta_boot smm_boot;
+ struct sr_meta_keydisk smm_keydisk;
} som_meta;
} _som_invariant;
#define somi _som_invariant