From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 8 May 2000 08:24:34 -0400 From: presotto@plan9.bell-labs.com presotto@plan9.bell-labs.com Subject: [9fans] encrypt(void*, void*, int) and authentication Topicbox-Message-UUID: a852fc82-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <20000508122434.hfoqfYD01emklPErw2sPMZ-11ZH6At4oG1yPjlg1Je0@z> #include #include #include #include #include /* * destructively encrypt the buffer, which * must be at least 8 characters long. */ int encrypt(void *key, void *vbuf, int n) { ulong ekey[32]; uchar *buf; int i, r; if(n < 8) return 0; key_setup(key, ekey); buf = vbuf; n--; r = n % 7; n /= 7; for(i = 0; i < n; i++){ block_cipher(ekey, buf, 0); buf += 7; } if(r) block_cipher(ekey, buf - 7 + r, 0); return 1; } /* * destructively decrypt the buffer, which * must be at least 8 characters long. */ int decrypt(void *key, void *vbuf, int n) { ulong ekey[128]; uchar *buf; int i, r; if(n < 8) return 0; key_setup(key, ekey); buf = vbuf; n--; r = n % 7; n /= 7; buf += n * 7; if(r) block_cipher(ekey, buf - 7 + r, 1); for(i = 0; i < n; i++){ buf -= 7; block_cipher(ekey, buf, 1); } return 1; } block_cipher is des