g_eli.h (213165) | g_eli.h (214118) |
---|---|
1/*- 2 * Copyright (c) 2005-2010 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 * | 1/*- 2 * Copyright (c) 2005-2010 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 213165 2010-09-25 10:32:04Z pjd $ | 26 * $FreeBSD: head/sys/geom/eli/g_eli.h 214118 2010-10-20 20:50:55Z 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> --- 46 unchanged lines hidden (view full) --- 81/* Provider was open for writing. */ 82#define G_ELI_FLAG_WOPEN 0x00010000 83/* Destroy device. */ 84#define G_ELI_FLAG_DESTROY 0x00020000 85/* Provider uses native byte-order for IV generation. */ 86#define G_ELI_FLAG_NATIVE_BYTE_ORDER 0x00040000 87/* Provider uses single encryption key. */ 88#define G_ELI_FLAG_SINGLE_KEY 0x00080000 | 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> --- 46 unchanged lines hidden (view full) --- 81/* Provider was open for writing. */ 82#define G_ELI_FLAG_WOPEN 0x00010000 83/* Destroy device. */ 84#define G_ELI_FLAG_DESTROY 0x00020000 85/* Provider uses native byte-order for IV generation. */ 86#define G_ELI_FLAG_NATIVE_BYTE_ORDER 0x00040000 87/* Provider uses single encryption key. */ 88#define G_ELI_FLAG_SINGLE_KEY 0x00080000 |
89/* Device suspended. */ 90#define G_ELI_FLAG_SUSPEND 0x00100000 |
|
89 | 91 |
92#define G_ELI_NEW_BIO 255 93 |
|
90#define SHA512_MDLEN 64 91#define G_ELI_AUTH_SECKEYLEN SHA256_DIGEST_LENGTH 92 93#define G_ELI_MAXMKEYS 2 94#define G_ELI_MAXKEYLEN 64 95#define G_ELI_USERKEYLEN G_ELI_MAXKEYLEN 96#define G_ELI_DATAKEYLEN G_ELI_MAXKEYLEN 97#define G_ELI_AUTHKEYLEN G_ELI_MAXKEYLEN --- 37 unchanged lines hidden (view full) --- 135 } \ 136} while (0) 137 138struct g_eli_worker { 139 struct g_eli_softc *w_softc; 140 struct proc *w_proc; 141 u_int w_number; 142 uint64_t w_sid; | 94#define SHA512_MDLEN 64 95#define G_ELI_AUTH_SECKEYLEN SHA256_DIGEST_LENGTH 96 97#define G_ELI_MAXMKEYS 2 98#define G_ELI_MAXKEYLEN 64 99#define G_ELI_USERKEYLEN G_ELI_MAXKEYLEN 100#define G_ELI_DATAKEYLEN G_ELI_MAXKEYLEN 101#define G_ELI_AUTHKEYLEN G_ELI_MAXKEYLEN --- 37 unchanged lines hidden (view full) --- 139 } \ 140} while (0) 141 142struct g_eli_worker { 143 struct g_eli_softc *w_softc; 144 struct proc *w_proc; 145 u_int w_number; 146 uint64_t w_sid; |
147 boolean_t w_active; |
|
143 LIST_ENTRY(g_eli_worker) w_next; 144}; 145 146struct g_eli_softc { 147 struct g_geom *sc_geom; 148 u_int sc_crypto; 149 uint8_t sc_mkey[G_ELI_DATAIVKEYLEN]; 150 uint8_t **sc_ekeys; --- 4 unchanged lines hidden (view full) --- 155 u_int sc_aalgo; 156 u_int sc_akeylen; 157 u_int sc_alen; 158 SHA256_CTX sc_akeyctx; 159 uint8_t sc_ivkey[G_ELI_IVKEYLEN]; 160 SHA256_CTX sc_ivctx; 161 int sc_nkey; 162 uint32_t sc_flags; | 148 LIST_ENTRY(g_eli_worker) w_next; 149}; 150 151struct g_eli_softc { 152 struct g_geom *sc_geom; 153 u_int sc_crypto; 154 uint8_t sc_mkey[G_ELI_DATAIVKEYLEN]; 155 uint8_t **sc_ekeys; --- 4 unchanged lines hidden (view full) --- 160 u_int sc_aalgo; 161 u_int sc_akeylen; 162 u_int sc_alen; 163 SHA256_CTX sc_akeyctx; 164 uint8_t sc_ivkey[G_ELI_IVKEYLEN]; 165 SHA256_CTX sc_ivctx; 166 int sc_nkey; 167 uint32_t sc_flags; |
168 int sc_inflight; |
|
163 off_t sc_mediasize; 164 size_t sc_sectorsize; 165 u_int sc_bytes_per_sector; 166 u_int sc_data_per_sector; 167 168 /* Only for software cryptography. */ 169 struct bio_queue_head sc_queue; 170 struct mtx sc_queue_mtx; --- 323 unchanged lines hidden (view full) --- 494void g_eli_read_done(struct bio *bp); 495void g_eli_write_done(struct bio *bp); 496int g_eli_crypto_rerun(struct cryptop *crp); 497uint8_t *g_eli_crypto_key(struct g_eli_softc *sc, off_t offset, 498 size_t blocksize); 499void g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, 500 size_t size); 501 | 169 off_t sc_mediasize; 170 size_t sc_sectorsize; 171 u_int sc_bytes_per_sector; 172 u_int sc_data_per_sector; 173 174 /* Only for software cryptography. */ 175 struct bio_queue_head sc_queue; 176 struct mtx sc_queue_mtx; --- 323 unchanged lines hidden (view full) --- 500void g_eli_read_done(struct bio *bp); 501void g_eli_write_done(struct bio *bp); 502int g_eli_crypto_rerun(struct cryptop *crp); 503uint8_t *g_eli_crypto_key(struct g_eli_softc *sc, off_t offset, 504 size_t blocksize); 505void g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, 506 size_t size); 507 |
508void g_eli_crypto_read(struct g_eli_softc *sc, struct bio *bp, boolean_t fromworker); |
|
502void g_eli_crypto_run(struct g_eli_worker *wr, struct bio *bp); 503 504void g_eli_auth_read(struct g_eli_softc *sc, struct bio *bp); 505void g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp); 506#endif 507 508void g_eli_mkey_hmac(unsigned char *mkey, const unsigned char *key); 509int g_eli_mkey_decrypt(const struct g_eli_metadata *md, --- 25 unchanged lines hidden --- | 509void g_eli_crypto_run(struct g_eli_worker *wr, struct bio *bp); 510 511void g_eli_auth_read(struct g_eli_softc *sc, struct bio *bp); 512void g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp); 513#endif 514 515void g_eli_mkey_hmac(unsigned char *mkey, const unsigned char *key); 516int g_eli_mkey_decrypt(const struct g_eli_metadata *md, --- 25 unchanged lines hidden --- |