1 cfa37a7b 2004-04-10 devnull .TH ENCRYPT 3
3 cfa37a7b 2004-04-10 devnull encrypt, decrypt, netcrypt \- DES encryption
4 cfa37a7b 2004-04-10 devnull .SH SYNOPSIS
5 cfa37a7b 2004-04-10 devnull .B #include <u.h>
7 cfa37a7b 2004-04-10 devnull .B #include <libc.h>
10 cfa37a7b 2004-04-10 devnull int encrypt(void *key, void *data, int len)
13 cfa37a7b 2004-04-10 devnull int decrypt(void *key, void *data, int len)
16 cfa37a7b 2004-04-10 devnull int netcrypt(void *key, void *data)
17 cfa37a7b 2004-04-10 devnull .SH DESCRIPTION
18 cfa37a7b 2004-04-10 devnull .I Encrypt
20 cfa37a7b 2004-04-10 devnull .I decrypt
21 cfa37a7b 2004-04-10 devnull perform DES encryption and decryption.
23 cfa37a7b 2004-04-10 devnull is an array of
24 cfa37a7b 2004-04-10 devnull .B DESKEYLEN
25 cfa37a7b 2004-04-10 devnull (defined as 7 in
26 cfa37a7b 2004-04-10 devnull .BR <auth.h> )
27 cfa37a7b 2004-04-10 devnull bytes containing the encryption key.
29 cfa37a7b 2004-04-10 devnull is an array of
32 cfa37a7b 2004-04-10 devnull it must be at least 8 bytes long.
33 cfa37a7b 2004-04-10 devnull The bytes are encrypted or decrypted in place.
35 cfa37a7b 2004-04-10 devnull The DES algorithm encrypts an individual 8-byte block of data.
36 cfa37a7b 2004-04-10 devnull .I Encrypt
37 cfa37a7b 2004-04-10 devnull uses the following method to encrypt data longer than 8 bytes.
38 cfa37a7b 2004-04-10 devnull The first 8 bytes are encrypted as usual.
39 cfa37a7b 2004-04-10 devnull The last byte of the encrypted result
40 cfa37a7b 2004-04-10 devnull is prefixed to the next 7 unencrypted bytes to make the next 8
41 cfa37a7b 2004-04-10 devnull bytes to encrypt.
42 cfa37a7b 2004-04-10 devnull This is repeated until fewer than 7 bytes remain unencrypted.
43 cfa37a7b 2004-04-10 devnull Any remaining unencrypted bytes are encrypted with enough of the preceding
44 cfa37a7b 2004-04-10 devnull encrypted bytes to make a full 8-byte block.
45 cfa37a7b 2004-04-10 devnull .I Decrypt
46 cfa37a7b 2004-04-10 devnull uses the inverse algorithm.
48 cfa37a7b 2004-04-10 devnull .I Netcrypt
49 cfa37a7b 2004-04-10 devnull performs the same encryption as a SecureNet Key.
51 cfa37a7b 2004-04-10 devnull points to an
52 cfa37a7b 2004-04-10 devnull .SM ASCII
53 cfa37a7b 2004-04-10 devnull string of decimal digits with numeric value between 0 and 10000.
54 cfa37a7b 2004-04-10 devnull These digits are copied into an 8-byte buffer with trailing binary zero fill
55 cfa37a7b 2004-04-10 devnull and encrypted as one DES block.
56 cfa37a7b 2004-04-10 devnull The first four bytes are each formatted as two digit
57 cfa37a7b 2004-04-10 devnull .SM ASCII
58 cfa37a7b 2004-04-10 devnull hexadecimal numbers,
59 cfa37a7b 2004-04-10 devnull and the string is copied into
60 cfa37a7b 2004-04-10 devnull .IR data .
61 cfa37a7b 2004-04-10 devnull .SH SOURCE
62 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/libc/port
63 cfa37a7b 2004-04-10 devnull .SH DIAGNOSTICS
64 cfa37a7b 2004-04-10 devnull These routines return 1 if the data was encrypted,
65 cfa37a7b 2004-04-10 devnull and 0 if the encryption fails.
66 cfa37a7b 2004-04-10 devnull .I Encrypt
68 cfa37a7b 2004-04-10 devnull .I decrypt
69 cfa37a7b 2004-04-10 devnull fail if the data passed is less than 8 bytes long.
70 cfa37a7b 2004-04-10 devnull .I Netcrypt
71 cfa37a7b 2004-04-10 devnull can fail if it is passed invalid data.
72 cfa37a7b 2004-04-10 devnull .SH SEE ALSO
73 cfa37a7b 2004-04-10 devnull .IR securenet (8)
75 cfa37a7b 2004-04-10 devnull The implementation is broken in a way that makes
76 cfa37a7b 2004-04-10 devnull it unsuitable for anything but authentication.