├── .gitattributes ├── .gitignore ├── Ciphers ├── DCPblowfish.inc ├── DCPblowfish.pas ├── DCPcast128.inc ├── DCPcast128.pas ├── DCPcast256.inc ├── DCPcast256.pas ├── DCPdes.inc ├── DCPdes.pas ├── DCPgost.inc ├── DCPgost.pas ├── DCPice.pas ├── DCPidea.pas ├── DCPmars.inc ├── DCPmars.pas ├── DCPmisty1.inc ├── DCPmisty1.pas ├── DCPrc2.inc ├── DCPrc2.pas ├── DCPrc4.pas ├── DCPrc5.pas ├── DCPrc6.pas ├── DCPrijndael.inc ├── DCPrijndael.pas ├── DCPserpent.pas ├── DCPtea.pas ├── DCPtwofish.inc └── DCPtwofish.pas ├── DCP_XE.dpk ├── DCP_XE.dproj ├── DCP_XE.res ├── DCP_XE2.dpk ├── DCP_XE2.dproj ├── DCP_XE2.res ├── DCP_XE2.skincfg ├── DCP_XE5.dpk ├── DCP_XE5.dproj ├── DCP_XE5.res ├── DCP_XE6.dpk ├── DCP_XE6.dproj ├── DCP_XE6.res ├── DCP_XE7.deployproj ├── DCP_XE7.dpk ├── DCP_XE7.dproj ├── DCP_XE7.res ├── DCPbase64.pas ├── DCPblockciphers.pas ├── DCPciphers.dcr ├── DCPconst.pas ├── DCPcppbuilder5.bpk ├── DCPcppbuilder5.cpp ├── DCPcppbuilder5.res ├── DCPcrypt2.pas ├── DCPdelphi2007.dof ├── DCPdelphi2007.dpk ├── DCPdelphi2007.dproj ├── DCPdelphi2007.res ├── DCPdelphi2009.dof ├── DCPdelphi2009.dpk ├── DCPdelphi2009.dproj ├── DCPdelphi2009.res ├── DCPdelphi4.dof ├── DCPdelphi4.dpk ├── DCPdelphi4.res ├── DCPdelphi5.dof ├── DCPdelphi5.dpk ├── DCPdelphi5.res ├── DCPdelphi6.dof ├── DCPdelphi6.dpk ├── DCPdelphi6.res ├── DCPhashes.dcr ├── DCPkylix.conf ├── DCPkylix.dpk ├── DCPkylix.kof ├── DCPkylix.res ├── DCPreg.pas ├── Docs ├── BlockCiphers.html ├── Ciphers.html ├── Hashes.html ├── Index.html ├── MIT_license.txt └── osi-certified-120x100.png ├── Hashes ├── DCPhaval.pas ├── DCPhaval3.inc ├── DCPhaval4.inc ├── DCPhaval5.inc ├── DCPmd4.pas ├── DCPmd5.pas ├── DCPripemd128.pas ├── DCPripemd160.pas ├── DCPsha1.pas ├── DCPsha256.pas ├── DCPsha512.pas ├── DCPtiger.inc └── DCPtiger.pas ├── ORawByteString.pas ├── Readme.txt ├── dcp.inc └── demos ├── FileEncrypt ├── FileEncrypt.dpr ├── FileEncrypt.res ├── uMain.dfm └── uMain.pas └── FileHash ├── FileHash.dpr ├── FileHash.res ├── uMain.dfm └── uMain.pas /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | #*.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | 25 | # Delphi compiler-generated binaries (safe to delete) 26 | *.exe 27 | *.dll 28 | *.bpl 29 | *.bpi 30 | *.dcp 31 | *.so 32 | *.apk 33 | *.drc 34 | *.map 35 | *.dres 36 | *.rsm 37 | *.tds 38 | *.dcu 39 | *.lib 40 | 41 | # Delphi autogenerated files (duplicated info) 42 | *.cfg 43 | *Resource.rc 44 | 45 | # Delphi local files (user-specific info) 46 | *.local 47 | *.identcache 48 | *.projdata 49 | *.tvsconfig 50 | *.dsk 51 | 52 | # Delphi history and backups 53 | __history/ 54 | *.~* 55 | 56 | # ========================= 57 | # Operating System Files 58 | # ========================= 59 | 60 | # OSX 61 | # ========================= 62 | 63 | .DS_Store 64 | .AppleDouble 65 | .LSOverride 66 | 67 | # Thumbnails 68 | ._* 69 | 70 | # Files that might appear on external disk 71 | .Spotlight-V100 72 | .Trashes 73 | 74 | # Directories potentially created on remote AFP share 75 | .AppleDB 76 | .AppleDesktop 77 | Network Trash Folder 78 | Temporary Items 79 | .apdisk 80 | 81 | # Windows 82 | # ========================= 83 | 84 | # Windows image file caches 85 | Thumbs.db 86 | ehthumbs.db 87 | 88 | # Folder config file 89 | Desktop.ini 90 | 91 | # Recycle Bin used on file shares 92 | $RECYCLE.BIN/ 93 | 94 | # Windows Installer files 95 | *.cab 96 | *.msi 97 | *.msm 98 | *.msp 99 | 100 | # Windows shortcuts 101 | *.lnk 102 | -------------------------------------------------------------------------------- /Ciphers/DCPgost.inc: -------------------------------------------------------------------------------- 1 | const 2 | sTable: array[0..3, 0..255] of DWord= ( 3 | ($00072000,$00075000,$00074800,$00071000,$00076800,$00074000,$00070000,$00077000, 4 | $00073000,$00075800,$00070800,$00076000,$00073800,$00077800,$00072800,$00071800, 5 | $0005A000,$0005D000,$0005C800,$00059000,$0005E800,$0005C000,$00058000,$0005F000, 6 | $0005B000,$0005D800,$00058800,$0005E000,$0005B800,$0005F800,$0005A800,$00059800, 7 | $00022000,$00025000,$00024800,$00021000,$00026800,$00024000,$00020000,$00027000, 8 | $00023000,$00025800,$00020800,$00026000,$00023800,$00027800,$00022800,$00021800, 9 | $00062000,$00065000,$00064800,$00061000,$00066800,$00064000,$00060000,$00067000, 10 | $00063000,$00065800,$00060800,$00066000,$00063800,$00067800,$00062800,$00061800, 11 | $00032000,$00035000,$00034800,$00031000,$00036800,$00034000,$00030000,$00037000, 12 | $00033000,$00035800,$00030800,$00036000,$00033800,$00037800,$00032800,$00031800, 13 | $0006A000,$0006D000,$0006C800,$00069000,$0006E800,$0006C000,$00068000,$0006F000, 14 | $0006B000,$0006D800,$00068800,$0006E000,$0006B800,$0006F800,$0006A800,$00069800, 15 | $0007A000,$0007D000,$0007C800,$00079000,$0007E800,$0007C000,$00078000,$0007F000, 16 | $0007B000,$0007D800,$00078800,$0007E000,$0007B800,$0007F800,$0007A800,$00079800, 17 | $00052000,$00055000,$00054800,$00051000,$00056800,$00054000,$00050000,$00057000, 18 | $00053000,$00055800,$00050800,$00056000,$00053800,$00057800,$00052800,$00051800, 19 | $00012000,$00015000,$00014800,$00011000,$00016800,$00014000,$00010000,$00017000, 20 | $00013000,$00015800,$00010800,$00016000,$00013800,$00017800,$00012800,$00011800, 21 | $0001A000,$0001D000,$0001C800,$00019000,$0001E800,$0001C000,$00018000,$0001F000, 22 | $0001B000,$0001D800,$00018800,$0001E000,$0001B800,$0001F800,$0001A800,$00019800, 23 | $00042000,$00045000,$00044800,$00041000,$00046800,$00044000,$00040000,$00047000, 24 | $00043000,$00045800,$00040800,$00046000,$00043800,$00047800,$00042800,$00041800, 25 | $0000A000,$0000D000,$0000C800,$00009000,$0000E800,$0000C000,$00008000,$0000F000, 26 | $0000B000,$0000D800,$00008800,$0000E000,$0000B800,$0000F800,$0000A800,$00009800, 27 | $00002000,$00005000,$00004800,$00001000,$00006800,$00004000,$00000000,$00007000, 28 | $00003000,$00005800,$00000800,$00006000,$00003800,$00007800,$00002800,$00001800, 29 | $0003A000,$0003D000,$0003C800,$00039000,$0003E800,$0003C000,$00038000,$0003F000, 30 | $0003B000,$0003D800,$00038800,$0003E000,$0003B800,$0003F800,$0003A800,$00039800, 31 | $0002A000,$0002D000,$0002C800,$00029000,$0002E800,$0002C000,$00028000,$0002F000, 32 | $0002B000,$0002D800,$00028800,$0002E000,$0002B800,$0002F800,$0002A800,$00029800, 33 | $0004A000,$0004D000,$0004C800,$00049000,$0004E800,$0004C000,$00048000,$0004F000, 34 | $0004B000,$0004D800,$00048800,$0004E000,$0004B800,$0004F800,$0004A800,$00049800), 35 | ($03A80000,$03C00000,$03880000,$03E80000,$03D00000,$03980000,$03A00000,$03900000, 36 | $03F00000,$03F80000,$03E00000,$03B80000,$03B00000,$03800000,$03C80000,$03D80000, 37 | $06A80000,$06C00000,$06880000,$06E80000,$06D00000,$06980000,$06A00000,$06900000, 38 | $06F00000,$06F80000,$06E00000,$06B80000,$06B00000,$06800000,$06C80000,$06D80000, 39 | $05280000,$05400000,$05080000,$05680000,$05500000,$05180000,$05200000,$05100000, 40 | $05700000,$05780000,$05600000,$05380000,$05300000,$05000000,$05480000,$05580000, 41 | $00A80000,$00C00000,$00880000,$00E80000,$00D00000,$00980000,$00A00000,$00900000, 42 | $00F00000,$00F80000,$00E00000,$00B80000,$00B00000,$00800000,$00C80000,$00D80000, 43 | $00280000,$00400000,$00080000,$00680000,$00500000,$00180000,$00200000,$00100000, 44 | $00700000,$00780000,$00600000,$00380000,$00300000,$00000000,$00480000,$00580000, 45 | $04280000,$04400000,$04080000,$04680000,$04500000,$04180000,$04200000,$04100000, 46 | $04700000,$04780000,$04600000,$04380000,$04300000,$04000000,$04480000,$04580000, 47 | $04A80000,$04C00000,$04880000,$04E80000,$04D00000,$04980000,$04A00000,$04900000, 48 | $04F00000,$04F80000,$04E00000,$04B80000,$04B00000,$04800000,$04C80000,$04D80000, 49 | $07A80000,$07C00000,$07880000,$07E80000,$07D00000,$07980000,$07A00000,$07900000, 50 | $07F00000,$07F80000,$07E00000,$07B80000,$07B00000,$07800000,$07C80000,$07D80000, 51 | $07280000,$07400000,$07080000,$07680000,$07500000,$07180000,$07200000,$07100000, 52 | $07700000,$07780000,$07600000,$07380000,$07300000,$07000000,$07480000,$07580000, 53 | $02280000,$02400000,$02080000,$02680000,$02500000,$02180000,$02200000,$02100000, 54 | $02700000,$02780000,$02600000,$02380000,$02300000,$02000000,$02480000,$02580000, 55 | $03280000,$03400000,$03080000,$03680000,$03500000,$03180000,$03200000,$03100000, 56 | $03700000,$03780000,$03600000,$03380000,$03300000,$03000000,$03480000,$03580000, 57 | $06280000,$06400000,$06080000,$06680000,$06500000,$06180000,$06200000,$06100000, 58 | $06700000,$06780000,$06600000,$06380000,$06300000,$06000000,$06480000,$06580000, 59 | $05A80000,$05C00000,$05880000,$05E80000,$05D00000,$05980000,$05A00000,$05900000, 60 | $05F00000,$05F80000,$05E00000,$05B80000,$05B00000,$05800000,$05C80000,$05D80000, 61 | $01280000,$01400000,$01080000,$01680000,$01500000,$01180000,$01200000,$01100000, 62 | $01700000,$01780000,$01600000,$01380000,$01300000,$01000000,$01480000,$01580000, 63 | $02A80000,$02C00000,$02880000,$02E80000,$02D00000,$02980000,$02A00000,$02900000, 64 | $02F00000,$02F80000,$02E00000,$02B80000,$02B00000,$02800000,$02C80000,$02D80000, 65 | $01A80000,$01C00000,$01880000,$01E80000,$01D00000,$01980000,$01A00000,$01900000, 66 | $01F00000,$01F80000,$01E00000,$01B80000,$01B00000,$01800000,$01C80000,$01D80000), 67 | ($30000002,$60000002,$38000002,$08000002,$28000002,$78000002,$68000002,$40000002, 68 | $20000002,$50000002,$48000002,$70000002,$00000002,$18000002,$58000002,$10000002, 69 | $B0000005,$E0000005,$B8000005,$88000005,$A8000005,$F8000005,$E8000005,$C0000005, 70 | $A0000005,$D0000005,$C8000005,$F0000005,$80000005,$98000005,$D8000005,$90000005, 71 | $30000005,$60000005,$38000005,$08000005,$28000005,$78000005,$68000005,$40000005, 72 | $20000005,$50000005,$48000005,$70000005,$00000005,$18000005,$58000005,$10000005, 73 | $30000000,$60000000,$38000000,$08000000,$28000000,$78000000,$68000000,$40000000, 74 | $20000000,$50000000,$48000000,$70000000,$00000000,$18000000,$58000000,$10000000, 75 | $B0000003,$E0000003,$B8000003,$88000003,$A8000003,$F8000003,$E8000003,$C0000003, 76 | $A0000003,$D0000003,$C8000003,$F0000003,$80000003,$98000003,$D8000003,$90000003, 77 | $30000001,$60000001,$38000001,$08000001,$28000001,$78000001,$68000001,$40000001, 78 | $20000001,$50000001,$48000001,$70000001,$00000001,$18000001,$58000001,$10000001, 79 | $B0000000,$E0000000,$B8000000,$88000000,$A8000000,$F8000000,$E8000000,$C0000000, 80 | $A0000000,$D0000000,$C8000000,$F0000000,$80000000,$98000000,$D8000000,$90000000, 81 | $B0000006,$E0000006,$B8000006,$88000006,$A8000006,$F8000006,$E8000006,$C0000006, 82 | $A0000006,$D0000006,$C8000006,$F0000006,$80000006,$98000006,$D8000006,$90000006, 83 | $B0000001,$E0000001,$B8000001,$88000001,$A8000001,$F8000001,$E8000001,$C0000001, 84 | $A0000001,$D0000001,$C8000001,$F0000001,$80000001,$98000001,$D8000001,$90000001, 85 | $30000003,$60000003,$38000003,$08000003,$28000003,$78000003,$68000003,$40000003, 86 | $20000003,$50000003,$48000003,$70000003,$00000003,$18000003,$58000003,$10000003, 87 | $30000004,$60000004,$38000004,$08000004,$28000004,$78000004,$68000004,$40000004, 88 | $20000004,$50000004,$48000004,$70000004,$00000004,$18000004,$58000004,$10000004, 89 | $B0000002,$E0000002,$B8000002,$88000002,$A8000002,$F8000002,$E8000002,$C0000002, 90 | $A0000002,$D0000002,$C8000002,$F0000002,$80000002,$98000002,$D8000002,$90000002, 91 | $B0000004,$E0000004,$B8000004,$88000004,$A8000004,$F8000004,$E8000004,$C0000004, 92 | $A0000004,$D0000004,$C8000004,$F0000004,$80000004,$98000004,$D8000004,$90000004, 93 | $30000006,$60000006,$38000006,$08000006,$28000006,$78000006,$68000006,$40000006, 94 | $20000006,$50000006,$48000006,$70000006,$00000006,$18000006,$58000006,$10000006, 95 | $B0000007,$E0000007,$B8000007,$88000007,$A8000007,$F8000007,$E8000007,$C0000007, 96 | $A0000007,$D0000007,$C8000007,$F0000007,$80000007,$98000007,$D8000007,$90000007, 97 | $30000007,$60000007,$38000007,$08000007,$28000007,$78000007,$68000007,$40000007, 98 | $20000007,$50000007,$48000007,$70000007,$00000007,$18000007,$58000007,$10000007), 99 | ($000000E8,$000000D8,$000000A0,$00000088,$00000098,$000000F8,$000000A8,$000000C8, 100 | $00000080,$000000D0,$000000F0,$000000B8,$000000B0,$000000C0,$00000090,$000000E0, 101 | $000007E8,$000007D8,$000007A0,$00000788,$00000798,$000007F8,$000007A8,$000007C8, 102 | $00000780,$000007D0,$000007F0,$000007B8,$000007B0,$000007C0,$00000790,$000007E0, 103 | $000006E8,$000006D8,$000006A0,$00000688,$00000698,$000006F8,$000006A8,$000006C8, 104 | $00000680,$000006D0,$000006F0,$000006B8,$000006B0,$000006C0,$00000690,$000006E0, 105 | $00000068,$00000058,$00000020,$00000008,$00000018,$00000078,$00000028,$00000048, 106 | $00000000,$00000050,$00000070,$00000038,$00000030,$00000040,$00000010,$00000060, 107 | $000002E8,$000002D8,$000002A0,$00000288,$00000298,$000002F8,$000002A8,$000002C8, 108 | $00000280,$000002D0,$000002F0,$000002B8,$000002B0,$000002C0,$00000290,$000002E0, 109 | $000003E8,$000003D8,$000003A0,$00000388,$00000398,$000003F8,$000003A8,$000003C8, 110 | $00000380,$000003D0,$000003F0,$000003B8,$000003B0,$000003C0,$00000390,$000003E0, 111 | $00000568,$00000558,$00000520,$00000508,$00000518,$00000578,$00000528,$00000548, 112 | $00000500,$00000550,$00000570,$00000538,$00000530,$00000540,$00000510,$00000560, 113 | $00000268,$00000258,$00000220,$00000208,$00000218,$00000278,$00000228,$00000248, 114 | $00000200,$00000250,$00000270,$00000238,$00000230,$00000240,$00000210,$00000260, 115 | $000004E8,$000004D8,$000004A0,$00000488,$00000498,$000004F8,$000004A8,$000004C8, 116 | $00000480,$000004D0,$000004F0,$000004B8,$000004B0,$000004C0,$00000490,$000004E0, 117 | $00000168,$00000158,$00000120,$00000108,$00000118,$00000178,$00000128,$00000148, 118 | $00000100,$00000150,$00000170,$00000138,$00000130,$00000140,$00000110,$00000160, 119 | $000001E8,$000001D8,$000001A0,$00000188,$00000198,$000001F8,$000001A8,$000001C8, 120 | $00000180,$000001D0,$000001F0,$000001B8,$000001B0,$000001C0,$00000190,$000001E0, 121 | $00000768,$00000758,$00000720,$00000708,$00000718,$00000778,$00000728,$00000748, 122 | $00000700,$00000750,$00000770,$00000738,$00000730,$00000740,$00000710,$00000760, 123 | $00000368,$00000358,$00000320,$00000308,$00000318,$00000378,$00000328,$00000348, 124 | $00000300,$00000350,$00000370,$00000338,$00000330,$00000340,$00000310,$00000360, 125 | $000005E8,$000005D8,$000005A0,$00000588,$00000598,$000005F8,$000005A8,$000005C8, 126 | $00000580,$000005D0,$000005F0,$000005B8,$000005B0,$000005C0,$00000590,$000005E0, 127 | $00000468,$00000458,$00000420,$00000408,$00000418,$00000478,$00000428,$00000448, 128 | $00000400,$00000450,$00000470,$00000438,$00000430,$00000440,$00000410,$00000460, 129 | $00000668,$00000658,$00000620,$00000608,$00000618,$00000678,$00000628,$00000648, 130 | $00000600,$00000650,$00000670,$00000638,$00000630,$00000640,$00000610,$00000660)); 131 | -------------------------------------------------------------------------------- /Ciphers/DCPidea.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.1 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of IDEA *********************************} 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 DCPidea; 26 | 27 | {$INCLUDE '..\dcp.inc'} 28 | 29 | interface 30 | uses 31 | Classes, Sysutils, DCPcrypt2, DCPconst, DCPblockciphers; 32 | 33 | type 34 | TDCP_idea= class(TDCP_blockcipher64) 35 | protected 36 | EK, DK: array[0..51] of word; 37 | procedure InitKey(const Key; Size: longword); override; 38 | public 39 | class function GetId: integer; override; 40 | class function GetAlgorithm: string; override; 41 | class function GetMaxKeySize: integer; override; 42 | class function SelfTest: boolean; override; 43 | procedure Burn; override; 44 | procedure EncryptECB(const InData; var OutData); override; 45 | procedure DecryptECB(const InData; var OutData); override; 46 | end; 47 | 48 | 49 | {******************************************************************************} 50 | {******************************************************************************} 51 | implementation 52 | {$R-}{$Q-} 53 | 54 | {$IFDEF DELPHIXE2_UP} 55 | {$POINTERMATH ON} 56 | {$ENDIF} 57 | 58 | class function TDCP_idea.GetMaxKeySize: integer; 59 | begin 60 | Result:= 128; 61 | end; 62 | 63 | class function TDCP_idea.GetID: integer; 64 | begin 65 | Result:= DCP_idea; 66 | end; 67 | 68 | class function TDCP_idea.GetAlgorithm: string; 69 | begin 70 | Result:= 'IDEA'; 71 | end; 72 | 73 | class function TDCP_idea.SelfTest: boolean; 74 | const 75 | Key1: array[0..15] of byte= 76 | ($3A,$98,$4E,$20,$00,$19,$5D,$B3,$2E,$E5,$01,$C8,$C4,$7C,$EA,$60); 77 | InData1: array[0..7] of byte= 78 | ($01,$02,$03,$04,$05,$06,$07,$08); 79 | OutData1: array[0..7] of byte= 80 | ($97,$BC,$D8,$20,$07,$80,$DA,$86); 81 | Key2: array[0..15] of byte= 82 | ($00,$64,$00,$C8,$01,$2C,$01,$90,$01,$F4,$02,$58,$02,$BC,$03,$20); 83 | InData2: array[0..7] of byte= 84 | ($05,$32,$0A,$64,$14,$C8,$19,$FA); 85 | OutData2: array[0..7] of byte= 86 | ($65,$BE,$87,$E7,$A2,$53,$8A,$ED); 87 | var 88 | Cipher: TDCP_idea; 89 | Data: array[0..7] of byte; 90 | begin 91 | FillChar(Data, SizeOf(Data), 0); 92 | Cipher:= TDCP_idea.Create(nil); 93 | Cipher.Init(Key1,Sizeof(Key1)*8,nil); 94 | Cipher.EncryptECB(InData1,Data); 95 | Result:= boolean(CompareMem(@Data,@OutData1,Sizeof(Data))); 96 | Cipher.DecryptECB(Data,Data); 97 | Result:= Result and boolean(CompareMem(@Data,@InData1,Sizeof(Data))); 98 | Cipher.Burn; 99 | Cipher.Init(Key2,Sizeof(Key2)*8,nil); 100 | Cipher.EncryptECB(InData2,Data); 101 | Result:= Result and boolean(CompareMem(@Data,@OutData2,Sizeof(Data))); 102 | Cipher.DecryptECB(Data,Data); 103 | Result:= Result and boolean(CompareMem(@Data,@InData2,Sizeof(Data))); 104 | Cipher.Burn; 105 | Cipher.Free; 106 | end; 107 | 108 | function MulInv(x: word): word; 109 | var 110 | t0, t1, q, y: word; 111 | begin 112 | if x<= 1 then 113 | begin 114 | Result:= x; 115 | Exit; 116 | end; 117 | t1:= DWord($10001) div x; 118 | y:= DWord($10001) mod x; 119 | if y= 1 then 120 | begin 121 | Result:= (1 - t1) and $FFFF; 122 | Exit; 123 | end; 124 | t0:= 1; 125 | repeat 126 | q:= x div y; 127 | x:= x mod y; 128 | t0:= t0 + (q*t1); 129 | if x= 1 then 130 | begin 131 | Result:= t0; 132 | Exit; 133 | end; 134 | q:= y div x; 135 | y:= y mod x; 136 | t1:= t1 + (q*t0); 137 | until y= 1; 138 | Result:= (1-t1) and $FFFF; 139 | end; 140 | 141 | procedure TDCP_idea.InitKey(const Key; Size: longword); 142 | var 143 | i: integer; 144 | begin 145 | Size:= Size div 8; 146 | 147 | FillChar(EK,Sizeof(EK),0); 148 | Move(Key,EK,Size); 149 | for i:= 0 to 7 do 150 | EK[i]:= (EK[i] shl 8) or (EK[i] shr 8); 151 | for i:= 1 to 5 do 152 | begin 153 | EK[(i*8)+0]:= (EK[((i-1)*8)+1] shl 9) or (EK[((i-1)*8)+2] shr 7); 154 | EK[(i*8)+1]:= (EK[((i-1)*8)+2] shl 9) or (EK[((i-1)*8)+3] shr 7); 155 | EK[(i*8)+2]:= (EK[((i-1)*8)+3] shl 9) or (EK[((i-1)*8)+4] shr 7); 156 | EK[(i*8)+3]:= (EK[((i-1)*8)+4] shl 9) or (EK[((i-1)*8)+5] shr 7); 157 | EK[(i*8)+4]:= (EK[((i-1)*8)+5] shl 9) or (EK[((i-1)*8)+6] shr 7); 158 | EK[(i*8)+5]:= (EK[((i-1)*8)+6] shl 9) or (EK[((i-1)*8)+7] shr 7); 159 | EK[(i*8)+6]:= (EK[((i-1)*8)+7] shl 9) or (EK[((i-1)*8)+0] shr 7); 160 | EK[(i*8)+7]:= (EK[((i-1)*8)+0] shl 9) or (EK[((i-1)*8)+1] shr 7); 161 | end; 162 | EK[48]:= (EK[41] shl 9) or (EK[42] shr 7); 163 | EK[49]:= (EK[42] shl 9) or (EK[43] shr 7); 164 | EK[50]:= (EK[43] shl 9) or (EK[44] shr 7); 165 | EK[51]:= (EK[44] shl 9) or (EK[45] shr 7); 166 | 167 | DK[51]:= MulInv(EK[3]); 168 | DK[50]:= -EK[2]; 169 | DK[49]:= -EK[1]; 170 | DK[48]:= MulInv(EK[0]); 171 | for i:= 0 to 6 do 172 | begin 173 | DK[47-i*6]:= EK[i*6+5]; 174 | DK[46-i*6]:= EK[i*6+4]; 175 | DK[45-i*6]:= MulInv(EK[i*6+9]); 176 | DK[44-i*6]:= -EK[i*6+7]; 177 | DK[43-i*6]:= -EK[i*6+8]; 178 | DK[42-i*6]:= MulInv(EK[i*6+6]); 179 | end; 180 | DK[5]:= EK[47]; 181 | DK[4]:= EK[46]; 182 | DK[3]:= MulInv(EK[51]); 183 | DK[2]:= -EK[50]; 184 | DK[1]:= -EK[49]; 185 | DK[0]:= MulInv(EK[48]); 186 | end; 187 | 188 | procedure TDCP_idea.Burn; 189 | begin 190 | FillChar(EK,Sizeof(EK),0); 191 | FillChar(DK,Sizeof(DK),0); 192 | inherited Burn; 193 | end; 194 | 195 | procedure Mul(var x: word; const y: word); 196 | var 197 | p: DWord; 198 | t16: word; 199 | begin 200 | p:= DWord(x)*y; 201 | if p= 0 then 202 | x:= 1 - x - y 203 | else 204 | begin 205 | x:= p shr 16; 206 | t16:= p and $FFFF; 207 | x:= t16 - x; 208 | if (t16 < x) then 209 | Inc(x); 210 | end; 211 | end; 212 | 213 | procedure TDCP_idea.EncryptECB(const InData; var OutData); 214 | var 215 | x: array[1..4] of word; 216 | s3, s2: word; 217 | i: longword; 218 | begin 219 | if not fInitialized then 220 | raise EDCP_blockcipher.Create('Cipher not initialized'); 221 | PDword(@X[1])^:= PDword(@InData)^; 222 | PDword(@X[3])^:= PDword(PointerToInt(@InData)+4)^; 223 | for i:= 1 to 4 do 224 | x[i]:= (x[i] shl 8) or (x[i] shr 8); 225 | for i:= 0 to 7 do 226 | begin 227 | Mul(x[1],EK[(i*6)+0]); 228 | Inc(x[2],EK[(i*6)+1]); 229 | Inc(x[3],EK[(i*6)+2]); 230 | Mul(x[4],EK[(i*6)+3]); 231 | s3:= x[3]; 232 | x[3]:= x[3] xor x[1]; 233 | Mul(x[3],EK[(i*6)+4]); 234 | s2:= x[2]; 235 | x[2]:= x[2] xor x[4]; 236 | Inc(x[2],x[3]); 237 | Mul(x[2],EK[(i*6)+5]); 238 | Inc(x[3],x[2]); 239 | x[1]:= x[1] xor x[2]; 240 | x[4]:= x[4] xor x[3]; 241 | x[2]:= x[2] xor s3; 242 | x[3]:= x[3] xor s2; 243 | end; 244 | Mul(x[1],EK[48]); 245 | Inc(x[3],EK[49]); 246 | Inc(x[2],EK[50]); 247 | Mul(x[4],EK[51]); 248 | x[1]:= (x[1] shl 8) or (x[1] shr 8); 249 | s2:= (x[3] shl 8) or (x[3] shr 8); 250 | x[3]:= (x[2] shl 8) or (x[2] shr 8); 251 | x[4]:= (x[4] shl 8) or (x[4] shr 8); 252 | x[2]:= s2; 253 | PDword(@OutData)^:= PDword(@x[1])^; 254 | PDword(PointerToInt(@OutData)+4)^:= PDword(@x[3])^; 255 | end; 256 | 257 | procedure TDCP_idea.DecryptECB(const InData; var OutData); 258 | var 259 | x: array[1..4] of word; 260 | s3, s2: word; 261 | i: longword; 262 | begin 263 | if not fInitialized then 264 | raise EDCP_blockcipher.Create('Cipher not initialized'); 265 | PDword(@X[1])^:= PDword(@InData)^; 266 | PDword(@X[3])^:= PDword(PointerToInt(@InData)+4)^; 267 | for i:= 1 to 4 do 268 | x[i]:= (x[i] shl 8) or (x[i] shr 8); 269 | for i:= 0 to 7 do 270 | begin 271 | Mul(x[1],DK[(i*6)+0]); 272 | Inc(x[2],DK[(i*6)+1]); 273 | Inc(x[3],DK[(i*6)+2]); 274 | Mul(x[4],DK[(i*6)+3]); 275 | s3:= x[3]; 276 | x[3]:= x[3] xor x[1]; 277 | Mul(x[3],DK[(i*6)+4]); 278 | s2:= x[2]; 279 | x[2]:= x[2] xor x[4]; 280 | Inc(x[2],x[3]); 281 | Mul(x[2],DK[(i*6)+5]); 282 | Inc(x[3],x[2]); 283 | x[1]:= x[1] xor x[2]; 284 | x[4]:= x[4] xor x[3]; 285 | x[2]:= x[2] xor s3; 286 | x[3]:= x[3] xor s2; 287 | end; 288 | Mul(x[1],DK[48]); 289 | Inc(x[3],DK[49]); 290 | Inc(x[2],DK[50]); 291 | Mul(x[4],DK[51]); 292 | x[1]:= (x[1] shl 8) or (x[1] shr 8); 293 | s2:= (x[3] shl 8) or (x[3] shr 8); 294 | x[3]:= (x[2] shl 8) or (x[2] shr 8); 295 | x[4]:= (x[4] shl 8) or (x[4] shr 8); 296 | x[2]:= s2; 297 | PDword(@OutData)^:= PDword(@x[1])^; 298 | PDword(PointerToInt(@OutData)+4)^:= PDword(@x[3])^; 299 | end; 300 | 301 | 302 | end. 303 | -------------------------------------------------------------------------------- /Ciphers/DCPmars.inc: -------------------------------------------------------------------------------- 1 | const 2 | S_Box: array[0..511] of DWord= ( 3 | $09d0c479, $28c8ffe0, $84aa6c39, $9dad7287, 4 | $7dff9be3, $d4268361, $c96da1d4, $7974cc93, 5 | $85d0582e, $2a4b5705, $1ca16a62, $c3bd279d, 6 | $0f1f25e5, $5160372f, $c695c1fb, $4d7ff1e4, 7 | $ae5f6bf4, $0d72ee46, $ff23de8a, $b1cf8e83, 8 | $f14902e2, $3e981e42, $8bf53eb6, $7f4bf8ac, 9 | $83631f83, $25970205, $76afe784, $3a7931d4, 10 | $4f846450, $5c64c3f6, $210a5f18, $c6986a26, 11 | $28f4e826, $3a60a81c, $d340a664, $7ea820c4, 12 | $526687c5, $7eddd12b, $32a11d1d, $9c9ef086, 13 | $80f6e831, $ab6f04ad, $56fb9b53, $8b2e095c, 14 | $b68556ae, $d2250b0d, $294a7721, $e21fb253, 15 | $ae136749, $e82aae86, $93365104, $99404a66, 16 | $78a784dc, $b69ba84b, $04046793, $23db5c1e, 17 | $46cae1d6, $2fe28134, $5a223942, $1863cd5b, 18 | $c190c6e3, $07dfb846, $6eb88816, $2d0dcc4a, 19 | $a4ccae59, $3798670d, $cbfa9493, $4f481d45, 20 | $eafc8ca8, $db1129d6, $b0449e20, $0f5407fb, 21 | $6167d9a8, $d1f45763, $4daa96c3, $3bec5958, 22 | $ababa014, $b6ccd201, $38d6279f, $02682215, 23 | $8f376cd5, $092c237e, $bfc56593, $32889d2c, 24 | $854b3e95, $05bb9b43, $7dcd5dcd, $a02e926c, 25 | $fae527e5, $36a1c330, $3412e1ae, $f257f462, 26 | $3c4f1d71, $30a2e809, $68e5f551, $9c61ba44, 27 | $5ded0ab8, $75ce09c8, $9654f93e, $698c0cca, 28 | $243cb3e4, $2b062b97, $0f3b8d9e, $00e050df, 29 | $fc5d6166, $e35f9288, $c079550d, $0591aee8, 30 | $8e531e74, $75fe3578, $2f6d829a, $f60b21ae, 31 | $95e8eb8d, $6699486b, $901d7d9b, $fd6d6e31, 32 | $1090acef, $e0670dd8, $dab2e692, $cd6d4365, 33 | $e5393514, $3af345f0, $6241fc4d, $460da3a3, 34 | $7bcf3729, $8bf1d1e0, $14aac070, $1587ed55, 35 | $3afd7d3e, $d2f29e01, $29a9d1f6, $efb10c53, 36 | $cf3b870f, $b414935c, $664465ed, $024acac7, 37 | $59a744c1, $1d2936a7, $dc580aa6, $cf574ca8, 38 | $040a7a10, $6cd81807, $8a98be4c, $accea063, 39 | $c33e92b5, $d1e0e03d, $b322517e, $2092bd13, 40 | $386b2c4a, $52e8dd58, $58656dfb, $50820371, 41 | $41811896, $e337ef7e, $d39fb119, $c97f0df6, 42 | $68fea01b, $a150a6e5, $55258962, $eb6ff41b, 43 | $d7c9cd7a, $a619cd9e, $bcf09576, $2672c073, 44 | $f003fb3c, $4ab7a50b, $1484126a, $487ba9b1, 45 | $a64fc9c6, $f6957d49, $38b06a75, $dd805fcd, 46 | $63d094cf, $f51c999e, $1aa4d343, $b8495294, 47 | $ce9f8e99, $bffcd770, $c7c275cc, $378453a7, 48 | $7b21be33, $397f41bd, $4e94d131, $92cc1f98, 49 | $5915ea51, $99f861b7, $c9980a88, $1d74fd5f, 50 | $b0a495f8, $614deed0, $b5778eea, $5941792d, 51 | $fa90c1f8, $33f824b4, $c4965372, $3ff6d550, 52 | $4ca5fec0, $8630e964, $5b3fbbd6, $7da26a48, 53 | $b203231a, $04297514, $2d639306, $2eb13149, 54 | $16a45272, $532459a0, $8e5f4872, $f966c7d9, 55 | $07128dc0, $0d44db62, $afc8d52d, $06316131, 56 | $d838e7ce, $1bc41d00, $3a2e8c0f, $ea83837e, 57 | $b984737d, $13ba4891, $c4f8b949, $a6d6acb3, 58 | $a215cdce, $8359838b, $6bd1aa31, $f579dd52, 59 | $21b93f93, $f5176781, $187dfdde, $e94aeb76, 60 | $2b38fd54, $431de1da, $ab394825, $9ad3048f, 61 | $dfea32aa, $659473e3, $623f7863, $f3346c59, 62 | $ab3ab685, $3346a90b, $6b56443e, $c6de01f8, 63 | $8d421fc0, $9b0ed10c, $88f1a1e9, $54c1f029, 64 | $7dead57b, $8d7ba426, $4cf5178a, $551a7cca, 65 | $1a9a5f08, $fcd651b9, $25605182, $e11fc6c3, 66 | $b6fd9676, $337b3027, $b7c8eb14, $9e5fd030, 67 | $6b57e354, $ad913cf7, $7e16688d, $58872a69, 68 | $2c2fc7df, $e389ccc6, $30738df1, $0824a734, 69 | $e1797a8b, $a4a8d57b, $5b5d193b, $c8a8309b, 70 | $73f9a978, $73398d32, $0f59573e, $e9df2b03, 71 | $e8a5b6c8, $848d0704, $98df93c2, $720a1dc3, 72 | $684f259a, $943ba848, $a6370152, $863b5ea3, 73 | $d17b978b, $6d9b58ef, $0a700dd4, $a73d36bf, 74 | $8e6a0829, $8695bc14, $e35b3447, $933ac568, 75 | $8894b022, $2f511c27, $ddfbcc3c, $006662b6, 76 | $117c83fe, $4e12b414, $c2bca766, $3a2fec10, 77 | $f4562420, $55792e2a, $46f5d857, $ceda25ce, 78 | $c3601d3b, $6c00ab46, $efac9c28, $b3c35047, 79 | $611dfee3, $257c3207, $fdd58482, $3b14d84f, 80 | $23becb64, $a075f3a3, $088f8ead, $07adf158, 81 | $7796943c, $facabf3d, $c09730cd, $f7679969, 82 | $da44e9ed, $2c854c12, $35935fa3, $2f057d9f, 83 | $690624f8, $1cb0bafd, $7b0dbdc6, $810f23bb, 84 | $fa929a1a, $6d969a17, $6742979b, $74ac7d05, 85 | $010e65c4, $86a3d963, $f907b5a0, $d0042bd3, 86 | $158d7d03, $287a8255, $bba8366f, $096edc33, 87 | $21916a7b, $77b56b86, $951622f9, $a6c5e650, 88 | $8cea17d1, $cd8c62bc, $a3d63433, $358a68fd, 89 | $0f9b9d3c, $d6aa295b, $fe33384a, $c000738e, 90 | $cd67eb2f, $e2eb6dc2, $97338b02, $06c9f246, 91 | $419cf1ad, $2b83c045, $3723f18a, $cb5b3089, 92 | $160bead7, $5d494656, $35f8a74b, $1e4e6c9e, 93 | $000399bd, $67466880, $b4174831, $acf423b2, 94 | $ca815ab3, $5a6395e7, $302a67c5, $8bdb446b, 95 | $108f8fa4, $10223eda, $92b8b48b, $7f38d0ee, 96 | $ab2701d4, $0262d415, $af224a30, $b3d88aba, 97 | $f8b2c3af, $daf7ef70, $cc97d3b7, $e9614b6c, 98 | $2baebff4, $70f687cf, $386c9156, $ce092ee5, 99 | $01e87da6, $6ce91e6a, $bb7bcc84, $c7922c20, 100 | $9d3b71fd, $060e41c6, $d7590f15, $4e03bb47, 101 | $183c198e, $63eeb240, $2ddbf49a, $6d5cba54, 102 | $923750af, $f9e14236, $7838162b, $59726c72, 103 | $81b66760, $bb2926c1, $48a0ce0d, $a6c0496d, 104 | $ad43507b, $718d496a, $9df057af, $44b1bde6, 105 | $054356dc, $de7ced35, $d51a138b, $62088cc9, 106 | $35830311, $c96efca2, $686f86ec, $8e77cb68, 107 | $63e1d6b8, $c80f9778, $79c491fd, $1b4c67f2, 108 | $72698d7d, $5e368c31, $f7d95e2e, $a1d3493f, 109 | $dcd9433e, $896f1552, $4bc4ca7a, $a6d1baf4, 110 | $a5a96dcc, $0bef8b46, $a169fda7, $74df40b7, 111 | $4e208804, $9a756607, $038e87c8, $20211e44, 112 | $8b7ad4bf, $c6403f35, $1848e36d, $80bdb038, 113 | $1e62891c, $643d2107, $bf04d6f8, $21092c8c, 114 | $f644f389, $0778404e, $7b78adb8, $a2c52d53, 115 | $42157abe, $a2253e2e, $7bf3f4ae, $80f594f9, 116 | $953194e7, $77eb92ed, $b3816930, $da8d9336, 117 | $bf447469, $f26d9483, $ee6faed5, $71371235, 118 | $de425f73, $b4e59f43, $7dbe2d4e, $2d37b185, 119 | $49dc9a63, $98c39d98, $1301c9a2, $389b1bbf, 120 | $0c18588d, $a421c1ba, $7aa3865c, $71e08558, 121 | $3c5cfcaa, $7d239ca4, $0297d9dd, $d7dc2830, 122 | $4b37802b, $7428ab54, $aeee0347, $4b3fbb85, 123 | $692f2f08, $134e578e, $36d9e0bf, $ae8b5fcf, 124 | $edb93ecf, $2b27248e, $170eb1ef, $7dc57fd6, 125 | $1e760f16, $b1136601, $864e1b9b, $d7ea7319, 126 | $3ab871bd, $cfa4d76f, $e31bd782, $0dbeb469, 127 | $abb96061, $5370f85d, $ffb07e37, $da30d0fb, 128 | $ebc977b6, $0b98b40f, $3a4d0fe6, $df4fc26b, 129 | $159cf22a, $c298d6e2, $2b78ef6a, $61a94ac0, 130 | $ab561187, $14eea0f0, $df0d4164, $19af70ee); 131 | 132 | vk: array[0..6] of DWord= ( 133 | $09d0c479, $28c8ffe0, $84aa6c39, $9dad7287, $7dff9be3, $d4268361, 134 | $c96da1d4); 135 | -------------------------------------------------------------------------------- /Ciphers/DCPmisty1.inc: -------------------------------------------------------------------------------- 1 | const 2 | S7TABLE: array[0..$7F] of byte= ( 3 | $1b, $32, $33, $5a, $3b, $10, $17, $54, $5b, $1a, $72, $73, $6b, $2c, $66, $49, 4 | $1f, $24, $13, $6c, $37, $2e, $3f, $4a, $5d, $0f, $40, $56, $25, $51, $1c, $04, 5 | $0b, $46, $20, $0d, $7b, $35, $44, $42, $2b, $1e, $41, $14, $4b, $79, $15, $6f, 6 | $0e, $55, $09, $36, $74, $0c, $67, $53, $28, $0a, $7e, $38, $02, $07, $60, $29, 7 | $19, $12, $65, $2f, $30, $39, $08, $68, $5f, $78, $2a, $4c, $64, $45, $75, $3d, 8 | $59, $48, $03, $57, $7c, $4f, $62, $3c, $1d, $21, $5e, $27, $6a, $70, $4d, $3a, 9 | $01, $6d, $6e, $63, $18, $77, $23, $05, $26, $76, $00, $31, $2d, $7a, $7f, $61, 10 | $50, $22, $11, $06, $47, $16, $52, $4e, $71, $3e, $69, $43, $34, $5c, $58, $7d); 11 | S9TABLE: array[0..$1FF] of Dword= ( 12 | $1c3, $0cb, $153, $19f, $1e3, $0e9, $0fb, $035, $181, $0b9, $117, $1eb, $133, $009, $02d, $0d3, 13 | $0c7, $14a, $037, $07e, $0eb, $164, $193, $1d8, $0a3, $11e, $055, $02c, $01d, $1a2, $163, $118, 14 | $14b, $152, $1d2, $00f, $02b, $030, $13a, $0e5, $111, $138, $18e, $063, $0e3, $0c8, $1f4, $01b, 15 | $001, $09d, $0f8, $1a0, $16d, $1f3, $01c, $146, $07d, $0d1, $082, $1ea, $183, $12d, $0f4, $19e, 16 | $1d3, $0dd, $1e2, $128, $1e0, $0ec, $059, $091, $011, $12f, $026, $0dc, $0b0, $18c, $10f, $1f7, 17 | $0e7, $16c, $0b6, $0f9, $0d8, $151, $101, $14c, $103, $0b8, $154, $12b, $1ae, $017, $071, $00c, 18 | $047, $058, $07f, $1a4, $134, $129, $084, $15d, $19d, $1b2, $1a3, $048, $07c, $051, $1ca, $023, 19 | $13d, $1a7, $165, $03b, $042, $0da, $192, $0ce, $0c1, $06b, $09f, $1f1, $12c, $184, $0fa, $196, 20 | $1e1, $169, $17d, $031, $180, $10a, $094, $1da, $186, $13e, $11c, $060, $175, $1cf, $067, $119, 21 | $065, $068, $099, $150, $008, $007, $17c, $0b7, $024, $019, $0de, $127, $0db, $0e4, $1a9, $052, 22 | $109, $090, $19c, $1c1, $028, $1b3, $135, $16a, $176, $0df, $1e5, $188, $0c5, $16e, $1de, $1b1, 23 | $0c3, $1df, $036, $0ee, $1ee, $0f0, $093, $049, $09a, $1b6, $069, $081, $125, $00b, $05e, $0b4, 24 | $149, $1c7, $174, $03e, $13b, $1b7, $08e, $1c6, $0ae, $010, $095, $1ef, $04e, $0f2, $1fd, $085, 25 | $0fd, $0f6, $0a0, $16f, $083, $08a, $156, $09b, $13c, $107, $167, $098, $1d0, $1e9, $003, $1fe, 26 | $0bd, $122, $089, $0d2, $18f, $012, $033, $06a, $142, $0ed, $170, $11b, $0e2, $14f, $158, $131, 27 | $147, $05d, $113, $1cd, $079, $161, $1a5, $179, $09e, $1b4, $0cc, $022, $132, $01a, $0e8, $004, 28 | $187, $1ed, $197, $039, $1bf, $1d7, $027, $18b, $0c6, $09c, $0d0, $14e, $06c, $034, $1f2, $06e, 29 | $0ca, $025, $0ba, $191, $0fe, $013, $106, $02f, $1ad, $172, $1db, $0c0, $10b, $1d6, $0f5, $1ec, 30 | $10d, $076, $114, $1ab, $075, $10c, $1e4, $159, $054, $11f, $04b, $0c4, $1be, $0f7, $029, $0a4, 31 | $00e, $1f0, $077, $04d, $17a, $086, $08b, $0b3, $171, $0bf, $10e, $104, $097, $15b, $160, $168, 32 | $0d7, $0bb, $066, $1ce, $0fc, $092, $1c5, $06f, $016, $04a, $0a1, $139, $0af, $0f1, $190, $00a, 33 | $1aa, $143, $17b, $056, $18d, $166, $0d4, $1fb, $14d, $194, $19a, $087, $1f8, $123, $0a7, $1b8, 34 | $141, $03c, $1f9, $140, $02a, $155, $11a, $1a1, $198, $0d5, $126, $1af, $061, $12e, $157, $1dc, 35 | $072, $18a, $0aa, $096, $115, $0ef, $045, $07b, $08d, $145, $053, $05f, $178, $0b2, $02e, $020, 36 | $1d5, $03f, $1c9, $1e7, $1ac, $044, $038, $014, $0b1, $16b, $0ab, $0b5, $05a, $182, $1c8, $1d4, 37 | $018, $177, $064, $0cf, $06d, $100, $199, $130, $15a, $005, $120, $1bb, $1bd, $0e0, $04f, $0d6, 38 | $13f, $1c4, $12a, $015, $006, $0ff, $19b, $0a6, $043, $088, $050, $15f, $1e8, $121, $073, $17e, 39 | $0bc, $0c2, $0c9, $173, $189, $1f5, $074, $1cc, $1e6, $1a8, $195, $01f, $041, $00d, $1ba, $032, 40 | $03d, $1d1, $080, $0a8, $057, $1b9, $162, $148, $0d9, $105, $062, $07a, $021, $1ff, $112, $108, 41 | $1c0, $0a9, $11d, $1b0, $1a6, $0cd, $0f3, $05c, $102, $05b, $1d9, $144, $1f6, $0ad, $0a5, $03a, 42 | $1cb, $136, $17f, $046, $0e1, $01e, $1dd, $0e6, $137, $1fa, $185, $08c, $08f, $040, $1b5, $0be, 43 | $078, $000, $0ac, $110, $15e, $124, $002, $1bc, $0a2, $0ea, $070, $1fc, $116, $15c, $04c, $1c2); 44 | -------------------------------------------------------------------------------- /Ciphers/DCPmisty1.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of Misty1 *******************************} 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 DCPmisty1; 26 | 27 | interface 28 | uses 29 | Classes, Sysutils, DCPcrypt2, DCPconst, DCPblockciphers; 30 | 31 | const 32 | NUMROUNDS= 8; 33 | 34 | type 35 | TDCP_misty1= class(TDCP_blockcipher64) 36 | protected 37 | KeyData: array[0..31] of DWord; 38 | function FI(const FI_IN, FI_KEY: DWord): DWord; 39 | function FO(const FO_IN: DWord; const k: longword): DWord; 40 | function FL(const FL_IN: DWord; const k: longword): DWord; 41 | function FLINV(const FL_IN: DWord; const k: longword): DWord; 42 | procedure InitKey(const Key; Size: longword); override; 43 | public 44 | class function GetId: integer; override; 45 | class function GetAlgorithm: string; override; 46 | class function GetMaxKeySize: integer; override; 47 | class function SelfTest: boolean; override; 48 | procedure Burn; override; 49 | procedure EncryptECB(const InData; var OutData); override; 50 | procedure DecryptECB(const InData; var OutData); override; 51 | end; 52 | 53 | 54 | {******************************************************************************} 55 | {******************************************************************************} 56 | implementation 57 | {$R-}{$Q-} 58 | 59 | {$I DCPmisty1.inc} 60 | 61 | function SwapDword(a: dword): dword; 62 | begin 63 | Result:= ((a and $FF) shl 24) or ((a and $FF00) shl 8) or ((a and $FF0000) shr 8) or ((a and $FF000000) shr 24); 64 | end; 65 | 66 | class function TDCP_misty1.GetID: integer; 67 | begin 68 | Result:= DCP_misty1; 69 | end; 70 | 71 | class function TDCP_misty1.GetAlgorithm: string; 72 | begin 73 | Result:= 'Misty1'; 74 | end; 75 | 76 | class function TDCP_misty1.GetMaxKeySize: integer; 77 | begin 78 | Result:= 128; 79 | end; 80 | 81 | class function TDCP_misty1.SelfTest: boolean; 82 | const 83 | Key: array[0..15] of byte= 84 | ($00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff); 85 | Plain1: array[0..7] of byte= ($01,$23,$45,$67,$89,$ab,$cd,$ef); 86 | Plain2: array[0..7] of byte= ($fe,$dc,$ba,$98,$76,$54,$32,$10); 87 | Cipher1: array[0..7] of byte= ($8b,$1d,$a5,$f5,$6a,$b3,$d0,$7c); 88 | Cipher2: array[0..7] of byte= ($04,$b6,$82,$40,$b1,$3b,$e9,$5d); 89 | var 90 | Cipher: TDCP_misty1; 91 | Block: array[0..7] of byte; 92 | begin 93 | FillChar(Block, SizeOf(Block), 0); 94 | Cipher:= TDCP_misty1.Create(nil); 95 | Cipher.Init(Key,Sizeof(Key)*8,nil); 96 | Cipher.EncryptECB(Plain1,Block); 97 | Result:= CompareMem(@Cipher1,@Block,Sizeof(Block)); 98 | Cipher.DecryptECB(Block,Block); 99 | Result:= Result and CompareMem(@Plain1,@Block,Sizeof(Block)); 100 | Cipher.EncryptECB(Plain2,Block); 101 | Result:= Result and CompareMem(@Cipher2,@Block,Sizeof(Block)); 102 | Cipher.DecryptECB(Block,Block); 103 | Result:= Result and CompareMem(@Plain2,@Block,Sizeof(Block)); 104 | Cipher.Burn; 105 | Cipher.Free; 106 | end; 107 | 108 | function TDCP_misty1.FI(const FI_IN, FI_KEY: DWord): DWord; 109 | var 110 | d7, d9: DWord; 111 | begin 112 | d9:= (FI_IN shr 7) and $1ff; 113 | d7:= FI_IN and $7f; 114 | d9:= S9Table[d9] xor d7; 115 | d7:= (S7Table[d7] xor d9) and $7f; 116 | d7:= d7 xor ((FI_KEY shr 9) and $7f); 117 | d9:= d9 xor (FI_KEY and $1ff); 118 | d9:= S9Table[d9] xor d7; 119 | Result:= (d7 shl 9) or d9; 120 | end; 121 | 122 | function TDCP_misty1.FO(const FO_IN: DWord; const k: longword): DWord; 123 | var 124 | t0, t1: DWord; 125 | begin 126 | t0:= FO_IN shr 16; 127 | t1:= FO_IN and $FFFF; 128 | t0:= t0 xor KeyData[k]; 129 | t0:= FI(t0,KeyData[((k+5) mod 8) + 8]); 130 | t0:= t0 xor t1; 131 | t1:= t1 xor KeyData[(k+2) mod 8]; 132 | t1:= FI(t1,KeyData[((k+1) mod 8) + 8]); 133 | t1:= t1 xor t0; 134 | t0:= t0 xor KeyData[(k+7) mod 8]; 135 | t0:= FI(t0,KeyData[((k+3) mod 8) + 8]); 136 | t0:= t0 xor t1; 137 | t1:= t1 xor KeyData[(k+4) mod 8]; 138 | Result:= (t1 shl 16) or t0; 139 | end; 140 | 141 | function TDCP_misty1.FL(const FL_IN: DWord; const k: longword): DWord; 142 | var 143 | d0, d1: DWord; 144 | t: byte; 145 | begin 146 | d0:= FL_IN shr 16; 147 | d1:= FL_IN and $FFFF; 148 | if (k mod 2)<> 0 then 149 | begin 150 | t:= (k-1) div 2; 151 | d1:= d1 xor (d0 and KeyData[((t + 2) mod 8) + 8]); 152 | d0:= d0 xor (d1 or KeyData[(t + 4) mod 8]); 153 | end 154 | else 155 | begin 156 | t:= k div 2; 157 | d1:= d1 xor (d0 and KeyData[t]); 158 | d0:= d0 xor (d1 or KeyData[((t+6) mod 8) + 8]); 159 | end; 160 | Result:= (d0 shl 16) or d1; 161 | end; 162 | 163 | function TDCP_misty1.FLINV(const FL_IN: DWord; const k: longword): DWord; 164 | var 165 | d0, d1: DWord; 166 | t: byte; 167 | begin 168 | d0:= FL_IN shr 16; 169 | d1:= FL_IN and $FFFF; 170 | if (k mod 2)<> 0 then 171 | begin 172 | t:= (k-1) div 2; 173 | d0:= d0 xor (d1 or KeyData[(t+4) mod 8]); 174 | d1:= d1 xor (d0 and KeyData[((t+2) mod 8) + 8]); 175 | end 176 | else 177 | begin 178 | t:= k div 2; 179 | d0:= d0 xor (d1 or KeyData[((t+6) mod 8) + 8]); 180 | d1:= d1 xor (d0 and KeyData[t]); 181 | end; 182 | Result:= (d0 shl 16) or d1; 183 | end; 184 | 185 | procedure TDCP_misty1.InitKey(const Key; Size: longword); 186 | var 187 | KeyB: array[0..15] of byte; 188 | i: longword; 189 | begin 190 | FillChar(KeyB,Sizeof(KeyB),0); 191 | Move(Key,KeyB,Size div 8); 192 | for i:= 0 to 7 do 193 | KeyData[i]:= (KeyB[i*2] * 256) + KeyB[i*2+1]; 194 | for i:= 0 to 7 do 195 | begin 196 | KeyData[i+8]:= FI(KeyData[i],KeyData[(i+1) mod 8]); 197 | KeyData[i+16]:= KeyData[i+8] and $1FF; 198 | KeyData[i+24]:= KeyData[i+8] shr 9; 199 | end; 200 | end; 201 | 202 | procedure TDCP_misty1.Burn; 203 | begin 204 | FillChar(KeyData,Sizeof(KeyData),0); 205 | inherited Burn; 206 | end; 207 | 208 | procedure TDCP_misty1.EncryptECB(const InData; var OutData); 209 | var 210 | d0, d1: DWord; 211 | i: longword; 212 | begin 213 | if not fInitialized then 214 | raise EDCP_blockcipher.Create('Cipher not initialized'); 215 | d0:= SwapDWord(PDWord(@InData)^); 216 | d1:= SwapDWord(PDWord(longword(@InData)+4)^); 217 | for i:= 0 to NUMROUNDS-1 do 218 | begin 219 | if (i mod 2)= 0 then 220 | begin 221 | d0:= FL(D0,i); 222 | d1:= FL(D1,i+1); 223 | d1:= d1 xor FO(d0,i); 224 | end 225 | else 226 | d0:= d0 xor FO(d1,i); 227 | end; 228 | d0:= FL(d0,NUMROUNDS); 229 | d1:= FL(d1,NUMROUNDS+1); 230 | PDWord(@OutData)^:= SwapDWord(d1); 231 | PDWord(longword(@OutData)+4)^:= SwapDWord(d0); 232 | end; 233 | 234 | procedure TDCP_misty1.DecryptECB(const InData; var OutData); 235 | var 236 | d0, d1: DWord; 237 | i: longword; 238 | begin 239 | if not fInitialized then 240 | raise EDCP_blockcipher.Create('Cipher not initialized'); 241 | d1:= SwapDWord(PDWord(@InData)^); 242 | d0:= SwapDWord(PDWord(longword(@InData)+4)^); 243 | d1:= FLINV(d1,NUMROUNDS+1); 244 | d0:= FLINV(d0,NUMROUNDS); 245 | for i:= NUMROUNDS-1 downto 0 do 246 | begin 247 | if (i mod 2)= 0 then 248 | begin 249 | d1:= d1 xor FO(d0,i); 250 | d0:= FLINV(D0,i); 251 | d1:= FLINV(D1,i+1); 252 | end 253 | else 254 | d0:= d0 xor FO(d1,i); 255 | end; 256 | PDWord(@OutData)^:= SwapDWord(d0); 257 | PDWord(longword(@OutData)+4)^:= SwapDWord(d1); 258 | end; 259 | 260 | end. 261 | -------------------------------------------------------------------------------- /Ciphers/DCPrc2.inc: -------------------------------------------------------------------------------- 1 | const 2 | sBox: array[0..255] of byte= ( 3 | $D9,$78,$F9,$C4,$19,$DD,$B5,$ED,$28,$E9,$FD,$79,$4A,$A0,$D8,$9D, 4 | $C6,$7E,$37,$83,$2B,$76,$53,$8E,$62,$4C,$64,$88,$44,$8B,$FB,$A2, 5 | $17,$9A,$59,$F5,$87,$B3,$4F,$13,$61,$45,$6D,$8D,$09,$81,$7D,$32, 6 | $BD,$8F,$40,$EB,$86,$B7,$7B,$0B,$F0,$95,$21,$22,$5C,$6B,$4E,$82, 7 | $54,$D6,$65,$93,$CE,$60,$B2,$1C,$73,$56,$C0,$14,$A7,$8C,$F1,$DC, 8 | $12,$75,$CA,$1F,$3B,$BE,$E4,$D1,$42,$3D,$D4,$30,$A3,$3C,$B6,$26, 9 | $6F,$BF,$0E,$DA,$46,$69,$07,$57,$27,$F2,$1D,$9B,$BC,$94,$43,$03, 10 | $F8,$11,$C7,$F6,$90,$EF,$3E,$E7,$06,$C3,$D5,$2F,$C8,$66,$1E,$D7, 11 | $08,$E8,$EA,$DE,$80,$52,$EE,$F7,$84,$AA,$72,$AC,$35,$4D,$6A,$2A, 12 | $96,$1A,$D2,$71,$5A,$15,$49,$74,$4B,$9F,$D0,$5E,$04,$18,$A4,$EC, 13 | $C2,$E0,$41,$6E,$0F,$51,$CB,$CC,$24,$91,$AF,$50,$A1,$F4,$70,$39, 14 | $99,$7C,$3A,$85,$23,$B8,$B4,$7A,$FC,$02,$36,$5B,$25,$55,$97,$31, 15 | $2D,$5D,$FA,$98,$E3,$8A,$92,$AE,$05,$DF,$29,$10,$67,$6C,$BA,$C9, 16 | $D3,$00,$E6,$CF,$E1,$9E,$A8,$2C,$63,$16,$01,$3F,$58,$E2,$89,$A9, 17 | $0D,$38,$34,$1B,$AB,$33,$FF,$B0,$BB,$48,$0C,$5F,$B9,$B1,$CD,$2E, 18 | $C5,$F3,$DB,$47,$E5,$A5,$9C,$77,$0A,$A6,$20,$68,$FE,$7F,$C1,$AD); 19 | -------------------------------------------------------------------------------- /Ciphers/DCPrc2.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.1 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of RC2 **********************************} 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 DCPrc2; 26 | 27 | {$INCLUDE '..\dcp.inc'} 28 | 29 | interface 30 | uses 31 | Classes, Sysutils, DCPcrypt2, DCPconst, DCPblockciphers; 32 | 33 | type 34 | TDCP_rc2= class(TDCP_blockcipher64) 35 | protected 36 | KeyData: array[0..63] of word; 37 | procedure InitKey(const Key; Size: longword); override; 38 | public 39 | class function GetId: integer; override; 40 | class function GetAlgorithm: string; override; 41 | class function GetMaxKeySize: integer; override; 42 | class function SelfTest: boolean; override; 43 | procedure Burn; override; 44 | procedure EncryptECB(const InData; var OutData); override; 45 | procedure DecryptECB(const InData; var OutData); override; 46 | end; 47 | 48 | 49 | {******************************************************************************} 50 | {******************************************************************************} 51 | implementation 52 | {$R-}{$Q-} 53 | 54 | {$I DCPrc2.inc} 55 | 56 | {$IFDEF DELPHIXE2_UP} 57 | {$POINTERMATH ON} 58 | {$ENDIF} 59 | 60 | function LRot16(a, n: word): word; 61 | begin 62 | Result:= (a shl n) or (a shr (16-n)); 63 | end; 64 | 65 | function RRot16(a, n: word): word; 66 | begin 67 | Result:= (a shr n) or (a shl (16-n)); 68 | end; 69 | 70 | class function TDCP_rc2.GetMaxKeySize: integer; 71 | begin 72 | Result:= 1024; 73 | end; 74 | 75 | class function TDCP_rc2.GetID: integer; 76 | begin 77 | Result:= DCP_rc2; 78 | end; 79 | 80 | class function TDCP_rc2.GetAlgorithm: string; 81 | begin 82 | Result:= 'RC2'; 83 | end; 84 | 85 | class function TDCP_rc2.SelfTest: boolean; 86 | const 87 | Key1: array[0..15] of byte= 88 | ($00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$0B,$0C,$0D,$0E,$0F); 89 | InData1: array[0..7] of byte= 90 | ($00,$00,$00,$00,$00,$00,$00,$00); 91 | OutData1: array[0..7] of byte= 92 | ($50,$DC,$01,$62,$BD,$75,$7F,$31); 93 | Key2: array[0..15] of byte= 94 | ($00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01); 95 | InData2: array[0..7] of byte= 96 | ($00,$00,$00,$00,$00,$00,$00,$00); 97 | OutData2: array[0..7] of byte= 98 | ($21,$82,$9C,$78,$A9,$F9,$C0,$74); 99 | var 100 | Cipher: TDCP_rc2; 101 | Data: array[0..7] of byte; 102 | begin 103 | FillChar(Data, SizeOf(Data), 0); 104 | Cipher:= TDCP_rc2.Create(nil); 105 | Cipher.Init(Key1,Sizeof(Key1)*8,nil); 106 | Cipher.EncryptECB(InData1,Data); 107 | Result:= boolean(CompareMem(@Data,@OutData1,Sizeof(Data))); 108 | Cipher.DecryptECB(Data,Data); 109 | Result:= boolean(CompareMem(@Data,@InData1,Sizeof(Data))) and Result; 110 | Cipher.Burn; 111 | Cipher.Init(Key2,Sizeof(Key2)*8,nil); 112 | Cipher.EncryptECB(InData2,Data); 113 | Result:= boolean(CompareMem(@Data,@OutData2,Sizeof(Data))) and Result; 114 | Cipher.DecryptECB(Data,Data); 115 | Result:= boolean(CompareMem(@Data,@InData2,Sizeof(Data))) and Result; 116 | Cipher.Burn; 117 | Cipher.Free; 118 | end; 119 | 120 | procedure TDCP_rc2.InitKey(const Key; Size: longword); 121 | var 122 | i: longword; 123 | KeyB: array[0..127] of byte; 124 | begin 125 | FillChar(KeyB, SizeOf(KeyB), 0); 126 | Move(Key,KeyB,Size div 8); 127 | for i:= (Size div 8) to 127 do 128 | KeyB[i]:= sBox[(KeyB[i-(Size div 8)]+KeyB[i-1]) and $FF]; 129 | KeyB[0]:= sBox[KeyB[0]]; 130 | Move(KeyB,KeyData,Sizeof(KeyData)); 131 | end; 132 | 133 | procedure TDCP_rc2.Burn; 134 | begin 135 | FillChar(KeyData,Sizeof(KeyData),0); 136 | inherited Burn; 137 | end; 138 | 139 | procedure TDCP_rc2.EncryptECB(const InData; var OutData); 140 | var 141 | i, j: longword; 142 | w: array[0..3] of word; 143 | begin 144 | if not fInitialized then 145 | raise EDCP_blockcipher.Create('Cipher not initialized'); 146 | Pdword(@w[0])^:= Pdword(@InData)^; 147 | Pdword(@w[2])^:= Pdword(PointerToInt(@InData)+4)^; 148 | for i:= 0 to 15 do 149 | begin 150 | j:= i*4; 151 | w[0]:= LRot16((w[0]+(w[1] and (not w[3]))+(w[2] and w[3])+KeyData[j+0]),1); 152 | w[1]:= LRot16((w[1]+(w[2] and (not w[0]))+(w[3] and w[0])+KeyData[j+1]),2); 153 | w[2]:= LRot16((w[2]+(w[3] and (not w[1]))+(w[0] and w[1])+KeyData[j+2]),3); 154 | w[3]:= LRot16((w[3]+(w[0] and (not w[2]))+(w[1] and w[2])+KeyData[j+3]),5); 155 | if (i= 4) or (i= 10) then 156 | begin 157 | w[0]:= w[0]+KeyData[w[3] and 63]; 158 | w[1]:= w[1]+KeyData[w[0] and 63]; 159 | w[2]:= w[2]+KeyData[w[1] and 63]; 160 | w[3]:= w[3]+KeyData[w[2] and 63]; 161 | end; 162 | end; 163 | Pdword(@OutData)^:= Pdword(@w[0])^; 164 | Pdword(PointerToInt(@OutData)+4)^:= Pdword(@w[2])^; 165 | end; 166 | 167 | procedure TDCP_rc2.DecryptECB(const InData; var OutData); 168 | var 169 | i, j: longword; 170 | w: array[0..3] of word; 171 | begin 172 | if not fInitialized then 173 | raise EDCP_blockcipher.Create('Cipher not initialized'); 174 | Pdword(@w[0])^:= Pdword(@InData)^; 175 | Pdword(@w[2])^:= Pdword(PointerToInt(@InData)+4)^; 176 | for i:= 15 downto 0 do 177 | begin 178 | j:= i*4; 179 | w[3]:= RRot16(w[3],5)-(w[0] and (not w[2]))-(w[1] and w[2])-KeyData[j+3]; 180 | w[2]:= RRot16(w[2],3)-(w[3] and (not w[1]))-(w[0] and w[1])-KeyData[j+2]; 181 | w[1]:= RRot16(w[1],2)-(w[2] and (not w[0]))-(w[3] and w[0])-KeyData[j+1]; 182 | w[0]:= RRot16(w[0],1)-(w[1] and (not w[3]))-(w[2] and w[3])-KeyData[j+0]; 183 | if (i= 5) or (i= 11) then 184 | begin 185 | w[3]:= w[3]-KeyData[w[2] and 63]; 186 | w[2]:= w[2]-KeyData[w[1] and 63]; 187 | w[1]:= w[1]-KeyData[w[0] and 63]; 188 | w[0]:= w[0]-KeyData[w[3] and 63]; 189 | end; 190 | end; 191 | Pdword(@OutData)^:= Pdword(@w[0])^; 192 | Pdword(PointerToInt(@OutData)+4)^:= Pdword(@w[2])^; 193 | end; 194 | 195 | end. 196 | -------------------------------------------------------------------------------- /Ciphers/DCPrc4.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.1 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of RC4 **********************************} 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 DCPrc4; 26 | 27 | {$INCLUDE '..\dcp.inc'} 28 | 29 | interface 30 | uses 31 | Classes, Sysutils, DCPcrypt2, DCPconst; 32 | 33 | type 34 | TDCP_rc4= class(TDCP_cipher) 35 | protected 36 | KeyData, KeyOrg: array[0..255] of byte; 37 | public 38 | class function GetId: integer; override; 39 | class function GetAlgorithm: string; override; 40 | class function GetMaxKeySize: integer; override; 41 | class function SelfTest: boolean; override; 42 | procedure Init(const Key; Size: longword; InitVector: pointer); override; 43 | procedure Reset; override; 44 | procedure Burn; override; 45 | procedure Encrypt(const InData; var OutData; Size: longword); override; 46 | procedure Decrypt(const InData; var OutData; Size: longword); override; 47 | end; 48 | 49 | {******************************************************************************} 50 | {******************************************************************************} 51 | implementation 52 | {$R-}{$Q-} 53 | 54 | {$IFDEF DELPHIXE2_UP} 55 | {$POINTERMATH ON} 56 | {$ENDIF} 57 | 58 | class function TDCP_rc4.GetID: integer; 59 | begin 60 | Result:= DCP_rc4; 61 | end; 62 | 63 | class function TDCP_rc4.GetAlgorithm: string; 64 | begin 65 | Result:= 'RC4'; 66 | end; 67 | 68 | class function TDCP_rc4.GetMaxKeySize: integer; 69 | begin 70 | Result:= 2048; 71 | end; 72 | 73 | class function TDCP_rc4.SelfTest: boolean; 74 | const 75 | Key1: array[0..4] of byte= ($61,$8A,$63,$D2,$FB); 76 | InData1: array[0..4] of byte= ($DC,$EE,$4C,$F9,$2C); 77 | OutData1: array[0..4] of byte= ($F1,$38,$29,$C9,$DE); 78 | var 79 | Cipher: TDCP_rc4; 80 | Data: array[0..4] of byte; 81 | begin 82 | FillChar(Data, SizeOf(Data), 0); 83 | Cipher:= TDCP_rc4.Create(nil); 84 | Cipher.Init(Key1,Sizeof(Key1)*8,nil); 85 | Cipher.Encrypt(InData1,Data,Sizeof(Data)); 86 | Result:= boolean(CompareMem(@Data,@OutData1,Sizeof(Data))); 87 | Cipher.Reset; 88 | Cipher.Decrypt(Data,Data,Sizeof(Data)); 89 | Result:= boolean(CompareMem(@Data,@InData1,Sizeof(Data))) and Result; 90 | Cipher.Burn; 91 | Cipher.Free; 92 | end; 93 | 94 | procedure TDCP_rc4.Init(const Key; Size: longword; InitVector: pointer); 95 | var 96 | i, j, t: longword; 97 | xKey: array[0..255] of byte; 98 | begin 99 | if fInitialized then 100 | Burn; 101 | inherited Init(Key,Size,nil); 102 | Size:= Size div 8; 103 | i:= 0; 104 | while i< 255 do 105 | begin 106 | KeyData[i]:= i; 107 | xKey[i]:= PByte(PointerToInt(@Key)+(i mod Size))^; 108 | KeyData[i+1]:= i+1; 109 | xKey[i+1]:= PByte(PointerToInt(@Key)+((i+1) mod Size))^; 110 | KeyData[i+2]:= i+2; 111 | xKey[i+2]:= PByte(PointerToInt(@Key)+((i+2) mod Size))^; 112 | KeyData[i+3]:= i+3; 113 | xKey[i+3]:= PByte(PointerToInt(@Key)+((i+3) mod Size))^; 114 | KeyData[i+4]:= i+4; 115 | xKey[i+4]:= PByte(PointerToInt(@Key)+((i+4) mod Size))^; 116 | KeyData[i+5]:= i+5; 117 | xKey[i+5]:= PByte(PointerToInt(@Key)+((i+5) mod Size))^; 118 | KeyData[i+6]:= i+6; 119 | xKey[i+6]:= PByte(PointerToInt(@Key)+((i+6) mod Size))^; 120 | KeyData[i+7]:= i+7; 121 | xKey[i+7]:= PByte(PointerToInt(@Key)+((i+7) mod Size))^; 122 | Inc(i,8); 123 | end; 124 | j:= 0; 125 | i:= 0; 126 | while i< 255 do 127 | begin 128 | j:= (j+KeyData[i]+xKey[i]) and $FF; 129 | t:= KeyData[i]; 130 | KeyData[i]:= KeyData[j]; 131 | KeyData[j]:= t; 132 | j:= (j+KeyData[i+1]+xKey[i+1]) and $FF; 133 | t:= KeyData[i+1]; 134 | KeyData[i+1]:= KeyData[j]; 135 | KeyData[j]:= t; 136 | j:= (j+KeyData[i+2]+xKey[i+2]) and $FF; 137 | t:= KeyData[i+2]; 138 | KeyData[i+2]:= KeyData[j]; 139 | KeyData[j]:= t; 140 | j:= (j+KeyData[i+3]+xKey[i+3]) and $FF; 141 | t:= KeyData[i+3]; 142 | KeyData[i+3]:= KeyData[j]; 143 | KeyData[j]:= t; 144 | j:= (j+KeyData[i+4]+xKey[i+4]) and $FF; 145 | t:= KeyData[i+4]; 146 | KeyData[i+4]:= KeyData[j]; 147 | KeyData[j]:= t; 148 | j:= (j+KeyData[i+5]+xKey[i+5]) and $FF; 149 | t:= KeyData[i+5]; 150 | KeyData[i+5]:= KeyData[j]; 151 | KeyData[j]:= t; 152 | j:= (j+KeyData[i+6]+xKey[i+6]) and $FF; 153 | t:= KeyData[i+6]; 154 | KeyData[i+6]:= KeyData[j]; 155 | KeyData[j]:= t; 156 | j:= (j+KeyData[i+7]+xKey[i+7]) and $FF; 157 | t:= KeyData[i+7]; 158 | KeyData[i+7]:= KeyData[j]; 159 | KeyData[j]:= t; 160 | Inc(i,8); 161 | end; 162 | Move(KeyData,KeyOrg,Sizeof(KeyOrg)); 163 | end; 164 | 165 | procedure TDCP_rc4.Reset; 166 | begin 167 | Move(KeyOrg,KeyData,Sizeof(KeyData)); 168 | end; 169 | 170 | procedure TDCP_rc4.Burn; 171 | begin 172 | FillChar(KeyOrg,Sizeof(KeyOrg),$FF); 173 | FillChar(KeyData,Sizeof(KeyData),$FF); 174 | inherited Burn; 175 | end; 176 | 177 | procedure TDCP_rc4.Encrypt(const InData; var OutData; Size: longword); 178 | var 179 | i, j, t, k: longword; 180 | begin 181 | if not fInitialized then 182 | raise EDCP_cipher.Create('Cipher not initialized'); 183 | i:= 0; j:= 0; 184 | for k:= 0 to Size-1 do 185 | begin 186 | i:= (i + 1) and $FF; 187 | t:= KeyData[i]; 188 | j:= (j + t) and $FF; 189 | KeyData[i]:= KeyData[j]; 190 | KeyData[j]:= t; 191 | t:= (t + KeyData[i]) and $FF; 192 | Pbytearray(@OutData)^[k]:= Pbytearray(@InData)^[k] xor KeyData[t]; 193 | end; 194 | end; 195 | 196 | procedure TDCP_rc4.Decrypt(const InData; var OutData; Size: longword); 197 | var 198 | i, j, t, k: longword; 199 | begin 200 | if not fInitialized then 201 | raise EDCP_cipher.Create('Cipher not initialized'); 202 | i:= 0; j:= 0; 203 | for k:= 0 to Size-1 do 204 | begin 205 | i:= (i + 1) and $FF; 206 | t:= KeyData[i]; 207 | j:= (j + t) and $FF; 208 | KeyData[i]:= KeyData[j]; 209 | KeyData[j]:= t; 210 | t:= (t + KeyData[i]) and $FF; 211 | Pbytearray(@OutData)^[k]:= Pbytearray(@InData)^[k] xor KeyData[t]; 212 | end; 213 | end; 214 | 215 | 216 | end. 217 | -------------------------------------------------------------------------------- /Ciphers/DCPrc5.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of RC5 **********************************} 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 DCPrc5; 26 | 27 | interface 28 | uses 29 | Classes, Sysutils, DCPcrypt2, DCPconst, DCPblockciphers; 30 | 31 | const 32 | NUMROUNDS= 12; { number of rounds must be between 12-16 } 33 | 34 | type 35 | TDCP_rc5= class(TDCP_blockcipher64) 36 | protected 37 | KeyData: array[0..((NUMROUNDS*2)+1)] of DWord; 38 | procedure InitKey(const Key; Size: longword); override; 39 | public 40 | class function GetId: integer; override; 41 | class function GetAlgorithm: string; override; 42 | class function GetMaxKeySize: integer; override; 43 | class function SelfTest: boolean; override; 44 | procedure Burn; override; 45 | procedure EncryptECB(const InData; var OutData); override; 46 | procedure DecryptECB(const InData; var OutData); override; 47 | end; 48 | 49 | 50 | {******************************************************************************} 51 | {******************************************************************************} 52 | implementation 53 | {$R-}{$Q-} 54 | 55 | const 56 | sBox: array[0..33] of dword= ( 57 | $B7E15163,$5618CB1C,$F45044D5,$9287BE8E,$30BF3847,$CEF6B200, 58 | $6D2E2BB9,$0B65A572,$A99D1F2B,$47D498E4,$E60C129D,$84438C56, 59 | $227B060F,$C0B27FC8,$5EE9F981,$FD21733A,$9B58ECF3,$399066AC, 60 | $D7C7E065,$75FF5A1E,$1436D3D7,$B26E4D90,$50A5C749,$EEDD4102, 61 | $8D14BABB,$2B4C3474,$C983AE2D,$67BB27E6,$05F2A19F,$A42A1B58, 62 | $42619511,$E0990ECA,$7ED08883,$1D08023C); 63 | 64 | function LRot32(a, b: longword): longword; 65 | begin 66 | Result:= (a shl b) or (a shr (32-b)); 67 | end; 68 | 69 | function RRot32(a, b: longword): longword; 70 | begin 71 | Result:= (a shr b) or (a shl (32-b)); 72 | end; 73 | 74 | class function TDCP_rc5.GetID: integer; 75 | begin 76 | Result:= DCP_rc5; 77 | end; 78 | 79 | class function TDCP_rc5.GetAlgorithm: string; 80 | begin 81 | Result:= 'RC5'; 82 | end; 83 | 84 | class function TDCP_rc5.GetMaxKeySize: integer; 85 | begin 86 | Result:= 2048; 87 | end; 88 | 89 | class function TDCP_rc5.SelfTest: boolean; 90 | const 91 | Key1: array[0..15] of byte= 92 | ($DC,$49,$DB,$13,$75,$A5,$58,$4F,$64,$85,$B4,$13,$B5,$F1,$2B,$AF); 93 | Plain1: array[0..1] of dword= 94 | ($B7B3422F,$92FC6903); 95 | Cipher1: array[0..1] of dword= 96 | ($B278C165,$CC97D184); 97 | Key2: array[0..15] of byte= 98 | ($52,$69,$F1,$49,$D4,$1B,$A0,$15,$24,$97,$57,$4D,$7F,$15,$31,$25); 99 | Plain2: array[0..1] of dword= 100 | ($B278C165,$CC97D184); 101 | Cipher2: array[0..1] of dword= 102 | ($15E444EB,$249831DA); 103 | var 104 | Cipher: TDCP_rc5; 105 | Data: array[0..1] of dword; 106 | begin 107 | FillChar(Data, SizeOf(Data), 0); 108 | Cipher:= TDCP_rc5.Create(nil); 109 | Cipher.Init(Key1,Sizeof(Key1)*8,nil); 110 | Cipher.EncryptECB(Plain1,Data); 111 | Result:= boolean(CompareMem(@Data,@Cipher1,Sizeof(Data))); 112 | Cipher.DecryptECB(Data,Data); 113 | Result:= Result and boolean(CompareMem(@Data,@Plain1,Sizeof(Data))); 114 | Cipher.Burn; 115 | Cipher.Init(Key2,Sizeof(Key2)*8,nil); 116 | Cipher.EncryptECB(Plain2,Data); 117 | Result:= Result and boolean(CompareMem(@Data,@Cipher2,Sizeof(Data))); 118 | Cipher.DecryptECB(Data,Data); 119 | Result:= Result and boolean(CompareMem(@Data,@Plain2,Sizeof(Data))); 120 | Cipher.Burn; 121 | Cipher.Free; 122 | end; 123 | 124 | procedure TDCP_rc5.InitKey(const Key; Size: longword); 125 | var 126 | xKeyD: array[0..63] of DWord; 127 | i, j, k, xKeyLen: longword; 128 | A, B: DWord; 129 | begin 130 | FillChar(xKeyD,Sizeof(xKeyD),0); 131 | Size:= Size div 8; 132 | Move(Key,xKeyD,Size); 133 | xKeyLen:= Size div 4; 134 | if (Size mod 4)<> 0 then 135 | Inc(xKeyLen); 136 | Move(sBox,KeyData,(NUMROUNDS+1)*8); 137 | i:= 0; j:= 0; 138 | A:= 0; B:= 0; 139 | if xKeyLen> ((NUMROUNDS+1)*2) then 140 | k:= xKeyLen*3 141 | else 142 | k:= (NUMROUNDS+1)*6; 143 | for k:= k downto 1 do 144 | begin 145 | A:= LRot32(KeyData[i]+A+B,3); 146 | KeyData[i]:= A; 147 | B:= LRot32(xKeyD[j]+A+B,A+B); 148 | xKeyD[j]:= B; 149 | i:= (i+1) mod ((NUMROUNDS+1)*2); 150 | j:= (j+1) mod xKeyLen; 151 | end; 152 | FillChar(xKeyD,Sizeof(xKeyD),0); 153 | end; 154 | 155 | procedure TDCP_rc5.Burn; 156 | begin 157 | FillChar(KeyData,Sizeof(KeyData),$FF); 158 | inherited Burn; 159 | end; 160 | 161 | procedure TDCP_rc5.EncryptECB(const InData; var OutData); 162 | var 163 | A, B: DWord; 164 | i: longword; 165 | begin 166 | if not fInitialized then 167 | raise EDCP_blockcipher.Create('Cipher not initialized'); 168 | A:= PDword(@InData)^ + KeyData[0]; 169 | B:= PDword(longword(@InData)+4)^ + KeyData[1]; 170 | for i:= 1 to NUMROUNDS do 171 | begin 172 | A:= A xor B; 173 | A:= LRot32(A,B)+KeyData[2*i]; 174 | B:= B xor A; 175 | B:= LRot32(B,A)+KeyData[(2*i)+1]; 176 | end; 177 | PDword(@OutData)^:= A; 178 | PDword(longword(@OutData)+4)^:= B; 179 | end; 180 | 181 | procedure TDCP_rc5.DecryptECB(const InData; var OutData); 182 | var 183 | A, B: DWord; 184 | i: longword; 185 | begin 186 | if not fInitialized then 187 | raise EDCP_blockcipher.Create('Cipher not initialized'); 188 | A:= PDword(@InData)^; 189 | B:= PDword(longword(@InData)+4)^; 190 | for i:= NUMROUNDS downto 1 do 191 | begin 192 | B:= RRot32(B-KeyData[(2*i)+1],A); 193 | B:= B xor A; 194 | A:= RRot32(A-KeyData[2*i],B); 195 | A:= A xor B; 196 | end; 197 | PDword(@OutData)^:= A - KeyData[0]; 198 | PDword(longword(@OutData)+4)^:= B - KeyData[1]; 199 | end; 200 | 201 | end. 202 | -------------------------------------------------------------------------------- /Ciphers/DCPrc6.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of RC6 **********************************} 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 DCPrc6; 26 | 27 | interface 28 | uses 29 | Classes, Sysutils, DCPcrypt2, DCPconst, DCPblockciphers; 30 | 31 | const 32 | NUMROUNDS= 20; { number of rounds must be between 16-24 } 33 | 34 | type 35 | TDCP_rc6= class(TDCP_blockcipher128) 36 | protected 37 | KeyData: array[0..((NUMROUNDS*2)+3)] of DWord; 38 | procedure InitKey(const Key; Size: longword); override; 39 | public 40 | class function GetId: integer; override; 41 | class function GetAlgorithm: string; override; 42 | class function GetMaxKeySize: integer; override; 43 | class function SelfTest: boolean; override; 44 | procedure Burn; override; 45 | procedure EncryptECB(const InData; var OutData); override; 46 | procedure DecryptECB(const InData; var OutData); override; 47 | end; 48 | 49 | 50 | {******************************************************************************} 51 | {******************************************************************************} 52 | implementation 53 | {$R-}{$Q-} 54 | 55 | const 56 | sBox: array[0..51] of DWord= ( 57 | $B7E15163,$5618CB1C,$F45044D5,$9287BE8E,$30BF3847,$CEF6B200, 58 | $6D2E2BB9,$0B65A572,$A99D1F2B,$47D498E4,$E60C129D,$84438C56, 59 | $227B060F,$C0B27FC8,$5EE9F981,$FD21733A,$9B58ECF3,$399066AC, 60 | $D7C7E065,$75FF5A1E,$1436D3D7,$B26E4D90,$50A5C749,$EEDD4102, 61 | $8D14BABB,$2B4C3474,$C983AE2D,$67BB27E6,$05F2A19F,$A42A1B58, 62 | $42619511,$E0990ECA,$7ED08883,$1D08023C,$BB3F7BF5,$5976F5AE, 63 | $F7AE6F67,$95E5E920,$341D62D9,$D254DC92,$708C564B,$0EC3D004, 64 | $ACFB49BD,$4B32C376,$E96A3D2F,$87A1B6E8,$25D930A1,$C410AA5A, 65 | $62482413,$007F9DCC,$9EB71785,$3CEE913E); 66 | 67 | 68 | function LRot32(X: DWord; c: longword): DWord; 69 | begin 70 | LRot32:= (X shl c) or (X shr (32 - c)); 71 | end; 72 | 73 | function RRot32(X: DWord; c: longword): DWord; 74 | begin 75 | RRot32:= (X shr c) or (X shl (32 - c)); 76 | end; 77 | 78 | class function TDCP_rc6.GetID: integer; 79 | begin 80 | Result:= DCP_rc6; 81 | end; 82 | 83 | class function TDCP_rc6.GetAlgorithm: string; 84 | begin 85 | Result:= 'RC6'; 86 | end; 87 | 88 | class function TDCP_rc6.GetMaxKeySize: integer; 89 | begin 90 | Result:= 2048; 91 | end; 92 | 93 | class function TDCP_rc6.SelfTest: boolean; 94 | const 95 | Key1: array[0..15] of byte= 96 | ($01,$23,$45,$67,$89,$ab,$cd,$ef,$01,$12,$23,$34,$45,$56,$67,$78); 97 | Plain1: array[0..15] of byte= 98 | ($02,$13,$24,$35,$46,$57,$68,$79,$8a,$9b,$ac,$bd,$ce,$df,$e0,$f1); 99 | Cipher1: array[0..15] of byte= 100 | ($52,$4e,$19,$2f,$47,$15,$c6,$23,$1f,$51,$f6,$36,$7e,$a4,$3f,$18); 101 | Key2: array[0..31] of byte= 102 | ($01,$23,$45,$67,$89,$ab,$cd,$ef,$01,$12,$23,$34,$45,$56,$67,$78, 103 | $89,$9a,$ab,$bc,$cd,$de,$ef,$f0,$10,$32,$54,$76,$98,$ba,$dc,$fe); 104 | Plain2: array[0..15] of byte= 105 | ($02,$13,$24,$35,$46,$57,$68,$79,$8a,$9b,$ac,$bd,$ce,$df,$e0,$f1); 106 | Cipher2: array[0..15] of byte= 107 | ($c8,$24,$18,$16,$f0,$d7,$e4,$89,$20,$ad,$16,$a1,$67,$4e,$5d,$48); 108 | var 109 | Cipher: TDCP_rc6; 110 | Data: array[0..15] of byte; 111 | begin 112 | FillChar(Data, SizeOf(Data), 0); 113 | Cipher:= TDCP_rc6.Create(nil); 114 | Cipher.Init(Key1,Sizeof(Key1)*8,nil); 115 | Cipher.EncryptECB(Plain1,Data); 116 | Result:= boolean(CompareMem(@Data,@Cipher1,Sizeof(Data))); 117 | Cipher.DecryptECB(Data,Data); 118 | Result:= Result and boolean(CompareMem(@Data,@Plain1,Sizeof(Data))); 119 | Cipher.Burn; 120 | Cipher.Init(Key2,Sizeof(Key2)*8,nil); 121 | Cipher.EncryptECB(Plain2,Data); 122 | Result:= Result and boolean(CompareMem(@Data,@Cipher2,Sizeof(Data))); 123 | Cipher.DecryptECB(Data,Data); 124 | Result:= Result and boolean(CompareMem(@Data,@Plain2,Sizeof(Data))); 125 | Cipher.Burn; 126 | Cipher.Free; 127 | end; 128 | 129 | procedure TDCP_rc6.InitKey(const Key; Size: longword); 130 | var 131 | xKeyD: array[0..63] of DWord; 132 | i, j, k, xKeyLen: longword; 133 | A, B: DWord; 134 | begin 135 | Size:= Size div 8; 136 | FillChar(xKeyD,Sizeof(xKeyD),0); 137 | Move(Key,xKeyD,Size); 138 | xKeyLen:= Size div 4; 139 | if (Size mod 4)<> 0 then 140 | Inc(xKeyLen); 141 | Move(sBox,KeyData,((NUMROUNDS*2)+4)*4); 142 | i:= 0; j:= 0; 143 | A:= 0; B:= 0; 144 | if xKeyLen> ((NUMROUNDS*2)+4) then 145 | k:= xKeyLen*3 146 | else 147 | k:= ((NUMROUNDS*2)+4)*3; 148 | for k:= 1 to k do 149 | begin 150 | A:= LRot32(KeyData[i]+A+B,3); 151 | KeyData[i]:= A; 152 | B:= LRot32(xKeyD[j]+A+B,A+B); 153 | xKeyD[j]:= B; 154 | i:= (i+1) mod ((NUMROUNDS*2)+4); 155 | j:= (j+1) mod xKeyLen; 156 | end; 157 | FillChar(xKeyD,Sizeof(xKeyD),0); 158 | end; 159 | 160 | procedure TDCP_rc6.Burn; 161 | begin 162 | FillChar(KeyData,Sizeof(KeyData),$FF); 163 | inherited Burn; 164 | end; 165 | 166 | procedure TDCP_rc6.EncryptECB(const InData; var OutData); 167 | var 168 | x0, x1, x2, x3: DWord; 169 | u, t: DWord; 170 | i: longword; 171 | begin 172 | if not fInitialized then 173 | raise EDCP_blockcipher.Create('Cipher not initialized'); 174 | x0:= PDword(@InData)^; 175 | x1:= PDword(longword(@InData)+4)^; 176 | x2:= PDword(longword(@InData)+8)^; 177 | x3:= PDword(longword(@InData)+12)^; 178 | x1:= x1 + KeyData[0]; 179 | x3:= x3 + KeyData[1]; 180 | for i:= 1 to NUMROUNDS do 181 | begin 182 | t:= Lrot32(x1 * (2*x1 + 1),5); 183 | u:= Lrot32(x3 * (2*x3 + 1),5); 184 | x0:= Lrot32(x0 xor t,u) + KeyData[2*i]; 185 | x2:= Lrot32(x2 xor u,t) + KeyData[2*i+1]; 186 | t:= x0; x0:= x1; x1:= x2; x2:= x3; x3:= t; 187 | end; 188 | x0:= x0 + KeyData[(2*NUMROUNDS)+2]; 189 | x2:= x2 + KeyData[(2*NUMROUNDS)+3]; 190 | PDword(@OutData)^:= x0; 191 | PDword(longword(@OutData)+4)^:= x1; 192 | PDword(longword(@OutData)+8)^:= x2; 193 | PDword(longword(@OutData)+12)^:= x3; 194 | end; 195 | 196 | procedure TDCP_rc6.DecryptECB(const InData; var OutData); 197 | var 198 | x0, x1, x2, x3: DWord; 199 | u, t: DWord; 200 | i: longword; 201 | begin 202 | if not fInitialized then 203 | raise EDCP_blockcipher.Create('Cipher not initialized'); 204 | x0:= PDword(@InData)^; 205 | x1:= PDword(longword(@InData)+4)^; 206 | x2:= PDword(longword(@InData)+8)^; 207 | x3:= PDword(longword(@InData)+12)^; 208 | x2:= x2 - KeyData[(2*NUMROUNDS)+3]; 209 | x0:= x0 - KeyData[(2*NUMROUNDS)+2]; 210 | for i:= NUMROUNDS downto 1 do 211 | begin 212 | t:= x0; x0:= x3; x3:= x2; x2:= x1; x1:= t; 213 | u:= Lrot32(x3 * (2*x3 + 1),5); 214 | t:= Lrot32(x1 * (2*x1 + 1),5); 215 | x2:= Rrot32(x2 - KeyData[2*i+1],t) xor u; 216 | x0:= Rrot32(x0 - KeyData[2*i],u) xor t; 217 | end; 218 | x3:= x3 - KeyData[1]; 219 | x1:= x1 - KeyData[0]; 220 | PDword(@OutData)^:= x0; 221 | PDword(longword(@OutData)+4)^:= x1; 222 | PDword(longword(@OutData)+8)^:= x2; 223 | PDword(longword(@OutData)+12)^:= x3; 224 | end; 225 | 226 | end. 227 | -------------------------------------------------------------------------------- /Ciphers/DCPtea.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A binary compatible implementation of Tea **********************************} 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 DCPtea; 26 | 27 | interface 28 | uses 29 | Classes, Sysutils, DCPcrypt2, DCPconst, DCPblockciphers; 30 | 31 | type 32 | TDCP_tea= class(TDCP_blockcipher64) 33 | protected 34 | KeyData: array[0..3] of dword; 35 | procedure InitKey(const Key; Size: longword); override; 36 | public 37 | class function GetId: integer; override; 38 | class function GetAlgorithm: string; override; 39 | class function GetMaxKeySize: integer; override; 40 | class function SelfTest: boolean; override; 41 | procedure Burn; override; 42 | procedure EncryptECB(const InData; var OutData); override; 43 | procedure DecryptECB(const InData; var OutData); override; 44 | end; 45 | 46 | 47 | {******************************************************************************} 48 | {******************************************************************************} 49 | implementation 50 | {$R-}{$Q-} 51 | 52 | const 53 | Delta: DWord = $9e3779b9; 54 | Rounds= 32; 55 | 56 | function SwapDword(a: dword): dword; 57 | begin 58 | Result:= ((a and $FF) shl 24) or ((a and $FF00) shl 8) or ((a and $FF0000) shr 8) or ((a and $FF000000) shr 24); 59 | end; 60 | 61 | class function TDCP_tea.GetID: integer; 62 | begin 63 | Result:= DCP_tea; 64 | end; 65 | 66 | class function TDCP_tea.GetAlgorithm: string; 67 | begin 68 | Result:= 'Tea'; 69 | end; 70 | 71 | class function TDCP_tea.GetMaxKeySize: integer; 72 | begin 73 | Result:= 128; 74 | end; 75 | 76 | class function TDCP_tea.SelfTest: boolean; 77 | const 78 | Key: array[0..3] of dword= ($12345678,$9ABCDEF0,$0FEDCBA9,$87654321); 79 | PT: array[0..1] of dword= ($12345678,$9ABCDEF0); 80 | var 81 | Data: array[0..1] of dword; 82 | Cipher: TDCP_tea; 83 | begin 84 | FillChar(Data, SizeOf(Data), 0); 85 | Cipher:= TDCP_tea.Create(nil); 86 | Cipher.Init(Key,Sizeof(Key)*8,nil); 87 | Cipher.EncryptECB(PT,Data); 88 | Result:= not CompareMem(@Data,@PT,Sizeof(PT)); 89 | Cipher.DecryptECB(Data,Data); 90 | Result:= Result and CompareMem(@Data,@PT,Sizeof(PT)); 91 | Cipher.Burn; 92 | Cipher.Free; 93 | end; 94 | 95 | procedure TDCP_tea.InitKey(const Key; Size: longword); 96 | begin 97 | FillChar(KeyData,Sizeof(KeyData),0); 98 | Move(Key,KeyData,Size div 8); 99 | KeyData[0]:= SwapDWord(KeyData[0]); KeyData[1]:= SwapDWord(KeyData[1]); 100 | KeyData[2]:= SwapDWord(KeyData[2]); KeyData[3]:= SwapDWord(KeyData[3]); 101 | end; 102 | 103 | procedure TDCP_tea.Burn; 104 | begin 105 | FillChar(KeyData,Sizeof(KeyData),0); 106 | inherited Burn; 107 | end; 108 | 109 | procedure TDCP_tea.EncryptECB(const InData; var OutData); 110 | var 111 | a, b, c, d, x, y, n, sum: dword; 112 | begin 113 | if not fInitialized then 114 | raise EDCP_blockcipher.Create('Cipher not initialized'); 115 | 116 | x:= SwapDWord(pdword(@InData)^); 117 | y:= SwapDWord(pdword(longword(@InData)+4)^); 118 | sum:= 0; a:= KeyData[0]; b:= KeyData[1]; c:= KeyData[2]; d:= KeyData[3]; 119 | for n:= 1 to Rounds do 120 | begin 121 | Inc(sum,Delta); 122 | Inc(x,(y shl 4) + (a xor y) + (sum xor (y shr 5)) + b); 123 | Inc(y,(x shl 4) + (c xor x) + (sum xor (x shr 5)) + d); 124 | end; 125 | pdword(@OutData)^:= SwapDWord(x); 126 | pdword(longword(@OutData)+4)^:= SwapDWord(y); 127 | end; 128 | 129 | procedure TDCP_tea.DecryptECB(const InData; var OutData); 130 | var 131 | a, b, c, d, x, y, n, sum: dword; 132 | begin 133 | if not fInitialized then 134 | raise EDCP_blockcipher.Create('Cipher not initialized'); 135 | 136 | x:= SwapDWord(pdword(@InData)^); 137 | y:= SwapDWord(pdword(longword(@InData)+4)^); 138 | sum:= Delta shl 5; 139 | a:= KeyData[0]; 140 | b:= KeyData[1]; 141 | c:= KeyData[2]; 142 | d:= KeyData[3]; 143 | for n:= 1 to Rounds do 144 | begin 145 | Dec(y,(x shl 4) + (c xor x) + (sum xor (x shr 5)) + d); 146 | Dec(x,(y shl 4) + (a xor y) + (sum xor (y shr 5)) + b); 147 | Dec(sum,Delta); 148 | end; 149 | pdword(@OutData)^:= SwapDWord(x); 150 | pdword(longword(@OutData)+4)^:= SwapDWord(y); 151 | end; 152 | 153 | end. 154 | -------------------------------------------------------------------------------- /Ciphers/DCPtwofish.inc: -------------------------------------------------------------------------------- 1 | const 2 | p8x8: array[0..1,0..255] of byte= (( 3 | $a9, $67, $b3, $e8, $04, $fd, $a3, $76, 4 | $9a, $92, $80, $78, $e4, $dd, $d1, $38, 5 | $0d, $c6, $35, $98, $18, $f7, $ec, $6c, 6 | $43, $75, $37, $26, $fa, $13, $94, $48, 7 | $f2, $d0, $8b, $30, $84, $54, $df, $23, 8 | $19, $5b, $3d, $59, $f3, $ae, $a2, $82, 9 | $63, $01, $83, $2e, $d9, $51, $9b, $7c, 10 | $a6, $eb, $a5, $be, $16, $0c, $e3, $61, 11 | $c0, $8c, $3a, $f5, $73, $2c, $25, $0b, 12 | $bb, $4e, $89, $6b, $53, $6a, $b4, $f1, 13 | $e1, $e6, $bd, $45, $e2, $f4, $b6, $66, 14 | $cc, $95, $03, $56, $d4, $1c, $1e, $d7, 15 | $fb, $c3, $8e, $b5, $e9, $cf, $bf, $ba, 16 | $ea, $77, $39, $af, $33, $c9, $62, $71, 17 | $81, $79, $09, $ad, $24, $cd, $f9, $d8, 18 | $e5, $c5, $b9, $4d, $44, $08, $86, $e7, 19 | $a1, $1d, $aa, $ed, $06, $70, $b2, $d2, 20 | $41, $7b, $a0, $11, $31, $c2, $27, $90, 21 | $20, $f6, $60, $ff, $96, $5c, $b1, $ab, 22 | $9e, $9c, $52, $1b, $5f, $93, $0a, $ef, 23 | $91, $85, $49, $ee, $2d, $4f, $8f, $3b, 24 | $47, $87, $6d, $46, $d6, $3e, $69, $64, 25 | $2a, $ce, $cb, $2f, $fc, $97, $05, $7a, 26 | $ac, $7f, $d5, $1a, $4b, $0e, $a7, $5a, 27 | $28, $14, $3f, $29, $88, $3c, $4c, $02, 28 | $b8, $da, $b0, $17, $55, $1f, $8a, $7d, 29 | $57, $c7, $8d, $74, $b7, $c4, $9f, $72, 30 | $7e, $15, $22, $12, $58, $07, $99, $34, 31 | $6e, $50, $de, $68, $65, $bc, $db, $f8, 32 | $c8, $a8, $2b, $40, $dc, $fe, $32, $a4, 33 | $ca, $10, $21, $f0, $d3, $5d, $0f, $00, 34 | $6f, $9d, $36, $42, $4a, $5e, $c1, $e0),( 35 | $75, $f3, $c6, $f4, $db, $7b, $fb, $c8, 36 | $4a, $d3, $e6, $6b, $45, $7d, $e8, $4b, 37 | $d6, $32, $d8, $fd, $37, $71, $f1, $e1, 38 | $30, $0f, $f8, $1b, $87, $fa, $06, $3f, 39 | $5e, $ba, $ae, $5b, $8a, $00, $bc, $9d, 40 | $6d, $c1, $b1, $0e, $80, $5d, $d2, $d5, 41 | $a0, $84, $07, $14, $b5, $90, $2c, $a3, 42 | $b2, $73, $4c, $54, $92, $74, $36, $51, 43 | $38, $b0, $bd, $5a, $fc, $60, $62, $96, 44 | $6c, $42, $f7, $10, $7c, $28, $27, $8c, 45 | $13, $95, $9c, $c7, $24, $46, $3b, $70, 46 | $ca, $e3, $85, $cb, $11, $d0, $93, $b8, 47 | $a6, $83, $20, $ff, $9f, $77, $c3, $cc, 48 | $03, $6f, $08, $bf, $40, $e7, $2b, $e2, 49 | $79, $0c, $aa, $82, $41, $3a, $ea, $b9, 50 | $e4, $9a, $a4, $97, $7e, $da, $7a, $17, 51 | $66, $94, $a1, $1d, $3d, $f0, $de, $b3, 52 | $0b, $72, $a7, $1c, $ef, $d1, $53, $3e, 53 | $8f, $33, $26, $5f, $ec, $76, $2a, $49, 54 | $81, $88, $ee, $21, $c4, $1a, $eb, $d9, 55 | $c5, $39, $99, $cd, $ad, $31, $8b, $01, 56 | $18, $23, $dd, $1f, $4e, $2d, $f9, $48, 57 | $4f, $f2, $65, $8e, $78, $5c, $58, $19, 58 | $8d, $e5, $98, $57, $67, $7f, $05, $64, 59 | $af, $63, $b6, $fe, $f5, $b7, $3c, $a5, 60 | $ce, $e9, $68, $44, $e0, $4d, $43, $69, 61 | $29, $2e, $ac, $15, $59, $a8, $0a, $9e, 62 | $6e, $47, $df, $34, $35, $6a, $cf, $dc, 63 | $22, $c9, $c0, $9b, $89, $d4, $ed, $ab, 64 | $12, $a2, $0d, $52, $bb, $02, $2f, $a9, 65 | $d7, $61, $1e, $b4, $50, $04, $f6, $c2, 66 | $16, $25, $86, $56, $55, $09, $be, $91)); 67 | -------------------------------------------------------------------------------- /DCP_XE.dpk: -------------------------------------------------------------------------------- 1 | package DCP_XE; 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 | -------------------------------------------------------------------------------- /DCP_XE.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {ae9b70a6-b2c2-45a0-ba7b-2448a376d73f} 4 | DCP_XE.dpk 5 | Debug 6 | DCC32 7 | C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\Bpl\DCPdelphi2007.bpl 8 | 12.3 9 | True 10 | Debug 11 | Win32 12 | Package 13 | None 14 | 15 | 16 | true 17 | 18 | 19 | true 20 | Base 21 | true 22 | 23 | 24 | true 25 | Base 26 | true 27 | 28 | 29 | DCPcrypt cryptographic component library v2 BETA 3 30 | WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;$(DCC_UnitAlias) 31 | 00400000 32 | true 33 | true 34 | 35 | 36 | 7.0 37 | False 38 | False 39 | 0 40 | RELEASE;$(DCC_Define) 41 | 42 | 43 | 7.0 44 | 45 | 46 | Delphi.Personality.12 47 | Package 48 | 49 | 50 | 51 | 52 | True 53 | False 54 | 1 55 | 0 56 | 0 57 | 0 58 | False 59 | False 60 | False 61 | False 62 | False 63 | 1036 64 | 1252 65 | 66 | 67 | 68 | 69 | 1.0.0.0 70 | 71 | 72 | 73 | 74 | 75 | 1.0.0.0 76 | 77 | 78 | 79 | DCP_XE.dpk 80 | 81 | 82 | 83 | True 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 | Cfg_2 126 | Base 127 | 128 | 129 | Base 130 | 131 | 132 | Cfg_1 133 | Base 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /DCP_XE.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCP_XE.res -------------------------------------------------------------------------------- /DCP_XE2.dpk: -------------------------------------------------------------------------------- 1 | package DCP_XE2; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO ON} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$ENDIF IMPLICITBUILDING} 27 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'} 28 | {$IMPLICITBUILD ON} 29 | 30 | requires 31 | rtl; 32 | 33 | contains 34 | DCPbase64 in 'DCPbase64.pas', 35 | DCPblockciphers in 'DCPblockciphers.pas', 36 | DCPconst in 'DCPconst.pas', 37 | DCPcrypt2 in 'DCPcrypt2.pas', 38 | DCPblowfish in 'Ciphers\DCPblowfish.pas', 39 | DCPcast128 in 'Ciphers\DCPcast128.pas', 40 | DCPcast256 in 'Ciphers\DCPcast256.pas', 41 | DCPdes in 'Ciphers\DCPdes.pas', 42 | DCPgost in 'Ciphers\DCPgost.pas', 43 | DCPice in 'Ciphers\DCPice.pas', 44 | DCPidea in 'Ciphers\DCPidea.pas', 45 | DCPmars in 'Ciphers\DCPmars.pas', 46 | DCPmisty1 in 'Ciphers\DCPmisty1.pas', 47 | DCPrc2 in 'Ciphers\DCPrc2.pas', 48 | DCPrc4 in 'Ciphers\DCPrc4.pas', 49 | DCPrc5 in 'Ciphers\DCPrc5.pas', 50 | DCPrc6 in 'Ciphers\DCPrc6.pas', 51 | DCPrijndael in 'Ciphers\DCPrijndael.pas', 52 | DCPtea in 'Ciphers\DCPtea.pas', 53 | DCPtwofish in 'Ciphers\DCPtwofish.pas', 54 | DCPhaval in 'Hashes\DCPhaval.pas', 55 | DCPmd4 in 'Hashes\DCPmd4.pas', 56 | DCPmd5 in 'Hashes\DCPmd5.pas', 57 | DCPripemd128 in 'Hashes\DCPripemd128.pas', 58 | DCPripemd160 in 'Hashes\DCPripemd160.pas', 59 | DCPsha1 in 'Hashes\DCPsha1.pas', 60 | DCPtiger in 'Hashes\DCPtiger.pas', 61 | DCPreg in 'DCPreg.pas', 62 | DCPserpent in 'Ciphers\DCPserpent.pas', 63 | DCPsha256 in 'Hashes\DCPsha256.pas', 64 | DCPsha512 in 'Hashes\DCPsha512.pas'; 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /DCP_XE2.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {ae9b70a6-b2c2-45a0-ba7b-2448a376d73f} 4 | DCP_XE2.dpk 5 | Debug 6 | DCC32 7 | C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\Bpl\DCPdelphi2007.bpl 8 | 13.4 9 | True 10 | Debug 11 | Package 12 | None 13 | Win32 14 | 1 15 | 16 | 17 | true 18 | 19 | 20 | true 21 | Base 22 | true 23 | 24 | 25 | true 26 | Base 27 | true 28 | 29 | 30 | true 31 | Base 32 | true 33 | 34 | 35 | true 36 | Cfg_2 37 | true 38 | true 39 | 40 | 41 | .\$(Platform)\$(Config) 42 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 43 | 1036 44 | true 45 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 46 | DCPcrypt cryptographic component library v2 BETA 3 47 | 00400000 48 | true 49 | true 50 | 51 | 52 | 1033 53 | true 54 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 55 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 56 | 57 | 58 | 7.0 59 | False 60 | False 61 | 0 62 | RELEASE;$(DCC_Define) 63 | 64 | 65 | 7.0 66 | 67 | 68 | 1033 69 | 70 | 71 | Delphi.Personality.12 72 | Package 73 | 74 | 75 | 76 | 77 | True 78 | False 79 | 1 80 | 0 81 | 0 82 | 0 83 | False 84 | False 85 | False 86 | False 87 | False 88 | 1036 89 | 1252 90 | 91 | 92 | 93 | 94 | 1.0.0.0 95 | 96 | 97 | 98 | 99 | 100 | 1.0.0.0 101 | 102 | 103 | 104 | DCP_XE2.dpk 105 | 106 | 107 | Microsoft Office 2000 Sample Automation Server Wrapper Components 108 | Microsoft Office XP Sample Automation Server Wrapper Components 109 | 110 | 111 | 112 | False 113 | False 114 | True 115 | 116 | 117 | 12 118 | 119 | 120 | 121 | MainSource 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | Cfg_2 157 | Base 158 | 159 | 160 | Base 161 | 162 | 163 | Cfg_1 164 | Base 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /DCP_XE2.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCP_XE2.res -------------------------------------------------------------------------------- /DCP_XE2.skincfg: -------------------------------------------------------------------------------- 1 | [ExpressSkins] 2 | Default=0 3 | ShowNotifications=1 4 | Enabled=0 5 | dxSkinBlack=1 6 | dxSkinBlue=1 7 | dxSkinBlueprint=1 8 | dxSkinCaramel=1 9 | dxSkinCoffee=1 10 | dxSkinDarkRoom=1 11 | dxSkinDarkSide=1 12 | dxSkinDevExpressDarkStyle=1 13 | dxSkinDevExpressStyle=1 14 | dxSkinFoggy=1 15 | dxSkinGlassOceans=1 16 | dxSkinHighContrast=1 17 | dxSkiniMaginary=1 18 | dxSkinLilian=1 19 | dxSkinLiquidSky=1 20 | dxSkinLondonLiquidSky=1 21 | dxSkinMcSkin=1 22 | dxSkinMetropolis=1 23 | dxSkinMetropolisDark=1 24 | dxSkinMoneyTwins=1 25 | dxSkinOffice2007Black=1 26 | dxSkinOffice2007Blue=1 27 | dxSkinOffice2007Green=1 28 | dxSkinOffice2007Pink=1 29 | dxSkinOffice2007Silver=1 30 | dxSkinOffice2010Black=1 31 | dxSkinOffice2010Blue=1 32 | dxSkinOffice2010Silver=1 33 | dxSkinOffice2013DarkGray=1 34 | dxSkinOffice2013LightGray=1 35 | dxSkinOffice2013White=1 36 | dxSkinPumpkin=1 37 | RamsoftMetropolisDark=1 38 | dxSkinSeven=1 39 | dxSkinSevenClassic=1 40 | dxSkinSharp=1 41 | dxSkinSharpPlus=1 42 | dxSkinSilver=1 43 | dxSkinSpringTime=1 44 | dxSkinStardust=1 45 | dxSkinSummer2008=1 46 | dxSkinTheAsphaltWorld=1 47 | dxSkinsDefaultPainters=1 48 | dxSkinValentine=1 49 | dxSkinVS2010=1 50 | dxSkinWhiteprint=1 51 | dxSkinXmas2008Blue=1 52 | -------------------------------------------------------------------------------- /DCP_XE5.dpk: -------------------------------------------------------------------------------- 1 | package DCP_XE5; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO ON} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$ENDIF IMPLICITBUILDING} 27 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'} 28 | {$IMPLICITBUILD ON} 29 | 30 | requires 31 | rtl; 32 | 33 | contains 34 | DCPbase64 in 'DCPbase64.pas', 35 | DCPblockciphers in 'DCPblockciphers.pas', 36 | DCPconst in 'DCPconst.pas', 37 | DCPcrypt2 in 'DCPcrypt2.pas', 38 | DCPblowfish in 'Ciphers\DCPblowfish.pas', 39 | DCPcast128 in 'Ciphers\DCPcast128.pas', 40 | DCPcast256 in 'Ciphers\DCPcast256.pas', 41 | DCPdes in 'Ciphers\DCPdes.pas', 42 | DCPgost in 'Ciphers\DCPgost.pas', 43 | DCPice in 'Ciphers\DCPice.pas', 44 | DCPidea in 'Ciphers\DCPidea.pas', 45 | DCPmars in 'Ciphers\DCPmars.pas', 46 | DCPmisty1 in 'Ciphers\DCPmisty1.pas', 47 | DCPrc2 in 'Ciphers\DCPrc2.pas', 48 | DCPrc4 in 'Ciphers\DCPrc4.pas', 49 | DCPrc5 in 'Ciphers\DCPrc5.pas', 50 | DCPrc6 in 'Ciphers\DCPrc6.pas', 51 | DCPrijndael in 'Ciphers\DCPrijndael.pas', 52 | DCPtea in 'Ciphers\DCPtea.pas', 53 | DCPtwofish in 'Ciphers\DCPtwofish.pas', 54 | DCPhaval in 'Hashes\DCPhaval.pas', 55 | DCPmd4 in 'Hashes\DCPmd4.pas', 56 | DCPmd5 in 'Hashes\DCPmd5.pas', 57 | DCPripemd128 in 'Hashes\DCPripemd128.pas', 58 | DCPripemd160 in 'Hashes\DCPripemd160.pas', 59 | DCPsha1 in 'Hashes\DCPsha1.pas', 60 | DCPtiger in 'Hashes\DCPtiger.pas', 61 | DCPreg in 'DCPreg.pas', 62 | DCPserpent in 'Ciphers\DCPserpent.pas', 63 | DCPsha256 in 'Hashes\DCPsha256.pas', 64 | DCPsha512 in 'Hashes\DCPsha512.pas'; 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /DCP_XE5.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCP_XE5.res -------------------------------------------------------------------------------- /DCP_XE6.dpk: -------------------------------------------------------------------------------- 1 | package DCP_XE6; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$ENDIF IMPLICITBUILDING} 27 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'} 28 | {$IMPLICITBUILD ON} 29 | 30 | requires 31 | rtl; 32 | 33 | contains 34 | DCPbase64 in 'DCPbase64.pas', 35 | DCPblockciphers in 'DCPblockciphers.pas', 36 | DCPconst in 'DCPconst.pas', 37 | DCPcrypt2 in 'DCPcrypt2.pas', 38 | DCPblowfish in 'Ciphers\DCPblowfish.pas', 39 | DCPcast128 in 'Ciphers\DCPcast128.pas', 40 | DCPcast256 in 'Ciphers\DCPcast256.pas', 41 | DCPdes in 'Ciphers\DCPdes.pas', 42 | DCPgost in 'Ciphers\DCPgost.pas', 43 | DCPice in 'Ciphers\DCPice.pas', 44 | DCPidea in 'Ciphers\DCPidea.pas', 45 | DCPmars in 'Ciphers\DCPmars.pas', 46 | DCPmisty1 in 'Ciphers\DCPmisty1.pas', 47 | DCPrc2 in 'Ciphers\DCPrc2.pas', 48 | DCPrc4 in 'Ciphers\DCPrc4.pas', 49 | DCPrc5 in 'Ciphers\DCPrc5.pas', 50 | DCPrc6 in 'Ciphers\DCPrc6.pas', 51 | DCPrijndael in 'Ciphers\DCPrijndael.pas', 52 | DCPtea in 'Ciphers\DCPtea.pas', 53 | DCPtwofish in 'Ciphers\DCPtwofish.pas', 54 | DCPhaval in 'Hashes\DCPhaval.pas', 55 | DCPmd4 in 'Hashes\DCPmd4.pas', 56 | DCPmd5 in 'Hashes\DCPmd5.pas', 57 | DCPripemd128 in 'Hashes\DCPripemd128.pas', 58 | DCPripemd160 in 'Hashes\DCPripemd160.pas', 59 | DCPsha1 in 'Hashes\DCPsha1.pas', 60 | DCPtiger in 'Hashes\DCPtiger.pas', 61 | DCPreg in 'DCPreg.pas', 62 | DCPserpent in 'Ciphers\DCPserpent.pas', 63 | DCPsha256 in 'Hashes\DCPsha256.pas', 64 | DCPsha512 in 'Hashes\DCPsha512.pas'; 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /DCP_XE6.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCP_XE6.res -------------------------------------------------------------------------------- /DCP_XE7.deployproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 12 5 | 6 | 7 | 8 | 9 | 10 | 11 | DCP_XE7\ 12 | bplDCP_XE7.dylib 13 | 1 14 | 15 | 16 | True 17 | True 18 | 19 | 20 | DCP_XE7\ 21 | bplrtl210.dylib 22 | 1 23 | 24 | 25 | True 26 | True 27 | 28 | 29 | DCP_XE7\ 30 | libcgunwind.1.0.dylib 31 | 1 32 | 33 | 34 | True 35 | 36 | 37 | DCP_XE7\ 38 | bplrtl210.de 39 | 0 40 | 41 | 42 | True 43 | 44 | 45 | DCP_XE7\ 46 | bplrtl210.ja 47 | 0 48 | 49 | 50 | True 51 | 52 | 53 | DCP_XE7\ 54 | bplrtl210.fr 55 | 0 56 | 57 | 58 | True 59 | 60 | 61 | 62 | 63 | DCP_XE7.app\ 64 | libcgunwind.1.0.dylib 65 | 0 66 | 67 | 68 | True 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /DCP_XE7.dpk: -------------------------------------------------------------------------------- 1 | package DCP_XE7; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$ENDIF IMPLICITBUILDING} 27 | {$DESCRIPTION 'DCPcrypt cryptographic component library v2 BETA 3'} 28 | {$IMPLICITBUILD ON} 29 | 30 | requires 31 | rtl; 32 | 33 | contains 34 | DCPbase64 in 'DCPbase64.pas', 35 | DCPblockciphers in 'DCPblockciphers.pas', 36 | DCPconst in 'DCPconst.pas', 37 | DCPcrypt2 in 'DCPcrypt2.pas', 38 | DCPblowfish in 'Ciphers\DCPblowfish.pas', 39 | DCPcast128 in 'Ciphers\DCPcast128.pas', 40 | DCPcast256 in 'Ciphers\DCPcast256.pas', 41 | DCPdes in 'Ciphers\DCPdes.pas', 42 | DCPgost in 'Ciphers\DCPgost.pas', 43 | DCPice in 'Ciphers\DCPice.pas', 44 | DCPidea in 'Ciphers\DCPidea.pas', 45 | DCPmars in 'Ciphers\DCPmars.pas', 46 | DCPmisty1 in 'Ciphers\DCPmisty1.pas', 47 | DCPrc2 in 'Ciphers\DCPrc2.pas', 48 | DCPrc4 in 'Ciphers\DCPrc4.pas', 49 | DCPrc5 in 'Ciphers\DCPrc5.pas', 50 | DCPrc6 in 'Ciphers\DCPrc6.pas', 51 | DCPrijndael in 'Ciphers\DCPrijndael.pas', 52 | DCPtea in 'Ciphers\DCPtea.pas', 53 | DCPtwofish in 'Ciphers\DCPtwofish.pas', 54 | DCPhaval in 'Hashes\DCPhaval.pas', 55 | DCPmd4 in 'Hashes\DCPmd4.pas', 56 | DCPmd5 in 'Hashes\DCPmd5.pas', 57 | DCPripemd128 in 'Hashes\DCPripemd128.pas', 58 | DCPripemd160 in 'Hashes\DCPripemd160.pas', 59 | DCPsha1 in 'Hashes\DCPsha1.pas', 60 | DCPtiger in 'Hashes\DCPtiger.pas', 61 | DCPreg in 'DCPreg.pas', 62 | DCPserpent in 'Ciphers\DCPserpent.pas', 63 | DCPsha256 in 'Hashes\DCPsha256.pas', 64 | DCPsha512 in 'Hashes\DCPsha512.pas'; 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /DCP_XE7.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCP_XE7.res -------------------------------------------------------------------------------- /DCPbase64.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* A Base64 encoding/decoding unit ********************************************} 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 DCPbase64; 26 | 27 | interface 28 | 29 | 30 | uses 31 | {$ifdef NEXTGEN_FIXES} 32 | ORawByteString, 33 | {$endif} 34 | Sysutils; 35 | 36 | function Base64EncodeStr(const Value: AnsiString): AnsiString; overload; 37 | { Encode a string into Base64 format } 38 | function Base64DecodeStr(const Value: AnsiString): AnsiString; overload; 39 | { Decode a Base64 format string } 40 | {$IFDEF UNICODE} 41 | function Base64EncodeStr(const Value: UnicodeString): UnicodeString; overload; 42 | { Encode a Unicode string into Base64 format } 43 | function Base64DecodeStr(const Value: UnicodeString): UnicodeString; overload; 44 | { Decode a Base64 format Unicode string } 45 | {$ENDIF} 46 | function Base64Encode(pInput: pointer; pOutput: pointer; Size: longint): longint; 47 | { Encode a lump of raw data (output is (4/3) times bigger than input) } 48 | function Base64Decode(pInput: pointer; pOutput: pointer; Size: longint): longint; 49 | { Decode a lump of raw data } 50 | 51 | 52 | {******************************************************************************} 53 | {******************************************************************************} 54 | implementation 55 | {$Q-}{$R-} 56 | 57 | const 58 | B64: array[0..63] of byte= (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80, 59 | 81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108, 60 | 109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53, 61 | 54,55,56,57,43,47); 62 | 63 | function Base64Encode(pInput: pointer; pOutput: pointer; Size: longint): longint; 64 | var 65 | i, iptr, optr: integer; 66 | Input, Output: PByteArray; 67 | begin 68 | Input:= PByteArray(pInput); Output:= PByteArray(pOutput); 69 | iptr:= 0; optr:= 0; 70 | for i:= 1 to (Size div 3) do 71 | begin 72 | Output^[optr+0]:= B64[Input^[iptr] shr 2]; 73 | Output^[optr+1]:= B64[((Input^[iptr] and 3) shl 4) + (Input^[iptr+1] shr 4)]; 74 | Output^[optr+2]:= B64[((Input^[iptr+1] and 15) shl 2) + (Input^[iptr+2] shr 6)]; 75 | Output^[optr+3]:= B64[Input^[iptr+2] and 63]; 76 | Inc(optr,4); Inc(iptr,3); 77 | end; 78 | case (Size mod 3) of 79 | 1: begin 80 | Output^[optr+0]:= B64[Input^[iptr] shr 2]; 81 | Output^[optr+1]:= B64[(Input^[iptr] and 3) shl 4]; 82 | Output^[optr+2]:= byte('='); 83 | Output^[optr+3]:= byte('='); 84 | end; 85 | 2: begin 86 | Output^[optr+0]:= B64[Input^[iptr] shr 2]; 87 | Output^[optr+1]:= B64[((Input^[iptr] and 3) shl 4) + (Input^[iptr+1] shr 4)]; 88 | Output^[optr+2]:= B64[(Input^[iptr+1] and 15) shl 2]; 89 | Output^[optr+3]:= byte('='); 90 | end; 91 | end; 92 | Result:= ((Size+2) div 3) * 4; 93 | end; 94 | 95 | function Base64EncodeStr(const Value: AnsiString): AnsiString; 96 | begin 97 | {$IFDEF NEXTGEN} 98 | Result.SetLength( ((AnsiLength(Value)+2) div 3) * 4); 99 | Base64Encode(@Value.GetBuffer[0],@Result.GetBuffer[0],AnsiLength(Value)); 100 | {$ELSE} 101 | SetLength(Result,((Length(Value)+2) div 3) * 4); 102 | Base64Encode(@Value[1],@Result[1],Length(Value)); 103 | {$ENDIF} 104 | end; 105 | 106 | {$IFDEF UNICODE} 107 | function Base64EncodeStr(const Value: UnicodeString): UnicodeString; 108 | var 109 | temp: AnsiString; 110 | begin 111 | {$IFDEF NEXTGEN} 112 | temp.SetLength(((Length(Value)*SizeOf(Value[1])+2) div 3) * 4); 113 | Base64Encode(@Value[1],@temp.GetBuffer[0],Length(Value)*SizeOf(Value[1])); 114 | {$ELSE} 115 | SetLength(temp,(((Length(Value)*SizeOf(Value[1])+2) div 3) * 4)); 116 | Base64Encode(@Value[1],@temp[1],Length(Value)*SizeOf(Value[1])); 117 | {$ENDIF} 118 | Result:= UnicodeString(temp); 119 | end; 120 | {$ENDIF} 121 | 122 | function Base64Decode(pInput: pointer; pOutput: pointer; Size: longint): longint; 123 | var 124 | i, j, iptr, optr: integer; 125 | Temp: array[0..3] of byte; 126 | Input, Output: PByteArray; 127 | begin 128 | Input:= PByteArray(pInput); Output:= PByteArray(pOutput); 129 | iptr:= 0; optr:= 0; 130 | Result:= 0; 131 | for i:= 1 to (Size div 4) do 132 | begin 133 | for j:= 0 to 3 do 134 | begin 135 | case Input^[iptr] of 136 | 65..90 : Temp[j]:= Input^[iptr] - Ord('A'); 137 | 97..122: Temp[j]:= Input^[iptr] - Ord('a') + 26; 138 | 48..57 : Temp[j]:= Input^[iptr] - Ord('0') + 52; 139 | 43 : Temp[j]:= 62; 140 | 47 : Temp[j]:= 63; 141 | 61 : Temp[j]:= $FF; 142 | end; 143 | Inc(iptr); 144 | end; 145 | Output^[optr]:= (Temp[0] shl 2) or (Temp[1] shr 4); 146 | Result:= optr+1; 147 | if (Temp[2]<> $FF) and (Temp[3]= $FF) then 148 | begin 149 | Output^[optr+1]:= (Temp[1] shl 4) or (Temp[2] shr 2); 150 | Result:= optr+2; 151 | Inc(optr) 152 | end 153 | else if (Temp[2]<> $FF) then 154 | begin 155 | Output^[optr+1]:= (Temp[1] shl 4) or (Temp[2] shr 2); 156 | Output^[optr+2]:= (Temp[2] shl 6) or Temp[3]; 157 | Result:= optr+3; 158 | Inc(optr,2); 159 | end; 160 | Inc(optr); 161 | end; 162 | end; 163 | 164 | function Base64DecodeStr(const Value: AnsiString): AnsiString; 165 | begin 166 | {$IFDEF NEXTGEN} 167 | Result.SetLength((AnsiLength(Value) div 4) * 3); 168 | Result.SetLength(Base64Decode(@Value.GetBuffer[0],@Result.GetBuffer[0],AnsiLength(Value))); 169 | {$ELSE} 170 | SetLength(Result,(Length(Value) div 4) * 3); 171 | SetLength(Result,Base64Decode(@Value[1],@Result[1],Length(Value))); 172 | {$ENDIF} 173 | end; 174 | 175 | {$IFDEF UNICODE} 176 | function Base64DecodeStr(const Value: UnicodeString): UnicodeString; 177 | var 178 | temp: AnsiString; 179 | begin 180 | temp:= AnsiString(Value); 181 | {$IFDEF NEXTGEN} 182 | SetLength(Result,(AnsiLength(temp) div 4) * 3); 183 | SetLength(Result,Base64Decode(@temp.GetBuffer[0],@Result[1],AnsiLength(temp)) div SizeOf(Result[1])); 184 | {$ELSE} 185 | SetLength(Result,(Length(temp) div 4) * 3); 186 | SetLength(Result,Base64Decode(@temp[1],@Result[1],Length(temp)) div SizeOf(Result[1])); 187 | {$ENDIF} 188 | end; 189 | {$ENDIF} 190 | 191 | end. 192 | -------------------------------------------------------------------------------- /DCPciphers.dcr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGenusa/DCPCrypt/7e33ec7a32a748df05822ac54fc631945854ddd9/DCPciphers.dcr -------------------------------------------------------------------------------- /DCPconst.pas: -------------------------------------------------------------------------------- 1 | {******************************************************************************} 2 | {* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} 3 | {******************************************************************************} 4 | {* Constants for use with 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 DCPconst; 26 | 27 | interface 28 | 29 | {******************************************************************************} 30 | const 31 | { Component registration } 32 | DCPcipherpage = 'DCPciphers'; 33 | DCPhashpage = 'DCPhashes'; 34 | 35 | { ID values } 36 | DCP_rc2 = 1; 37 | DCP_sha1 = 2; 38 | DCP_rc5 = 3; 39 | DCP_rc6 = 4; 40 | DCP_blowfish = 5; 41 | DCP_twofish = 6; 42 | DCP_cast128 = 7; 43 | DCP_gost = 8; 44 | DCP_rijndael = 9; 45 | DCP_ripemd160 = 10; 46 | DCP_misty1 = 11; 47 | DCP_idea = 12; 48 | DCP_mars = 13; 49 | DCP_haval = 14; 50 | DCP_cast256 = 15; 51 | DCP_md5 = 16; 52 | DCP_md4 = 17; 53 | DCP_tiger = 18; 54 | DCP_rc4 = 19; 55 | DCP_ice = 20; 56 | DCP_thinice = 21; 57 | DCP_ice2 = 22; 58 | DCP_des = 23; 59 | DCP_3des = 24; 60 | DCP_tea = 25; 61 | DCP_serpent = 26; 62 | DCP_ripemd128 = 27; 63 | DCP_sha256 = 28; 64 | DCP_sha384 = 29; 65 | DCP_sha512 = 30; 66 | 67 | 68 | {******************************************************************************} 69 | {******************************************************************************} 70 | implementation 71 | 72 | end. 73 | -------------------------------------------------------------------------------- /DCPcppbuilder5.bpk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | [Version Info] 54 | IncludeVerInfo=1 55 | AutoIncBuild=0 56 | MajorVer=1 57 | MinorVer=0 58 | Release=0 59 | Build=0 60 | Debug=0 61 | PreRelease=0 62 | Special=0 63 | Private=0 64 | DLL=0 65 | Locale=2057 66 | CodePage=1252 67 | 68 | [Version Info Keys] 69 | CompanyName= 70 | FileDescription=DCPcrypt cryptographic component library v2 BETA 3 71 | FileVersion=2.0.0.0 72 | InternalName=DCPcrypt 73 | LegalCopyright=Copyright © 1999-2002 David Barton 74 | LegalTrademarks= 75 | OriginalFilename= 76 | ProductName=DCPcrypt 77 | ProductVersion=2.0.0.0 78 | Comments=Web: http://www.cityinthesky.co.uk/ Email:crypto@cityinthesky.co.uk 79 | 80 | [Debugging] 81 | DebugSourceDirs=$(BCB)\source\vcl 82 | 83 | [Parameters] 84 | RunParams= 85 | HostApplication= 86 | RemoteHost= 87 | RemotePath= 88 | RemoteDebug=0 89 | 90 | [Compiler] 91 | ShowInfoMsgs=0 92 | LinkDebugVcl=0 93 | LinkCGLIB=0 94 | 95 | [Language] 96 | ActiveLang= 97 | ProjectLang= 98 | RootDir= 99 | 100 | -------------------------------------------------------------------------------- /DCPcppbuilder5.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 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 |

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 | --------------------------------------------------------------------------------