Blame


1 83c4506a 2005-02-11 devnull .TH ENCRYPT 3
2 d93fca6a 2005-02-11 devnull .SH NAME
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>
6 d93fca6a 2005-02-11 devnull .br
7 d93fca6a 2005-02-11 devnull .B #include <libc.h>
8 d93fca6a 2005-02-11 devnull .PP
9 d93fca6a 2005-02-11 devnull .B
10 d93fca6a 2005-02-11 devnull int encrypt(void *key, void *data, int len)
11 d93fca6a 2005-02-11 devnull .PP
12 d93fca6a 2005-02-11 devnull .B
13 d93fca6a 2005-02-11 devnull int decrypt(void *key, void *data, int len)
14 d93fca6a 2005-02-11 devnull .PP
15 d93fca6a 2005-02-11 devnull .B
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
19 d93fca6a 2005-02-11 devnull and
20 d93fca6a 2005-02-11 devnull .I decrypt
21 d93fca6a 2005-02-11 devnull perform DES encryption and decryption.
22 d93fca6a 2005-02-11 devnull .I Key
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.
28 d93fca6a 2005-02-11 devnull .I Data
29 d93fca6a 2005-02-11 devnull is an array of
30 d93fca6a 2005-02-11 devnull .I len
31 d93fca6a 2005-02-11 devnull bytes;
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.
34 d93fca6a 2005-02-11 devnull .PP
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.
47 d93fca6a 2005-02-11 devnull .PP
48 d93fca6a 2005-02-11 devnull .I Netcrypt
49 d93fca6a 2005-02-11 devnull performs the same encryption as a SecureNet Key.
50 d93fca6a 2005-02-11 devnull .I Data
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
67 d93fca6a 2005-02-11 devnull and
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)
74 d93fca6a 2005-02-11 devnull .SH BUGS
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.
77 d93fca6a 2005-02-11 devnull .PP
78 d93fca6a 2005-02-11 devnull To avoid name conflicts with the underlying system,
79 d93fca6a 2005-02-11 devnull .IR encrypt
80 d93fca6a 2005-02-11 devnull and
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
84 d93fca6a 2005-02-11 devnull and
85 d93fca6a 2005-02-11 devnull .IR p9decrypt ;
86 d93fca6a 2005-02-11 devnull see
87 d32deab1 2020-08-16 rsc .MR intro (3) .