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, int decrypting)
20 void setupDESstate(DESstate *s, uchar key[8], uchar *ivec)
23 void desCBCencrypt(uchar *p, int len, DESstate *s)
26 void desCBCdecrypt(uchar *p, int len, DESstate *s)
29 void desECBencrypt(uchar *p, int len, DESstate *s)
32 void desECBdecrypt(uchar *p, int len, DESstate *s)
37 void triple_block_cipher(ulong expanded_key[3][32], uchar text[8], int ende)
40 void setupDES3state(DES3state *s, uchar key[3][8], uchar *ivec)
43 void des3CBCencrypt(uchar *p, int len, DES3state *s)
46 void des3CBCdecrypt(uchar *p, int len, DES3state *s)
49 void des3ECBencrypt(uchar *p, int len, DES3state *s)
52 void des3ECBdecrypt(uchar *p, int len, DES3state *s)
55 void key_setup(uchar[7], ulong[32])
58 void des56to64(uchar *k56, uchar *k64)
61 void des64to56(uchar *k64, uchar *k56)
63 The Digital Encryption Standard (DES)
64 is a shared-key or symmetric encryption algorithm using either
65 a 56-bit key for single DES or three 56-bit keys for triple DES.
66 The keys are encoded into 64 bits where every eight bit
69 The basic DES function,
71 works on a block of 8 bytes, converting them in place.
72 It takes a key schedule, a pointer to the block, and
73 a flag indicating encrypting (0) or decrypting (1).
74 The key schedule is created from the key using
77 Since it is a bit awkward,
79 is rarely called directly. Instead, one normally uses
80 routines that encrypt larger buffers of data and
81 which may chain the encryption state from one buffer
83 These routines keep track of the state of the
86 structure that contains the key schedule and any chained
91 structure using the key and an 8-byte initialization vector.
93 Electronic code book, using
97 is the less secure mode. The encryption of each 8 bytes
98 does not depend on the encryption of any other.
99 Hence the encryption is a substitution
100 cipher using 64 bit characters.
102 Cipher block chaining mode, using
106 is more secure. Every block encrypted depends on the initialization
107 vector and all blocks encrypted before it.
109 For both CBC and ECB modes, a stream of data can be encrypted as
110 multiple buffers. However, all buffers except the last must
111 be a multiple of 8 bytes to ensure successful decryption of
114 There are equivalent triple-DES (DES3-EDE) functions for each of the
117 In the past, Plan 9 used a 56-bit or 7-byte
118 format for DES keys. To be compatible with the rest
119 of the world, we've abandoned this format.
120 There are two functions,
124 to convert back and forth between the two formats.
125 Also a key schedule can be set up from the 7-byte format using
142 Electronic Frontier Foundation,
145 Single DES can be realistically broken by brute-force;
146 its 56-bit key is just too short.
147 It should not be used in new code, which should probably use
149 instead, or at least triple DES.