summaryrefslogtreecommitdiffstats
path: root/sys/geom/bde
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-04-03 11:33:51 +0000
committerphk <phk@FreeBSD.org>2003-04-03 11:33:51 +0000
commit34a3abe946eab30b458fd0ab6237e03764b5a182 (patch)
treee6dd6df478d8ca2f9cf46b6ed5cfb2c269b45033 /sys/geom/bde
parentf8257495cfc91bb077fec7f102ef9041f0f69e99 (diff)
downloadFreeBSD-src-34a3abe946eab30b458fd0ab6237e03764b5a182.zip
FreeBSD-src-34a3abe946eab30b458fd0ab6237e03764b5a182.tar.gz
Use sys/endian.h instead of geom_enc.c for endian-agnostfication.
Diffstat (limited to 'sys/geom/bde')
-rw-r--r--sys/geom/bde/g_bde_crypt.c3
-rw-r--r--sys/geom/bde/g_bde_lock.c33
2 files changed, 19 insertions, 17 deletions
diff --git a/sys/geom/bde/g_bde_crypt.c b/sys/geom/bde/g_bde_crypt.c
index b20fd1c..f4ffa12 100644
--- a/sys/geom/bde/g_bde_crypt.c
+++ b/sys/geom/bde/g_bde_crypt.c
@@ -43,6 +43,7 @@
#include <sys/queue.h>
#include <sys/malloc.h>
#include <sys/libkern.h>
+#include <sys/endian.h>
#include <sys/md5.h>
#include <crypto/rijndael/rijndael.h>
@@ -80,7 +81,7 @@ g_bde_kkey(struct g_bde_softc *sc, keyInstance *ki, int dir, off_t sector)
u_char buf2[8];
/* We have to be architecture neutral */
- g_enc_le8(buf2, sector);
+ le64enc(buf2, sector);
MD5Init(&ct);
MD5Update(&ct, sc->key.salt, 8);
diff --git a/sys/geom/bde/g_bde_lock.c b/sys/geom/bde/g_bde_lock.c
index 1d8fd3e..b06f279 100644
--- a/sys/geom/bde/g_bde_lock.c
+++ b/sys/geom/bde/g_bde_lock.c
@@ -40,6 +40,7 @@
#include <sys/queue.h>
#include <sys/lock.h>
#include <sys/mutex.h>
+#include <sys/endian.h>
#include <sys/md5.h>
#ifdef _KERNEL
@@ -156,30 +157,30 @@ g_bde_encode_lock(struct g_bde_softc *sc, struct g_bde_key *gl, u_char *ptr)
for (i = 0; i < NLOCK_FIELDS; i++) {
switch(shuffle[i]) {
case 0:
- g_enc_le8(p, gl->sector0);
+ le64enc(p, gl->sector0);
p += 8;
break;
case 1:
- g_enc_le8(p, gl->sectorN);
+ le64enc(p, gl->sectorN);
p += 8;
break;
case 2:
- g_enc_le8(p, gl->keyoffset);
+ le64enc(p, gl->keyoffset);
p += 8;
break;
case 3:
- g_enc_le4(p, gl->sectorsize);
+ le32enc(p, gl->sectorsize);
p += 4;
break;
case 4:
- g_enc_le4(p, gl->flags);
+ le32enc(p, gl->flags);
p += 4;
break;
case 5:
case 6:
case 7:
case 8:
- g_enc_le8(p, gl->lsector[shuffle[i] - 5]);
+ le64enc(p, gl->lsector[shuffle[i] - 5]);
p += 8;
break;
case 9:
@@ -226,30 +227,30 @@ g_bde_decode_lock(struct g_bde_softc *sc, struct g_bde_key *gl, u_char *ptr)
for (i = 0; i < NLOCK_FIELDS; i++) {
switch(shuffle[i]) {
case 0:
- gl->sector0 = g_dec_le8(p);
+ gl->sector0 = le64dec(p);
p += 8;
break;
case 1:
- gl->sectorN = g_dec_le8(p);
+ gl->sectorN = le64dec(p);
p += 8;
break;
case 2:
- gl->keyoffset = g_dec_le8(p);
+ gl->keyoffset = le64dec(p);
p += 8;
break;
case 3:
- gl->sectorsize = g_dec_le4(p);
+ gl->sectorsize = le32dec(p);
p += 4;
break;
case 4:
- gl->flags = g_dec_le4(p);
+ gl->flags = le32dec(p);
p += 4;
break;
case 5:
case 6:
case 7:
case 8:
- gl->lsector[shuffle[i] - 5] = g_dec_le8(p);
+ gl->lsector[shuffle[i] - 5] = le64dec(p);
p += 8;
break;
case 9:
@@ -308,8 +309,8 @@ g_bde_keyloc_encrypt(struct g_bde_softc *sc, uint64_t *input, void *output)
keyInstance ki;
cipherInstance ci;
- g_enc_le8(buf, input[0]);
- g_enc_le8(buf + 8, input[1]);
+ le64enc(buf, input[0]);
+ le64enc(buf + 8, input[1]);
AES_init(&ci);
AES_makekey(&ki, DIR_ENCRYPT, G_BDE_KKEYBITS, sc->sha2 + 0);
AES_encrypt(&ci, &ki, buf, output, sizeof buf);
@@ -329,8 +330,8 @@ g_bde_keyloc_decrypt(struct g_bde_softc *sc, void *input, uint64_t *output)
AES_init(&ci);
AES_makekey(&ki, DIR_DECRYPT, G_BDE_KKEYBITS, sc->sha2 + 0);
AES_decrypt(&ci, &ki, input, buf, sizeof buf);
- output[0] = g_dec_le8(buf);
- output[1] = g_dec_le8(buf + 8);
+ output[0] = le64dec(buf);
+ output[1] = le64dec(buf + 8);
bzero(buf, sizeof buf);
bzero(&ci, sizeof ci);
bzero(&ki, sizeof ki);
OpenPOWER on IntegriCloud