4 | #pragma hdrstop
5 | USERES("DCPcppbuilder5.res");
6 | USEPACKAGE("vcl50.bpi");
7 | USEUNIT("DCPbase64.pas");
8 | USEUNIT("DCPblockciphers.pas");
9 | USEUNIT("DCPconst.pas");
10 | USEUNIT("DCPcrypt2.pas");
11 | USEUNIT("DCPreg.pas");
12 | USEUNIT("Ciphers\DCPblowfish.pas");
13 | USEUNIT("Ciphers\DCPcast128.pas");
14 | USEUNIT("Ciphers\DCPcast256.pas");
15 | USEUNIT("Ciphers\DCPdes.pas");
16 | USEUNIT("Ciphers\DCPgost.pas");
17 | USEUNIT("Ciphers\DCPice.pas");
18 | USEUNIT("Ciphers\DCPidea.pas");
19 | USEUNIT("Ciphers\DCPmars.pas");
20 | USEUNIT("Ciphers\DCPmisty1.pas");
21 | USEUNIT("Ciphers\DCPrc2.pas");
22 | USEUNIT("Ciphers\DCPrc4.pas");
23 | USEUNIT("Ciphers\DCPrc5.pas");
24 | USEUNIT("Ciphers\DCPrc6.pas");
25 | USEUNIT("Ciphers\DCPrijndael.pas");
26 | USEUNIT("Ciphers\DCPserpent.pas");
27 | USEUNIT("Ciphers\DCPtea.pas");
28 | USEUNIT("Ciphers\DCPtwofish.pas");
29 | USEUNIT("Hashes\DCPhaval.pas");
30 | USEUNIT("Hashes\DCPmd4.pas");
31 | USEUNIT("Hashes\DCPmd5.pas");
32 | USEUNIT("Hashes\DCPripemd128.pas");
33 | USEUNIT("Hashes\DCPripemd160.pas");
34 | USEUNIT("Hashes\DCPsha1.pas");
35 | USEUNIT("Hashes\DCPsha256.pas");
36 | USEUNIT("Hashes\DCPsha512.pas");
37 | USEUNIT("Hashes\DCPtiger.pas");
38 | //---------------------------------------------------------------------------
39 | #pragma package(smart_init)
40 | //---------------------------------------------------------------------------
41 |
42 | // Package source.
43 | //---------------------------------------------------------------------------
44 |
45 | #pragma argsused
46 | int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
47 | {
48 | return 1;
49 | }
50 | //---------------------------------------------------------------------------
51 |
--------------------------------------------------------------------------------
/DCPcppbuilder5.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPcppbuilder5.res
--------------------------------------------------------------------------------
/DCPdelphi2007.dof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi2007.dof
--------------------------------------------------------------------------------
/DCPdelphi2007.dpk:
--------------------------------------------------------------------------------
1 | package DCPdelphi2007;
2 |
3 | {$R *.res}
4 | {$ALIGN 8}
5 | {$ASSERTIONS ON}
6 | {$BOOLEVAL OFF}
7 | {$DEBUGINFO ON}
8 | {$EXTENDEDSYNTAX ON}
9 | {$IMPORTEDDATA ON}
10 | {$IOCHECKS ON}
11 | {$LOCALSYMBOLS ON}
12 | {$LONGSTRINGS ON}
13 | {$OPENSTRINGS ON}
14 | {$OPTIMIZATION ON}
15 | {$OVERFLOWCHECKS OFF}
16 | {$RANGECHECKS OFF}
17 | {$REFERENCEINFO ON}
18 | {$SAFEDIVIDE OFF}
19 | {$STACKFRAMES OFF}
20 | {$TYPEDADDRESS OFF}
21 | {$VARSTRINGCHECKS ON}
22 | {$WRITEABLECONST OFF}
23 | {$MINENUMSIZE 1}
24 | {$IMAGEBASE $400000}
25 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'}
26 | {$IMPLICITBUILD ON}
27 |
28 | requires
29 | rtl;
30 |
31 | contains
32 | DCPbase64 in 'DCPbase64.pas',
33 | DCPblockciphers in 'DCPblockciphers.pas',
34 | DCPconst in 'DCPconst.pas',
35 | DCPcrypt2 in 'DCPcrypt2.pas',
36 | DCPblowfish in 'Ciphers\DCPblowfish.pas',
37 | DCPcast128 in 'Ciphers\DCPcast128.pas',
38 | DCPcast256 in 'Ciphers\DCPcast256.pas',
39 | DCPdes in 'Ciphers\DCPdes.pas',
40 | DCPgost in 'Ciphers\DCPgost.pas',
41 | DCPice in 'Ciphers\DCPice.pas',
42 | DCPidea in 'Ciphers\DCPidea.pas',
43 | DCPmars in 'Ciphers\DCPmars.pas',
44 | DCPmisty1 in 'Ciphers\DCPmisty1.pas',
45 | DCPrc2 in 'Ciphers\DCPrc2.pas',
46 | DCPrc4 in 'Ciphers\DCPrc4.pas',
47 | DCPrc5 in 'Ciphers\DCPrc5.pas',
48 | DCPrc6 in 'Ciphers\DCPrc6.pas',
49 | DCPrijndael in 'Ciphers\DCPrijndael.pas',
50 | DCPtea in 'Ciphers\DCPtea.pas',
51 | DCPtwofish in 'Ciphers\DCPtwofish.pas',
52 | DCPhaval in 'Hashes\DCPhaval.pas',
53 | DCPmd4 in 'Hashes\DCPmd4.pas',
54 | DCPmd5 in 'Hashes\DCPmd5.pas',
55 | DCPripemd128 in 'Hashes\DCPripemd128.pas',
56 | DCPripemd160 in 'Hashes\DCPripemd160.pas',
57 | DCPsha1 in 'Hashes\DCPsha1.pas',
58 | DCPtiger in 'Hashes\DCPtiger.pas',
59 | DCPreg in 'DCPreg.pas',
60 | DCPserpent in 'Ciphers\DCPserpent.pas',
61 | DCPsha256 in 'Hashes\DCPsha256.pas',
62 | DCPsha512 in 'Hashes\DCPsha512.pas';
63 |
64 | end.
65 |
--------------------------------------------------------------------------------
/DCPdelphi2007.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi2007.res
--------------------------------------------------------------------------------
/DCPdelphi2009.dof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi2009.dof
--------------------------------------------------------------------------------
/DCPdelphi2009.dpk:
--------------------------------------------------------------------------------
1 | package DCPdelphi2009;
2 |
3 | {$R *.res}
4 | {$ALIGN 8}
5 | {$ASSERTIONS ON}
6 | {$BOOLEVAL OFF}
7 | {$DEBUGINFO ON}
8 | {$EXTENDEDSYNTAX ON}
9 | {$IMPORTEDDATA ON}
10 | {$IOCHECKS ON}
11 | {$LOCALSYMBOLS ON}
12 | {$LONGSTRINGS ON}
13 | {$OPENSTRINGS ON}
14 | {$OPTIMIZATION ON}
15 | {$OVERFLOWCHECKS OFF}
16 | {$RANGECHECKS OFF}
17 | {$REFERENCEINFO ON}
18 | {$SAFEDIVIDE OFF}
19 | {$STACKFRAMES OFF}
20 | {$TYPEDADDRESS OFF}
21 | {$VARSTRINGCHECKS ON}
22 | {$WRITEABLECONST OFF}
23 | {$MINENUMSIZE 1}
24 | {$IMAGEBASE $400000}
25 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'}
26 | {$IMPLICITBUILD ON}
27 |
28 | requires
29 | rtl;
30 |
31 | contains
32 | DCPbase64 in 'DCPbase64.pas',
33 | DCPblockciphers in 'DCPblockciphers.pas',
34 | DCPconst in 'DCPconst.pas',
35 | DCPcrypt2 in 'DCPcrypt2.pas',
36 | DCPblowfish in 'Ciphers\DCPblowfish.pas',
37 | DCPcast128 in 'Ciphers\DCPcast128.pas',
38 | DCPcast256 in 'Ciphers\DCPcast256.pas',
39 | DCPdes in 'Ciphers\DCPdes.pas',
40 | DCPgost in 'Ciphers\DCPgost.pas',
41 | DCPice in 'Ciphers\DCPice.pas',
42 | DCPidea in 'Ciphers\DCPidea.pas',
43 | DCPmars in 'Ciphers\DCPmars.pas',
44 | DCPmisty1 in 'Ciphers\DCPmisty1.pas',
45 | DCPrc2 in 'Ciphers\DCPrc2.pas',
46 | DCPrc4 in 'Ciphers\DCPrc4.pas',
47 | DCPrc5 in 'Ciphers\DCPrc5.pas',
48 | DCPrc6 in 'Ciphers\DCPrc6.pas',
49 | DCPrijndael in 'Ciphers\DCPrijndael.pas',
50 | DCPtea in 'Ciphers\DCPtea.pas',
51 | DCPtwofish in 'Ciphers\DCPtwofish.pas',
52 | DCPhaval in 'Hashes\DCPhaval.pas',
53 | DCPmd4 in 'Hashes\DCPmd4.pas',
54 | DCPmd5 in 'Hashes\DCPmd5.pas',
55 | DCPripemd128 in 'Hashes\DCPripemd128.pas',
56 | DCPripemd160 in 'Hashes\DCPripemd160.pas',
57 | DCPsha1 in 'Hashes\DCPsha1.pas',
58 | DCPtiger in 'Hashes\DCPtiger.pas',
59 | DCPreg in 'DCPreg.pas',
60 | DCPserpent in 'Ciphers\DCPserpent.pas',
61 | DCPsha256 in 'Hashes\DCPsha256.pas',
62 | DCPsha512 in 'Hashes\DCPsha512.pas';
63 |
64 | end.
65 |
--------------------------------------------------------------------------------
/DCPdelphi2009.dproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {ae9b70a6-b2c2-45a0-ba7b-2448a376d73f}
4 | DCPdelphi2009.dpk
5 | Debug
6 | AnyCPU
7 | DCC32
8 | C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\Bpl\DCPdelphi2009.bpl
9 | 12.0
10 | Debug
11 |
12 |
13 | true
14 |
15 |
16 | true
17 | Base
18 | true
19 |
20 |
21 | true
22 | Base
23 | true
24 |
25 |
26 | 00400000
27 | C:\Documents and Settings\All Users\Documents\RAD Studio\6.0\Bpl\DCPdelphi2009.bpl
28 | DCPcrypt cryptographic component library v2 BETA 3
29 | false
30 | true
31 | true
32 | 1
33 |
34 |
35 | 7.0
36 | False
37 | False
38 | 0
39 | RELEASE;$(DCC_Define)
40 |
41 |
42 | 7.0
43 |
44 |
45 | Delphi.Personality.12
46 | Package
47 |
48 |
49 |
50 | False
51 | True
52 | False
53 |
54 |
55 | True
56 | False
57 | 1
58 | 0
59 | 0
60 | 0
61 | False
62 | False
63 | False
64 | False
65 | False
66 | 1036
67 | 1252
68 |
69 |
70 |
71 |
72 | 1.0.0.0
73 |
74 |
75 |
76 |
77 |
78 | 1.0.0.0
79 |
80 |
81 |
82 | DCPdelphi2009.dpk
83 |
84 |
85 |
86 | 12
87 |
88 |
89 |
90 | MainSource
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | Base
126 |
127 |
128 | Cfg_2
129 | Base
130 |
131 |
132 | Cfg_1
133 | Base
134 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/DCPdelphi2009.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi2009.res
--------------------------------------------------------------------------------
/DCPdelphi4.dof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi4.dof
--------------------------------------------------------------------------------
/DCPdelphi4.dpk:
--------------------------------------------------------------------------------
1 | package DCPdelphi4;
2 |
3 | {$R *.RES}
4 | {$ALIGN ON}
5 | {$ASSERTIONS ON}
6 | {$BOOLEVAL OFF}
7 | {$DEBUGINFO ON}
8 | {$EXTENDEDSYNTAX ON}
9 | {$IMPORTEDDATA ON}
10 | {$IOCHECKS ON}
11 | {$LOCALSYMBOLS ON}
12 | {$LONGSTRINGS ON}
13 | {$OPENSTRINGS ON}
14 | {$OPTIMIZATION ON}
15 | {$OVERFLOWCHECKS OFF}
16 | {$RANGECHECKS OFF}
17 | {$REFERENCEINFO ON}
18 | {$SAFEDIVIDE OFF}
19 | {$STACKFRAMES OFF}
20 | {$TYPEDADDRESS OFF}
21 | {$VARSTRINGCHECKS ON}
22 | {$WRITEABLECONST ON}
23 | {$MINENUMSIZE 1}
24 | {$IMAGEBASE $00400000}
25 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'}
26 | {$DESIGNONLY}
27 | {$IMPLICITBUILD OFF}
28 |
29 | requires
30 | vcl40;
31 |
32 | contains
33 | DCPbase64 in 'DCPbase64.pas',
34 | DCPblockciphers in 'DCPblockciphers.pas',
35 | DCPconst in 'DCPconst.pas',
36 | DCPcrypt2 in 'DCPcrypt2.pas',
37 | DCPblowfish in 'Ciphers\DCPblowfish.pas',
38 | DCPcast128 in 'Ciphers\DCPcast128.pas',
39 | DCPcast256 in 'Ciphers\DCPcast256.pas',
40 | DCPdes in 'Ciphers\DCPdes.pas',
41 | DCPgost in 'Ciphers\DCPgost.pas',
42 | DCPice in 'Ciphers\DCPice.pas',
43 | DCPidea in 'Ciphers\DCPidea.pas',
44 | DCPmars in 'Ciphers\DCPmars.pas',
45 | DCPmisty1 in 'Ciphers\DCPmisty1.pas',
46 | DCPrc2 in 'Ciphers\DCPrc2.pas',
47 | DCPrc4 in 'Ciphers\DCPrc4.pas',
48 | DCPrc5 in 'Ciphers\DCPrc5.pas',
49 | DCPrc6 in 'Ciphers\DCPrc6.pas',
50 | DCPrijndael in 'Ciphers\DCPrijndael.pas',
51 | DCPtea in 'Ciphers\DCPtea.pas',
52 | DCPtwofish in 'Ciphers\DCPtwofish.pas',
53 | DCPhaval in 'Hashes\DCPhaval.pas',
54 | DCPmd4 in 'Hashes\DCPmd4.pas',
55 | DCPmd5 in 'Hashes\DCPmd5.pas',
56 | DCPripemd128 in 'Hashes\DCPripemd128.pas',
57 | DCPripemd160 in 'Hashes\DCPripemd160.pas',
58 | DCPsha1 in 'Hashes\DCPsha1.pas',
59 | DCPtiger in 'Hashes\DCPtiger.pas',
60 | DCPreg in 'DCPreg.pas',
61 | DCPserpent in 'Ciphers\DCPserpent.pas',
62 | DCPsha256 in 'Hashes\DCPsha256.pas',
63 | DCPsha512 in 'Hashes\DCPsha512.pas';
64 |
65 | end.
66 |
--------------------------------------------------------------------------------
/DCPdelphi4.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi4.res
--------------------------------------------------------------------------------
/DCPdelphi5.dof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi5.dof
--------------------------------------------------------------------------------
/DCPdelphi5.dpk:
--------------------------------------------------------------------------------
1 | package DCPdelphi4;
2 |
3 | {$R *.RES}
4 | {$ALIGN ON}
5 | {$ASSERTIONS ON}
6 | {$BOOLEVAL OFF}
7 | {$DEBUGINFO ON}
8 | {$EXTENDEDSYNTAX ON}
9 | {$IMPORTEDDATA ON}
10 | {$IOCHECKS ON}
11 | {$LOCALSYMBOLS ON}
12 | {$LONGSTRINGS ON}
13 | {$OPENSTRINGS ON}
14 | {$OPTIMIZATION ON}
15 | {$OVERFLOWCHECKS OFF}
16 | {$RANGECHECKS OFF}
17 | {$REFERENCEINFO ON}
18 | {$SAFEDIVIDE OFF}
19 | {$STACKFRAMES OFF}
20 | {$TYPEDADDRESS OFF}
21 | {$VARSTRINGCHECKS ON}
22 | {$WRITEABLECONST ON}
23 | {$MINENUMSIZE 1}
24 | {$IMAGEBASE $400000}
25 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'}
26 | {$DESIGNONLY}
27 | {$IMPLICITBUILD OFF}
28 |
29 | requires
30 | vcl50;
31 |
32 | contains
33 | DCPbase64 in 'DCPbase64.pas',
34 | DCPblockciphers in 'DCPblockciphers.pas',
35 | DCPconst in 'DCPconst.pas',
36 | DCPcrypt2 in 'DCPcrypt2.pas',
37 | DCPblowfish in 'Ciphers\DCPblowfish.pas',
38 | DCPcast128 in 'Ciphers\DCPcast128.pas',
39 | DCPcast256 in 'Ciphers\DCPcast256.pas',
40 | DCPdes in 'Ciphers\DCPdes.pas',
41 | DCPgost in 'Ciphers\DCPgost.pas',
42 | DCPice in 'Ciphers\DCPice.pas',
43 | DCPidea in 'Ciphers\DCPidea.pas',
44 | DCPmars in 'Ciphers\DCPmars.pas',
45 | DCPmisty1 in 'Ciphers\DCPmisty1.pas',
46 | DCPrc2 in 'Ciphers\DCPrc2.pas',
47 | DCPrc4 in 'Ciphers\DCPrc4.pas',
48 | DCPrc5 in 'Ciphers\DCPrc5.pas',
49 | DCPrc6 in 'Ciphers\DCPrc6.pas',
50 | DCPrijndael in 'Ciphers\DCPrijndael.pas',
51 | DCPtea in 'Ciphers\DCPtea.pas',
52 | DCPtwofish in 'Ciphers\DCPtwofish.pas',
53 | DCPhaval in 'Hashes\DCPhaval.pas',
54 | DCPmd4 in 'Hashes\DCPmd4.pas',
55 | DCPmd5 in 'Hashes\DCPmd5.pas',
56 | DCPripemd128 in 'Hashes\DCPripemd128.pas',
57 | DCPripemd160 in 'Hashes\DCPripemd160.pas',
58 | DCPsha1 in 'Hashes\DCPsha1.pas',
59 | DCPtiger in 'Hashes\DCPtiger.pas',
60 | DCPreg in 'DCPreg.pas',
61 | DCPserpent in 'Ciphers\DCPserpent.pas',
62 | DCPsha256 in 'Hashes\DCPsha256.pas',
63 | DCPsha512 in 'Hashes\DCPsha512.pas';
64 |
65 | end.
66 |
--------------------------------------------------------------------------------
/DCPdelphi5.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi5.res
--------------------------------------------------------------------------------
/DCPdelphi6.dof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi6.dof
--------------------------------------------------------------------------------
/DCPdelphi6.dpk:
--------------------------------------------------------------------------------
1 | package DCPdelphi6;
2 |
3 | {$R *.res}
4 | {$ALIGN 8}
5 | {$ASSERTIONS ON}
6 | {$BOOLEVAL OFF}
7 | {$DEBUGINFO ON}
8 | {$EXTENDEDSYNTAX ON}
9 | {$IMPORTEDDATA ON}
10 | {$IOCHECKS ON}
11 | {$LOCALSYMBOLS ON}
12 | {$LONGSTRINGS ON}
13 | {$OPENSTRINGS ON}
14 | {$OPTIMIZATION ON}
15 | {$OVERFLOWCHECKS OFF}
16 | {$RANGECHECKS OFF}
17 | {$REFERENCEINFO ON}
18 | {$SAFEDIVIDE OFF}
19 | {$STACKFRAMES OFF}
20 | {$TYPEDADDRESS OFF}
21 | {$VARSTRINGCHECKS ON}
22 | {$WRITEABLECONST OFF}
23 | {$MINENUMSIZE 1}
24 | {$IMAGEBASE $400000}
25 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'}
26 | {$DESIGNONLY}
27 | {$IMPLICITBUILD OFF}
28 |
29 | requires
30 | rtl;
31 |
32 | contains
33 | DCPbase64 in 'DCPbase64.pas',
34 | DCPblockciphers in 'DCPblockciphers.pas',
35 | DCPconst in 'DCPconst.pas',
36 | DCPcrypt2 in 'DCPcrypt2.pas',
37 | DCPblowfish in 'Ciphers\DCPblowfish.pas',
38 | DCPcast128 in 'Ciphers\DCPcast128.pas',
39 | DCPcast256 in 'Ciphers\DCPcast256.pas',
40 | DCPdes in 'Ciphers\DCPdes.pas',
41 | DCPgost in 'Ciphers\DCPgost.pas',
42 | DCPice in 'Ciphers\DCPice.pas',
43 | DCPidea in 'Ciphers\DCPidea.pas',
44 | DCPmars in 'Ciphers\DCPmars.pas',
45 | DCPmisty1 in 'Ciphers\DCPmisty1.pas',
46 | DCPrc2 in 'Ciphers\DCPrc2.pas',
47 | DCPrc4 in 'Ciphers\DCPrc4.pas',
48 | DCPrc5 in 'Ciphers\DCPrc5.pas',
49 | DCPrc6 in 'Ciphers\DCPrc6.pas',
50 | DCPrijndael in 'Ciphers\DCPrijndael.pas',
51 | DCPtea in 'Ciphers\DCPtea.pas',
52 | DCPtwofish in 'Ciphers\DCPtwofish.pas',
53 | DCPhaval in 'Hashes\DCPhaval.pas',
54 | DCPmd4 in 'Hashes\DCPmd4.pas',
55 | DCPmd5 in 'Hashes\DCPmd5.pas',
56 | DCPripemd128 in 'Hashes\DCPripemd128.pas',
57 | DCPripemd160 in 'Hashes\DCPripemd160.pas',
58 | DCPsha1 in 'Hashes\DCPsha1.pas',
59 | DCPtiger in 'Hashes\DCPtiger.pas',
60 | DCPreg in 'DCPreg.pas',
61 | DCPserpent in 'Ciphers\DCPserpent.pas',
62 | DCPsha256 in 'Hashes\DCPsha256.pas',
63 | DCPsha512 in 'Hashes\DCPsha512.pas';
64 |
65 | end.
66 |
--------------------------------------------------------------------------------
/DCPdelphi6.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPdelphi6.res
--------------------------------------------------------------------------------
/DCPhashes.dcr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPhashes.dcr
--------------------------------------------------------------------------------
/DCPkylix.conf:
--------------------------------------------------------------------------------
1 | -$A8
2 | -$B-
3 | -$C+
4 | -$D+
5 | -$E-
6 | -$F-
7 | -$G+
8 | -$H+
9 | -$I+
10 | -$J-
11 | -$K-
12 | -$L+
13 | -$M-
14 | -$N+
15 | -$O+
16 | -$P+
17 | -$Q-
18 | -$R-
19 | -$S-
20 | -$T-
21 | -$U-
22 | -$V+
23 | -$W-
24 | -$X+
25 | -$YD
26 | -$Z1
27 | -cg
28 | -H+
29 | -W+
30 | -M
31 | -$M16384,1048576
32 | -K$00400000
33 | -Z
34 |
--------------------------------------------------------------------------------
/DCPkylix.dpk:
--------------------------------------------------------------------------------
1 | package DCPkylix;
2 |
3 | {$R *.res}
4 | {$ALIGN 8}
5 | {$ASSERTIONS ON}
6 | {$BOOLEVAL OFF}
7 | {$DEBUGINFO ON}
8 | {$EXTENDEDSYNTAX ON}
9 | {$IMPORTEDDATA ON}
10 | {$IOCHECKS ON}
11 | {$LOCALSYMBOLS ON}
12 | {$LONGSTRINGS ON}
13 | {$OPENSTRINGS ON}
14 | {$OPTIMIZATION ON}
15 | {$OVERFLOWCHECKS OFF}
16 | {$RANGECHECKS OFF}
17 | {$REFERENCEINFO ON}
18 | {$SAFEDIVIDE OFF}
19 | {$STACKFRAMES OFF}
20 | {$TYPEDADDRESS OFF}
21 | {$VARSTRINGCHECKS ON}
22 | {$WRITEABLECONST OFF}
23 | {$MINENUMSIZE 1}
24 | {$IMAGEBASE $400000}
25 | {$DESCRIPTION 'DCPcrypt cryptographic components library v2 BETA 3'}
26 | {$DESIGNONLY}
27 | {$IMPLICITBUILD OFF}
28 |
29 | requires
30 | baseclx,
31 | visualclx;
32 |
33 | contains
34 | DCPbase64 in 'DCPbase64.pas',
35 | DCPblockciphers in 'DCPblockciphers.pas',
36 | DCPconst in 'DCPconst.pas',
37 | DCPcrypt2 in 'DCPcrypt2.pas',
38 | DCPreg in 'DCPreg.pas',
39 | DCPblowfish in 'Ciphers/DCPblowfish.pas',
40 | DCPcast128 in 'Ciphers/DCPcast128.pas',
41 | DCPcast256 in 'Ciphers/DCPcast256.pas',
42 | DCPdes in 'Ciphers/DCPdes.pas',
43 | DCPgost in 'Ciphers/DCPgost.pas',
44 | DCPice in 'Ciphers/DCPice.pas',
45 | DCPidea in 'Ciphers/DCPidea.pas',
46 | DCPmars in 'Ciphers/DCPmars.pas',
47 | DCPmisty1 in 'Ciphers/DCPmisty1.pas',
48 | DCPrc2 in 'Ciphers/DCPrc2.pas',
49 | DCPrc4 in 'Ciphers/DCPrc4.pas',
50 | DCPrc5 in 'Ciphers/DCPrc5.pas',
51 | DCPrc6 in 'Ciphers/DCPrc6.pas',
52 | DCPrijndael in 'Ciphers/DCPrijndael.pas',
53 | DCPserpent in 'Ciphers/DCPserpent.pas',
54 | DCPtea in 'Ciphers/DCPtea.pas',
55 | DCPtwofish in 'Ciphers/DCPtwofish.pas',
56 | DCPhaval in 'Hashes/DCPhaval.pas',
57 | DCPmd4 in 'Hashes/DCPmd4.pas',
58 | DCPmd5 in 'Hashes/DCPmd5.pas',
59 | DCPripemd128 in 'Hashes/DCPripemd128.pas',
60 | DCPripemd160 in 'Hashes/DCPripemd160.pas',
61 | DCPsha1 in 'Hashes/DCPsha1.pas',
62 | DCPsha256 in 'Hashes/DCPsha256.pas',
63 | DCPsha512 in 'Hashes/DCPsha512.pas',
64 | DCPtiger in 'Hashes/DCPtiger.pas';
65 |
66 | end.
67 |
--------------------------------------------------------------------------------
/DCPkylix.kof:
--------------------------------------------------------------------------------
1 | [Compiler]
2 | A=8
3 | B=0
4 | C=1
5 | D=1
6 | E=0
7 | F=0
8 | G=1
9 | H=1
10 | I=1
11 | J=0
12 | K=0
13 | L=1
14 | M=0
15 | N=1
16 | O=1
17 | P=1
18 | Q=0
19 | R=0
20 | S=0
21 | T=0
22 | U=0
23 | V=1
24 | W=0
25 | X=1
26 | Y=1
27 | Z=1
28 | ShowHints=1
29 | ShowWarnings=1
30 | UnitAliases=
31 |
32 | [Linker]
33 | MapFile=0
34 | OutputObjs=0
35 | ConsoleApp=1
36 | DebugInfo=0
37 | RemoteSymbols=0
38 | MinStackSize=16384
39 | MaxStackSize=1048576
40 | ImageBase=4194304
41 | ExeDescription=DCPcrypt cryptographic components library v2 BETA 3
42 | DynamicLoader=/lib/ld-linux.so.2
43 |
44 | [Directories]
45 | OutputDir=
46 | UnitOutputDir=
47 | PackageDLLOutputDir=
48 | PackageDCPOutputDir=
49 | SearchPath=
50 | Packages=baseclx:visualclx
51 | Conditionals=
52 | DebugSourceDirs=
53 | UsePackages=0
54 |
55 | [Parameters]
56 | RunParams=
57 | HostApplication=
58 | Launcher=/usr/X11R6/bin/xterm -T KylixDebuggerOutput -e bash -i -c %debuggee%
59 | UseLauncher=0
60 | DebugCWD=
61 |
62 |
--------------------------------------------------------------------------------
/DCPkylix.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPkylix.res
--------------------------------------------------------------------------------
/DCPreg.pas:
--------------------------------------------------------------------------------
1 | {******************************************************************************}
2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
3 | {******************************************************************************}
4 | {* Component registration for DCPcrypt ****************************************}
5 | {******************************************************************************}
6 | {* Copyright (c) 1999-2002 David Barton *}
7 | {* Permission is hereby granted, free of charge, to any person obtaining a *}
8 | {* copy of this software and associated documentation files (the "Software"), *}
9 | {* to deal in the Software without restriction, including without limitation *}
10 | {* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
11 | {* and/or sell copies of the Software, and to permit persons to whom the *}
12 | {* Software is furnished to do so, subject to the following conditions: *}
13 | {* *}
14 | {* The above copyright notice and this permission notice shall be included in *}
15 | {* all copies or substantial portions of the Software. *}
16 | {* *}
17 | {* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
18 | {* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
19 | {* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
20 | {* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
21 | {* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
22 | {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
23 | {* DEALINGS IN THE SOFTWARE. *}
24 | {******************************************************************************}
25 | unit DCPreg;
26 |
27 | interface
28 | uses
29 | Classes;
30 |
31 | procedure Register;
32 |
33 | implementation
34 | uses
35 | DCPcrypt2, DCPblockciphers, DCPconst, DCPblowfish, DCPcast128, DCPcast256,
36 | DCPdes, DCPgost, DCPice, DCPidea, DCPmars, DCPmisty1, DCPrc2, DCPrc4, DCPrc5,
37 | DCPrc6, DCPrijndael, DCPserpent, DCPtea, DCPtwofish,
38 | DCPhaval, DCPmd4, DCPmd5, DCPripemd128, DCPripemd160, DCPsha1, DCPsha256,
39 | DCPsha512, DCPtiger;
40 |
41 | {$R DCPciphers.dcr}
42 | {$R DCPhashes.dcr}
43 |
44 | procedure Register;
45 | begin
46 | RegisterComponents(DCPcipherpage,[TDCP_blowfish,TDCP_cast128,TDCP_cast256,
47 | TDCP_des,TDCP_3des,{TDCP_gost,}TDCP_ice,TDCP_thinice,TDCP_ice2,TDCP_idea,
48 | TDCP_mars,TDCP_misty1,TDCP_rc2,TDCP_rc4,TDCP_rc5,TDCP_rc6,TDCP_rijndael,
49 | TDCP_serpent,TDCP_tea,TDCP_twofish]);
50 | RegisterComponents(DCPhashpage,[TDCP_haval,TDCP_md4,TDCP_md5,TDCP_ripemd128,
51 | TDCP_ripemd160,TDCP_sha1,TDCP_sha256,TDCP_sha384,TDCP_sha512,TDCP_tiger]);
52 | end;
53 |
54 | end.
55 |
--------------------------------------------------------------------------------
/Docs/BlockCiphers.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | DCPcrypt v2: Users Guide - Block Ciphers
4 |
5 |
6 | DCPcrypt Cryptographic Component Library v2
7 | Copyright © 1999-2002 David Barton
8 | http://www.cityinthesky.co.uk/
9 | crypto@cityinthesky.co.uk
10 |
Block Ciphers - TDCP_blockcipher
11 |
All block ciphers are inherited from the TDCP_blockcipher component via either the TDCP_blockcipher64 and TDCP_blockcipher128 components (the latter implement the block size specific code).
12 |
The TDCP_blockcipher component extends the TDCP_cipher component to provide chaining mode functions. Functions available are:
13 |
14 | property Initialized : boolean;
15 | property Id : integer;
16 | property Algorithm : string;
17 | property MaxKeySize : integer;
18 | property BlockSize : integer;
19 | property CipherMode : TDCP_ciphermode;
20 |
21 | class function SelfTest : boolean;
22 |
23 | procedure SetIV (const Value);
24 | procedure GetIV (var Value);
25 |
26 | procedure Init (const Key; Size: longword; InitVector: pointer);
27 | procedure InitStr (const Key: string; HashType: TDCP_hashclass);
28 | procedure Burn ;
29 | procedure Reset ;
30 | procedure Encrypt (const Indata; var Outdata; Size: longword);
31 | procedure Decrypt (const Indata; var Outdata; Size: longword);
32 | function EncryptStream (InStream, OutStream: TStream; Size: longword): longword;
33 | function DecryptStream (InStream, OutStream: TStream; Size: longword): longword;
34 | function EncryptString (const Str: string): string;
35 | function DecryptString (const Str: string): string;
36 | procedure EncryptECB (const Indata; var Outdata);
37 | procedure DecryptECB (const Indata; var Outdata);
38 | procedure EncryptCBC (const Indata; var Outdata; Size: longword);
39 | procedure DecryptCBC (const Indata; var Outdata; Size: longword);
40 | procedure EncryptCFB8bit (const Indata; var Outdata; Size: longword);
41 | procedure DecryptCFB8bit (const Indata; var Outdata; Size: longword);
42 | procedure EncryptCFBblock (const Indata; var Outdata; Size: longword);
43 | procedure DecryptCFBblock (const Indata; var Outdata; Size: longword);
44 | procedure EncryptOFB (const Indata; var Outdata; Size: longword);
45 | procedure DecryptOFB (const Indata; var Outdata; Size: longword);
46 | procedure EncryptCTR (const Indata; var Outdata; Size: longword);
47 | procedure DecryptCTR (const Indata; var Outdata; Size: longword);
48 |
49 |
50 | Function descriptions
51 |
property BlockSize: integer;
52 |
This contains the block size of the cipher in BITS.
53 |
property CipherMode: TDCP_ciphermode;
54 |
This is the current chaining mode used when Encrypt is called. The available modes are:
55 |
56 | cmCBC - Cipher block chaining.
57 | cmCFB8bit - 8bit cipher feedback.
58 | cmCFBblock - Cipher feedback (using the block size of the algorithm).
59 | cmOFB - Output feedback.
60 | cmCTR - Counter.
61 |
62 | Each chaining mode has it's own pro's and cons. See any good book on cryptography or the NIST publication SP800-38A for details on each.
63 |
procedure SetIV(const Value);
64 |
Use this procedure to set the current chaining mode information to Value. This variable should be the same size as the block size. When Reset is called subsequent to this, the chaining information will be set back to Value.
65 |
procedure GetIV(var Value);
66 |
This returns in Value the current chaining mode information, to get the initial chaining mode information you need to call Reset before calling GetIV. The variable passed in Value must be at least the same size as the block size otherwise you will get a buffer overflow.
67 |
procedure EncryptCBC(const Indata; var Outdata; Size: longword);
68 | procedure DecryptCBC(const Indata; var Outdata; Size: longword);
69 | procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword);
70 | procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword);
71 | procedure EncryptCFBblock(const Indata; var Outdata; Size: longword);
72 | procedure DecryptCFBblock(const Indata; var Outdata; Size: longword);
73 | procedure EncryptOFB(const Indata; var Outdata; Size: longword);
74 | procedure DecryptOFB(const Indata; var Outdata; Size: longword);
75 | procedure EncryptCTR(const Indata; var Outdata; Size: longword);
76 | procedure DecryptCTR(const Indata; var Outdata; Size: longword);
77 |
These procedures encrypt/decrypt Size bytes of data from Indata and places the result in Outdata. These all employ chaining mode methods of encryption/decryption and so may need to be used inconjunction with Reset . The CBC method uses short block encryption as specified in Bruce Schneier's "Applied Cryptography" for data blocks that are not multiples of the block size.
78 |
79 |
Index , Ciphers , Hashes
80 |
81 |
DCPcrypt is copyrighted © 1999-2002 David Barton.
82 | All trademarks are property of their respective owners.
83 |
84 |
85 |
--------------------------------------------------------------------------------
/Docs/Hashes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | DCPcrypt v2: Users Guide - Hash Algorithms
4 |
5 |
6 | DCPcrypt Cryptographic Component Library v2
7 | Copyright © 1999-2002 David Barton
8 | http://www.cityinthesky.co.uk/
9 | crypto@cityinthesky.co.uk
10 |
Hash Algorithms - TDCP_hash
11 |
All hashes are derived from the TDCP_hash component. It provides a range of functions to allow the hashing of virtually every type of data.
12 |
Functions available are:
13 |
14 | property Initialized : boolean;
15 | property Id: integer ;
16 | property Algorithm : string;
17 | property HashSize : integer;
18 |
19 | class function SelfTest : boolean;
20 |
21 | procedure Init ;
22 | procedure Final (var Digest);
23 | procedure Burn ;
24 |
25 | procedure Update (const Buffer; Size: longword);
26 | procedure UpdateStream (Stream: TStream; Size: longword);
27 | procedure UpdateStr (const Str: string);
28 |
29 | Example usage:
30 |
33 |
34 | property Initialized: boolean;
35 |
This is set to true after Init has been called.
36 |
property Id: integer;
37 |
Every algorithm I implement gets given a unique ID number so that if I use several different algorithms within a program I can determine which one was used. This is a purely arbitrary numbering system.
38 |
property Algorithm: string;
39 |
This is the name of the algorithm implemented in the component.
40 |
property HashSize: integer;
41 |
This is the size of the output of the hash algorithm in BITS.
42 |
class function SelfTest: boolean;
43 |
In order to test whether the implementations have all been compiled correctly you can call the SelfTest function. This compares the results of several hash operations with known results for the algorithms (so called test vectors). If all the tests are passed then true is returned. If ANY of the tests are failed then false is returned. You may want to run this function for all the components when you first install the DCPcrypt package and again if you modify any of the source files, you don't need to run this everytime your program is run. Note: this only performs a selection of tests, it is not exhaustive.
44 |
procedure Init;
45 |
Call this procedure to initialize the hash algorithm, this must be called before using the Update procedure.
46 |
procedure Final(var Digest);
47 |
This procedure returns the final message digest (hash) in Digest. This variable must be the same size as the hash size. This procedure also calls Burn to clear any stored information.
48 |
procedure Burn;
49 |
Call this procedure if you want to abort the hashing operation (normally Final is used). This clears all information stored within the hash. Before the hash can be used again Init must be called.
50 |
procedure Update(const Buffer; Size: longword);
51 |
This procedure hashes Size bytes of Buffer. To get the hash result call Final .
52 |
Update example:
53 |
54 | procedure HashBuffer(const Buffer; Size: longint ; var Output);
55 | var
56 | Hash: TDCP_ripemd160;
57 | begin
58 | Hash:= TDCP_ripemd160.Create(nil );
59 | Hash.Init;
60 | Hash.Update(Buffer,Size);
61 | Hash.Final(Output);
62 | Hash.Free;
63 | end ;
64 |
65 | procedure UpdateStream(Stream: TStream; Size: longword);
66 |
This procedure hashes Size bytes from Stream. To get the hash result call Final .
67 |
procedure UpdateStr(const Str: string);
68 |
This procedure hashes the string Str. To get the hash result call Final .
69 |
70 | Example 1 - File hashing
71 |
This example shows how you can hash the contents of a file
72 |
73 | procedure TForm1.Button1Click(Sender: TObject);
74 | var
75 | Hash: TDCP_ripemd160;
76 | Digest: array [0..19] of byte ; // RipeMD-160 produces a 160bit digest (20bytes)
77 | Source: TFileStream;
78 | i: integer ;
79 | s: string;
80 | begin
81 | Source:= nil ;
82 | try
83 | Source:= TFileStream.Create(Edit1.Text,fmOpenRead); // open the file specified by Edit1
84 | except
85 | MessageDlg('Unable to open file',mtError,[mbOK],0);
86 | end ;
87 | if Source <> nil then
88 | begin
89 | Hash:= TDCP_ripemd160.Create(Self); // create the hash
90 | Hash.Init; // initialize it
91 | Hash.UpdateStream(Source,Source.Size); // hash the stream contents
92 | Hash.Final(Digest); // produce the digest
93 | Source.Free;
94 | s:= '';
95 | for i:= 0 to 19 do
96 | s:= s + IntToHex(Digest[i],2);
97 | Edit2.Text:= s; // display the digest
98 | end ;
99 | end ;
100 |
101 |
102 |
Index , Ciphers , Block Ciphers
103 |
104 |
DCPcrypt is copyrighted © 1999-2002 David Barton.
105 | All trademarks are property of their respective owners.
106 |
107 |
108 |
--------------------------------------------------------------------------------
/Docs/MIT_license.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a
6 | copy of this software and associated documentation files (the "Software"),
7 | to deal in the Software without restriction, including without limitation
8 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | and/or sell copies of the Software, and to permit persons to whom the
10 | Software is furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 | DEALINGS IN THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Docs/osi-certified-120x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/Docs/osi-certified-120x100.png
--------------------------------------------------------------------------------
/Hashes/DCPmd4.pas:
--------------------------------------------------------------------------------
1 | {******************************************************************************}
2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
3 | {******************************************************************************}
4 | {* A binary compatible implementation of MD4 **********************************}
5 | {******************************************************************************}
6 | {* Copyright (c) 1999-2002 David Barton *}
7 | {* Permission is hereby granted, free of charge, to any person obtaining a *}
8 | {* copy of this software and associated documentation files (the "Software"), *}
9 | {* to deal in the Software without restriction, including without limitation *}
10 | {* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
11 | {* and/or sell copies of the Software, and to permit persons to whom the *}
12 | {* Software is furnished to do so, subject to the following conditions: *}
13 | {* *}
14 | {* The above copyright notice and this permission notice shall be included in *}
15 | {* all copies or substantial portions of the Software. *}
16 | {* *}
17 | {* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
18 | {* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
19 | {* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
20 | {* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
21 | {* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
22 | {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
23 | {* DEALINGS IN THE SOFTWARE. *}
24 | {******************************************************************************}
25 | unit DCPmd4;
26 |
27 | interface
28 | uses
29 | Classes, Sysutils, DCPcrypt2, DCPconst;
30 |
31 | type
32 | TDCP_md4= class(TDCP_hash)
33 | protected
34 | LenHi, LenLo: longword;
35 | Index: DWord;
36 | CurrentHash: array[0..3] of DWord;
37 | HashBuffer: array[0..63] of byte;
38 | procedure Compress;
39 | public
40 | class function GetId: integer; override;
41 | class function GetAlgorithm: string; override;
42 | class function GetHashSize: integer; override;
43 | class function SelfTest: boolean; override;
44 | procedure Init; override;
45 | procedure Burn; override;
46 | procedure Update(const Buffer; Size: longword); override;
47 | procedure Final(var Digest); override;
48 | end;
49 |
50 |
51 |
52 | {******************************************************************************}
53 | {******************************************************************************}
54 | implementation
55 | {$R-}{$Q-}
56 |
57 | function LRot32(a, b: longword): longword;
58 | begin
59 | Result:= (a shl b) or (a shr (32-b));
60 | end;
61 |
62 | procedure TDCP_md4.Compress;
63 | var
64 | Data: array[0..15] of dword;
65 | A, B, C, D: dword;
66 | begin
67 | FillChar(Data, SizeOf(Data), 0);
68 | Move(HashBuffer,Data,Sizeof(Data));
69 | A:= CurrentHash[0];
70 | B:= CurrentHash[1];
71 | C:= CurrentHash[2];
72 | D:= CurrentHash[3];
73 |
74 | A:= LRot32(A + (D xor (B and (C xor D))) + Data[ 0],3);
75 | D:= LRot32(D + (C xor (A and (B xor C))) + Data[ 1],7);
76 | C:= LRot32(C + (B xor (D and (A xor B))) + Data[ 2],11);
77 | B:= LRot32(B + (A xor (C and (D xor A))) + Data[ 3],19);
78 | A:= LRot32(A + (D xor (B and (C xor D))) + Data[ 4],3);
79 | D:= LRot32(D + (C xor (A and (B xor C))) + Data[ 5],7);
80 | C:= LRot32(C + (B xor (D and (A xor B))) + Data[ 6],11);
81 | B:= LRot32(B + (A xor (C and (D xor A))) + Data[ 7],19);
82 | A:= LRot32(A + (D xor (B and (C xor D))) + Data[ 8],3);
83 | D:= LRot32(D + (C xor (A and (B xor C))) + Data[ 9],7);
84 | C:= LRot32(C + (B xor (D and (A xor B))) + Data[10],11);
85 | B:= LRot32(B + (A xor (C and (D xor A))) + Data[11],19);
86 | A:= LRot32(A + (D xor (B and (C xor D))) + Data[12],3);
87 | D:= LRot32(D + (C xor (A and (B xor C))) + Data[13],7);
88 | C:= LRot32(C + (B xor (D and (A xor B))) + Data[14],11);
89 | B:= LRot32(B + (A xor (C and (D xor A))) + Data[15],19);
90 |
91 | A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 0] + $5a827999,3);
92 | D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 4] + $5a827999,5);
93 | C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[ 8] + $5a827999,9);
94 | B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[12] + $5a827999,13);
95 | A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 1] + $5a827999,3);
96 | D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 5] + $5a827999,5);
97 | C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[ 9] + $5a827999,9);
98 | B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[13] + $5a827999,13);
99 | A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 2] + $5a827999,3);
100 | D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 6] + $5a827999,5);
101 | C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[10] + $5a827999,9);
102 | B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[14] + $5a827999,13);
103 | A:= LRot32(A + ((B and C) or (B and D) or (C and D)) + Data[ 3] + $5a827999,3);
104 | D:= LRot32(D + ((A and B) or (A and C) or (B and C)) + Data[ 7] + $5a827999,5);
105 | C:= LRot32(C + ((D and A) or (D and B) or (A and B)) + Data[11] + $5a827999,9);
106 | B:= LRot32(B + ((C and D) or (C and A) or (D and A)) + Data[15] + $5a827999,13);
107 |
108 | A:= LRot32(A + (B xor C xor D) + Data[ 0] + $6ed9eba1,3);
109 | D:= LRot32(D + (A xor B xor C) + Data[ 8] + $6ed9eba1,9);
110 | C:= LRot32(C + (D xor A xor B) + Data[ 4] + $6ed9eba1,11);
111 | B:= LRot32(B + (C xor D xor A) + Data[12] + $6ed9eba1,15);
112 | A:= LRot32(A + (B xor C xor D) + Data[ 2] + $6ed9eba1,3);
113 | D:= LRot32(D + (A xor B xor C) + Data[10] + $6ed9eba1,9);
114 | C:= LRot32(C + (D xor A xor B) + Data[ 6] + $6ed9eba1,11);
115 | B:= LRot32(B + (C xor D xor A) + Data[14] + $6ed9eba1,15);
116 | A:= LRot32(A + (B xor C xor D) + Data[ 1] + $6ed9eba1,3);
117 | D:= LRot32(D + (A xor B xor C) + Data[ 9] + $6ed9eba1,9);
118 | C:= LRot32(C + (D xor A xor B) + Data[ 5] + $6ed9eba1,11);
119 | B:= LRot32(B + (C xor D xor A) + Data[13] + $6ed9eba1,15);
120 | A:= LRot32(A + (B xor C xor D) + Data[ 3] + $6ed9eba1,3);
121 | D:= LRot32(D + (A xor B xor C) + Data[11] + $6ed9eba1,9);
122 | C:= LRot32(C + (D xor A xor B) + Data[ 7] + $6ed9eba1,11);
123 | B:= LRot32(B + (C xor D xor A) + Data[15] + $6ed9eba1,15);
124 |
125 | Inc(CurrentHash[0],A);
126 | Inc(CurrentHash[1],B);
127 | Inc(CurrentHash[2],C);
128 | Inc(CurrentHash[3],D);
129 | Index:= 0;
130 | FillChar(HashBuffer,Sizeof(HashBuffer),0);
131 | end;
132 |
133 | class function TDCP_md4.GetHashSize: integer;
134 | begin
135 | Result:= 128;
136 | end;
137 |
138 | class function TDCP_md4.GetId: integer;
139 | begin
140 | Result:= DCP_md4;
141 | end;
142 |
143 | class function TDCP_md4.GetAlgorithm: string;
144 | begin
145 | Result:= 'MD4';
146 | end;
147 |
148 | class function TDCP_md4.SelfTest: boolean;
149 | const
150 | Test1Out: array[0..15] of byte=
151 | ($a4,$48,$01,$7a,$af,$21,$d8,$52,$5f,$c1,$0a,$e8,$7a,$a6,$72,$9d);
152 | Test2Out: array[0..15] of byte=
153 | ($d7,$9e,$1c,$30,$8a,$a5,$bb,$cd,$ee,$a8,$ed,$63,$df,$41,$2d,$a9);
154 | var
155 | TestHash: TDCP_md4;
156 | TestOut: array[0..19] of byte;
157 | begin
158 | FillChar(TestOut, SizeOf(TestOut), 0);
159 | TestHash:= TDCP_md4.Create(nil);
160 | TestHash.Init;
161 | TestHash.UpdateStr(AnsiString('abc'));
162 | TestHash.Final(TestOut);
163 | Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
164 | TestHash.Init;
165 | TestHash.UpdateStr(AnsiString('abcdefghijklmnopqrstuvwxyz'));
166 | TestHash.Final(TestOut);
167 | Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
168 | TestHash.Free;
169 | end;
170 |
171 | procedure TDCP_md4.Init;
172 | begin
173 | Burn;
174 | CurrentHash[0]:= $67452301;
175 | CurrentHash[1]:= $efcdab89;
176 | CurrentHash[2]:= $98badcfe;
177 | CurrentHash[3]:= $10325476;
178 | fInitialized:= true;
179 | end;
180 |
181 | procedure TDCP_md4.Burn;
182 | begin
183 | LenHi:= 0; LenLo:= 0;
184 | Index:= 0;
185 | FillChar(HashBuffer,Sizeof(HashBuffer),0);
186 | FillChar(CurrentHash,Sizeof(CurrentHash),0);
187 | fInitialized:= false;
188 | end;
189 |
190 | procedure TDCP_md4.Update(const Buffer; Size: longword);
191 | var
192 | PBuf: ^byte;
193 | begin
194 | if not fInitialized then
195 | raise EDCP_hash.Create('Hash not initialized');
196 |
197 | Inc(LenHi,Size shr 29);
198 | Inc(LenLo,Size*8);
199 | if LenLo< (Size*8) then
200 | Inc(LenHi);
201 |
202 | PBuf:= @Buffer;
203 | while Size> 0 do
204 | begin
205 | if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
206 | begin
207 | Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
208 | Dec(Size,Sizeof(HashBuffer)-Index);
209 | Inc(PBuf,Sizeof(HashBuffer)-Index);
210 | Compress;
211 | end
212 | else
213 | begin
214 | Move(PBuf^,HashBuffer[Index],Size);
215 | Inc(Index,Size);
216 | Size:= 0;
217 | end;
218 | end;
219 | end;
220 |
221 | procedure TDCP_md4.Final(var Digest);
222 | begin
223 | if not fInitialized then
224 | raise EDCP_hash.Create('Hash not initialized');
225 | HashBuffer[Index]:= $80;
226 | if Index>= 56 then
227 | Compress;
228 | PDWord(@HashBuffer[56])^:= LenLo;
229 | PDWord(@HashBuffer[60])^:= LenHi;
230 | Compress;
231 | Move(CurrentHash,Digest,Sizeof(CurrentHash));
232 | Burn;
233 | end;
234 |
235 | end.
236 |
--------------------------------------------------------------------------------
/Hashes/DCPmd5.pas:
--------------------------------------------------------------------------------
1 | {******************************************************************************}
2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
3 | {******************************************************************************}
4 | {* A binary compatible implementation of MD5 **********************************}
5 | {******************************************************************************}
6 | {* Copyright (c) 1999-2002 David Barton *}
7 | {* Permission is hereby granted, free of charge, to any person obtaining a *}
8 | {* copy of this software and associated documentation files (the "Software"), *}
9 | {* to deal in the Software without restriction, including without limitation *}
10 | {* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
11 | {* and/or sell copies of the Software, and to permit persons to whom the *}
12 | {* Software is furnished to do so, subject to the following conditions: *}
13 | {* *}
14 | {* The above copyright notice and this permission notice shall be included in *}
15 | {* all copies or substantial portions of the Software. *}
16 | {* *}
17 | {* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
18 | {* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
19 | {* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
20 | {* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
21 | {* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
22 | {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
23 | {* DEALINGS IN THE SOFTWARE. *}
24 | {******************************************************************************}
25 | unit DCPmd5;
26 |
27 | interface
28 | uses
29 | Classes, Sysutils, DCPcrypt2, DCPconst;
30 |
31 | type
32 | TDCP_md5= class(TDCP_hash)
33 | protected
34 | LenHi, LenLo: longword;
35 | Index: DWord;
36 | CurrentHash: array[0..3] of DWord;
37 | HashBuffer: array[0..63] of byte;
38 | procedure Compress;
39 | public
40 | class function GetId: integer; override;
41 | class function GetAlgorithm: string; override;
42 | class function GetHashSize: integer; override;
43 | class function SelfTest: boolean; override;
44 | procedure Init; override;
45 | procedure Burn; override;
46 | procedure Update(const Buffer; Size: longword); override;
47 | procedure Final(var Digest); override;
48 | end;
49 |
50 |
51 |
52 | {******************************************************************************}
53 | {******************************************************************************}
54 | implementation
55 | {$R-}{$Q-}
56 |
57 | function LRot32(a, b: longword): longword;
58 | begin
59 | Result:= (a shl b) or (a shr (32-b));
60 | end;
61 |
62 | procedure TDCP_md5.Compress;
63 | var
64 | Data: array[0..15] of dword;
65 | A, B, C, D: dword;
66 | begin
67 | FillChar(Data, SizeOf(Data), 0);
68 | Move(HashBuffer,Data,Sizeof(Data));
69 | A:= CurrentHash[0];
70 | B:= CurrentHash[1];
71 | C:= CurrentHash[2];
72 | D:= CurrentHash[3];
73 |
74 | A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 0] + $d76aa478,7);
75 | D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 1] + $e8c7b756,12);
76 | C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[ 2] + $242070db,17);
77 | B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[ 3] + $c1bdceee,22);
78 | A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 4] + $f57c0faf,7);
79 | D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 5] + $4787c62a,12);
80 | C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[ 6] + $a8304613,17);
81 | B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[ 7] + $fd469501,22);
82 | A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[ 8] + $698098d8,7);
83 | D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[ 9] + $8b44f7af,12);
84 | C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[10] + $ffff5bb1,17);
85 | B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[11] + $895cd7be,22);
86 | A:= B + LRot32(A + (D xor (B and (C xor D))) + Data[12] + $6b901122,7);
87 | D:= A + LRot32(D + (C xor (A and (B xor C))) + Data[13] + $fd987193,12);
88 | C:= D + LRot32(C + (B xor (D and (A xor B))) + Data[14] + $a679438e,17);
89 | B:= C + LRot32(B + (A xor (C and (D xor A))) + Data[15] + $49b40821,22);
90 |
91 | A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 1] + $f61e2562,5);
92 | D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[ 6] + $c040b340,9);
93 | C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[11] + $265e5a51,14);
94 | B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 0] + $e9b6c7aa,20);
95 | A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 5] + $d62f105d,5);
96 | D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[10] + $02441453,9);
97 | C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[15] + $d8a1e681,14);
98 | B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 4] + $e7d3fbc8,20);
99 | A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[ 9] + $21e1cde6,5);
100 | D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[14] + $c33707d6,9);
101 | C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[ 3] + $f4d50d87,14);
102 | B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[ 8] + $455a14ed,20);
103 | A:= B + LRot32(A + (C xor (D and (B xor C))) + Data[13] + $a9e3e905,5);
104 | D:= A + LRot32(D + (B xor (C and (A xor B))) + Data[ 2] + $fcefa3f8,9);
105 | C:= D + LRot32(C + (A xor (B and (D xor A))) + Data[ 7] + $676f02d9,14);
106 | B:= C + LRot32(B + (D xor (A and (C xor D))) + Data[12] + $8d2a4c8a,20);
107 |
108 | A:= B + LRot32(A + (B xor C xor D) + Data[ 5] + $fffa3942,4);
109 | D:= A + LRot32(D + (A xor B xor C) + Data[ 8] + $8771f681,11);
110 | C:= D + LRot32(C + (D xor A xor B) + Data[11] + $6d9d6122,16);
111 | B:= C + LRot32(B + (C xor D xor A) + Data[14] + $fde5380c,23);
112 | A:= B + LRot32(A + (B xor C xor D) + Data[ 1] + $a4beea44,4);
113 | D:= A + LRot32(D + (A xor B xor C) + Data[ 4] + $4bdecfa9,11);
114 | C:= D + LRot32(C + (D xor A xor B) + Data[ 7] + $f6bb4b60,16);
115 | B:= C + LRot32(B + (C xor D xor A) + Data[10] + $bebfbc70,23);
116 | A:= B + LRot32(A + (B xor C xor D) + Data[13] + $289b7ec6,4);
117 | D:= A + LRot32(D + (A xor B xor C) + Data[ 0] + $eaa127fa,11);
118 | C:= D + LRot32(C + (D xor A xor B) + Data[ 3] + $d4ef3085,16);
119 | B:= C + LRot32(B + (C xor D xor A) + Data[ 6] + $04881d05,23);
120 | A:= B + LRot32(A + (B xor C xor D) + Data[ 9] + $d9d4d039,4);
121 | D:= A + LRot32(D + (A xor B xor C) + Data[12] + $e6db99e5,11);
122 | C:= D + LRot32(C + (D xor A xor B) + Data[15] + $1fa27cf8,16);
123 | B:= C + LRot32(B + (C xor D xor A) + Data[ 2] + $c4ac5665,23);
124 |
125 | A:= B + LRot32(A + (C xor (B or (not D))) + Data[ 0] + $f4292244,6);
126 | D:= A + LRot32(D + (B xor (A or (not C))) + Data[ 7] + $432aff97,10);
127 | C:= D + LRot32(C + (A xor (D or (not B))) + Data[14] + $ab9423a7,15);
128 | B:= C + LRot32(B + (D xor (C or (not A))) + Data[ 5] + $fc93a039,21);
129 | A:= B + LRot32(A + (C xor (B or (not D))) + Data[12] + $655b59c3,6);
130 | D:= A + LRot32(D + (B xor (A or (not C))) + Data[ 3] + $8f0ccc92,10);
131 | C:= D + LRot32(C + (A xor (D or (not B))) + Data[10] + $ffeff47d,15);
132 | B:= C + LRot32(B + (D xor (C or (not A))) + Data[ 1] + $85845dd1,21);
133 | A:= B + LRot32(A + (C xor (B or (not D))) + Data[ 8] + $6fa87e4f,6);
134 | D:= A + LRot32(D + (B xor (A or (not C))) + Data[15] + $fe2ce6e0,10);
135 | C:= D + LRot32(C + (A xor (D or (not B))) + Data[ 6] + $a3014314,15);
136 | B:= C + LRot32(B + (D xor (C or (not A))) + Data[13] + $4e0811a1,21);
137 | A:= B + LRot32(A + (C xor (B or (not D))) + Data[ 4] + $f7537e82,6);
138 | D:= A + LRot32(D + (B xor (A or (not C))) + Data[11] + $bd3af235,10);
139 | C:= D + LRot32(C + (A xor (D or (not B))) + Data[ 2] + $2ad7d2bb,15);
140 | B:= C + LRot32(B + (D xor (C or (not A))) + Data[ 9] + $eb86d391,21);
141 |
142 | Inc(CurrentHash[0],A);
143 | Inc(CurrentHash[1],B);
144 | Inc(CurrentHash[2],C);
145 | Inc(CurrentHash[3],D);
146 | Index:= 0;
147 | FillChar(HashBuffer,Sizeof(HashBuffer),0);
148 | end;
149 |
150 | class function TDCP_md5.GetHashSize: integer;
151 | begin
152 | Result:= 128;
153 | end;
154 |
155 | class function TDCP_md5.GetId: integer;
156 | begin
157 | Result:= DCP_md5;
158 | end;
159 |
160 | class function TDCP_md5.GetAlgorithm: string;
161 | begin
162 | Result:= 'MD5';
163 | end;
164 |
165 | class function TDCP_md5.SelfTest: boolean;
166 | const
167 | Test1Out: array[0..15] of byte=
168 | ($90,$01,$50,$98,$3c,$d2,$4f,$b0,$d6,$96,$3f,$7d,$28,$e1,$7f,$72);
169 | Test2Out: array[0..15] of byte=
170 | ($c3,$fc,$d3,$d7,$61,$92,$e4,$00,$7d,$fb,$49,$6c,$ca,$67,$e1,$3b);
171 | var
172 | TestHash: TDCP_md5;
173 | TestOut: array[0..19] of byte;
174 | begin
175 | FillChar(TestOut, SizeOf(TestOut), 0);
176 | TestHash:= TDCP_md5.Create(nil);
177 | TestHash.Init;
178 | TestHash.UpdateStr(AnsiString('abc'));
179 | TestHash.Final(TestOut);
180 | Result:= CompareMem(@TestOut,@Test1Out,Sizeof(Test1Out));
181 | TestHash.Init;
182 | TestHash.UpdateStr(AnsiString('abcdefghijklmnopqrstuvwxyz'));
183 | TestHash.Final(TestOut);
184 | Result:= CompareMem(@TestOut,@Test2Out,Sizeof(Test2Out)) and Result;
185 | TestHash.Free;
186 | end;
187 |
188 | procedure TDCP_md5.Init;
189 | begin
190 | Burn;
191 | CurrentHash[0]:= $67452301;
192 | CurrentHash[1]:= $efcdab89;
193 | CurrentHash[2]:= $98badcfe;
194 | CurrentHash[3]:= $10325476;
195 | fInitialized:= true;
196 | end;
197 |
198 | procedure TDCP_md5.Burn;
199 | begin
200 | LenHi:= 0; LenLo:= 0;
201 | Index:= 0;
202 | FillChar(HashBuffer,Sizeof(HashBuffer),0);
203 | FillChar(CurrentHash,Sizeof(CurrentHash),0);
204 | fInitialized:= false;
205 | end;
206 |
207 | procedure TDCP_md5.Update(const Buffer; Size: longword);
208 | var
209 | PBuf: ^byte;
210 | begin
211 | if not fInitialized then
212 | raise EDCP_hash.Create('Hash not initialized');
213 |
214 | Inc(LenHi,Size shr 29);
215 | Inc(LenLo,Size*8);
216 | if LenLo< (Size*8) then
217 | Inc(LenHi);
218 |
219 | PBuf:= @Buffer;
220 | while Size> 0 do
221 | begin
222 | if (Sizeof(HashBuffer)-Index)<= DWord(Size) then
223 | begin
224 | Move(PBuf^,HashBuffer[Index],Sizeof(HashBuffer)-Index);
225 | Dec(Size,Sizeof(HashBuffer)-Index);
226 | Inc(PBuf,Sizeof(HashBuffer)-Index);
227 | Compress;
228 | end
229 | else
230 | begin
231 | Move(PBuf^,HashBuffer[Index],Size);
232 | Inc(Index,Size);
233 | Size:= 0;
234 | end;
235 | end;
236 | end;
237 |
238 | procedure TDCP_md5.Final(var Digest);
239 | begin
240 | if not fInitialized then
241 | raise EDCP_hash.Create('Hash not initialized');
242 | HashBuffer[Index]:= $80;
243 | if Index>= 56 then
244 | Compress;
245 | PDWord(@HashBuffer[56])^:= LenLo;
246 | PDWord(@HashBuffer[60])^:= LenHi;
247 | Compress;
248 | Move(CurrentHash,Digest,Sizeof(CurrentHash));
249 | Burn;
250 | end;
251 |
252 | end.
253 |
--------------------------------------------------------------------------------
/Readme.txt:
--------------------------------------------------------------------------------
1 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2 | = DCPcrypt Cryptographic Component Library v2.1 =
3 | = =
4 | = Copyright (c) 1999-2009 David Barton =
5 | = =
6 | = Further Changes by Henri Gourvest, =
7 | = Warren Postma and others =
8 | = to support Delphi XE and up. =
9 | = =
10 | = warren.postma@gmail.com =
11 | = https://bitbucket.org/wpostma/dcpcrypt2010 =
12 | = =
13 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
14 |
15 | UPDATE JANUARY 2014:
16 | Updated and tested with Delphi 2009, 2010, XE, XE2, XE3, XE4, XE5
17 | by Warren Postma.
18 |
19 | Please report bugs on Delphi versions XE or newer at bitbucket
20 | here: https://bitbucket.org/wpostma/dcpcrypt2010
21 |
22 | Introduction:
23 |
24 | DCPcrypt is a collection of cryptographic components for Delphi,
25 | and C++ Builder. Version 2.1 should work with almost all versions of
26 | Delphi, from ancient versions like Delphi 5 to the latest versions as
27 | of 2014, which is Delphi XE5.
28 |
29 | ** The remainder of this introduction was written around 2003 and
30 | has not been modified since then, and was written by David Barton. **
31 |
32 | The idea behind DCPcrypt is that it should be possible to "drop in"
33 | any algorithm implementation to replace another with minimum or no
34 | code changes. To aid in this goal all cryptographic components are
35 | descended from one of several base classes, TDCP_cipher for encryption
36 | algorithms and TDCP_hash for message digest algorithms.
37 |
38 | DCPcrypt is open source software (released under the MIT license) and
39 | as such there is no charge for inclusion in other software. However, I
40 | am currently a student and if you are making money from my software I
41 | would really appreciate a donation of some sort, whether financial or
42 | a license for the software you develop (or if anyone wants to sponsor
43 | a Mathematical Modelling (Masters) student for their final year...).
44 | Please note THIS IS NOT COMPULSORY IN ANY WAY. See
45 | http://www.cityinthesky.co.uk/cryptography.html for details on
46 | financial donations.
47 |
48 | This software is OSI Certified Open Source Software.
49 | OSI Certified is a certification mark of the Open Source Initiative.
50 |
51 | If you maintain a website then a link to my page at
52 | http://www.cityinthesky.co.uk/ would be great!
53 |
54 |
55 |
56 | What's New:
57 |
58 | Changes since DCPcrypt v2 Beta 2 include
59 |
60 | * Corrected C++ Builder compilation problem.
61 |
62 |
63 | Changes since DCPcrypt v2 Beta 1 include
64 |
65 | * Renamed source code files for hashes and ciphers to DCPxxx.pas
66 |
67 | * Change the format of Cipher.InitStr so that the hash algorithm
68 | used to generate the key is explicitly specified. In order to
69 | get the same functionality as before, use TDCP_sha1.
70 | e.g. Cipher.InitStr('Hello World',TDCP_sha1);
71 |
72 | * Block ciphers are now inherited from an intermediate component
73 | that implements the block size specific chaining mode encryption
74 | routines.
75 |
76 | * Remove the internal component registration, it was more hassle
77 | than it was worth. If there is a demand for this to be put back
78 | then I might...
79 |
80 | * Added the full range of operation modes for Haval. By changing
81 | the defines at the top of DCPhaval.pas you can specify the
82 | number of passes and the output hash size.
83 |
84 | * Added the Tiger hash algorithm (192bit digest).
85 |
86 | * Changed the name of the file containing TDCP_ripemd160 for
87 | consistency to DCPripemd160 from DCPrmd160.
88 |
89 | * GOST no longer appears on the component palette pending verifying
90 | what the actual standard is (the code is still included however).
91 |
92 | * Added the RipeMD-128 hash algorithm (128bit digest).
93 |
94 | * Added the Serpent block cipher (AES finalist).
95 |
96 | * Added the SHA-256,384,512 hash algorithms (256, 384, 512bit digest
97 | respectively).
98 |
99 | * Added CTR chaining mode to all block ciphers.
100 |
101 |
102 |
103 | Installation:
104 |
105 | Delphi: Open the appropriate package, DCPdelphiX.dpk where X is
106 | your version of Delphi (either 4, 5 or 6). Then press the
107 | install button.
108 |
109 | C++ Builder: Create a new design time package and add all the .pas
110 | files from the DCPcrypt2.zip archive including all those
111 | in the Ciphers and Hashes subdirectories. Then press the
112 | install button.
113 |
114 | Kylix: Open the DCPkylix.dpk package and then press the install
115 | button (note: Kylix 1 users may need to create a new
116 | package as with C++ Builder as this is a Kylix 2 package).
117 |
118 | You may need to add the directory containing DCPcrypt (and the Ciphers
119 | and Hashes subdirectories) to your library search path (found under
120 | Environment Options).
121 |
122 | Once installed you will find two extra pages of components on your
123 | component palette, namely DCPciphers and DCPhashes. You can now place
124 | these components onto the form of your application to start using the
125 | algorithms.
126 |
127 |
128 |
129 | Usage:
130 |
131 | See the main html documentation in the Docs subdirectory.
132 |
133 |
134 |
135 | Contact:
136 |
137 | I appreciate knowing what DCPcrypt is being used for and also if you
138 | have any queries or bug reports please email me at crypto@cityinthesky.co.uk.
139 |
140 |
141 |
142 | DCPcrypt is copyrighted (c) 1999-2003 David Barton.
143 | All trademarks are property of their respective owners.
144 |
--------------------------------------------------------------------------------
/dcp.inc:
--------------------------------------------------------------------------------
1 |
2 | { begin dcp.inc }
3 |
4 | {$IF CompilerVersion >= 23 }
5 | {$define DELPHIXE2_UP}
6 | {$IFEND}
7 |
8 | { end dcp.inc}
9 |
--------------------------------------------------------------------------------
/demos/FileEncrypt/FileEncrypt.dpr:
--------------------------------------------------------------------------------
1 | program FileEncrypt;
2 |
3 | uses
4 | Forms,
5 | uMain in 'uMain.pas' {frmMain};
6 |
7 | {$R *.res}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.CreateForm(TfrmMain, frmMain);
12 | Application.Run;
13 | end.
14 |
--------------------------------------------------------------------------------
/demos/FileEncrypt/FileEncrypt.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/demos/FileEncrypt/FileEncrypt.res
--------------------------------------------------------------------------------
/demos/FileEncrypt/uMain.dfm:
--------------------------------------------------------------------------------
1 | object frmMain: TfrmMain
2 | Left = 327
3 | Top = 112
4 | BorderIcons = [biSystemMenu, biMinimize]
5 | BorderStyle = bsDialog
6 | Caption = 'DCPcrypt File Encryption Demo'
7 | ClientHeight = 440
8 | ClientWidth = 528
9 | Color = clBtnFace
10 | Font.Charset = ANSI_CHARSET
11 | Font.Color = clWindowText
12 | Font.Height = -13
13 | Font.Name = 'Arial'
14 | Font.Style = []
15 | OldCreateOrder = False
16 | Position = poScreenCenter
17 | OnCreate = FormCreate
18 | PixelsPerInch = 96
19 | TextHeight = 16
20 | object grpInput: TGroupBox
21 | Left = 8
22 | Top = 8
23 | Width = 281
24 | Height = 81
25 | Caption = 'Input file'
26 | TabOrder = 0
27 | object btnInputBrowse: TSpeedButton
28 | Left = 248
29 | Top = 24
30 | Width = 24
31 | Height = 24
32 | Glyph.Data = {
33 | 76010000424D7601000000000000760000002800000020000000100000000100
34 | 04000000000000010000120B0000120B00001000000000000000000000000000
35 | 800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
36 | FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00555555555555
37 | 5555555555555555555555555555555555555555555555555555555555555555
38 | 555555555555555555555555555555555555555FFFFFFFFFF555550000000000
39 | 55555577777777775F55500B8B8B8B8B05555775F555555575F550F0B8B8B8B8
40 | B05557F75F555555575F50BF0B8B8B8B8B0557F575FFFFFFFF7F50FBF0000000
41 | 000557F557777777777550BFBFBFBFB0555557F555555557F55550FBFBFBFBF0
42 | 555557F555555FF7555550BFBFBF00055555575F555577755555550BFBF05555
43 | 55555575FFF75555555555700007555555555557777555555555555555555555
44 | 5555555555555555555555555555555555555555555555555555}
45 | NumGlyphs = 2
46 | OnClick = btnInputBrowseClick
47 | end
48 | object lblInputFileSize: TLabel
49 | Left = 8
50 | Top = 56
51 | Width = 53
52 | Height = 16
53 | Caption = 'File size:'
54 | end
55 | object dblInputFileSize: TLabel
56 | Left = 64
57 | Top = 56
58 | Width = 89
59 | Height = 16
60 | Caption = 'no file specified'
61 | end
62 | object boxInputFile: TEdit
63 | Left = 8
64 | Top = 24
65 | Width = 241
66 | Height = 24
67 | TabOrder = 0
68 | OnExit = boxInputFileExit
69 | end
70 | end
71 | object grpOutput: TGroupBox
72 | Left = 8
73 | Top = 96
74 | Width = 281
75 | Height = 57
76 | Caption = 'Output file'
77 | TabOrder = 1
78 | object btnOutputBrowse: TSpeedButton
79 | Left = 248
80 | Top = 24
81 | Width = 24
82 | Height = 24
83 | Glyph.Data = {
84 | 76010000424D7601000000000000760000002800000020000000100000000100
85 | 04000000000000010000120B0000120B00001000000000000000000000000000
86 | 800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
87 | FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00555555555555
88 | 5555555555555555555555555555555555555555555555555555555555555555
89 | 555555555555555555555555555555555555555FFFFFFFFFF555550000000000
90 | 55555577777777775F55500B8B8B8B8B05555775F555555575F550F0B8B8B8B8
91 | B05557F75F555555575F50BF0B8B8B8B8B0557F575FFFFFFFF7F50FBF0000000
92 | 000557F557777777777550BFBFBFBFB0555557F555555557F55550FBFBFBFBF0
93 | 555557F555555FF7555550BFBFBF00055555575F555577755555550BFBF05555
94 | 55555575FFF75555555555700007555555555557777555555555555555555555
95 | 5555555555555555555555555555555555555555555555555555}
96 | NumGlyphs = 2
97 | OnClick = btnOutputBrowseClick
98 | end
99 | object boxOutputFile: TEdit
100 | Left = 8
101 | Top = 24
102 | Width = 241
103 | Height = 24
104 | TabOrder = 0
105 | end
106 | end
107 | object grpOptions: TGroupBox
108 | Left = 8
109 | Top = 160
110 | Width = 281
111 | Height = 241
112 | Caption = 'Options'
113 | TabOrder = 2
114 | object lblCipher: TLabel
115 | Left = 8
116 | Top = 24
117 | Width = 37
118 | Height = 16
119 | Caption = 'Cipher'
120 | end
121 | object lblHash: TLabel
122 | Left = 8
123 | Top = 72
124 | Width = 30
125 | Height = 16
126 | Caption = 'Hash'
127 | end
128 | object lblKeySize: TLabel
129 | Left = 8
130 | Top = 120
131 | Width = 105
132 | Height = 16
133 | Caption = 'Effective key size:'
134 | end
135 | object dblKeySize: TLabel
136 | Left = 116
137 | Top = 120
138 | Width = 66
139 | Height = 16
140 | Caption = 'dblKeySize'
141 | end
142 | object lblPassphrase: TLabel
143 | Left = 8
144 | Top = 144
145 | Width = 69
146 | Height = 16
147 | Caption = 'Passphrase'
148 | end
149 | object lblConfirmPassphrase: TLabel
150 | Left = 8
151 | Top = 192
152 | Width = 115
153 | Height = 16
154 | Caption = 'Confirm passphrase'
155 | end
156 | object cbxCipher: TComboBox
157 | Left = 8
158 | Top = 40
159 | Width = 265
160 | Height = 24
161 | Style = csDropDownList
162 | ItemHeight = 16
163 | Sorted = True
164 | TabOrder = 0
165 | OnChange = cbxCipherChange
166 | end
167 | object cbxHash: TComboBox
168 | Left = 8
169 | Top = 88
170 | Width = 265
171 | Height = 24
172 | Style = csDropDownList
173 | ItemHeight = 16
174 | Sorted = True
175 | TabOrder = 1
176 | OnChange = cbxCipherChange
177 | end
178 | object boxPassphrase: TEdit
179 | Left = 8
180 | Top = 160
181 | Width = 265
182 | Height = 24
183 | PasswordChar = '*'
184 | TabOrder = 2
185 | OnChange = boxPassphraseChange
186 | end
187 | object boxConfirmPassphrase: TEdit
188 | Left = 8
189 | Top = 208
190 | Width = 265
191 | Height = 24
192 | PasswordChar = '*'
193 | TabOrder = 3
194 | OnChange = boxPassphraseChange
195 | end
196 | end
197 | object btnEncrypt: TButton
198 | Left = 8
199 | Top = 408
200 | Width = 81
201 | Height = 25
202 | Caption = 'Encrypt'
203 | Enabled = False
204 | TabOrder = 3
205 | OnClick = btnEncryptClick
206 | end
207 | object btnDecrypt: TButton
208 | Left = 96
209 | Top = 408
210 | Width = 81
211 | Height = 25
212 | Caption = 'Decrypt'
213 | Enabled = False
214 | TabOrder = 4
215 | OnClick = btnDecryptClick
216 | end
217 | object btnClose: TButton
218 | Left = 208
219 | Top = 408
220 | Width = 81
221 | Height = 25
222 | Cancel = True
223 | Caption = 'Close'
224 | TabOrder = 5
225 | OnClick = btnCloseClick
226 | end
227 | object DCP_blowfish1: TDCP_blowfish
228 | Id = 5
229 | Algorithm = 'Blowfish'
230 | MaxKeySize = 448
231 | BlockSize = 64
232 | Left = 296
233 | Top = 16
234 | end
235 | object DCP_cast1281: TDCP_cast128
236 | Id = 7
237 | Algorithm = 'Cast128'
238 | MaxKeySize = 128
239 | BlockSize = 64
240 | Left = 328
241 | Top = 16
242 | end
243 | object DCP_des1: TDCP_des
244 | Id = 23
245 | Algorithm = 'DES'
246 | MaxKeySize = 64
247 | BlockSize = 64
248 | Left = 360
249 | Top = 16
250 | end
251 | object DCP_3des1: TDCP_3des
252 | Id = 24
253 | Algorithm = '3DES'
254 | MaxKeySize = 192
255 | BlockSize = 64
256 | Left = 392
257 | Top = 16
258 | end
259 | object DCP_ice1: TDCP_ice
260 | Id = 20
261 | Algorithm = 'Ice'
262 | MaxKeySize = 64
263 | BlockSize = 64
264 | Left = 424
265 | Top = 16
266 | end
267 | object DCP_thinice1: TDCP_thinice
268 | Id = 21
269 | Algorithm = 'Thin Ice'
270 | MaxKeySize = 64
271 | BlockSize = 64
272 | Left = 456
273 | Top = 16
274 | end
275 | object DCP_ice21: TDCP_ice2
276 | Id = 22
277 | Algorithm = 'Ice2'
278 | MaxKeySize = 128
279 | BlockSize = 64
280 | Left = 488
281 | Top = 16
282 | end
283 | object DCP_rc21: TDCP_rc2
284 | Id = 1
285 | Algorithm = 'RC2'
286 | MaxKeySize = 1024
287 | BlockSize = 64
288 | Left = 296
289 | Top = 48
290 | end
291 | object DCP_rc41: TDCP_rc4
292 | Id = 19
293 | Algorithm = 'RC4'
294 | MaxKeySize = 2048
295 | Left = 328
296 | Top = 48
297 | end
298 | object DCP_rijndael1: TDCP_rijndael
299 | Id = 9
300 | Algorithm = 'Rijndael'
301 | MaxKeySize = 256
302 | BlockSize = 128
303 | Left = 360
304 | Top = 48
305 | end
306 | object DCP_serpent1: TDCP_serpent
307 | Id = 26
308 | Algorithm = 'Serpent'
309 | MaxKeySize = 256
310 | BlockSize = 128
311 | Left = 392
312 | Top = 48
313 | end
314 | object DCP_tea1: TDCP_tea
315 | Id = 25
316 | Algorithm = 'Tea'
317 | MaxKeySize = 128
318 | BlockSize = 64
319 | Left = 424
320 | Top = 48
321 | end
322 | object DCP_twofish1: TDCP_twofish
323 | Id = 6
324 | Algorithm = 'Twofish'
325 | MaxKeySize = 256
326 | BlockSize = 128
327 | Left = 456
328 | Top = 48
329 | end
330 | object DCP_haval1: TDCP_haval
331 | Id = 14
332 | Algorithm = 'Haval (256bit, 5 passes)'
333 | HashSize = 256
334 | Left = 296
335 | Top = 104
336 | end
337 | object DCP_md41: TDCP_md4
338 | Id = 17
339 | Algorithm = 'MD4'
340 | HashSize = 128
341 | Left = 328
342 | Top = 104
343 | end
344 | object DCP_md51: TDCP_md5
345 | Id = 16
346 | Algorithm = 'MD5'
347 | HashSize = 128
348 | Left = 360
349 | Top = 104
350 | end
351 | object DCP_ripemd1281: TDCP_ripemd128
352 | Id = 27
353 | Algorithm = 'RipeMD-128'
354 | HashSize = 128
355 | Left = 392
356 | Top = 104
357 | end
358 | object DCP_ripemd1601: TDCP_ripemd160
359 | Id = 10
360 | Algorithm = 'RipeMD-160'
361 | HashSize = 160
362 | Left = 424
363 | Top = 104
364 | end
365 | object DCP_sha11: TDCP_sha1
366 | Id = 2
367 | Algorithm = 'SHA1'
368 | HashSize = 160
369 | Left = 456
370 | Top = 104
371 | end
372 | object DCP_sha2561: TDCP_sha256
373 | Id = 28
374 | Algorithm = 'SHA256'
375 | HashSize = 256
376 | Left = 488
377 | Top = 104
378 | end
379 | object DCP_sha3841: TDCP_sha384
380 | Id = 29
381 | Algorithm = 'SHA384'
382 | HashSize = 384
383 | Left = 296
384 | Top = 136
385 | end
386 | object DCP_sha5121: TDCP_sha512
387 | Id = 30
388 | Algorithm = 'SHA512'
389 | HashSize = 512
390 | Left = 328
391 | Top = 136
392 | end
393 | object DCP_tiger1: TDCP_tiger
394 | Id = 18
395 | Algorithm = 'Tiger'
396 | HashSize = 192
397 | Left = 360
398 | Top = 136
399 | end
400 | object dlgInput: TOpenDialog
401 | Filter = 'All files (*.*)|*.*'
402 | Title = 'Input file'
403 | Left = 296
404 | Top = 192
405 | end
406 | object dlgOutput: TSaveDialog
407 | Filter = 'All files (*.*)|*.*'
408 | Title = 'Output file'
409 | Left = 328
410 | Top = 192
411 | end
412 | end
413 |
--------------------------------------------------------------------------------
/demos/FileHash/FileHash.dpr:
--------------------------------------------------------------------------------
1 | program FileHash;
2 |
3 | uses
4 | Forms,
5 | uMain in 'uMain.pas' {frmMain};
6 |
7 | {$R *.res}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.CreateForm(TfrmMain, frmMain);
12 | Application.Run;
13 | end.
14 |
--------------------------------------------------------------------------------
/demos/FileHash/FileHash.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/demos/FileHash/FileHash.res
--------------------------------------------------------------------------------
/demos/FileHash/uMain.dfm:
--------------------------------------------------------------------------------
1 | object frmMain: TfrmMain
2 | Left = 224
3 | Top = 110
4 | Width = 416
5 | Height = 450
6 | BorderIcons = [biSystemMenu, biMinimize]
7 | Caption = 'DCPcrypt File Hashing Demo'
8 | Color = clBtnFace
9 | Font.Charset = ANSI_CHARSET
10 | Font.Color = clWindowText
11 | Font.Height = -13
12 | Font.Name = 'Arial'
13 | Font.Style = []
14 | OldCreateOrder = False
15 | OnCreate = FormCreate
16 | DesignSize = (
17 | 408
18 | 416)
19 | PixelsPerInch = 96
20 | TextHeight = 16
21 | object grpInputFile: TGroupBox
22 | Left = 8
23 | Top = 8
24 | Width = 393
25 | Height = 57
26 | Anchors = [akLeft, akTop, akRight]
27 | Caption = 'Input File'
28 | TabOrder = 0
29 | DesignSize = (
30 | 393
31 | 57)
32 | object btnBrowseFiles: TSpeedButton
33 | Left = 360
34 | Top = 24
35 | Width = 24
36 | Height = 24
37 | Anchors = [akTop, akRight]
38 | Glyph.Data = {
39 | 76010000424D7601000000000000760000002800000020000000100000000100
40 | 04000000000000010000120B0000120B00001000000000000000000000000000
41 | 800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
42 | FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00555555555555
43 | 5555555555555555555555555555555555555555555555555555555555555555
44 | 555555555555555555555555555555555555555FFFFFFFFFF555550000000000
45 | 55555577777777775F55500B8B8B8B8B05555775F555555575F550F0B8B8B8B8
46 | B05557F75F555555575F50BF0B8B8B8B8B0557F575FFFFFFFF7F50FBF0000000
47 | 000557F557777777777550BFBFBFBFB0555557F555555557F55550FBFBFBFBF0
48 | 555557F555555FF7555550BFBFBF00055555575F555577755555550BFBF05555
49 | 55555575FFF75555555555700007555555555557777555555555555555555555
50 | 5555555555555555555555555555555555555555555555555555}
51 | NumGlyphs = 2
52 | OnClick = btnBrowseFilesClick
53 | end
54 | object boxInputFile: TEdit
55 | Left = 8
56 | Top = 24
57 | Width = 345
58 | Height = 24
59 | Anchors = [akLeft, akTop, akRight]
60 | TabOrder = 0
61 | end
62 | end
63 | object grpHashes: TGroupBox
64 | Left = 8
65 | Top = 72
66 | Width = 393
67 | Height = 153
68 | Anchors = [akLeft, akTop, akRight]
69 | Caption = 'Hashes'
70 | TabOrder = 1
71 | DesignSize = (
72 | 393
73 | 153)
74 | object lstHashes: TCheckListBox
75 | Left = 8
76 | Top = 24
77 | Width = 289
78 | Height = 121
79 | Anchors = [akLeft, akTop, akRight]
80 | ItemHeight = 16
81 | Sorted = True
82 | TabOrder = 0
83 | end
84 | object btnHash: TButton
85 | Left = 304
86 | Top = 120
87 | Width = 81
88 | Height = 25
89 | Anchors = [akTop, akRight]
90 | Caption = 'Hash Files'
91 | TabOrder = 1
92 | OnClick = btnHashClick
93 | end
94 | end
95 | object grpOutput: TGroupBox
96 | Left = 8
97 | Top = 232
98 | Width = 393
99 | Height = 177
100 | Anchors = [akLeft, akTop, akRight, akBottom]
101 | Caption = 'Output'
102 | TabOrder = 2
103 | DesignSize = (
104 | 393
105 | 177)
106 | object txtOutput: TMemo
107 | Left = 8
108 | Top = 24
109 | Width = 377
110 | Height = 145
111 | Anchors = [akLeft, akTop, akRight, akBottom]
112 | Font.Charset = ANSI_CHARSET
113 | Font.Color = clWindowText
114 | Font.Height = -13
115 | Font.Name = 'Courier New'
116 | Font.Style = []
117 | ParentFont = False
118 | ReadOnly = True
119 | ScrollBars = ssBoth
120 | TabOrder = 0
121 | end
122 | end
123 | object DCP_haval1: TDCP_haval
124 | Id = 14
125 | Algorithm = 'Haval (256bit, 5 passes)'
126 | HashSize = 256
127 | Left = 24
128 | Top = 104
129 | end
130 | object DCP_md41: TDCP_md4
131 | Id = 17
132 | Algorithm = 'MD4'
133 | HashSize = 128
134 | Left = 56
135 | Top = 104
136 | end
137 | object DCP_md51: TDCP_md5
138 | Id = 16
139 | Algorithm = 'MD5'
140 | HashSize = 128
141 | Left = 88
142 | Top = 104
143 | end
144 | object DCP_ripemd1281: TDCP_ripemd128
145 | Id = 27
146 | Algorithm = 'RipeMD-128'
147 | HashSize = 128
148 | Left = 120
149 | Top = 104
150 | end
151 | object DCP_ripemd1601: TDCP_ripemd160
152 | Id = 10
153 | Algorithm = 'RipeMD-160'
154 | HashSize = 160
155 | Left = 152
156 | Top = 104
157 | end
158 | object DCP_sha11: TDCP_sha1
159 | Id = 2
160 | Algorithm = 'SHA1'
161 | HashSize = 160
162 | Left = 24
163 | Top = 136
164 | end
165 | object DCP_sha2561: TDCP_sha256
166 | Id = 28
167 | Algorithm = 'SHA256'
168 | HashSize = 256
169 | Left = 56
170 | Top = 136
171 | end
172 | object DCP_sha3841: TDCP_sha384
173 | Id = 29
174 | Algorithm = 'SHA384'
175 | HashSize = 384
176 | Left = 88
177 | Top = 136
178 | end
179 | object DCP_sha5121: TDCP_sha512
180 | Id = 30
181 | Algorithm = 'SHA512'
182 | HashSize = 512
183 | Left = 120
184 | Top = 136
185 | end
186 | object DCP_tiger1: TDCP_tiger
187 | Id = 18
188 | Algorithm = 'Tiger'
189 | HashSize = 192
190 | Left = 152
191 | Top = 136
192 | end
193 | object dlgOpen: TOpenDialog
194 | Filter = 'All Files (*.*)|*.*'
195 | Title = 'Choose input file'
196 | Left = 24
197 | Top = 168
198 | end
199 | end
200 |
--------------------------------------------------------------------------------
/demos/FileHash/uMain.pas:
--------------------------------------------------------------------------------
1 | {******************************************************************************}
2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********}
3 | {******************************************************************************}
4 | {* A file hashing demo ********************************************************}
5 | {******************************************************************************}
6 | {* Copyright (c) 2003 David Barton *}
7 | {* Permission is hereby granted, free of charge, to any person obtaining a *}
8 | {* copy of this software and associated documentation files (the "Software"), *}
9 | {* to deal in the Software without restriction, including without limitation *}
10 | {* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
11 | {* and/or sell copies of the Software, and to permit persons to whom the *}
12 | {* Software is furnished to do so, subject to the following conditions: *}
13 | {* *}
14 | {* The above copyright notice and this permission notice shall be included in *}
15 | {* all copies or substantial portions of the Software. *}
16 | {* *}
17 | {* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
18 | {* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
19 | {* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
20 | {* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
21 | {* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
22 | {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
23 | {* DEALINGS IN THE SOFTWARE. *}
24 | {******************************************************************************}
25 | unit uMain;
26 |
27 | interface
28 |
29 | uses
30 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
31 | Dialogs, Buttons, StdCtrls, CheckLst, DCPtiger, DCPsha512, DCPsha256,
32 | DCPsha1, DCPripemd160, DCPripemd128, DCPmd5, DCPmd4, DCPcrypt2, DCPhaval;
33 |
34 | type
35 | TfrmMain = class(TForm)
36 | DCP_haval1: TDCP_haval;
37 | DCP_md41: TDCP_md4;
38 | DCP_md51: TDCP_md5;
39 | DCP_ripemd1281: TDCP_ripemd128;
40 | DCP_ripemd1601: TDCP_ripemd160;
41 | DCP_sha11: TDCP_sha1;
42 | DCP_sha2561: TDCP_sha256;
43 | DCP_sha3841: TDCP_sha384;
44 | DCP_sha5121: TDCP_sha512;
45 | DCP_tiger1: TDCP_tiger;
46 | grpInputFile: TGroupBox;
47 | boxInputFile: TEdit;
48 | grpHashes: TGroupBox;
49 | lstHashes: TCheckListBox;
50 | grpOutput: TGroupBox;
51 | txtOutput: TMemo;
52 | btnHash: TButton;
53 | btnBrowseFiles: TSpeedButton;
54 | dlgOpen: TOpenDialog;
55 | procedure FormCreate(Sender: TObject);
56 | procedure btnBrowseFilesClick(Sender: TObject);
57 | procedure btnHashClick(Sender: TObject);
58 | private
59 | { Private declarations }
60 | public
61 | { Public declarations }
62 | end;
63 |
64 | var
65 | frmMain: TfrmMain;
66 |
67 | implementation
68 |
69 | {$R *.dfm}
70 |
71 | procedure TfrmMain.FormCreate(Sender: TObject);
72 | var
73 | i: integer;
74 | Hash: TDCP_hash;
75 | begin
76 | ClientHeight := 416;
77 | ClientWidth := 408;
78 | MessageDlg('This is a file hashing demo using the DCPcrypt component set.'+#13+'For more information see http://www.cityinthesky.co.uk/cryptography.html',mtInformation,[mbOK],0);
79 |
80 | // find all the hash algorithms on the form
81 | for i := 0 to ComponentCount - 1 do
82 | begin
83 | if Components[i] is TDCP_hash then
84 | begin
85 | Hash := TDCP_hash(Components[i]);
86 | lstHashes.Items.AddObject(Hash.Algorithm + ' (Digest size: ' + IntToStr(Hash.HashSize) + ' bits)',Components[i]);
87 | end;
88 | end;
89 | end;
90 |
91 | procedure TfrmMain.btnBrowseFilesClick(Sender: TObject);
92 | begin
93 | if dlgOpen.Execute then
94 | boxInputFile.Text := dlgOpen.FileName;
95 | end;
96 |
97 | procedure TfrmMain.btnHashClick(Sender: TObject);
98 | var
99 | Hashes: array of TDCP_hash;
100 | HashDigest: array of byte;
101 | i, j, read: integer;
102 | s: string;
103 | buffer: array[0..16383] of byte;
104 | strmInput: TFileStream;
105 | begin
106 | txtOutput.Clear;
107 | if not FileExists(boxInputFile.Text) then
108 | begin
109 | MessageDlg('File does not exist',mtInformation,[mbOK],0);
110 | Exit;
111 | end;
112 | Hashes := nil;
113 | // make a list of all the hash algorithms to use
114 | for i := 0 to lstHashes.Items.Count - 1 do
115 | begin
116 | if lstHashes.Checked[i] then
117 | begin
118 | // yes I know this is inefficient but it's also easy ;-)
119 | SetLength(Hashes,Length(Hashes) + 1);
120 | Hashes[Length(Hashes) - 1] := TDCP_hash(lstHashes.Items.Objects[i]);
121 | TDCP_hash(lstHashes.Items.Objects[i]).Init;
122 | end;
123 | end;
124 | strmInput := nil;
125 | try
126 | strmInput := TFileStream.Create(boxInputFile.Text,fmOpenRead);
127 | repeat
128 | // read into the buffer
129 | read := strmInput.Read(buffer,Sizeof(buffer));
130 | // hash the buffer with each of the selected hashes
131 | for i := 0 to Length(Hashes) - 1 do
132 | Hashes[i].Update(buffer,read);
133 | until read <> Sizeof(buffer);
134 | strmInput.Free;
135 | // iterate through the selected hashes
136 | for i := 0 to Length(Hashes) - 1 do
137 | begin
138 | SetLength(HashDigest,Hashes[i].HashSize div 8);
139 | Hashes[i].Final(HashDigest[0]); // get the output
140 | s := '';
141 | for j := 0 to Length(HashDigest) - 1 do // convert it into a hex string
142 | s := s + IntToHex(HashDigest[j],2);
143 | txtOutput.Lines.Add(Hashes[i].Algorithm + ': ' + s);
144 | end;
145 | except
146 | strmInput.Free;
147 | MessageDlg('An error occurred while reading the file',mtError,[mbOK],0);
148 | end;
149 | end;
150 |
151 | end.
152 |
--------------------------------------------------------------------------------