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