1#![allow(missing_docs)]
10#![allow(unused_must_use)]
11#![allow(dead_code)]
12#![allow(unused_imports)]
13#![allow(non_snake_case)]
14
15
16pub fn main()
23{
24 bigcryptor64_encrypt_with_padding_pkcs7_pcbc();
25 bigcryptor64_encrypt_with_padding_pkcs7_pcbc_into_vec();
26 bigcryptor64_encrypt_with_padding_pkcs7_pcbc_into_array();
27 bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc();
28 bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc_into_vec();
29 bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc_into_array();
30 bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc();
31 bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc_into_vec();
32 bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc_into_array();
33 bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc();
34 bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc_into_vec();
35 bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc_into_array();
36 bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc();
37 bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc_into_vec();
38 bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc_into_array();
39
40 bigcryptor64_decrypt_with_padding_pkcs7_pcbc();
41 bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_vec();
42 bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_array();
43 bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_string();
44 bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc();
45 bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_vec();
46 bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_array();
47 bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_string();
48 bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc();
49 bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_vec();
50 bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_array();
51 bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_string();
52}
53
54fn bigcryptor64_encrypt_with_padding_pkcs7_pcbc()
55{
56 println!("bigcryptor64_encrypt_with_padding_pkcs7_pcbc()");
57 use std::io::Write;
58 use std::fmt::Write as _;
59 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
60
61 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
63 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
64 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
65 let iv = 0x_FEDCBA0987654321_u64;
66 println!("IV = {:#018X}", iv);
67 let message = "In the beginning God created the heavens and the earth.";
68 println!("M =\t{}", message);
69 let mut cipher = [0_u8; 56];
70 tdes.encrypt(iv, message.as_ptr(), message.len() as u64, cipher.as_mut_ptr());
71 print!("C =\t");
72 for c in cipher.clone()
73 { print!("{:02X} ", c); }
74 println!();
75 let mut txt = String::new();
76 for c in cipher.clone()
77 { write!(txt, "{:02X} ", c); }
78 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
79 println!("-------------------------------");
80}
81
82fn bigcryptor64_encrypt_with_padding_pkcs7_pcbc_into_vec()
83{
84 println!("bigcryptor64_encrypt_with_padding_pkcs7_pcbc_into_vec()");
85 use std::io::Write;
86 use std::fmt::Write as _;
87 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
88
89 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
91 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
92 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
93 let iv = 0x_FEDCBA0987654321_u64;
94 println!("IV = {:#018X}", iv);
95 let message = "In the beginning God created the heavens and the earth.";
96 println!("M =\t{}", message);
97 let mut cipher = Vec::<u8>::new();
98 tdes.encrypt_into_vec(iv, message.as_ptr(), message.len() as u64, &mut cipher);
99 print!("C =\t");
100 for c in cipher.clone()
101 { print!("{:02X} ", c); }
102 println!();
103 let mut txt = String::new();
104 for c in cipher.clone()
105 { write!(txt, "{:02X} ", c); }
106 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
107 println!("-------------------------------");
108}
109
110fn bigcryptor64_encrypt_with_padding_pkcs7_pcbc_into_array()
111{
112 println!("bigcryptor64_encrypt_with_padding_pkcs7_pcbc_into_array()");
113 use std::io::Write;
114 use std::fmt::Write as _;
115 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
116
117 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
119 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
120 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
121 let iv = 0x_FEDCBA0987654321_u64;
122 println!("IV = {:#018X}", iv);
123 let message = "In the beginning God created the heavens and the earth.";
124 println!("M =\t{}", message);
125 let mut cipher = [0_u8; 56];
126 tdes.encrypt_into_array(iv, message.as_ptr(), message.len() as u64, &mut cipher);
127 print!("C =\t");
128 for c in cipher.clone()
129 { print!("{:02X} ", c); }
130 println!();
131 let mut txt = String::new();
132 for c in cipher.clone()
133 { write!(txt, "{:02X} ", c); }
134 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
135 println!("-------------------------------");
136}
137
138fn bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc()
139{
140 println!("bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc()");
141 use std::io::Write;
142 use std::fmt::Write as _;
143 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
144
145 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
147 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
148 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
149 let iv = 0x_FEDCBA0987654321_u64;
150 println!("IV = {:#018X}", iv);
151 let message = "In the beginning God created the heavens and the earth.";
152 println!("M =\t{}", message);
153 let mut cipher = [0_u8; 56];
154 tdes.encrypt_str(iv, &message, cipher.as_mut_ptr());
155 print!("C =\t");
156 for c in cipher.clone()
157 { print!("{:02X} ", c); }
158 println!();
159 let mut txt = String::new();
160 for c in cipher.clone()
161 { write!(txt, "{:02X} ", c); }
162 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
163 println!("-------------------------------");
164}
165
166fn bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc_into_vec()
167{
168 println!("bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc_into_vec()");
169 use std::io::Write;
170 use std::fmt::Write as _;
171 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
172
173 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
175 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
176 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
177 let iv = 0x_FEDCBA0987654321_u64;
178 println!("IV = {:#018X}", iv);
179 let message = "In the beginning God created the heavens and the earth.";
180 let mut cipher = Vec::<u8>::new();
181 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
182 print!("C =\t");
183 for c in cipher.clone()
184 { print!("{:02X} ", c); }
185 println!();
186 let mut txt = String::new();
187 for c in cipher.clone()
188 { write!(txt, "{:02X} ", c); }
189 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
190 println!("-------------------------------");
191}
192
193fn bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc_into_array()
194{
195 println!("bigcryptor64_encrypt_str_with_padding_pkcs7_pcbc_into_array()");
196 use std::io::Write;
197 use std::fmt::Write as _;
198 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
199
200 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
202 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
203 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
204 let iv = 0x_FEDCBA0987654321_u64;
205 println!("IV = {:#018X}", iv);
206 let message = "In the beginning God created the heavens and the earth.";
207 let mut cipher = [0_u8; 56];
208 tdes.encrypt_str_into_array(iv, &message, &mut cipher);
209 print!("C =\t");
210 for c in cipher.clone()
211 { print!("{:02X} ", c); }
212 println!();
213 let mut txt = String::new();
214 for c in cipher.clone()
215 { write!(txt, "{:02X} ", c); }
216 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
217 println!("-------------------------------");
218}
219
220fn bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc()
221{
222 println!("bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc()");
223 use std::io::Write;
224 use std::fmt::Write as _;
225 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
226
227 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
229 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
230 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
231 let iv = 0x_FEDCBA0987654321_u64;
232 println!("IV = {:#018X}", iv);
233 let message = "In the beginning God created the heavens and the earth.".to_string();
234 let mut cipher = [0_u8; 56];
235 tdes.encrypt_string(iv, &message, cipher.as_mut_ptr());
236 print!("C =\t");
237 for c in cipher.clone()
238 { print!("{:02X} ", c); }
239 println!();
240 let mut txt = String::new();
241 for c in cipher.clone()
242 { write!(txt, "{:02X} ", c); }
243 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
244 println!("-------------------------------");
245}
246
247fn bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc_into_vec()
248{
249 println!("bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc_into_vec()");
250 use std::io::Write;
251 use std::fmt::Write as _;
252 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
253
254 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
256 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
257 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
258 let iv = 0x_FEDCBA0987654321_u64;
259 println!("IV = {:#018X}", iv);
260 let message = "In the beginning God created the heavens and the earth.".to_string();
261 let mut cipher = Vec::<u8>::new();
262 tdes.encrypt_string_into_vec(iv, &message, &mut cipher);
263 print!("C =\t");
264 for c in cipher.clone()
265 { print!("{:02X} ", c); }
266 println!();
267 let mut txt = String::new();
268 for c in cipher.clone()
269 { write!(txt, "{:02X} ", c); }
270 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
271 println!("-------------------------------");
272}
273
274fn bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc_into_array()
275{
276 println!("bigcryptor64_encrypt_string_with_padding_pkcs7_pcbc_into_array()");
277 use std::io::Write;
278 use std::fmt::Write as _;
279 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
280
281 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
283 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
284 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
285 let iv = 0x_FEDCBA0987654321_u64;
286 println!("IV = {:#018X}", iv);
287 let message = "In the beginning God created the heavens and the earth.".to_string();
288 let mut cipher = [0_u8; 56];
289 tdes.encrypt_string_into_array(iv, &message, &mut cipher);
290 print!("C =\t");
291 for c in cipher.clone()
292 { print!("{:02X} ", c); }
293 println!();
294 let mut txt = String::new();
295 for c in cipher.clone()
296 { write!(txt, "{:02X} ", c); }
297 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
298 println!("-------------------------------");
299}
300
301fn bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc()
302{
303 println!("bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc()");
304 use std::io::Write;
305 use std::fmt::Write as _;
306 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
307
308 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
310 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
311 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
312 let iv = 0x_FEDCBA0987654321_u64;
313 println!("IV = {:#018X}", iv);
314 let message = "In the beginning God created the heavens and the earth.";
315 println!("M =\t{}", message);
316 let message = unsafe { message.to_string().as_mut_vec().clone() };
317 let mut cipher = [0_u8; 56];
318 tdes.encrypt_vec(iv, &message, cipher.as_mut_ptr());
319 print!("C =\t");
320 for c in cipher.clone()
321 { print!("{:02X} ", c); }
322 println!();
323 let mut txt = String::new();
324 for c in cipher.clone()
325 { write!(txt, "{:02X} ", c); }
326 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
327 println!("-------------------------------");
328}
329
330fn bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc_into_vec()
331{
332 println!("bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc_into_vec()");
333 use std::io::Write;
334 use std::fmt::Write as _;
335 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
336
337 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
339 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
340 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
341 let iv = 0x_FEDCBA0987654321_u64;
342 println!("IV = {:#018X}", iv);
343 let message = "In the beginning God created the heavens and the earth.";
344 println!("M =\t{}", message);
345 let message = unsafe { message.to_string().as_mut_vec().clone() };
346 let mut cipher = Vec::<u8>::new();
347 tdes.encrypt_vec_into_vec(iv, &message, &mut cipher);
348 print!("C =\t");
349 for c in cipher.clone()
350 { print!("{:02X} ", c); }
351 println!();
352 let mut txt = String::new();
353 for c in cipher.clone()
354 { write!(txt, "{:02X} ", c); }
355 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
356 println!("-------------------------------");
357}
358
359fn bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc_into_array()
360{
361 println!("bigcryptor64_encrypt_vec_with_padding_pkcs7_pcbc_into_array()");
362 use std::io::Write;
363 use std::fmt::Write as _;
364 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
365
366 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
368 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
369 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
370 let iv = 0x_FEDCBA0987654321_u64;
371 println!("IV = {:#018X}", iv);
372 let message = "In the beginning God created the heavens and the earth.";
373 println!("M =\t{}", message);
374 let message = unsafe { message.to_string().as_mut_vec().clone() };
375 let mut cipher = [0_u8; 56];
376 tdes.encrypt_vec_into_array(iv, &message, &mut cipher);
377 print!("C =\t");
378 for c in cipher.clone()
379 { print!("{:02X} ", c); }
380 println!();
381 let mut txt = String::new();
382 for c in cipher.clone()
383 { write!(txt, "{:02X} ", c); }
384 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
385 println!("-------------------------------");
386}
387
388fn bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc()
389{
390 println!("bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc()");
391 use std::io::Write;
392 use std::fmt::Write as _;
393 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
394
395 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
397 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
398 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
399 let iv = 0x_FEDCBA0987654321_u64;
400 println!("IV = {:#018X}", iv);
401 let mes = "In the beginning God created the heavens and the earth.";
402 println!("M =\t{}", mes);
403 let mut message = [0_u8; 55];
404 message.copy_from_slice(unsafe { mes.to_string().as_mut_vec() });
405 let mut cipher = [0_u8; 56];
406 tdes.encrypt_array(iv, &message, cipher.as_mut_ptr());
407 print!("C =\t");
408 for c in cipher.clone()
409 { print!("{:02X} ", c); }
410 println!();
411 let mut txt = String::new();
412 for c in cipher.clone()
413 { write!(txt, "{:02X} ", c); }
414 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
415 println!("-------------------------------");
416}
417
418fn bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc_into_vec()
419{
420 println!("bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc_into_vec()");
421 use std::io::Write;
422 use std::fmt::Write as _;
423 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
424
425 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
427 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
428 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
429 let iv = 0x_FEDCBA0987654321_u64;
430 println!("IV = {:#018X}", iv);
431 let mes = "In the beginning God created the heavens and the earth.";
432 println!("M =\t{}", mes);
433 let mut message = [0_u8; 55];
434 message.copy_from_slice(unsafe { mes.to_string().as_mut_vec() });
435 let mut cipher = Vec::<u8>::new();
436 tdes.encrypt_array_into_vec(iv, &message, &mut cipher);
437 print!("C =\t");
438 for c in cipher.clone()
439 { print!("{:02X} ", c); }
440 println!();
441 let mut txt = String::new();
442 for c in cipher.clone()
443 { write!(txt, "{:02X} ", c); }
444 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
445 println!("-------------------------------");
446}
447
448fn bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc_into_array()
449{
450 println!("bigcryptor64_encrypt_array_with_padding_pkcs7_pcbc_into_array()");
451 use std::io::Write;
452 use std::fmt::Write as _;
453 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
454
455 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
457 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
458 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
459 let iv = 0x_FEDCBA0987654321_u64;
460 println!("IV = {:#018X}", iv);
461 let mes = "In the beginning God created the heavens and the earth.";
462 println!("M =\t{}", mes);
463 let mut message = [0_u8; 55];
464 message.copy_from_slice(unsafe { mes.to_string().as_mut_vec() });
465 let mut cipher = [0_u8; 56];
466 tdes.encrypt_array_into_array(iv, &message, &mut cipher);
467 for c in cipher.clone()
468 { print!("{:02X} ", c); }
469 println!();
470 let mut txt = String::new();
471 for c in cipher.clone()
472 { write!(txt, "{:02X} ", c); }
473 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
474 println!("-------------------------------");
475}
476
477fn bigcryptor64_decrypt_with_padding_pkcs7_pcbc()
478{
479 println!("bigcryptor64_decrypt_with_padding_pkcs7_pcbc()");
480 use std::io::Write;
481 use std::fmt::Write as _;
482 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
483
484 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
486 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
487 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
488 let iv = 0x_FEDCBA0987654321_u64;
489 println!("IV = {:#018X}", iv);
490 let message = "In the beginning God created the heavens and the earth.";
491 println!("M =\t{}", message);
492 let mut cipher = Vec::<u8>::new();
493 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
494 print!("C =\t");
495 for c in cipher.clone()
496 { print!("{:02X} ", c); }
497 println!();
498 let mut txt = String::new();
499 for c in cipher.clone()
500 { write!(txt, "{:02X} ", c); }
501 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
502
503 let mut recovered = vec![0; 55];
504 tdes.decrypt(iv, cipher.as_ptr(), cipher.len() as u64, recovered.as_mut_ptr());
505 print!("Ba =\t");
506 for b in recovered.clone()
507 { print!("{:02X} ", b); }
508 println!();
509 let mut txt = String::new();
510 for c in recovered.clone()
511 { write!(txt, "{:02X} ", c); }
512 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
513
514 let mut converted = String::new();
515 unsafe { converted.as_mut_vec() }.append(&mut recovered);
516
517 println!("Bb =\t{}", converted);
518 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
519 assert_eq!(converted, message);
520 println!("-------------------------------");
521}
522
523fn bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_vec()
524{
525 println!("bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_vec()");
526 use std::io::Write;
527 use std::fmt::Write as _;
528 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
529
530 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
532 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
533 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
534 let iv = 0x_FEDCBA0987654321_u64;
535 println!("IV = {:#018X}", iv);
536 let message = "In the beginning God created the heavens and the earth.";
537 println!("M =\t{}", message);
538 let mut cipher = Vec::<u8>::new();
539 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
540 print!("C =\t");
541 for c in cipher.clone()
542 { print!("{:02X} ", c); }
543 println!();
544 let mut txt = String::new();
545 for c in cipher.clone()
546 { write!(txt, "{:02X} ", c); }
547 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
548
549 let mut recovered = Vec::<u8>::new();
550 tdes.decrypt_into_vec(iv, cipher.as_ptr(), cipher.len() as u64, &mut recovered);
551 print!("Ba =\t");
552 for b in recovered.clone()
553 { print!("{:02X} ", b); }
554 println!();
555 let mut txt = String::new();
556 for c in recovered.clone()
557 { write!(txt, "{:02X} ", c); }
558 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
559
560 let mut converted = String::new();
561 unsafe { converted.as_mut_vec() }.append(&mut recovered);
562
563 println!("Bb =\t{}", converted);
564 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
565 assert_eq!(converted, message);
566 println!("-------------------------------");
567}
568
569fn bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_array()
570{
571 println!("bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_array()");
572 use std::io::Write;
573 use std::fmt::Write as _;
574 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
575
576 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
578 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
579 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
580 let iv = 0x_FEDCBA0987654321_u64;
581 println!("IV = {:#018X}", iv);
582 let message = "In the beginning God created the heavens and the earth.";
583 println!("M =\t{}", message);
584 let mut cipher = Vec::<u8>::new();
585 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
586 print!("C =\t");
587 for c in cipher.clone()
588 { print!("{:02X} ", c); }
589 println!();
590 let mut txt = String::new();
591 for c in cipher.clone()
592 { write!(txt, "{:02X} ", c); }
593 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
594
595 let mut recovered = [0u8; 56];
596 let len = tdes.decrypt_into_array(iv, cipher.as_ptr(), cipher.len() as u64, &mut recovered);
597 print!("Ba =\t");
598 for b in recovered.clone()
599 { print!("{:02X} ", b); }
600 println!();
601 let mut txt = String::new();
602 for c in recovered.clone()
603 { write!(txt, "{:02X} ", c); }
604 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E 00 ");
605
606 let mut converted = String::new();
607 unsafe { converted.as_mut_vec() }.write(&recovered);
608 unsafe { converted.as_mut_vec() }.truncate(len as usize);
609 println!("Bb =\t{}", converted);
610 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
611 assert_eq!(converted, message);
612 println!("-------------------------------");
613}
614
615fn bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_string()
616{
617 println!("bigcryptor64_decrypt_with_padding_pkcs7_pcbc_into_string()");
618 use std::io::Write;
619 use std::fmt::Write as _;
620 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
621
622 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
624 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
625 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
626 let iv = 0x_FEDCBA0987654321_u64;
627 println!("IV = {:#018X}", iv);
628 let message = "In the beginning God created the heavens and the earth.";
629 println!("M =\t{}", message);
630 let mut cipher = Vec::<u8>::new();
631 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
632 print!("C =\t");
633 for c in cipher.clone()
634 { print!("{:02X} ", c); }
635 println!();
636 let mut txt = String::new();
637 for c in cipher.clone()
638 { write!(txt, "{:02X} ", c); }
639 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
640
641 let mut recovered = String::new();
642 tdes.decrypt_into_string(iv, cipher.as_ptr(), cipher.len() as u64, &mut recovered);
643 println!("B =\t{}", recovered);
644 assert_eq!(recovered, "In the beginning God created the heavens and the earth.");
645 assert_eq!(recovered, message);
646 println!("-------------------------------");
647}
648
649fn bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc()
650{
651 println!("bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc()");
652 use std::io::Write;
653 use std::fmt::Write as _;
654 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
655
656 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
658 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
659 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
660 let iv = 0x_FEDCBA0987654321_u64;
661 println!("IV = {:#018X}", iv);
662 let message = "In the beginning God created the heavens and the earth.";
663 println!("M =\t{}", message);
664 let mut cipher = Vec::<u8>::new();
665 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
666 print!("C =\t");
667 for c in cipher.clone()
668 { print!("{:02X} ", c); }
669 println!();
670 let mut txt = String::new();
671 for c in cipher.clone()
672 { write!(txt, "{:02X} ", c); }
673 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
674
675 let mut recovered = vec![0; 55];
676 tdes.decrypt_vec(iv, &cipher, recovered.as_mut_ptr());
677 print!("Ba =\t");
678 for b in recovered.clone()
679 { print!("{:02X} ", b); }
680 println!();
681 let mut txt = String::new();
682 for c in recovered.clone()
683 { write!(txt, "{:02X} ", c); }
684 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
685
686 let mut converted = String::new();
687 unsafe { converted.as_mut_vec() }.append(&mut recovered);
688
689 println!("Bb =\t{}", converted);
690 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
691 assert_eq!(converted, message);
692 println!("-------------------------------");
693}
694
695fn bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_vec()
696{
697 println!("bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_vec()");
698 use std::io::Write;
699 use std::fmt::Write as _;
700 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
701
702 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
704 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
705 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
706 let iv = 0x_FEDCBA0987654321_u64;
707 println!("IV = {:#018X}", iv);
708 let message = "In the beginning God created the heavens and the earth.";
709 println!("M =\t{}", message);
710 let mut cipher = Vec::<u8>::new();
711 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
712 print!("C =\t");
713 for c in cipher.clone()
714 { print!("{:02X} ", c); }
715 println!();
716 let mut txt = String::new();
717 for c in cipher.clone()
718 { write!(txt, "{:02X} ", c); }
719 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
720
721 let mut recovered = Vec::<u8>::new();
722 tdes.decrypt_vec_into_vec(iv, &cipher, &mut recovered);
723 print!("Ba =\t");
724 for b in recovered.clone()
725 { print!("{:02X} ", b); }
726 println!();
727 let mut txt = String::new();
728 for c in recovered.clone()
729 { write!(txt, "{:02X} ", c); }
730 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
731
732 let mut converted = String::new();
733 unsafe { converted.as_mut_vec() }.append(&mut recovered);
734
735 println!("Bb =\t{}", converted);
736 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
737 assert_eq!(converted, message);
738 println!("-------------------------------");
739}
740
741fn bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_array()
742{
743 println!("bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_array()");
744 use std::io::Write;
745 use std::fmt::Write as _;
746 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
747
748 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
750 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
751 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
752 let iv = 0x_FEDCBA0987654321_u64;
753 println!("IV = {:#018X}", iv);
754 let message = "In the beginning God created the heavens and the earth.";
755 println!("M =\t{}", message);
756 let mut cipher = Vec::<u8>::new();
757 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
758 print!("C =\t");
759 for c in cipher.clone()
760 { print!("{:02X} ", c); }
761 println!();
762 let mut txt = String::new();
763 for c in cipher.clone()
764 { write!(txt, "{:02X} ", c); }
765 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
766
767 let mut recovered = [0u8; 56];
768 let len = tdes.decrypt_vec_into_array(iv, &cipher, &mut recovered);
769 print!("Ba =\t");
770 for b in recovered.clone()
771 { print!("{:02X} ", b); }
772 println!();
773 let mut txt = String::new();
774 for c in recovered.clone()
775 { write!(txt, "{:02X} ", c); }
776 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E 00 ");
777
778 let mut converted = String::new();
779 unsafe { converted.as_mut_vec() }.write(&recovered);
780 unsafe { converted.as_mut_vec() }.truncate(len as usize);
781 println!("Bb =\t{}", converted);
782 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
783 assert_eq!(converted, message);
784 println!("-------------------------------");
785}
786
787fn bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_string()
788{
789 println!("bigcryptor64_decrypt_vec_with_padding_pkcs7_pcbc_into_string()");
790 use std::io::Write;
791 use std::fmt::Write as _;
792 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
793
794 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
796 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
797 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
798 let iv = 0x_FEDCBA0987654321_u64;
799 println!("IV = {:#018X}", iv);
800 let message = "In the beginning God created the heavens and the earth.";
801 println!("M =\t{}", message);
802 let mut cipher = Vec::<u8>::new();
803 tdes.encrypt_str_into_vec(iv, &message, &mut cipher);
804 print!("C =\t");
805 for c in cipher.clone()
806 { print!("{:02X} ", c); }
807 println!();
808 let mut txt = String::new();
809 for c in cipher.clone()
810 { write!(txt, "{:02X} ", c); }
811 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
812
813 let mut recovered = String::new();
814 tdes.decrypt_vec_into_string(iv, &cipher, &mut recovered);
815 println!("B =\t{}", recovered);
816 assert_eq!(recovered, "In the beginning God created the heavens and the earth.");
817 assert_eq!(recovered, message);
818 println!("-------------------------------");
819}
820
821fn bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc()
822{
823 println!("bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc()");
824 use std::io::Write;
825 use std::fmt::Write as _;
826 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
827
828 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
830 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
831 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
832 let iv = 0x_FEDCBA0987654321_u64;
833 println!("IV = {:#018X}", iv);
834 let message = "In the beginning God created the heavens and the earth.";
835 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
836 tdes.encrypt_into_array(iv, message.as_ptr(), message.len() as u64, &mut cipher);
837 print!("C =\t");
838 for c in cipher.clone()
839 { print!("{:02X} ", c); }
840 println!();
841 let mut txt = String::new();
842 for c in cipher.clone()
843 { write!(txt, "{:02X} ", c); }
844 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
845
846 let mut recovered = vec![0; 55];
847 let len = tdes.decrypt_array(iv, &cipher, recovered.as_mut_ptr());
848 recovered.truncate(len as usize);
849 print!("Ba =\t");
850 for b in recovered.clone()
851 { print!("{:02X} ", b); }
852 println!();
853 let mut txt = String::new();
854 for c in recovered.clone()
855 { write!(txt, "{:02X} ", c); }
856 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
857
858 let mut converted = String::new();
859 unsafe { converted.as_mut_vec() }.append(&mut recovered);
860
861 println!("Bb =\t{}", converted);
862 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
863 assert_eq!(converted, message);
864 println!("-------------------------------");
865}
866
867fn bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_vec()
868{
869 println!("bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_vec()");
870 use std::io::Write;
871 use std::fmt::Write as _;
872 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
873
874 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
876 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
877 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
878 let iv = 0x_FEDCBA0987654321_u64;
879 println!("IV = {:#018X}", iv);
880 let message = "In the beginning God created the heavens and the earth.";
881 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
882 tdes.encrypt_into_array(iv, message.as_ptr(), message.len() as u64, &mut cipher);
883 print!("C =\t");
884 for c in cipher.clone()
885 { print!("{:02X} ", c); }
886 println!();
887 let mut txt = String::new();
888 for c in cipher.clone()
889 { write!(txt, "{:02X} ", c); }
890 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
891
892 let mut recovered = Vec::<u8>::new();
893 tdes.decrypt_array_into_vec(iv, &cipher, &mut recovered);
894 print!("Ba =\t");
895 for b in recovered.clone()
896 { print!("{:02X} ", b); }
897 println!();
898 let mut txt = String::new();
899 for c in recovered.clone()
900 { write!(txt, "{:02X} ", c); }
901 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
902
903 let mut converted = String::new();
904 unsafe { converted.as_mut_vec() }.append(&mut recovered);
905
906 println!("Bb =\t{}", converted);
907 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
908 assert_eq!(converted, message);
909 println!("-------------------------------");
910}
911
912fn bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_array()
913{
914 println!("bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_array()");
915 use std::io::Write;
916 use std::fmt::Write as _;
917 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
918
919 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
921 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
922 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
923 let iv = 0x_FEDCBA0987654321_u64;
924 println!("IV = {:#018X}", iv);
925 let message = "In the beginning God created the heavens and the earth.";
926 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
927 tdes.encrypt_into_array(iv, message.as_ptr(), message.len() as u64, &mut cipher);
928 print!("C =\t");
929 for c in cipher.clone()
930 { print!("{:02X} ", c); }
931 println!();
932 let mut txt = String::new();
933 for c in cipher.clone()
934 { write!(txt, "{:02X} ", c); }
935 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
936
937 let mut recovered = [0u8; 56];
938 let len = tdes.decrypt_array_into_array(iv, &cipher, &mut recovered);
939 print!("Ba =\t");
940 for b in recovered.clone()
941 { print!("{:02X} ", b); }
942 println!();
943 let mut txt = String::new();
944 for c in recovered.clone()
945 { write!(txt, "{:02X} ", c); }
946 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E 00 ");
947
948 let mut converted = String::new();
949 unsafe { converted.as_mut_vec() }.write(&recovered);
950 unsafe { converted.as_mut_vec() }.truncate(len as usize);
951 println!("Bb =\t{}", converted);
952 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
953 assert_eq!(converted, message);
954 println!("-------------------------------");
955}
956
957fn bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_string()
958{
959 println!("bigcryptor64_decrypt_array_with_padding_pkcs7_pcbc_into_string()");
960 use std::io::Write;
961 use std::fmt::Write as _;
962 use cryptocol::symmetric::{ BigCryptor64, DES, PCBC_PKCS7 };
963
964 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
966 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
967 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
968 let iv = 0x_FEDCBA0987654321_u64;
969 println!("IV = {:#018X}", iv);
970 let message = "In the beginning God created the heavens and the earth.";
971 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
972 tdes.encrypt_into_array(iv, message.as_ptr(), message.len() as u64, &mut cipher);
973 print!("C =\t");
974 for c in cipher.clone()
975 { print!("{:02X} ", c); }
976 println!();
977 let mut txt = String::new();
978 for c in cipher.clone()
979 { write!(txt, "{:02X} ", c); }
980 assert_eq!(txt, "01 A5 7E BC ED 83 28 FB DD AC 7F 93 37 1B A6 28 89 A6 19 D3 9E E6 A0 29 B6 EA 99 D9 D1 F1 F0 E4 9D 54 E9 55 2B FD 40 DA B7 B3 3D 5F 86 2D 30 BF B2 28 DD A3 42 A4 70 06 ");
981
982 let mut recovered = String::new();
983 tdes.decrypt_array_into_string(iv, &cipher, &mut recovered);
984 println!("B =\t{}", recovered);
985 assert_eq!(recovered, "In the beginning God created the heavens and the earth.");
986 assert_eq!(recovered, message);
987 println!("-------------------------------");
988}