3 setupDESstate, des_key_setup, block_cipher, desCBCencrypt, desCBCdecrypt, desECBencrypt, desECBdecrypt, des3CBCencrypt, des3CBCdecrypt, des3ECBencrypt, des3ECBdecrypt, key_setup, des56to64, des64to56, setupDES3state, triple_block_cipher, - single and triple digital encryption standard
11 .B #include <libsec.h>
14 void des_key_setup(uchar key[8], ulong schedule[32])
17 void block_cipher(ulong *schedule, uchar *data,
22 void setupDESstate(DESstate *s, uchar key[8], uchar *ivec)
25 void desCBCencrypt(uchar*, int, DESstate*)
28 void desCBCdecrypt(uchar*, int, DESstate*)
31 void desECBencrypt(uchar*, int, DESstate*)
34 void desECBdecrypt(uchar*, int, DESstate*)
37 void triple_block_cipher(ulong keys[3][32], uchar*, int)
40 void setupDES3state(DES3state *s, uchar key[3][8],
45 void des3CBCencrypt(uchar*, int, DES3state*)
48 void des3CBCdecrypt(uchar*, int, DES3state*)
51 void des3ECBencrypt(uchar*, int, DES3state*)
54 void des3ECBdecrypt(uchar*, int, DES3state*)
57 void key_setup(uchar[7], ulong[32])
60 void des56to64(uchar *k56, uchar *k64)
63 void des64to56(uchar *k64, uchar *k56)
66 The Digital Encryption Standard (DES)
67 is a shared key or symmetric encryption using either
68 a 56 bit key for single DES or three 56 bit keys for triple des.
69 The keys are encoded into 64 bits where every eight bit
72 The basic DES function,
74 works on a block of 8 bytes, converting them in place.
75 It takes a key schedule, a pointer to the block, and
76 a flag indicating encrypting (0) or decrypting (1).
77 The key schedule is created from the key using
80 Since it is a bit awkward,
82 is rarely called directly. Instead, one normally uses
83 routines that encrypt larger buffers of data and
84 which may chain the encryption state from one buffer
86 These routines keep track of the state of the
89 structure that contains the key schedule and any chained
94 structure using the key and an 8 byte initialization vector.
96 Electronic code book, using
100 is the less secure mode. The encryption of each 8 bytes
101 does not depend on the encryption of any other.
102 Hence the encryption is a substitution
103 cipher using 64 bit characters.
105 Cipher block chaining mode, using
109 is more secure. Every block encrypted depends on the initialization
110 vector and all blocks encrypted before it.
112 For both CBC and ECB modes, a stream of data can be encrypted as
113 multiple buffers. However, all buffers except the last must
114 be a multiple of 8 bytes to ensure successful decryption of
117 There are equivalent triple DES functions for each of the
120 In the past Plan 9 used a 56 bit or 7 byte
121 format for DES keys. To be compatible with the rest
122 of the world, we've abandoned this format.
123 There are two functions:
127 to convert back and forth between the two formats.
128 Also a key schedule can be set up from the 7 byte format