diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2000-06-17 17:16:08 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2000-06-17 17:16:08 +0000 |
commit | 883d8fd44467302c3565033377329596ff584353 (patch) | |
tree | 6a4fab996854c794c5bbb82961a34807efb5bdb0 /sys/miscfs/tcfs/tcfs_crypto.c | |
parent | e5891f818a179b348802443c30c18b6ab4adfed8 (diff) |
initial import of tcfs.
Diffstat (limited to 'sys/miscfs/tcfs/tcfs_crypto.c')
-rw-r--r-- | sys/miscfs/tcfs/tcfs_crypto.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/miscfs/tcfs/tcfs_crypto.c b/sys/miscfs/tcfs/tcfs_crypto.c new file mode 100644 index 00000000000..e9d1782ffa3 --- /dev/null +++ b/sys/miscfs/tcfs/tcfs_crypto.c @@ -0,0 +1,38 @@ +#include "tcfs_cipher.h" + +#define BLOCKSIZE 1024 +#define SBLOCKSIZE 8 +#define MIN(a,b) ((a)<(b)?(a):(b)) +#define D_NOBLK(o) ((o)/BLOCKSIZE+(o%BLOCKSIZE?1:0)) + + +void mkencrypt(struct tcfs_mount *mp,char *block,int nb, void* ks) +{ + int i,r; + char *tmp; + + tmp=block; + r=nb; + for(i=0;i<D_NOBLK(nb)&&r>0;i++) + { + TCFS_ENCRYPT(mp,tmp,MIN(BLOCKSIZE,r),ks); + tmp+=BLOCKSIZE; + r-=BLOCKSIZE; + } +} + +void mkdecrypt(struct tcfs_mount *mp,char *block,int nb,void* ks) +{ + int i,r; + char *tmp; + + tmp=block; + r=nb; + for(i=0;i<D_NOBLK(nb)&&r>0;i++) + { + TCFS_DECRYPT(mp, tmp,MIN(BLOCKSIZE,r),ks); + tmp+=BLOCKSIZE; + r-=BLOCKSIZE; + } +} + |