src/eric7/Documentation/Source/eric7.Utilities.crypto.py3AES.html

branch
eric7
changeset 10479
856476537696
parent 10433
328f3ec4b77a
equal deleted inserted replaced
10478:de9106c55c3d 10479:856476537696
5 <link rel="stylesheet" href="styles.css"> 5 <link rel="stylesheet" href="styles.css">
6 </head> 6 </head>
7 <body> 7 <body>
8 <a NAME="top" ID="top"></a> 8 <a NAME="top" ID="top"></a>
9 <h1>eric7.Utilities.crypto.py3AES</h1> 9 <h1>eric7.Utilities.crypto.py3AES</h1>
10
11 <p> 10 <p>
12 Module implementing classes for encryption according 11 Module implementing classes for encryption according
13 Advanced Encryption Standard. 12 Advanced Encryption Standard.
14 </p> 13 </p>
14
15 <h3>Global Attributes</h3> 15 <h3>Global Attributes</h3>
16
17 <table> 16 <table>
18 <tr><td>None</td></tr> 17 <tr><td>None</td></tr>
19 </table> 18 </table>
19
20 <h3>Classes</h3> 20 <h3>Classes</h3>
21
22 <table> 21 <table>
23
24 <tr> 22 <tr>
25 <td><a href="#AES">AES</a></td> 23 <td><a href="#AES">AES</a></td>
26 <td>Class implementing the Advanced Encryption Standard algorithm.</td> 24 <td>Class implementing the Advanced Encryption Standard algorithm.</td>
27 </tr> 25 </tr>
28 <tr> 26 <tr>
29 <td><a href="#AESModeOfOperation">AESModeOfOperation</a></td> 27 <td><a href="#AESModeOfOperation">AESModeOfOperation</a></td>
30 <td>Class implementing the different AES mode of operations.</td> 28 <td>Class implementing the different AES mode of operations.</td>
31 </tr> 29 </tr>
32 </table> 30 </table>
31
33 <h3>Functions</h3> 32 <h3>Functions</h3>
34
35 <table> 33 <table>
36
37 <tr> 34 <tr>
38 <td><a href="#append_PKCS7_padding">append_PKCS7_padding</a></td> 35 <td><a href="#append_PKCS7_padding">append_PKCS7_padding</a></td>
39 <td>Function to pad the given data to a multiple of 16-bytes by PKCS7 padding.</td> 36 <td>Function to pad the given data to a multiple of 16-bytes by PKCS7 padding.</td>
40 </tr> 37 </tr>
41 <tr> 38 <tr>
49 <tr> 46 <tr>
50 <td><a href="#strip_PKCS7_padding">strip_PKCS7_padding</a></td> 47 <td><a href="#strip_PKCS7_padding">strip_PKCS7_padding</a></td>
51 <td>Function to strip off PKCS7 padding.</td> 48 <td>Function to strip off PKCS7 padding.</td>
52 </tr> 49 </tr>
53 </table> 50 </table>
51
54 <hr /> 52 <hr />
55 <hr /> 53 <hr />
56 <a NAME="AES" ID="AES"></a> 54 <a NAME="AES" ID="AES"></a>
57 <h2>AES</h2> 55 <h2>AES</h2>
58
59 <p> 56 <p>
60 Class implementing the Advanced Encryption Standard algorithm. 57 Class implementing the Advanced Encryption Standard algorithm.
61 </p> 58 </p>
59
62 <h3>Derived from</h3> 60 <h3>Derived from</h3>
63 None 61 None
64 <h3>Class Attributes</h3> 62 <h3>Class Attributes</h3>
65
66 <table> 63 <table>
67 <tr><td>KeySize</td></tr><tr><td>Rcon</td></tr><tr><td>rsbox</td></tr><tr><td>sbox</td></tr> 64 <tr><td>KeySize</td></tr>
65 <tr><td>Rcon</td></tr>
66 <tr><td>rsbox</td></tr>
67 <tr><td>sbox</td></tr>
68 </table> 68 </table>
69
69 <h3>Class Methods</h3> 70 <h3>Class Methods</h3>
70
71 <table> 71 <table>
72 <tr><td>None</td></tr> 72 <tr><td>None</td></tr>
73 </table> 73 </table>
74
74 <h3>Methods</h3> 75 <h3>Methods</h3>
75
76 <table> 76 <table>
77
78 <tr> 77 <tr>
79 <td><a href="#AES.__addRoundKey">__addRoundKey</a></td> 78 <td><a href="#AES.__addRoundKey">__addRoundKey</a></td>
80 <td>Private method to add (XORs) the round key to the state.</td> 79 <td>Private method to add (XORs) the round key to the state.</td>
81 </tr> 80 </tr>
82 <tr> 81 <tr>
154 <tr> 153 <tr>
155 <td><a href="#AES.encrypt">encrypt</a></td> 154 <td><a href="#AES.encrypt">encrypt</a></td>
156 <td>Public method to encrypt a 128 bit input block against the given key of size specified.</td> 155 <td>Public method to encrypt a 128 bit input block against the given key of size specified.</td>
157 </tr> 156 </tr>
158 </table> 157 </table>
158
159 <h3>Static Methods</h3> 159 <h3>Static Methods</h3>
160
161 <table> 160 <table>
162 <tr><td>None</td></tr> 161 <tr><td>None</td></tr>
163 </table> 162 </table>
164 163
164
165 <a NAME="AES.__addRoundKey" ID="AES.__addRoundKey"></a> 165 <a NAME="AES.__addRoundKey" ID="AES.__addRoundKey"></a>
166 <h4>AES.__addRoundKey</h4> 166 <h4>AES.__addRoundKey</h4>
167 <b>__addRoundKey</b>(<i>state, roundKey</i>) 167 <b>__addRoundKey</b>(<i>state, roundKey</i>)
168
169 <p> 168 <p>
170 Private method to add (XORs) the round key to the state. 169 Private method to add (XORs) the round key to the state.
171 </p> 170 </p>
171
172 <dl> 172 <dl>
173 173
174 <dt><i>state</i> (bytearray)</dt> 174 <dt><i>state</i> (bytearray)</dt>
175 <dd> 175 <dd>
176 state to be changed 176 state to be changed
193 </dd> 193 </dd>
194 </dl> 194 </dl>
195 <a NAME="AES.__aes_invMain" ID="AES.__aes_invMain"></a> 195 <a NAME="AES.__aes_invMain" ID="AES.__aes_invMain"></a>
196 <h4>AES.__aes_invMain</h4> 196 <h4>AES.__aes_invMain</h4>
197 <b>__aes_invMain</b>(<i>state, expandedKey, nbrRounds</i>) 197 <b>__aes_invMain</b>(<i>state, expandedKey, nbrRounds</i>)
198
199 <p> 198 <p>
200 Private method to do the inverse AES encryption for one round. 199 Private method to do the inverse AES encryption for one round.
201 </p> 200 </p>
202 <p> 201 <p>
203 Perform the initial operations, the standard round, and the 202 Perform the initial operations, the standard round, and the
204 final operations of the inverse AES, creating a round key for 203 final operations of the inverse AES, creating a round key for
205 each round. 204 each round.
206 </p> 205 </p>
206
207 <dl> 207 <dl>
208 208
209 <dt><i>state</i> (bytearray)</dt> 209 <dt><i>state</i> (bytearray)</dt>
210 <dd> 210 <dd>
211 state to be worked on 211 state to be worked on
232 </dd> 232 </dd>
233 </dl> 233 </dl>
234 <a NAME="AES.__aes_invRound" ID="AES.__aes_invRound"></a> 234 <a NAME="AES.__aes_invRound" ID="AES.__aes_invRound"></a>
235 <h4>AES.__aes_invRound</h4> 235 <h4>AES.__aes_invRound</h4>
236 <b>__aes_invRound</b>(<i>state, roundKey</i>) 236 <b>__aes_invRound</b>(<i>state, roundKey</i>)
237
238 <p> 237 <p>
239 Private method to apply the 4 operations of the inverse round in 238 Private method to apply the 4 operations of the inverse round in
240 sequence. 239 sequence.
241 </p> 240 </p>
241
242 <dl> 242 <dl>
243 243
244 <dt><i>state</i> (bytearray)</dt> 244 <dt><i>state</i> (bytearray)</dt>
245 <dd> 245 <dd>
246 state to be worked on 246 state to be worked on
263 </dd> 263 </dd>
264 </dl> 264 </dl>
265 <a NAME="AES.__aes_main" ID="AES.__aes_main"></a> 265 <a NAME="AES.__aes_main" ID="AES.__aes_main"></a>
266 <h4>AES.__aes_main</h4> 266 <h4>AES.__aes_main</h4>
267 <b>__aes_main</b>(<i>state, expandedKey, nbrRounds</i>) 267 <b>__aes_main</b>(<i>state, expandedKey, nbrRounds</i>)
268
269 <p> 268 <p>
270 Private method to do the AES encryption for one round. 269 Private method to do the AES encryption for one round.
271 </p> 270 </p>
272 <p> 271 <p>
273 Perform the initial operations, the standard round, and the 272 Perform the initial operations, the standard round, and the
274 final operations of the forward AES, creating a round key for 273 final operations of the forward AES, creating a round key for
275 each round. 274 each round.
276 </p> 275 </p>
276
277 <dl> 277 <dl>
278 278
279 <dt><i>state</i> (bytearray)</dt> 279 <dt><i>state</i> (bytearray)</dt>
280 <dd> 280 <dd>
281 state to be worked on 281 state to be worked on
302 </dd> 302 </dd>
303 </dl> 303 </dl>
304 <a NAME="AES.__aes_round" ID="AES.__aes_round"></a> 304 <a NAME="AES.__aes_round" ID="AES.__aes_round"></a>
305 <h4>AES.__aes_round</h4> 305 <h4>AES.__aes_round</h4>
306 <b>__aes_round</b>(<i>state, roundKey</i>) 306 <b>__aes_round</b>(<i>state, roundKey</i>)
307
308 <p> 307 <p>
309 Private method to apply the 4 operations of the forward round in 308 Private method to apply the 4 operations of the forward round in
310 sequence. 309 sequence.
311 </p> 310 </p>
311
312 <dl> 312 <dl>
313 313
314 <dt><i>state</i> (bytearray)</dt> 314 <dt><i>state</i> (bytearray)</dt>
315 <dd> 315 <dd>
316 state to be worked on 316 state to be worked on
333 </dd> 333 </dd>
334 </dl> 334 </dl>
335 <a NAME="AES.__core" ID="AES.__core"></a> 335 <a NAME="AES.__core" ID="AES.__core"></a>
336 <h4>AES.__core</h4> 336 <h4>AES.__core</h4>
337 <b>__core</b>(<i>data, iteration</i>) 337 <b>__core</b>(<i>data, iteration</i>)
338
339 <p> 338 <p>
340 Private method performing the key schedule core operation. 339 Private method performing the key schedule core operation.
341 </p> 340 </p>
341
342 <dl> 342 <dl>
343 343
344 <dt><i>data</i> (bytearray)</dt> 344 <dt><i>data</i> (bytearray)</dt>
345 <dd> 345 <dd>
346 data to operate on 346 data to operate on
363 </dd> 363 </dd>
364 </dl> 364 </dl>
365 <a NAME="AES.__createRoundKey" ID="AES.__createRoundKey"></a> 365 <a NAME="AES.__createRoundKey" ID="AES.__createRoundKey"></a>
366 <h4>AES.__createRoundKey</h4> 366 <h4>AES.__createRoundKey</h4>
367 <b>__createRoundKey</b>(<i>expandedKey, roundKeyPointer</i>) 367 <b>__createRoundKey</b>(<i>expandedKey, roundKeyPointer</i>)
368
369 <p> 368 <p>
370 Private method to create a round key. 369 Private method to create a round key.
371 </p> 370 </p>
371
372 <dl> 372 <dl>
373 373
374 <dt><i>expandedKey</i> (bytearray)</dt> 374 <dt><i>expandedKey</i> (bytearray)</dt>
375 <dd> 375 <dd>
376 expanded key to be used 376 expanded key to be used
393 </dd> 393 </dd>
394 </dl> 394 </dl>
395 <a NAME="AES.__expandKey" ID="AES.__expandKey"></a> 395 <a NAME="AES.__expandKey" ID="AES.__expandKey"></a>
396 <h4>AES.__expandKey</h4> 396 <h4>AES.__expandKey</h4>
397 <b>__expandKey</b>(<i>key, size, expandedKeySize</i>) 397 <b>__expandKey</b>(<i>key, size, expandedKeySize</i>)
398
399 <p> 398 <p>
400 Private method performing Rijndael's key expansion. 399 Private method performing Rijndael's key expansion.
401 </p> 400 </p>
402 <p> 401 <p>
403 Expands a 128, 192 or 256 bit key into a 176, 208 or 240 bit key. 402 Expands a 128, 192 or 256 bit key into a 176, 208 or 240 bit key.
404 </p> 403 </p>
404
405 <dl> 405 <dl>
406 406
407 <dt><i>key</i> (bytes or bytearray)</dt> 407 <dt><i>key</i> (bytes or bytearray)</dt>
408 <dd> 408 <dd>
409 key to be expanded 409 key to be expanded
430 </dd> 430 </dd>
431 </dl> 431 </dl>
432 <a NAME="AES.__galois_multiplication" ID="AES.__galois_multiplication"></a> 432 <a NAME="AES.__galois_multiplication" ID="AES.__galois_multiplication"></a>
433 <h4>AES.__galois_multiplication</h4> 433 <h4>AES.__galois_multiplication</h4>
434 <b>__galois_multiplication</b>(<i>a, b</i>) 434 <b>__galois_multiplication</b>(<i>a, b</i>)
435
436 <p> 435 <p>
437 Private method to perform a Galois multiplication of 8 bit characters 436 Private method to perform a Galois multiplication of 8 bit characters
438 a and b. 437 a and b.
439 </p> 438 </p>
439
440 <dl> 440 <dl>
441 441
442 <dt><i>a</i> (bytes)</dt> 442 <dt><i>a</i> (bytes)</dt>
443 <dd> 443 <dd>
444 first factor 444 first factor
461 </dd> 461 </dd>
462 </dl> 462 </dl>
463 <a NAME="AES.__getRconValue" ID="AES.__getRconValue"></a> 463 <a NAME="AES.__getRconValue" ID="AES.__getRconValue"></a>
464 <h4>AES.__getRconValue</h4> 464 <h4>AES.__getRconValue</h4>
465 <b>__getRconValue</b>(<i>num</i>) 465 <b>__getRconValue</b>(<i>num</i>)
466
467 <p> 466 <p>
468 Private method to retrieve a given Rcon value. 467 Private method to retrieve a given Rcon value.
469 </p> 468 </p>
469
470 <dl> 470 <dl>
471 471
472 <dt><i>num</i> (int)</dt> 472 <dt><i>num</i> (int)</dt>
473 <dd> 473 <dd>
474 position of the value 474 position of the value
487 </dd> 487 </dd>
488 </dl> 488 </dl>
489 <a NAME="AES.__getSBoxInvert" ID="AES.__getSBoxInvert"></a> 489 <a NAME="AES.__getSBoxInvert" ID="AES.__getSBoxInvert"></a>
490 <h4>AES.__getSBoxInvert</h4> 490 <h4>AES.__getSBoxInvert</h4>
491 <b>__getSBoxInvert</b>(<i>num</i>) 491 <b>__getSBoxInvert</b>(<i>num</i>)
492
493 <p> 492 <p>
494 Private method to retrieve a given Inverted S-Box value. 493 Private method to retrieve a given Inverted S-Box value.
495 </p> 494 </p>
495
496 <dl> 496 <dl>
497 497
498 <dt><i>num</i> (int)</dt> 498 <dt><i>num</i> (int)</dt>
499 <dd> 499 <dd>
500 position of the value 500 position of the value
513 </dd> 513 </dd>
514 </dl> 514 </dl>
515 <a NAME="AES.__getSBoxValue" ID="AES.__getSBoxValue"></a> 515 <a NAME="AES.__getSBoxValue" ID="AES.__getSBoxValue"></a>
516 <h4>AES.__getSBoxValue</h4> 516 <h4>AES.__getSBoxValue</h4>
517 <b>__getSBoxValue</b>(<i>num</i>) 517 <b>__getSBoxValue</b>(<i>num</i>)
518
519 <p> 518 <p>
520 Private method to retrieve a given S-Box value. 519 Private method to retrieve a given S-Box value.
521 </p> 520 </p>
521
522 <dl> 522 <dl>
523 523
524 <dt><i>num</i> (int)</dt> 524 <dt><i>num</i> (int)</dt>
525 <dd> 525 <dd>
526 position of the value 526 position of the value
539 </dd> 539 </dd>
540 </dl> 540 </dl>
541 <a NAME="AES.__mixColumn" ID="AES.__mixColumn"></a> 541 <a NAME="AES.__mixColumn" ID="AES.__mixColumn"></a>
542 <h4>AES.__mixColumn</h4> 542 <h4>AES.__mixColumn</h4>
543 <b>__mixColumn</b>(<i>column, isInv</i>) 543 <b>__mixColumn</b>(<i>column, isInv</i>)
544
545 <p> 544 <p>
546 Private method to perform a galois multiplication of 1 column the 545 Private method to perform a galois multiplication of 1 column the
547 4x4 matrix. 546 4x4 matrix.
548 </p> 547 </p>
548
549 <dl> 549 <dl>
550 550
551 <dt><i>column</i> (bytearray)</dt> 551 <dt><i>column</i> (bytearray)</dt>
552 <dd> 552 <dd>
553 column to be worked on 553 column to be worked on
570 </dd> 570 </dd>
571 </dl> 571 </dl>
572 <a NAME="AES.__mixColumns" ID="AES.__mixColumns"></a> 572 <a NAME="AES.__mixColumns" ID="AES.__mixColumns"></a>
573 <h4>AES.__mixColumns</h4> 573 <h4>AES.__mixColumns</h4>
574 <b>__mixColumns</b>(<i>state, isInv</i>) 574 <b>__mixColumns</b>(<i>state, isInv</i>)
575
576 <p> 575 <p>
577 Private method to perform a galois multiplication of the 4x4 matrix. 576 Private method to perform a galois multiplication of the 4x4 matrix.
578 </p> 577 </p>
578
579 <dl> 579 <dl>
580 580
581 <dt><i>state</i> (bytearray)</dt> 581 <dt><i>state</i> (bytearray)</dt>
582 <dd> 582 <dd>
583 state to be worked on 583 state to be worked on
600 </dd> 600 </dd>
601 </dl> 601 </dl>
602 <a NAME="AES.__rotate" ID="AES.__rotate"></a> 602 <a NAME="AES.__rotate" ID="AES.__rotate"></a>
603 <h4>AES.__rotate</h4> 603 <h4>AES.__rotate</h4>
604 <b>__rotate</b>(<i>data</i>) 604 <b>__rotate</b>(<i>data</i>)
605
606 <p> 605 <p>
607 Private method performing Rijndael's key schedule rotate operation. 606 Private method performing Rijndael's key schedule rotate operation.
608 </p> 607 </p>
609 <p> 608 <p>
610 Rotate the data word eight bits to the left: eg, 609 Rotate the data word eight bits to the left: eg,
611 rotate(1d2c3a4f) == 2c3a4f1d. 610 rotate(1d2c3a4f) == 2c3a4f1d.
612 </p> 611 </p>
612
613 <dl> 613 <dl>
614 614
615 <dt><i>data</i> (bytearray)</dt> 615 <dt><i>data</i> (bytearray)</dt>
616 <dd> 616 <dd>
617 data of size 4 617 data of size 4
630 </dd> 630 </dd>
631 </dl> 631 </dl>
632 <a NAME="AES.__shiftRow" ID="AES.__shiftRow"></a> 632 <a NAME="AES.__shiftRow" ID="AES.__shiftRow"></a>
633 <h4>AES.__shiftRow</h4> 633 <h4>AES.__shiftRow</h4>
634 <b>__shiftRow</b>(<i>state, statePointer, nbr, isInv</i>) 634 <b>__shiftRow</b>(<i>state, statePointer, nbr, isInv</i>)
635
636 <p> 635 <p>
637 Private method to shift the bytes of a row to the left. 636 Private method to shift the bytes of a row to the left.
638 </p> 637 </p>
638
639 <dl> 639 <dl>
640 640
641 <dt><i>state</i> (bytearray)</dt> 641 <dt><i>state</i> (bytearray)</dt>
642 <dd> 642 <dd>
643 state to be worked on 643 state to be worked on
668 </dd> 668 </dd>
669 </dl> 669 </dl>
670 <a NAME="AES.__shiftRows" ID="AES.__shiftRows"></a> 670 <a NAME="AES.__shiftRows" ID="AES.__shiftRows"></a>
671 <h4>AES.__shiftRows</h4> 671 <h4>AES.__shiftRows</h4>
672 <b>__shiftRows</b>(<i>state, isInv</i>) 672 <b>__shiftRows</b>(<i>state, isInv</i>)
673
674 <p> 673 <p>
675 Private method to iterate over the 4 rows and call __shiftRow() with 674 Private method to iterate over the 4 rows and call __shiftRow() with
676 that row. 675 that row.
677 </p> 676 </p>
677
678 <dl> 678 <dl>
679 679
680 <dt><i>state</i> (bytearray)</dt> 680 <dt><i>state</i> (bytearray)</dt>
681 <dd> 681 <dd>
682 state to be worked on 682 state to be worked on
699 </dd> 699 </dd>
700 </dl> 700 </dl>
701 <a NAME="AES.__subBytes" ID="AES.__subBytes"></a> 701 <a NAME="AES.__subBytes" ID="AES.__subBytes"></a>
702 <h4>AES.__subBytes</h4> 702 <h4>AES.__subBytes</h4>
703 <b>__subBytes</b>(<i>state, isInv</i>) 703 <b>__subBytes</b>(<i>state, isInv</i>)
704
705 <p> 704 <p>
706 Private method to substitute all the values from the state with the 705 Private method to substitute all the values from the state with the
707 value in the SBox using the state value as index for the SBox. 706 value in the SBox using the state value as index for the SBox.
708 </p> 707 </p>
708
709 <dl> 709 <dl>
710 710
711 <dt><i>state</i> (bytearray)</dt> 711 <dt><i>state</i> (bytearray)</dt>
712 <dd> 712 <dd>
713 state to be worked on 713 state to be worked on
730 </dd> 730 </dd>
731 </dl> 731 </dl>
732 <a NAME="AES.decrypt" ID="AES.decrypt"></a> 732 <a NAME="AES.decrypt" ID="AES.decrypt"></a>
733 <h4>AES.decrypt</h4> 733 <h4>AES.decrypt</h4>
734 <b>decrypt</b>(<i>iput, key, size</i>) 734 <b>decrypt</b>(<i>iput, key, size</i>)
735
736 <p> 735 <p>
737 Public method to decrypt a 128 bit input block against the given key 736 Public method to decrypt a 128 bit input block against the given key
738 of size specified. 737 of size specified.
739 </p> 738 </p>
739
740 <dl> 740 <dl>
741 741
742 <dt><i>iput</i> (bytearray)</dt> 742 <dt><i>iput</i> (bytearray)</dt>
743 <dd> 743 <dd>
744 input data 744 input data
772 </dd> 772 </dd>
773 </dl> 773 </dl>
774 <a NAME="AES.encrypt" ID="AES.encrypt"></a> 774 <a NAME="AES.encrypt" ID="AES.encrypt"></a>
775 <h4>AES.encrypt</h4> 775 <h4>AES.encrypt</h4>
776 <b>encrypt</b>(<i>iput, key, size</i>) 776 <b>encrypt</b>(<i>iput, key, size</i>)
777
778 <p> 777 <p>
779 Public method to encrypt a 128 bit input block against the given key 778 Public method to encrypt a 128 bit input block against the given key
780 of size specified. 779 of size specified.
781 </p> 780 </p>
781
782 <dl> 782 <dl>
783 783
784 <dt><i>iput</i> (bytearray)</dt> 784 <dt><i>iput</i> (bytearray)</dt>
785 <dd> 785 <dd>
786 input data 786 input data
816 <div align="right"><a href="#top">Up</a></div> 816 <div align="right"><a href="#top">Up</a></div>
817 <hr /> 817 <hr />
818 <hr /> 818 <hr />
819 <a NAME="AESModeOfOperation" ID="AESModeOfOperation"></a> 819 <a NAME="AESModeOfOperation" ID="AESModeOfOperation"></a>
820 <h2>AESModeOfOperation</h2> 820 <h2>AESModeOfOperation</h2>
821
822 <p> 821 <p>
823 Class implementing the different AES mode of operations. 822 Class implementing the different AES mode of operations.
824 </p> 823 </p>
824
825 <h3>Derived from</h3> 825 <h3>Derived from</h3>
826 None 826 None
827 <h3>Class Attributes</h3> 827 <h3>Class Attributes</h3>
828
829 <table> 828 <table>
830 <tr><td>ModeOfOperation</td></tr><tr><td>aes</td></tr> 829 <tr><td>ModeOfOperation</td></tr>
830 <tr><td>aes</td></tr>
831 </table> 831 </table>
832
832 <h3>Class Methods</h3> 833 <h3>Class Methods</h3>
833
834 <table> 834 <table>
835 <tr><td>None</td></tr> 835 <tr><td>None</td></tr>
836 </table> 836 </table>
837
837 <h3>Methods</h3> 838 <h3>Methods</h3>
838
839 <table> 839 <table>
840
841 <tr> 840 <tr>
842 <td><a href="#AESModeOfOperation.__extractBytes">__extractBytes</a></td> 841 <td><a href="#AESModeOfOperation.__extractBytes">__extractBytes</a></td>
843 <td>Private method to extract a range of bytes from the input.</td> 842 <td>Private method to extract a range of bytes from the input.</td>
844 </tr> 843 </tr>
845 <tr> 844 <tr>
849 <tr> 848 <tr>
850 <td><a href="#AESModeOfOperation.encrypt">encrypt</a></td> 849 <td><a href="#AESModeOfOperation.encrypt">encrypt</a></td>
851 <td>Public method to perform the encryption operation.</td> 850 <td>Public method to perform the encryption operation.</td>
852 </tr> 851 </tr>
853 </table> 852 </table>
853
854 <h3>Static Methods</h3> 854 <h3>Static Methods</h3>
855
856 <table> 855 <table>
857 <tr><td>None</td></tr> 856 <tr><td>None</td></tr>
858 </table> 857 </table>
859 858
859
860 <a NAME="AESModeOfOperation.__extractBytes" ID="AESModeOfOperation.__extractBytes"></a> 860 <a NAME="AESModeOfOperation.__extractBytes" ID="AESModeOfOperation.__extractBytes"></a>
861 <h4>AESModeOfOperation.__extractBytes</h4> 861 <h4>AESModeOfOperation.__extractBytes</h4>
862 <b>__extractBytes</b>(<i>inputData, start, end, mode</i>) 862 <b>__extractBytes</b>(<i>inputData, start, end, mode</i>)
863
864 <p> 863 <p>
865 Private method to extract a range of bytes from the input. 864 Private method to extract a range of bytes from the input.
866 </p> 865 </p>
866
867 <dl> 867 <dl>
868 868
869 <dt><i>inputData</i> (bytes)</dt> 869 <dt><i>inputData</i> (bytes)</dt>
870 <dd> 870 <dd>
871 input data 871 input data
896 </dd> 896 </dd>
897 </dl> 897 </dl>
898 <a NAME="AESModeOfOperation.decrypt" ID="AESModeOfOperation.decrypt"></a> 898 <a NAME="AESModeOfOperation.decrypt" ID="AESModeOfOperation.decrypt"></a>
899 <h4>AESModeOfOperation.decrypt</h4> 899 <h4>AESModeOfOperation.decrypt</h4>
900 <b>decrypt</b>(<i>cipherIn, originalsize, mode, key, size, IV</i>) 900 <b>decrypt</b>(<i>cipherIn, originalsize, mode, key, size, IV</i>)
901
902 <p> 901 <p>
903 Public method to perform the decryption operation. 902 Public method to perform the decryption operation.
904 </p> 903 </p>
904
905 <dl> 905 <dl>
906 906
907 <dt><i>cipherIn</i> (bytes)</dt> 907 <dt><i>cipherIn</i> (bytes)</dt>
908 <dd> 908 <dd>
909 data to be decrypted 909 data to be decrypted
949 </dd> 949 </dd>
950 </dl> 950 </dl>
951 <a NAME="AESModeOfOperation.encrypt" ID="AESModeOfOperation.encrypt"></a> 951 <a NAME="AESModeOfOperation.encrypt" ID="AESModeOfOperation.encrypt"></a>
952 <h4>AESModeOfOperation.encrypt</h4> 952 <h4>AESModeOfOperation.encrypt</h4>
953 <b>encrypt</b>(<i>inputData, mode, key, size, IV</i>) 953 <b>encrypt</b>(<i>inputData, mode, key, size, IV</i>)
954
955 <p> 954 <p>
956 Public method to perform the encryption operation. 955 Public method to perform the encryption operation.
957 </p> 956 </p>
957
958 <dl> 958 <dl>
959 959
960 <dt><i>inputData</i> (bytes)</dt> 960 <dt><i>inputData</i> (bytes)</dt>
961 <dd> 961 <dd>
962 data to be encrypted 962 data to be encrypted
1002 <hr /> 1002 <hr />
1003 <hr /> 1003 <hr />
1004 <a NAME="append_PKCS7_padding" ID="append_PKCS7_padding"></a> 1004 <a NAME="append_PKCS7_padding" ID="append_PKCS7_padding"></a>
1005 <h2>append_PKCS7_padding</h2> 1005 <h2>append_PKCS7_padding</h2>
1006 <b>append_PKCS7_padding</b>(<i>b</i>) 1006 <b>append_PKCS7_padding</b>(<i>b</i>)
1007
1008 <p> 1007 <p>
1009 Function to pad the given data to a multiple of 16-bytes by PKCS7 padding. 1008 Function to pad the given data to a multiple of 16-bytes by PKCS7 padding.
1010 </p> 1009 </p>
1010
1011 <dl> 1011 <dl>
1012 1012
1013 <dt><i>b</i> (bytes)</dt> 1013 <dt><i>b</i> (bytes)</dt>
1014 <dd> 1014 <dd>
1015 data to be padded 1015 data to be padded
1031 <hr /> 1031 <hr />
1032 <hr /> 1032 <hr />
1033 <a NAME="decryptData" ID="decryptData"></a> 1033 <a NAME="decryptData" ID="decryptData"></a>
1034 <h2>decryptData</h2> 1034 <h2>decryptData</h2>
1035 <b>decryptData</b>(<i>key, data, mode=AESModeOfOperation.ModeOfOperation["CBC"]</i>) 1035 <b>decryptData</b>(<i>key, data, mode=AESModeOfOperation.ModeOfOperation["CBC"]</i>)
1036
1037 <p> 1036 <p>
1038 Module function to decrypt the given data with the given key. 1037 Module function to decrypt the given data with the given key.
1039 </p> 1038 </p>
1039
1040 <dl> 1040 <dl>
1041 1041
1042 <dt><i>key</i> (bytes)</dt> 1042 <dt><i>key</i> (bytes)</dt>
1043 <dd> 1043 <dd>
1044 key to be used for decryption 1044 key to be used for decryption
1075 <hr /> 1075 <hr />
1076 <hr /> 1076 <hr />
1077 <a NAME="encryptData" ID="encryptData"></a> 1077 <a NAME="encryptData" ID="encryptData"></a>
1078 <h2>encryptData</h2> 1078 <h2>encryptData</h2>
1079 <b>encryptData</b>(<i>key, data, mode=AESModeOfOperation.ModeOfOperation["CBC"]</i>) 1079 <b>encryptData</b>(<i>key, data, mode=AESModeOfOperation.ModeOfOperation["CBC"]</i>)
1080
1081 <p> 1080 <p>
1082 Module function to encrypt the given data with the given key. 1081 Module function to encrypt the given data with the given key.
1083 </p> 1082 </p>
1083
1084 <dl> 1084 <dl>
1085 1085
1086 <dt><i>key</i> (bytes)</dt> 1086 <dt><i>key</i> (bytes)</dt>
1087 <dd> 1087 <dd>
1088 key to be used for encryption 1088 key to be used for encryption
1119 <hr /> 1119 <hr />
1120 <hr /> 1120 <hr />
1121 <a NAME="strip_PKCS7_padding" ID="strip_PKCS7_padding"></a> 1121 <a NAME="strip_PKCS7_padding" ID="strip_PKCS7_padding"></a>
1122 <h2>strip_PKCS7_padding</h2> 1122 <h2>strip_PKCS7_padding</h2>
1123 <b>strip_PKCS7_padding</b>(<i>b</i>) 1123 <b>strip_PKCS7_padding</b>(<i>b</i>)
1124
1125 <p> 1124 <p>
1126 Function to strip off PKCS7 padding. 1125 Function to strip off PKCS7 padding.
1127 </p> 1126 </p>
1127
1128 <dl> 1128 <dl>
1129 1129
1130 <dt><i>b</i> (bytes)</dt> 1130 <dt><i>b</i> (bytes)</dt>
1131 <dd> 1131 <dd>
1132 data to be stripped 1132 data to be stripped

eric ide

mercurial