-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathBlockCipherExample.pas
More file actions
56 lines (46 loc) · 2.41 KB
/
Copy pathBlockCipherExample.pas
File metadata and controls
56 lines (46 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{ *********************************************************************************** }
{ * CryptoLib Library * }
{ * Author - Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * the development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit BlockCipherExample;
interface
{$IFDEF FPC}
{$MODE DELPHI}
{$HINTS OFF}
{$WARNINGS OFF}
{$ENDIF FPC}
uses
CipherExampleBase;
type
TBlockCipherExample = class(TSymmetricCipherExampleBase)
public
procedure Run; override;
end;
implementation
const
// Add a block cipher/mode by adding a row. Arbitrary-length modes only
// (so any plaintext works); each is driven through the shared non-AEAD
// roundtrip.
BlockSpecs: array[0..5] of TSymmetricSpec = (
(Algorithm: 'AES/CBC/PKCS7PADDING'; DisplayName: 'AES-128-CBC'; KeyByteCount: 16; IvByteCount: 16),
(Algorithm: 'AES/CBC/PKCS7PADDING'; DisplayName: 'AES-192-CBC'; KeyByteCount: 24; IvByteCount: 16),
(Algorithm: 'AES/CBC/PKCS7PADDING'; DisplayName: 'AES-256-CBC'; KeyByteCount: 32; IvByteCount: 16),
(Algorithm: 'AES/CTR/NOPADDING'; DisplayName: 'AES-256-CTR'; KeyByteCount: 32; IvByteCount: 16),
(Algorithm: 'AES/CFB/NOPADDING'; DisplayName: 'AES-256-CFB'; KeyByteCount: 32; IvByteCount: 16),
(Algorithm: 'BLOWFISH/CBC/PKCS7PADDING'; DisplayName: 'Blowfish-CBC'; KeyByteCount: 16; IvByteCount: 8)
);
procedure TBlockCipherExample.Run;
begin
RunSpecs('--- Block cipher example: encrypt/decrypt ---', BlockSpecs);
end;
end.