├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Demos ├── Cipher_Console │ ├── Cipher_Console.deployproj │ ├── Cipher_Console.dpr │ ├── Cipher_Console.dproj │ ├── Cipher_Console.res │ └── Cipher_Console_project.tvsconfig ├── Cipher_Console_KDF │ ├── Cipher_Console_KDF.dpr │ ├── Cipher_Console_KDF.dproj │ └── Cipher_Console_KDF.res ├── Cipher_FMX │ ├── AndroidManifest.template.xml │ ├── Cipher_FMX.deployproj │ ├── Cipher_FMX.dpr │ ├── Cipher_FMX.dproj │ ├── Cipher_FMX.res │ ├── CryptoIcon_144.png │ ├── CryptoIcon_192.png │ ├── CryptoIcon_36.png │ ├── CryptoIcon_48.png │ ├── CryptoIcon_72.png │ ├── CryptoIcon_96.png │ ├── Crypto_426_320.png │ ├── Crypto_470_320.png │ ├── Crypto_640_480.png │ ├── Crypto_960_720.png │ ├── MainFormCipherFMX.fmx │ └── MainFormCipherFMX.pas ├── Format_Console │ ├── Format_Console.dpr │ ├── Format_Console.dproj │ └── Format_Console.res ├── HashBenchmark_FMX │ ├── AndroidManifest.template.xml │ ├── Crypto_426_320.png │ ├── Crypto_470_320.png │ ├── Crypto_640_480.png │ ├── Crypto_960_720.png │ ├── Hash.ico │ ├── Hash144.png │ ├── Hash192.png │ ├── Hash256.png │ ├── Hash36.png │ ├── Hash48.png │ ├── Hash72.png │ ├── Hash96.png │ ├── HashBenchmark.deployproj │ ├── HashBenchmark.dpr │ ├── HashBenchmark.dproj │ ├── HashBenchmark.res │ ├── MainFormHashBenchmark.fmx │ └── MainFormHashBenchmark.pas ├── Hash_Console │ ├── Hash_Console.dpr │ ├── Hash_Console.dproj │ └── Hash_Console.res ├── Hash_FMX │ ├── AndroidManifest.template.xml │ ├── Crypto_426_320.png │ ├── Crypto_470_320.png │ ├── Crypto_640_480.png │ ├── Crypto_960_720.png │ ├── Hash.ico │ ├── Hash144.png │ ├── Hash192.png │ ├── Hash256.png │ ├── Hash36.png │ ├── Hash48.png │ ├── Hash72.png │ ├── Hash96.png │ ├── Hash_FMX.deployproj │ ├── Hash_FMX.dpr │ ├── Hash_FMX.dproj │ ├── Hash_FMX.res │ ├── MainFormHashFMX.SmXhdpiPh.fmx │ ├── MainFormHashFMX.fmx │ └── MainFormHashFMX.pas ├── Password_Console │ ├── Password_Console.dpr │ ├── Password_Console.dproj │ └── Password_Console.res ├── Progress_VCL │ ├── MainFormProgressVCL.dfm │ ├── MainFormProgressVCL.pas │ ├── ProgressDemoVCL.dpr │ ├── ProgressDemoVCL.dproj │ └── ProgressDemoVCL.res ├── Random_Console │ ├── Random_Console.dpr │ ├── Random_Console.dproj │ ├── Random_Console.res │ ├── Win32 │ │ └── Debug │ │ │ ├── DECBaseClass.dcu │ │ │ ├── DECCRC.dcu │ │ │ ├── DECData.dcu │ │ │ ├── DECDataHash.dcu │ │ │ ├── DECFormat.dcu │ │ │ ├── DECFormatBase.dcu │ │ │ ├── DECHash.dcu │ │ │ ├── DECHashBase.dcu │ │ │ ├── DECHashInterface.dcu │ │ │ ├── DECRandom.dcu │ │ │ ├── DECTypes.dcu │ │ │ ├── DECUtil.dcu │ │ │ ├── DECUtilRawByteStringHelper.dcu │ │ │ ├── Random_Console.exe │ │ │ └── TestDECRandom.dcu │ └── __history │ │ └── .gitignore └── Random_VCL_Comparison │ ├── MainForm.dfm │ ├── MainForm.pas │ ├── RandomComparison_VCL.dpr │ ├── RandomComparison_VCL.dproj │ └── RandomComparison_VCL.res ├── Docs ├── DEC65.pdf ├── PrivacyPolicy.txt └── VersionHistory.pdf ├── Install ├── SetIDEPaths.dpr ├── SetIDEPaths.dproj ├── SetIDEPaths.res └── readme.txt ├── LICENSE.txt ├── NOTICE.txt ├── SECURITY.md ├── Source ├── BuildAll.cmd ├── DEC60.dpr ├── DEC60.dproj ├── DEC60.res ├── DEC60.todo ├── DEC60Complete.groupproj ├── DEC60Complete_prjgroup.tvsconfig ├── DEC60Lazarus.lpk ├── DEC60Lazarus.pas ├── DEC60_project.tvsconfig ├── DECBaseClass.pas ├── DECCRC.pas ├── DECCipherBase.pas ├── DECCipherFormats.pas ├── DECCipherInterface.pas ├── DECCipherModes.pas ├── DECCipherModesGCM.pas ├── DECCipherPaddings.pas ├── DECCiphers.pas ├── DECData.pas ├── DECDataCipher.pas ├── DECDataHash.pas ├── DECFormat.pas ├── DECFormatBase.pas ├── DECHash.asm86.inc ├── DECHash.pas ├── DECHash.sha3_mmx.inc ├── DECHash.sha3_x64.inc ├── DECHashAuthentication.pas ├── DECHashBase.pas ├── DECHashBitBase.pas ├── DECHashInterface.pas ├── DECOptions.inc ├── DECRandom.pas ├── DECTypes.pas ├── DECUtil.pas ├── DECUtilRawByteStringHelper.pas ├── DECZIPHelper.pas ├── LibrarySupport │ └── DelphiWin32 │ │ ├── DECBaseClass │ │ └── default.txaPackage │ │ ├── GUITestRunner │ │ └── default.txaPackage │ │ ├── SysInit │ │ └── default.txaPackage │ │ ├── System │ │ ├── Classes │ │ │ └── default.txaPackage │ │ ├── Generics │ │ │ ├── Collections │ │ │ │ └── default.txaPackage │ │ │ └── default.txaPackage │ │ ├── SysUtils │ │ │ └── default.txaPackage │ │ ├── TypInfo │ │ │ └── default.txaPackage │ │ └── default.txaPackage │ │ ├── TestFramework │ │ └── default.txaPackage │ │ ├── TextTestRunner │ │ └── default.txaPackage │ │ ├── Vcl │ │ └── default.txaPackage │ │ ├── Winapi │ │ └── default.txaPackage │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig ├── SearchPaths-Demo.optset ├── SearchPaths-Source.optset ├── SearchPaths-Test.optset ├── fpc │ ├── DECUtil.inc │ ├── dec.lpk │ └── dec.pas ├── x86 │ └── DECUtil.inc └── x86_64 │ └── DECUtil.inc ├── Unit Tests ├── AndroidManifest.template.xml ├── CodeCoverage │ ├── DECCodeCoverage.dccp │ ├── DECCodeCoverage_dcov_execute.bat │ ├── DECCodeCoverage_dcov_paths.lst │ ├── DECCodeCoverage_dcov_units.lst │ ├── Output │ │ ├── CodeCoverage_summary.html │ │ ├── DECBaseClass(DECBaseClass.pas).html │ │ ├── DECCRC(DECCRC.pas).html │ │ ├── DECCipherBase(DECCipherBase.pas).html │ │ ├── DECCipherFormats(DECCipherFormats.pas).html │ │ ├── DECCipherModes(DECCipherModes.pas).html │ │ ├── DECCipherModesGCM(DECCipherModesGCM.pas).html │ │ ├── DECCiphers(DECCiphers.pas).html │ │ ├── DECCodeCoverage_DelphiCodeCoverageDebug.log │ │ ├── DECFormat(DECFormat.pas).html │ │ ├── DECFormatBase(DECFormatBase.pas).html │ │ ├── DECHash(DECHash.pas).html │ │ ├── DECHashAuthentication(DECHashAuthentication.pas).html │ │ ├── DECHashBase(DECHashBase.pas).html │ │ ├── DECHashBitBase(DECHashBitBase.pas).html │ │ ├── DECRandom(DECRandom.pas).html │ │ ├── DECTypes(DECTypes.pas).html │ │ ├── DECUtil(DECUtil.pas).html │ │ └── DECUtilRawByteStringHelper(DECUtilRawByteStringHelper.pas).html │ └── U │ │ ├── CodeCoverage_Summary.xml │ │ ├── CodeCoverage_summary.html │ │ ├── DECBaseClass(DECBaseClass.pas).html │ │ ├── DECBaseClass.html │ │ ├── DECCRC(DECCRC.pas).html │ │ ├── DECCipherBase(DECCipherBase.pas).html │ │ ├── DECCipherFormats(DECCipherFormats.pas).html │ │ ├── DECCipherModes(DECCipherModes.pas).html │ │ ├── DECCipherModesGCM(DECCipherModesGCM.pas).html │ │ ├── DECCiphers(DECCiphers.pas).html │ │ ├── DECFormat(DECFormat.pas).html │ │ ├── DECFormatBase(DECFormatBase.pas).html │ │ ├── DECHash(DECHash.asm86.inc).html │ │ ├── DECHash(DECHash.pas).html │ │ ├── DECHash(DECHash.sha3_mmx.inc).html │ │ ├── DECHash.html │ │ ├── DECHashAuthentication(DECHashAuthentication.pas).html │ │ ├── DECHashBase(DECHashBase.pas).html │ │ ├── DECHashBitBase(DECHashBitBase.pas).html │ │ ├── DECRandom(DECRandom.pas).html │ │ ├── DECTypes(DECTypes.pas).html │ │ ├── DECUtil(DECUtil.pas).html │ │ └── DECUtilRawByteStringHelper(DECUtilRawByteStringHelper.pas).html ├── DECDUnitTestSuite.dpr ├── DECDUnitTestSuite.dproj ├── DECDUnitTestSuite.res ├── DECDUnitTestSuite_project.tvsconfig ├── DECDUnitXTestSuite.deployproj ├── DECDUnitXTestSuite.dpr ├── DECDUnitXTestSuite.dproj ├── DECDUnitXTestSuite.dproj.local ├── DECDUnitXTestSuite.res ├── DECDUnitXTestSuite.stat ├── Data │ ├── GCM128AuthenticationFailures.rsp │ ├── GCM192AuthenticationFailures.rsp │ ├── GCM256AuthenticationFailures.rsp │ ├── SHA3_224LongMsg.rsp │ ├── SHA3_224ShortMsg.rsp │ ├── SHA3_256LongMsg.rsp │ ├── SHA3_256ShortMsg.rsp │ ├── SHA3_384LongMsg.rsp │ ├── SHA3_384ShortMsg.rsp │ ├── SHA3_512LongMsg.rsp │ ├── SHA3_512ShortMsg.rsp │ ├── ShortMsgKAT_SHAKE128.txt │ ├── ShortMsgKAT_SHAKE256.txt │ ├── aes-cbc-pkcs7.txt │ ├── gcmDecrypt128.rsp │ ├── gcmDecrypt192.rsp │ ├── gcmDecrypt256.rsp │ ├── gcmEncryptExtIV128.rsp │ ├── gcmEncryptExtIV192.rsp │ ├── gcmEncryptExtIV256.rsp │ └── gcmEncryptExtIV256_large.rsp ├── HashTestDataGenerator │ ├── GenerateData.dpr │ ├── GenerateData.dproj │ └── GenerateData.res ├── ModelSupport_DECDUnitTestSuite │ ├── DECDUnitTestSuite │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── Klassendiagramm.txvcls │ ├── Klassendiagramm_diagram.tvsconfig │ ├── TestDECCRC │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECCipher │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECCipherFormats │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECCipherModes │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECFormat │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECFormatBase │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECHash │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECHashKDF │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECHashMAC │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECRandom │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECTestDataContainer │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── TestDECUtil │ │ ├── default.txaPackage │ │ ├── default.txvpck │ │ └── default_diagram.tvsconfig │ ├── default.txaPackage │ ├── default.txvpck │ └── default_diagram.tvsconfig ├── Tests │ ├── TestDECBaseClass.pas │ ├── TestDECCRC.pas │ ├── TestDECCipher.pas │ ├── TestDECCipherFormats.pas │ ├── TestDECCipherModes.pas │ ├── TestDECCipherModesGCM.pas │ ├── TestDECCipherPaddings.pas │ ├── TestDECFormat.pas │ ├── TestDECFormatBase.pas │ ├── TestDECHash.pas │ ├── TestDECHashKDF.pas │ ├── TestDECHashMAC.pas │ ├── TestDECHashSHA3.pas │ ├── TestDECRandom.pas │ ├── TestDECTestDataContainer.pas │ ├── TestDECUtil.pas │ ├── TestDECZIPHelper.pas │ └── TestDefines.inc └── deployedassets.txt └── readme.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # These files are text and should be normalized (convert crlf => lf) 2 | *.pas text 3 | *.dpr text 4 | *.dproj text 5 | *.dfm text 6 | *.fmx text 7 | *.local text 8 | *.inc text 9 | *.txt text 10 | *.md text 11 | *.tvsconfig text 12 | *.deployproj text -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: MHumm 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is and if possible a small demo project showing the bug. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected and actual behavior** 21 | A clear and concise description of what you expected to happen 22 | and what you see happening. 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: MHumm 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | 22 | **Minimum Delphi version you need this for** 23 | Which is the minimum Delphi version this feature needs to work with? 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /Compiled 2 | /Source/BuildAll.log 3 | 4 | backup 5 | __history 6 | __recovery 7 | **/Android/ 8 | **/Android64/ 9 | **/Win32/ 10 | **/Win64/ 11 | 12 | *.local 13 | *.identcache 14 | *.dsk 15 | *.~* 16 | *.stat 17 | Thumbs.db 18 | 19 | 20 | *.dsv 21 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Delphi Encryption Compendium Code of Conduct 2 | 3 | ## 1. Purpose 4 | 5 | A primary goal of Delphi Encryption Compendium is to be inclusive to the largest number of contributors. 6 | As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless 7 | of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). 8 | 9 | This code of conduct outlines our expectations for all those who participate in our community, as well as 10 | the consequences for unacceptable behavior. 11 | 12 | We invite all those who participate in Delphi Encryption Compendium to help us create safe and positive 13 | experiences for everyone. 14 | 15 | ## 2. Expected Behavior 16 | 17 | The following behaviors are expected and requested of all community members: 18 | 19 | * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of 20 | this community. 21 | * Exercise consideration and respect in your speech and actions. 22 | * Attempt collaboration before conflict. 23 | * Refrain from demeaning, discriminatory, or harassing behavior and speech. 24 | * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice 25 | a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem 26 | inconsequential. 27 | 28 | ## 3. Unacceptable Behavior 29 | 30 | The following behaviors are considered harassment and are unacceptable within our community: 31 | 32 | * Violence, threats of violence or violent language directed against another person. 33 | * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. 34 | * Posting or displaying sexually explicit or violent material. 35 | * Posting or threatening to post other people's personally identifying information ("doxing"). 36 | * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. 37 | * Inappropriate photography or recording. 38 | * Inappropriate physical contact. You should have someone's consent before touching them. 39 | * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, 40 | and unwelcomed sexual advances. 41 | * Deliberate intimidation, stalking or following (online or in person). 42 | * Advocating for, or encouraging, any of the above behavior. 43 | * Sustained disruption of community events, including talks and presentations. 44 | 45 | ## 4. Weapons Policy 46 | 47 | Since this is a virtual community site no weapons policy is needed currently. 48 | If a physical community event should be planned, a weapons policy will be created and enforced. 49 | 50 | ## 5. Consequences of Unacceptable Behavior 51 | 52 | Unacceptable behavior from any community member, including sponsors and those with decision-making authority, 53 | will not be tolerated. 54 | 55 | Anyone asked to stop unacceptable behavior is expected to comply immediately. 56 | 57 | If a community member engages in unacceptable behavior, the community organizers may take any action they deem 58 | appropriate, up to and including a temporary ban or permanent expulsion from the community without warning 59 | (and without refund in the case of a paid event). 60 | 61 | ## 6. Reporting Guidelines 62 | 63 | If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community 64 | organizer as soon as possible. 65 | 66 | Additionally, community organizers are available to help community members engage with local law enforcement or 67 | to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, 68 | organizers will also provide escorts as desired by the person experiencing distress. 69 | 70 | ## 7. Addressing Grievances 71 | 72 | If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify 73 | with a concise description of your grievance. Your grievance will be handled in accordance with our existing 74 | governing policies. 75 | 76 | ## 8. Scope 77 | 78 | We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by 79 | this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications 80 | pertaining to community business. 81 | 82 | ## 9. Contact info 83 | 84 | See NOTICE.txt from the project repository. Preferably contact the person marked as "main contact" in this file. 85 | 86 | ## 10. License and attribution 87 | 88 | The Citizen Code of Conduct is distributed by "TeamDEC" under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/) 89 | and it is based on the one from [Stumptown Syndicate]. 90 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We welcome contributions from the Delphi and FPC communities! 2 | 3 | If you like to contribute then either submit a pull request with your proposed 4 | changes along with a description about what you like to achieve with the 5 | modification/addition you propose or send an e-mail to the person listed as main contact 6 | in notice.txt 7 | 8 | When creating a pull request please follow these rules: 9 | 10 | * one commit per pull request 11 | * base your fork/pull request on the development branch, that's the one with the newest code changes 12 | -------------------------------------------------------------------------------- /Demos/Cipher_Console/Cipher_Console.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Most simple demonstration of using a DEC cipher 20 | /// 21 | program Cipher_Console; 22 | 23 | {$APPTYPE CONSOLE} 24 | 25 | {$R *.res} 26 | 27 | uses 28 | System.SysUtils, 29 | DECCipherBase, 30 | DECCipherModes, 31 | DECCipherFormats, 32 | DECCiphers; 33 | 34 | var 35 | Cipher : TCipher_TwoFish; 36 | // We use raw byte string here since Unicode handling of Windows console 37 | // is not given 38 | SourceText : RawByteString; 39 | CipherKey : RawByteString; // Key for the initialization of our encryption run 40 | IV : RawByteString; // Initialization vector for the en/decryption 41 | Input, 42 | Output : TBytes; 43 | i : Integer; 44 | begin 45 | Cipher := TCipher_TwoFish.Create; 46 | 47 | try 48 | try 49 | WriteLn('Simple encryption demo using a better block chaining mode than ECB'); 50 | WriteLn; 51 | 52 | // Init our encryption, note that this is the German spelling of Password 53 | CipherKey := 'Passwort'; 54 | // The IV should be different each time you encrypt/decrypt something. The 55 | // decrypting party needs to know the IV as well of course. A more thorough 56 | // example for using IVs can befound in the Cipher_FMX example project. 57 | IV := #0#0#0#0#0#0#0#0; 58 | Cipher.Init(CipherKey, IV, 0); 59 | Cipher.Mode := cmCBCx; 60 | 61 | SourceText := 'Beispielklartext'; 62 | WriteLn('Source text: ' + SourceText); 63 | Input := System.SysUtils.BytesOf(SourceText); 64 | 65 | // Encrypt 66 | Output := Cipher.EncodeBytes(Input); 67 | Cipher.Done; 68 | 69 | Write('Encrypted data in hex: '); 70 | for i := 0 to high(Output) do 71 | Write(IntToHex(Output[i], 2), ' '); 72 | 73 | WriteLn; 74 | 75 | // Decrypt 76 | Cipher.Init(CipherKey, IV, 0); 77 | Output := Cipher.DecodeBytes(Output); 78 | Cipher.Done; 79 | 80 | SourceText := RawByteString(System.SysUtils.StringOf(Output)); 81 | 82 | WriteLn('Decrypted data: ' + SourceText); 83 | 84 | // Show that using a different key results in a different output 85 | WriteLn; 86 | 87 | // note the English spelling of Password here, so we differ in the last char 88 | CipherKey := 'Password'; 89 | Cipher.Init(CipherKey, IV, 0); 90 | Output := Cipher.DecodeBytes(Output); 91 | Cipher.Done; 92 | 93 | SourceText := RawByteString(System.SysUtils.StringOf(Output)); 94 | 95 | WriteLn('Decrypted with different key: ' + SourceText); 96 | 97 | WriteLn; 98 | except 99 | on E: Exception do 100 | Writeln(E.ClassName, ': ', E.Message); 101 | end; 102 | 103 | ReadLn; 104 | finally 105 | // clean up inside the cipher instance, which also removes the key from RAM 106 | Cipher.Free; 107 | end; 108 | end. 109 | -------------------------------------------------------------------------------- /Demos/Cipher_Console/Cipher_Console.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_Console/Cipher_Console.res -------------------------------------------------------------------------------- /Demos/Cipher_Console/Cipher_Console_project.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Demos/Cipher_Console_KDF/Cipher_Console_KDF.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Demonstration of using a DEC cipher where the key security is improved by 20 | /// using a key deviation function based on a hash algorithm. 21 | /// 22 | program Cipher_Console_KDF; 23 | 24 | {$APPTYPE CONSOLE} 25 | 26 | {$R *.res} 27 | 28 | uses 29 | System.SysUtils, 30 | DECCipherBase, 31 | DECCipherModes, 32 | DECCipherFormats, 33 | DECCiphers, 34 | DECHash; 35 | 36 | var 37 | Cipher : TCipher_TwoFish; 38 | // We use raw byte string here since Unicode handling of Windows console 39 | // is not given 40 | SourceText : RawByteString; 41 | CipherKey : RawByteString; // Key for the initialization of our encryption run 42 | Seed : RawByteString; // Seed for the key deviation function 43 | IV : RawByteString; // Initialization vector for the en/decryption 44 | Input, 45 | Output : TBytes; 46 | KeyKDF : TBytes; // Key after applying KDF to it 47 | i : Integer; 48 | begin 49 | Cipher := TCipher_TwoFish.Create; 50 | 51 | try 52 | try 53 | WriteLn('Encryption demo using a KDF to improve key security'); 54 | WriteLn; 55 | 56 | // Init our encryption, note that this is the German spelling of Password 57 | CipherKey := 'Passwort'; 58 | Seed := 'SaltValueForThePassword'; 59 | 60 | KeyKDF := THash_SHA256.KDF1(BytesOf(CipherKey), BytesOf(Seed), 8); 61 | 62 | // The IV should be different each time you encrypt/decrypt something. The 63 | // decrypting party needs to know the IV as well of course. 64 | IV := #0#0#0#0#0#0#0#0; 65 | Cipher.Init(RawByteString(StringOf(KeyKDF)), IV, 0); 66 | Cipher.Mode := cmCBCx; 67 | 68 | SourceText := 'Beispielklartext'; 69 | WriteLn('Source text: ' + SourceText); 70 | Input := System.SysUtils.BytesOf(SourceText); 71 | 72 | // Encrypt 73 | Output := Cipher.EncodeBytes(Input); 74 | Cipher.Done; 75 | 76 | Write('Encrypted data in hex: '); 77 | for i := 0 to high(Output) do 78 | Write(IntToHex(Output[i], 2), ' '); 79 | 80 | WriteLn; 81 | 82 | // Decrypt 83 | Cipher.Init(RawByteString(StringOf(KeyKDF)), IV, 0); 84 | Output := Cipher.DecodeBytes(Output); 85 | Cipher.Done; 86 | 87 | SourceText := RawByteString(System.SysUtils.StringOf(Output)); 88 | 89 | WriteLn('Decrypted data: ' + SourceText); 90 | except 91 | on E: Exception do 92 | Writeln(E.ClassName, ': ', E.Message); 93 | end; 94 | 95 | ReadLn; 96 | finally 97 | // clean up inside the cipher instance, which also removes the key from RAM 98 | Cipher.Free; 99 | end; 100 | end. 101 | -------------------------------------------------------------------------------- /Demos/Cipher_Console_KDF/Cipher_Console_KDF.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_Console_KDF/Cipher_Console_KDF.res -------------------------------------------------------------------------------- /Demos/Cipher_FMX/AndroidManifest.template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | <%uses-permission%> 12 | 13 | 21 | 22 | <%application-meta-data%> 23 | <%services%> 24 | 26 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | <%activity%> 40 | <%receivers%> 41 | 42 | 43 | -------------------------------------------------------------------------------- /Demos/Cipher_FMX/Cipher_FMX.dpr: -------------------------------------------------------------------------------- 1 | program Cipher_FMX; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | MainFormCipherFMX in 'MainFormCipherFMX.pas' {FormMain}; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.CreateForm(TFormMain, FormMain); 13 | Application.Run; 14 | end. 15 | -------------------------------------------------------------------------------- /Demos/Cipher_FMX/Cipher_FMX.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/Cipher_FMX.res -------------------------------------------------------------------------------- /Demos/Cipher_FMX/CryptoIcon_144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/CryptoIcon_144.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/CryptoIcon_192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/CryptoIcon_192.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/CryptoIcon_36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/CryptoIcon_36.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/CryptoIcon_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/CryptoIcon_48.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/CryptoIcon_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/CryptoIcon_72.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/CryptoIcon_96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/CryptoIcon_96.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/Crypto_426_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/Crypto_426_320.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/Crypto_470_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/Crypto_470_320.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/Crypto_640_480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/Crypto_640_480.png -------------------------------------------------------------------------------- /Demos/Cipher_FMX/Crypto_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Cipher_FMX/Crypto_960_720.png -------------------------------------------------------------------------------- /Demos/Format_Console/Format_Console.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Most simple demonstration of DEC formatting routines 20 | /// 21 | program Format_Console; 22 | 23 | {$APPTYPE CONSOLE} 24 | 25 | {$R *.res} 26 | 27 | uses 28 | System.SysUtils, 29 | DECFormat; 30 | 31 | var 32 | s, s1 : string; 33 | 34 | begin 35 | try 36 | s := 'Hello world!'; 37 | // Convert the string to be encoded in a byte array 38 | // and te result into a string for output 39 | s1 := System.SysUtils.StringOf(TFormat_HEX.Encode(System.SysUtils.BytesOf(s))); 40 | WriteLn(s + ' encoded in hex is: ' + s1); 41 | 42 | // the same for decoding 43 | WriteLn('Hex ' + s1 + ' is ' + 44 | System.SysUtils.StringOf(TFormat_HEX.Decode(System.SysUtils.BytesOf(s1))) + 45 | ' unencoded'); 46 | except 47 | on E: Exception do 48 | Writeln(E.ClassName, ': ', E.Message); 49 | end; 50 | 51 | ReadLn; 52 | end. 53 | -------------------------------------------------------------------------------- /Demos/Format_Console/Format_Console.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Format_Console/Format_Console.res -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/AndroidManifest.template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | <%uses-permission%> 11 | 12 | 22 | 23 | <%provider%> 24 | <%application-meta-data%> 25 | <%uses-libraries%> 26 | <%services%> 27 | 29 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | <%activity%> 42 | <%receivers%> 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Crypto_426_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Crypto_426_320.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Crypto_470_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Crypto_470_320.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Crypto_640_480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Crypto_640_480.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Crypto_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Crypto_960_720.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash.ico -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash144.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash192.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash256.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash36.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash48.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash72.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/Hash96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/Hash96.png -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/HashBenchmark.dpr: -------------------------------------------------------------------------------- 1 | program HashBenchmark; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | MainFormHashBenchmark in 'MainFormHashBenchmark.pas' {FormMain}; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.CreateForm(TFormMain, FormMain); 13 | Application.Run; 14 | end. 15 | -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/HashBenchmark.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/HashBenchmark_FMX/HashBenchmark.res -------------------------------------------------------------------------------- /Demos/HashBenchmark_FMX/MainFormHashBenchmark.fmx: -------------------------------------------------------------------------------- 1 | object FormMain: TFormMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'Hash benchmark' 5 | ClientHeight = 480 6 | ClientWidth = 640 7 | FormFactor.Width = 320 8 | FormFactor.Height = 480 9 | FormFactor.Devices = [Desktop] 10 | OnCreate = FormCreate 11 | OnResize = FormResize 12 | DesignerMasterStyle = 0 13 | object Rectangle1: TRectangle 14 | Anchors = [akLeft, akTop, akRight] 15 | Fill.Color = claCadetblue 16 | HitTest = False 17 | Position.X = 8.000000000000000000 18 | Position.Y = 8.000000000000000000 19 | Size.Width = 625.000000000000000000 20 | Size.Height = 41.000000000000000000 21 | Size.PlatformDefault = False 22 | object b_Start: TButton 23 | Align = Client 24 | Size.Width = 625.000000000000000000 25 | Size.Height = 41.000000000000000000 26 | Size.PlatformDefault = False 27 | StyleLookup = 'playtoolbutton' 28 | TabOrder = 0 29 | Text = 'b_Start' 30 | OnClick = b_StartClick 31 | end 32 | end 33 | object sg_Results: TStringGrid 34 | Anchors = [akLeft, akTop, akRight, akBottom] 35 | CanFocus = True 36 | ClipChildren = True 37 | Position.X = 8.000000000000000000 38 | Position.Y = 56.000000000000000000 39 | Size.Width = 625.000000000000000000 40 | Size.Height = 369.000000000000000000 41 | Size.PlatformDefault = False 42 | StyleLookup = 'gridstyle' 43 | TabOrder = 0 44 | RowCount = 0 45 | Options = [ColumnResize, ColLines, RowLines, RowSelect, Tabs, Header] 46 | Viewport.Width = 621.000000000000000000 47 | Viewport.Height = 344.000000000000000000 48 | object StringColumn1: TStringColumn 49 | Header = 'Algorithm' 50 | ReadOnly = True 51 | end 52 | object StringColumn2: TStringColumn 53 | Header = 'Speed MB/s' 54 | end 55 | object StringColumn3: TStringColumn 56 | Header = 'Time (hh:mm:ss:ms)' 57 | end 58 | end 59 | object TimerBenchmark: TTimer 60 | Enabled = False 61 | Interval = 50 62 | OnTimer = TimerBenchmarkTimer 63 | Left = 408 64 | Top = 96 65 | end 66 | object b_CopyToClipboard: TButton 67 | Anchors = [akLeft, akRight, akBottom] 68 | Position.X = 8.000000000000000000 69 | Position.Y = 432.000000000000000000 70 | Size.Width = 625.000000000000000000 71 | Size.Height = 41.000000000000000000 72 | Size.PlatformDefault = False 73 | TabOrder = 5 74 | Text = 'Copy to clipboard' 75 | OnClick = b_CopyToClipboardClick 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /Demos/Hash_Console/Hash_Console.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Most simple demonstration of DEC hash routines 20 | /// 21 | program Hash_Console; 22 | 23 | {$APPTYPE CONSOLE} 24 | 25 | {$R *.res} 26 | 27 | uses 28 | System.SysUtils, 29 | DECFormat, 30 | DECHash; 31 | 32 | var 33 | Hash : THash_RipeMD160; 34 | s : RawByteString; 35 | begin 36 | Hash := THash_RipeMD160.Create; 37 | try 38 | try 39 | // Calculate a hash value in accordance to the original author's test data 40 | // http://homes.esat.kuleuven.be/~bosselae/ripemd160.html 41 | s := 'message digest'; 42 | 43 | WriteLn('RipeMD160 digest (hash value) of ' + s + ' is ' + sLineBreak + 44 | Hash.CalcString(s, TFormat_HEX)); 45 | 46 | Hash.Done; 47 | except 48 | on E: Exception do 49 | Writeln(E.ClassName, ': ', E.Message); 50 | end; 51 | 52 | ReadLn; 53 | finally 54 | // Securely erase the memory 55 | Hash.Free; 56 | end; 57 | end. 58 | -------------------------------------------------------------------------------- /Demos/Hash_Console/Hash_Console.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_Console/Hash_Console.res -------------------------------------------------------------------------------- /Demos/Hash_FMX/AndroidManifest.template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | <%uses-permission%> 12 | 13 | 22 | 23 | <%provider%> 24 | <%application-meta-data%> 25 | <%services%> 26 | 28 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | <%activity%> 42 | <%receivers%> 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Demos/Hash_FMX/Crypto_426_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Crypto_426_320.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Crypto_470_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Crypto_470_320.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Crypto_640_480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Crypto_640_480.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Crypto_960_720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Crypto_960_720.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash.ico -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash144.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash192.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash256.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash36.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash48.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash72.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash96.png -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash_FMX.dpr: -------------------------------------------------------------------------------- 1 | program Hash_FMX; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | MainFormHashFMX in 'MainFormHashFMX.pas' {FormMain}; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | ReportMemoryLeaksOnShutdown := true; 12 | 13 | Application.Initialize; 14 | Application.CreateForm(TFormMain, FormMain); 15 | Application.Run; 16 | end. 17 | -------------------------------------------------------------------------------- /Demos/Hash_FMX/Hash_FMX.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/Hash_FMX.res -------------------------------------------------------------------------------- /Demos/Hash_FMX/MainFormHashFMX.SmXhdpiPh.fmx: -------------------------------------------------------------------------------- 1 | inherited Form1_SmXhdpiPh: TForm1_SmXhdpiPh 2 | ClientHeight = 375 3 | ClientWidth = 250 4 | DesignerMasterStyle = 0 5 | inherited VertScrollBox1: TVertScrollBox 6 | Size.Width = 250.000000000000000000 7 | Size.Height = 375.000000000000000000 8 | Viewport.Width = 245.000000000000000000 9 | Viewport.Height = 375.000000000000000000 10 | inherited LayoutBottom: TLayout 11 | inherited Label3: TLabel 12 | Size.Width = 42.000000000000000000 13 | Size.Height = 22.000000000000000000 14 | end 15 | inherited Label4: TLabel 16 | Size.Width = 150.000000000000000000 17 | Size.Height = 22.000000000000000000 18 | end 19 | inherited Edit1Input: TEdit 20 | Size.Height = 32.000000000000000000 21 | end 22 | inherited EditOutput: TEdit 23 | Size.Height = 32.000000000000000000 24 | end 25 | end 26 | inherited LayoutTop: TLayout 27 | inherited ComboBoxHashFunction: TComboBox 28 | Size.Height = 32.000000000000000000 29 | end 30 | inherited ComboBoxInputFormatting: TComboBox 31 | Size.Height = 32.000000000000000000 32 | end 33 | inherited ComboBoxOutputFormatting: TComboBox 34 | Size.Height = 32.000000000000000000 35 | end 36 | inherited Label2: TLabel 37 | Size.Width = 114.000000000000000000 38 | Size.Height = 22.000000000000000000 39 | end 40 | inherited Label5: TLabel 41 | Size.Width = 132.000000000000000000 42 | Size.Height = 22.000000000000000000 43 | end 44 | inherited Label6: TLabel 45 | Size.Width = 145.000000000000000000 46 | Size.Height = 22.000000000000000000 47 | end 48 | end 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /Demos/Hash_FMX/MainFormHashFMX.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Hash_FMX/MainFormHashFMX.pas -------------------------------------------------------------------------------- /Demos/Password_Console/Password_Console.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the license. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Some demonstrations of how to use the password hashing classes 20 | /// 21 | program Password_Console; 22 | 23 | {$APPTYPE CONSOLE} 24 | 25 | {$R *.res} 26 | 27 | uses 28 | System.SysUtils, 29 | DECHashAuthentication, 30 | DECHash, 31 | DECTypes, 32 | DECFormat; 33 | 34 | var 35 | HashInst : THash_BCrypt; 36 | HashInst2 : TDECPasswordHash; 37 | HashRef : TDECPasswordHashClass; 38 | Result : Boolean; 39 | Password : string; 40 | 41 | begin 42 | HashInst := THash_BCrypt.Create; 43 | try 44 | try 45 | // manually calculate the password hash using the BCrypt algorithm 46 | 47 | // Cost defines how many rounds are used, the higher the stronger. 48 | // See MinCost and MaxCost methods as well. 49 | HashInst.Cost := 6; 50 | // Salt for BCrypt must always be 16 byte long. 51 | HashInst.Salt := [$2a, $1f, $1d, $c7, $0a, $3d, $14, $79, 52 | $56, $a4, $6f, $eb, $e3, $01, $60, $17]; 53 | // Calculate the hash for password 'abc' and display it in hexadecimal 54 | WriteLn('Hash for password abc is:'); 55 | WriteLn(HashInst.CalcString('abc', TFormat_HEXL)); 56 | WriteLn; 57 | 58 | // Generate a Crypt/BSD style password entry. The BSD operating system 59 | // stores his password records in this format. More information about the 60 | // format in the XMLDOC of the TDECHash_Authentication and THash_BCrypt 61 | // classes. 62 | // The formatting class TFormat_BCryptBSD must be passed here, as this 63 | // avoids dragging the TDECFormat unit into DECHashAuthentication and 64 | // DECHash units just for a case not everybody needs. The right output 65 | // is: '$2a$06$If6bvum7DFjUnE9p2uDeDu0YHzrHM6tf.iqN8.yx.jNN1ILEf7h0i' 66 | WriteLn('Crypt/BSD data for password abc is:'); 67 | WriteLn(HashInst.GetDigestInCryptFormat('abc', 68 | '6', 69 | 'If6bvum7DFjUnE9p2uDeDu', 70 | false, 71 | TFormat_BCryptBSD)); 72 | WriteLn; 73 | 74 | // Check some entered password 75 | WriteLn('Enter correct password to continue (correct value is: GoOn!):'); 76 | 77 | repeat 78 | ReadLn(Password); 79 | // the data against which the entered password is compared is given 80 | // in Crypt/BSD style format, esp. in the BCrypt variant of that format 81 | Result := HashInst.IsValidPassword(Password, 82 | '$2a$06$If6bvum7DFjUnE9p2uDeDuJZX' + 83 | '1LXp30kMOn/QEnf4laWZvcLxd0iK', 84 | TFormat_BCryptBSD); 85 | if not Result then 86 | WriteLn('Entered password is wrong!'); 87 | until Result; 88 | 89 | WriteLn('Entered password is correct!'); 90 | WriteLn; 91 | 92 | // find the class reference of the BCrypt inplementation and create an 93 | // object from it 94 | try 95 | HashRef := TDECPasswordHash.ClassByCryptIdentity('$2a'); 96 | HashInst2 := HashRef.Create; 97 | try 98 | WriteLn('Class created: ' + HashInst2.ClassName); 99 | Result := HashInst.IsValidPassword('GoOn!', 100 | '$2a$06$If6bvum7DFjUnE9p2uDeDuJZX' + 101 | '1LXp30kMOn/QEnf4laWZvcLxd0iK', 102 | TFormat_BCryptBSD); 103 | WriteLn('Is right password: ' + BoolToStr(Result, true)); 104 | finally 105 | HashInst2.Free; 106 | end; 107 | except 108 | on e:EDECClassNotRegisteredException do 109 | WriteLn('Algorithm implementation not found'); 110 | end; 111 | except 112 | on E: Exception do 113 | Writeln(E.ClassName, ': ', E.Message); 114 | end; 115 | finally 116 | HashInst.Free; 117 | end; 118 | 119 | WriteLn; 120 | WriteLn('Press enter to quit'); 121 | ReadLn; 122 | end. 123 | -------------------------------------------------------------------------------- /Demos/Password_Console/Password_Console.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Password_Console/Password_Console.res -------------------------------------------------------------------------------- /Demos/Progress_VCL/MainFormProgressVCL.dfm: -------------------------------------------------------------------------------- 1 | object FormMain: TFormMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'Progress Test for File Encrypt/Decrypt' 5 | ClientHeight = 319 6 | ClientWidth = 635 7 | Color = clBtnFace 8 | Constraints.MaxHeight = 358 9 | Constraints.MinHeight = 358 10 | Constraints.MinWidth = 350 11 | Font.Charset = DEFAULT_CHARSET 12 | Font.Color = clWindowText 13 | Font.Height = -11 14 | Font.Name = 'Tahoma' 15 | Font.Style = [] 16 | OnCreate = FormCreate 17 | OnDestroy = FormDestroy 18 | DesignSize = ( 19 | 635 20 | 319) 21 | TextHeight = 13 22 | object LabelPaddingMode: TLabel 23 | Left = 8 24 | Top = 106 25 | Width = 67 26 | Height = 13 27 | Caption = 'Padding mode' 28 | end 29 | object ProgressBar1: TProgressBar 30 | Left = 8 31 | Top = 193 32 | Width = 619 33 | Height = 17 34 | Anchors = [akLeft, akTop, akRight] 35 | TabOrder = 0 36 | end 37 | object RadioButtonMethod: TRadioButton 38 | Left = 8 39 | Top = 216 40 | Width = 193 41 | Height = 17 42 | Caption = 'Use method as progress event' 43 | Checked = True 44 | TabOrder = 1 45 | TabStop = True 46 | end 47 | object RadioButtonProcedure: TRadioButton 48 | Left = 8 49 | Top = 248 50 | Width = 193 51 | Height = 17 52 | Caption = 'Use procedure as progress event' 53 | TabOrder = 2 54 | end 55 | object RadioButtonAnonMethod: TRadioButton 56 | Left = 8 57 | Top = 282 58 | Width = 233 59 | Height = 17 60 | Caption = 'Use anonymous method as progress event' 61 | TabOrder = 3 62 | end 63 | object PageControl1: TPageControl 64 | Left = 8 65 | Top = 130 66 | Width = 619 67 | Height = 57 68 | ActivePage = tabEncrypt 69 | TabOrder = 4 70 | object tabEncrypt: TTabSheet 71 | Caption = 'Encrypt AES256-CBC' 72 | DesignSize = ( 73 | 611 74 | 29) 75 | object ButtonEncrypt: TButton 76 | Left = 7 77 | Top = 3 78 | Width = 75 79 | Height = 25 80 | Caption = 'Encrypt' 81 | TabOrder = 0 82 | OnClick = ButtonEncryptClick 83 | end 84 | object EditEncrypt: TEdit 85 | Left = 88 86 | Top = 5 87 | Width = 523 88 | Height = 21 89 | Anchors = [akLeft, akTop, akRight] 90 | TabOrder = 1 91 | Text = 'D:\Test.txt' 92 | end 93 | end 94 | object tabDecrypt: TTabSheet 95 | Caption = 'Decrypt AES256-CBC' 96 | ImageIndex = 1 97 | DesignSize = ( 98 | 611 99 | 29) 100 | object ButtonDecrypt: TButton 101 | Left = 7 102 | Top = 3 103 | Width = 75 104 | Height = 25 105 | Caption = 'Decrypt' 106 | TabOrder = 0 107 | OnClick = ButtonDecryptClick 108 | end 109 | object EditDecrypt: TEdit 110 | Left = 88 111 | Top = 5 112 | Width = 523 113 | Height = 21 114 | Anchors = [akLeft, akTop, akRight] 115 | TabOrder = 1 116 | Text = 'D:\Test.enc' 117 | end 118 | end 119 | end 120 | object EditKey: TLabeledEdit 121 | Left = 8 122 | Top = 24 123 | Width = 529 124 | Height = 21 125 | EditLabel.Width = 99 126 | EditLabel.Height = 13 127 | EditLabel.Caption = 'Key (base64 format)' 128 | TabOrder = 5 129 | Text = '' 130 | end 131 | object EditIV: TLabeledEdit 132 | Left = 8 133 | Top = 63 134 | Width = 529 135 | Height = 21 136 | EditLabel.Width = 141 137 | EditLabel.Height = 13 138 | EditLabel.Caption = 'Initial Vector (base64 format)' 139 | TabOrder = 6 140 | Text = '' 141 | end 142 | object ButtonCreateKeyAndIV: TButton 143 | Left = 552 144 | Top = 24 145 | Width = 75 146 | Height = 60 147 | Caption = 'Create Key and IV' 148 | TabOrder = 7 149 | WordWrap = True 150 | OnClick = ButtonCreateKeyAndIVClick 151 | end 152 | object ComboBoxPaddingMode: TComboBox 153 | Left = 100 154 | Top = 103 155 | Width = 185 156 | Height = 21 157 | Style = csDropDownList 158 | TabOrder = 8 159 | end 160 | end 161 | -------------------------------------------------------------------------------- /Demos/Progress_VCL/ProgressDemoVCL.dpr: -------------------------------------------------------------------------------- 1 | program ProgressDemoVCL; 2 | 3 | uses 4 | Vcl.Forms, 5 | DECBaseClass in '..\..\Source\DECBaseClass.pas', 6 | DECCipherBase in '..\..\Source\DECCipherBase.pas', 7 | DECCipherFormats in '..\..\Source\DECCipherFormats.pas', 8 | DECCipherInterface in '..\..\Source\DECCipherInterface.pas', 9 | DECCipherModes in '..\..\Source\DECCipherModes.pas', 10 | DECCiphers in '..\..\Source\DECCiphers.pas', 11 | DECDataCipher in '..\..\Source\DECDataCipher.pas', 12 | DECCRC in '..\..\Source\DECCRC.pas', 13 | DECUtil in '..\..\Source\DECUtil.pas', 14 | DECTypes in '..\..\Source\DECTypes.pas', 15 | DECUtilRawByteStringHelper in '..\..\Source\DECUtilRawByteStringHelper.pas', 16 | DECFormatBase in '..\..\Source\DECFormatBase.pas', 17 | DECData in '..\..\Source\DECData.pas', 18 | MainFormProgressVCL in 'MainFormProgressVCL.pas' {FormMain}; 19 | 20 | {$R *.res} 21 | 22 | begin 23 | Application.Initialize; 24 | Application.MainFormOnTaskbar := True; 25 | Application.CreateForm(TFormMain, FormMain); 26 | Application.Run; 27 | end. 28 | -------------------------------------------------------------------------------- /Demos/Progress_VCL/ProgressDemoVCL.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Progress_VCL/ProgressDemoVCL.res -------------------------------------------------------------------------------- /Demos/Random_Console/Random_Console.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the license. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Most simple demonstration of using the pseudo random number generator 20 | /// 21 | program Random_Console; 22 | 23 | {$APPTYPE CONSOLE} 24 | 25 | {$R *.res} 26 | 27 | uses 28 | System.SysUtils, 29 | DECRandom; 30 | 31 | var 32 | RandomNumbers: TBytes; 33 | i, n : Integer; 34 | 35 | begin 36 | try 37 | // Draw one random number each 38 | WriteLn('Random UInt32 1: ', RandomLong); 39 | WriteLn('Random UInt32 2: ', RandomLong); 40 | WriteLn; 41 | 42 | WriteLn('Get a buffer of random numbers'); 43 | 44 | for n := 1 to 2 do 45 | begin 46 | // Get a buffer full of random bytes 47 | RandomNumbers := RandomBytes(5); 48 | 49 | for i := Low(RandomNumbers) to High(RandomNumbers) do 50 | WriteLn('Random number ', i, ' ', RandomNumbers[i]); 51 | 52 | WriteLn; 53 | end; 54 | 55 | WriteLn('Fill existing buffer'); 56 | RandomBuffer(RandomNumbers[0], length(RandomNumbers)); 57 | 58 | for i := Low(RandomNumbers) to High(RandomNumbers) do 59 | WriteLn('Random number ', i, ' ', RandomNumbers[i]); 60 | 61 | WriteLn; 62 | 63 | WriteLn('The way we initialize the seed now we will always get the '); 64 | WriteLn('same random number 1092210896 - so this is not recommended!'); 65 | 66 | RandomSeed(RandomNumbers, 0); 67 | WriteLn('Random UInt32 1: ', RandomLong); 68 | except 69 | on E: Exception do 70 | Writeln(E.ClassName, ': ', E.Message); 71 | end; 72 | 73 | ReadLn; 74 | end. 75 | -------------------------------------------------------------------------------- /Demos/Random_Console/Random_Console.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Random_Console.res -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECBaseClass.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECBaseClass.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECCRC.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECCRC.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECData.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECData.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECDataHash.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECDataHash.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECFormat.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECFormat.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECFormatBase.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECFormatBase.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECHash.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECHash.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECHashBase.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECHashBase.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECHashInterface.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECHashInterface.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECRandom.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECRandom.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECTypes.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECTypes.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECUtil.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECUtil.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/DECUtilRawByteStringHelper.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/DECUtilRawByteStringHelper.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/Random_Console.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/Random_Console.exe -------------------------------------------------------------------------------- /Demos/Random_Console/Win32/Debug/TestDECRandom.dcu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_Console/Win32/Debug/TestDECRandom.dcu -------------------------------------------------------------------------------- /Demos/Random_Console/__history/.gitignore: -------------------------------------------------------------------------------- 1 | /Random_Console.dpr.~10~ 2 | /Random_Console.dpr.~11~ 3 | /Random_Console.dpr.~12~ 4 | /Random_Console.dpr.~13~ 5 | /Random_Console.dpr.~14~ 6 | /Random_Console.dpr.~5~ 7 | /Random_Console.dpr.~6~ 8 | /Random_Console.dpr.~7~ 9 | /Random_Console.dpr.~8~ 10 | /Random_Console.dpr.~9~ 11 | /Random_Console.dpr.~29~ 12 | /Random_Console.dpr.~30~ 13 | /Random_Console.dpr.~31~ 14 | /Random_Console.dpr.~32~ 15 | /Random_Console.dpr.~33~ 16 | /Random_Console.dpr.~34~ 17 | /Random_Console.dpr.~35~ 18 | /Random_Console.dpr.~36~ 19 | /Random_Console.dpr.~37~ 20 | /Random_Console.dpr.~38~ 21 | -------------------------------------------------------------------------------- /Demos/Random_VCL_Comparison/MainForm.dfm: -------------------------------------------------------------------------------- 1 | object RandomCompareForm: TRandomCompareForm 2 | Left = 0 3 | Top = 0 4 | Caption = 'Random Number Generator Comparison' 5 | ClientHeight = 469 6 | ClientWidth = 622 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -12 11 | Font.Name = 'Segoe UI' 12 | Font.Style = [] 13 | DesignSize = ( 14 | 622 15 | 469) 16 | TextHeight = 15 17 | object Label1: TLabel 18 | Left = 16 19 | Top = 16 20 | Width = 59 21 | Height = 15 22 | Caption = 'Repetitions' 23 | end 24 | object Label2: TLabel 25 | Left = 256 26 | Top = 16 27 | Width = 24 28 | Height = 15 29 | Caption = 'x256' 30 | end 31 | object EditRepetitions: TEdit 32 | Left = 120 33 | Top = 13 34 | Width = 121 35 | Height = 23 36 | NumbersOnly = True 37 | TabOrder = 0 38 | Text = '1000' 39 | end 40 | object Chart1: TChart 41 | Left = 0 42 | Top = 42 43 | Width = 625 44 | Height = 427 45 | Legend.Alignment = laBottom 46 | Legend.CheckBoxes = True 47 | Legend.LegendStyle = lsSeries 48 | Title.Text.Strings = ( 49 | 'Comparison of random number generators') 50 | BottomAxis.Automatic = False 51 | BottomAxis.AutomaticMaximum = False 52 | BottomAxis.AutomaticMinimum = False 53 | BottomAxis.LabelsAngle = 90 54 | BottomAxis.Maximum = 256.000000000000000000 55 | BottomAxis.Title.Caption = 'Values' 56 | LeftAxis.Title.Caption = 'Occurances' 57 | TopAxis.Title.Caption = 'Value' 58 | View3D = False 59 | TabOrder = 1 60 | Anchors = [akLeft, akTop, akRight, akBottom] 61 | ExplicitHeight = 399 62 | DefaultCanvas = 'TGDIPlusCanvas' 63 | ColorPaletteIndex = 13 64 | object Series1: TLineSeries 65 | HoverElement = [heCurrent] 66 | Legend.Text = 'DEC' 67 | LegendTitle = 'DEC' 68 | Brush.BackColor = clDefault 69 | Pointer.InflateMargins = True 70 | Pointer.Style = psRectangle 71 | XValues.Name = 'X' 72 | XValues.Order = loAscending 73 | YValues.Name = 'Y' 74 | YValues.Order = loNone 75 | end 76 | object Series2: TLineSeries 77 | HoverElement = [heCurrent] 78 | Legend.Text = 'Delphi RTL' 79 | LegendTitle = 'Delphi RTL' 80 | Brush.BackColor = clDefault 81 | Pointer.InflateMargins = True 82 | Pointer.Style = psRectangle 83 | XValues.Name = 'X' 84 | XValues.Order = loAscending 85 | YValues.Name = 'Y' 86 | YValues.Order = loNone 87 | end 88 | end 89 | object ButtonStart: TButton 90 | Left = 296 91 | Top = 11 92 | Width = 75 93 | Height = 25 94 | Caption = '&Start' 95 | TabOrder = 2 96 | OnClick = ButtonStartClick 97 | end 98 | end 99 | -------------------------------------------------------------------------------- /Demos/Random_VCL_Comparison/MainForm.pas: -------------------------------------------------------------------------------- 1 | unit MainForm; 2 | 3 | interface 4 | 5 | uses 6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 7 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VclTee.TeeGDIPlus, Vcl.StdCtrls, 8 | VCLTee.TeEngine, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series; 9 | 10 | type 11 | /// 12 | /// Our random numbers 13 | /// 14 | TValues = array[0..255] of UInt32; 15 | 16 | TRandomCompareForm = class(TForm) 17 | Label1: TLabel; 18 | EditRepetitions: TEdit; 19 | Label2: TLabel; 20 | Chart1: TChart; 21 | ButtonStart: TButton; 22 | Series1: TLineSeries; 23 | Series2: TLineSeries; 24 | procedure ButtonStartClick(Sender: TObject); 25 | private 26 | procedure ClearValues(var Values: TValues); 27 | procedure DisplayValues(const Values: TValues; Series: TLineSeries); 28 | procedure GenerateRTLValues(var Values: TValues; Repeats: UInt32); 29 | procedure GenerateDECValues(var Values: TValues; Repeats: UInt32); 30 | public 31 | end; 32 | 33 | var 34 | RandomCompareForm: TRandomCompareForm; 35 | 36 | implementation 37 | 38 | uses 39 | DECRandom; 40 | 41 | {$R *.dfm} 42 | 43 | procedure TRandomCompareForm.ButtonStartClick(Sender: TObject); 44 | var 45 | Max : UInt32; 46 | Values : TValues; 47 | begin 48 | Max := StrToInt(EditRepetitions.Text); 49 | 50 | Series1.Clear; 51 | Series2.Clear; 52 | 53 | ClearValues(Values); 54 | GenerateDECValues(Values, Max); 55 | DisplayValues(Values, Series1); 56 | 57 | ClearValues(Values); 58 | GenerateRTLValues(Values, Max); 59 | DisplayValues(Values, Series2); 60 | end; 61 | 62 | procedure TRandomCompareForm.GenerateDECValues(var Values : TValues; 63 | Repeats : UInt32); 64 | var 65 | i, n : UInt32; 66 | begin 67 | for i := 0 to Repeats do 68 | begin 69 | for n := 0 to 255 do 70 | inc(Values[RandomBytes(1)[0]]); 71 | end; 72 | end; 73 | 74 | procedure TRandomCompareForm.GenerateRTLValues(var Values : TValues; 75 | Repeats : UInt32); 76 | var 77 | i, n : UInt32; 78 | begin 79 | for i := 0 to Repeats do 80 | begin 81 | for n := 0 to 255 do 82 | inc(Values[Random(256)]); 83 | end; 84 | end; 85 | 86 | procedure TRandomCompareForm.ClearValues(var Values: TValues); 87 | var 88 | i: Cardinal; 89 | begin 90 | for i := Low(Values) to High(Values) do 91 | Values[i] := 0; 92 | end; 93 | 94 | procedure TRandomCompareForm.DisplayValues(const Values : TValues; 95 | Series : TLineSeries); 96 | var 97 | i : Integer; 98 | begin 99 | for i := 0 to 255 do 100 | Series.AddXY(i, Values[i]); 101 | end; 102 | 103 | end. 104 | -------------------------------------------------------------------------------- /Demos/Random_VCL_Comparison/RandomComparison_VCL.dpr: -------------------------------------------------------------------------------- 1 | program RandomComparison_VCL; 2 | 3 | uses 4 | Vcl.Forms, 5 | MainForm in 'MainForm.pas' {RandomCompareForm}; 6 | 7 | {$R *.res} 8 | 9 | begin 10 | Application.Initialize; 11 | Application.MainFormOnTaskbar := True; 12 | Application.CreateForm(TRandomCompareForm, RandomCompareForm); 13 | Application.Run; 14 | end. 15 | -------------------------------------------------------------------------------- /Demos/Random_VCL_Comparison/RandomComparison_VCL.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Demos/Random_VCL_Comparison/RandomComparison_VCL.res -------------------------------------------------------------------------------- /Docs/DEC65.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Docs/DEC65.pdf -------------------------------------------------------------------------------- /Docs/PrivacyPolicy.txt: -------------------------------------------------------------------------------- 1 | This is the privacy policy for the DEC Cipher Demo and DEC Hash Demo applications. 2 | 3 | We, Team DEC, do not collect any data entered in these apps. 4 | The only information we get from using these apps is an anonymous statistic 5 | about how many users installed these apps. -------------------------------------------------------------------------------- /Docs/VersionHistory.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Docs/VersionHistory.pdf -------------------------------------------------------------------------------- /Install/SetIDEPaths.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory 6 | of this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | program SetIDEPaths; 18 | 19 | {$APPTYPE CONSOLE} 20 | 21 | {$R *.res} 22 | 23 | uses 24 | System.SysUtils, 25 | System.Win.Registry, 26 | System.Classes; 27 | 28 | var 29 | reg : TRegistry; 30 | IDEKeys : TStringList; 31 | PlatformKeys : TStringList; 32 | LibraryPaths : string; 33 | InstallDir : string; 34 | 35 | const 36 | IDERootKey = 'SOFTWARE\Embarcadero\BDS'; 37 | LibraryKey = 'Library'; 38 | LibraryPathValue = 'Search Path'; 39 | SourceDir = 'Source'; 40 | 41 | /// 42 | /// Determine installation directory relative to the path of this exe file 43 | /// 44 | function GetInstallPath: string; 45 | begin 46 | Result := ParamStr(0); 47 | Result := ExtractFilePath(result); 48 | Result := Result.TrimRight([System.SysUtils.PathDelim]); 49 | Result := Result.Remove(result.LastDelimiter(System.SysUtils.PathDelim)); 50 | Result := Result + System.SysUtils.PathDelim + SourceDir; 51 | end; 52 | 53 | /// 54 | /// Add the installation source directory to the library path of the currently 55 | /// processed platform 56 | /// 57 | procedure AddInstallDirToLibraryPath; 58 | begin 59 | LibraryPaths := reg.ReadString(LibraryPathValue); 60 | // Only add path if not already added 61 | if pos(InstallDir.ToLower, LibraryPaths.ToLower) = 0 then 62 | begin 63 | if LibraryPaths.EndsWith(';') then 64 | LibraryPaths := LibraryPaths + InstallDir 65 | else 66 | LibraryPaths := LibraryPaths + ';' + InstallDir; 67 | 68 | reg.WriteString(LibraryPathValue, LibraryPaths); 69 | WriteLn('Success'); 70 | end 71 | else 72 | WriteLn('Path exists already'); 73 | end; 74 | 75 | /// 76 | /// Add the library source path to all platforms of the currently processed 77 | /// IDE version 78 | /// 79 | /// 80 | /// List of all platform library keys for the IDE version to be processed 81 | /// 82 | /// 83 | /// IDE version of the IDE to be processed as part of a registry path 84 | /// 85 | procedure ProcessAllPlatforms(Platforms: TStringList; IDEVersion: string); 86 | var 87 | platf : string; 88 | begin 89 | Assert(Assigned(Platforms), 'Empty list of platforms passed'); 90 | Assert(IDEVersion <> '', 'Empty version number passed'); 91 | 92 | for platf in Platforms do 93 | begin 94 | Write('Platform: ', platf:15, ' '); 95 | 96 | if reg.OpenKey(IDERootKey + '\' + IDEVersion + '\' + LibraryKey + '\' + 97 | platf, false) then 98 | begin 99 | AddInstallDirToLibraryPath; 100 | reg.CloseKey; 101 | end 102 | else 103 | WriteLn('Failed (cannot open key)'); 104 | end; 105 | end; 106 | 107 | /// 108 | /// Process all RAD Studio IDEs found 109 | /// 110 | /// 111 | /// List of all IDE versions found 112 | /// 113 | procedure ProcessAllIDEs(IDEVersions: TStringList); 114 | var 115 | IDEVersion: string; 116 | begin 117 | Assert(Assigned(IDEVersions), 'Empty list of IDE versions passed'); 118 | 119 | 120 | for IDEVersion in IDEVersions do 121 | begin 122 | WriteLn; 123 | WriteLn('RADStudio: ' + IDEVersion); 124 | 125 | // Skip versions older than D2009 126 | if (StrToFloat(IDEVersion, TFormatSettings.Create('en-US')) >= 6.0) then 127 | begin 128 | // Fetch all platforms for the currently processed IDE version 129 | if reg.OpenKey(IDERootKey + '\' + IDEVersion + '\' + LibraryKey, false) then 130 | begin 131 | PlatformKeys := TStringList.Create; 132 | try 133 | reg.GetKeyNames(PlatformKeys); 134 | reg.CloseKey; 135 | 136 | ProcessAllPlatforms(PlatformKeys, IDEVersion); 137 | finally 138 | PlatformKeys.Free; 139 | end; 140 | end 141 | else 142 | WriteLn('No platforms found'); 143 | end 144 | else 145 | WriteLn('Versions prior to D2009 are not supported'); 146 | end; 147 | end; 148 | 149 | begin 150 | try 151 | WriteLn('Adding DEC library paths to RAD Studio'); 152 | 153 | InstallDir := GetInstallPath; 154 | WriteLn('Path to add: ', InstallDir); 155 | 156 | // Fetch all RADStudio/Delphi/C++ Builder installations 157 | reg := TRegistry.Create; 158 | if reg.OpenKey(IDERootKey, false) then 159 | begin 160 | IDEKeys := TStringList.Create; 161 | try 162 | reg.GetKeyNames(IDEKeys); 163 | reg.CloseKey; 164 | 165 | if IDEKeys.Count > 0 then 166 | ProcessAllIDEs(IDEKeys) 167 | else 168 | WriteLn('No IDE versions found'); 169 | finally 170 | IDEKeys.Free; 171 | end; 172 | end 173 | else 174 | WriteLn('No RAD Studio installation found'); 175 | except 176 | on E: Exception do 177 | Writeln(E.ClassName, ': ', E.Message); 178 | end; 179 | 180 | WriteLn(''); 181 | WriteLn('Press enter to quit and then restart IDE'); 182 | ReadLn; 183 | end. 184 | -------------------------------------------------------------------------------- /Install/SetIDEPaths.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Install/SetIDEPaths.res -------------------------------------------------------------------------------- /Install/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains a utility to be used for 2 | setting up the library search path in the 3 | RAD Studio/Delphi/C++ Builder IDE. Do not run after 4 | installing DEC via GetIt or for Lazarus. 5 | 6 | For installation instructions see documentation 7 | contained in docs directory! -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | DEC - Delphi Encryption Compendium 2 | Version 6.5 3 | 4 | Copyright (c) 2018 - 2020 Norman Gallery (ng931884 [at] gmx [dot] de) 5 | Copyright (c) 2016 - 2024 Markus Humm (markus [dot] humm [at] googlemail [dot] com) (main contact) 6 | Copyright (c) 2008 - 2019 Frederik A. Winkelsdorf (winkelsdorf [at] gmail [dot] com) 7 | Copyright (c) 1999 - 2008 Hagen Reddmann (HaReddmann [at] T-Online [dot] de) 8 | 9 | This software is licensed to you under the Apache License 2.0. 10 | A copy of the license text can be found in the LICENSE.txt file in this project or 11 | alternatively at http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | The DEC team wishes to thank the following other people for their contributions: 14 | 15 | Andreas Hausladen 16 | Remy Lebeau 17 | himitsu 18 | NamenLozer 19 | Sebastian Jänicke 20 | Kas Ob. 21 | jaclas 22 | mknox74 23 | EdAdvokat 24 | Michael II 25 | jbg 26 | Gloegg 27 | pierangelodalben 28 | denovosoftware 29 | alexrayne 30 | Stevie 31 | danielmarschall 32 | Christoph Schneider (Schneider Infosystems AG) 33 | 34 | Parts of the work loosely based on the works of Wolfgang Erhardt, who is 35 | unfortunately dead already. 36 | 37 | The SHA3 permutation kernel used is original copyright by Eric Grange and used 38 | with his permission. Most parts of the Base32 implementation are based on his 39 | as well with minor parts taken from the one of Darian Miller. 40 | 41 | 42 | *** Export/Import Controls *** 43 | 44 | This is cryptographic software. Even if it is created, maintained and 45 | distributed from liberal countries in Europe (where it is legal to do this), 46 | it falls under certain export/import and/or use restrictions in some other 47 | parts of the world. 48 | 49 | PLEASE REMEMBER THAT EXPORT/IMPORT AND/OR USE OF STRONG CRYPTOGRAPHY 50 | SOFTWARE OR EVEN JUST COMMUNICATING TECHNICAL DETAILS ABOUT CRYPTOGRAPHY 51 | SOFTWARE IS ILLEGAL IN SOME PARTS OF THE WORLD. SO, WHEN YOU IMPORT THIS 52 | PACKAGE TO YOUR COUNTRY, RE-DISTRIBUTE IT FROM THERE OR EVEN JUST EMAIL 53 | TECHNICAL SUGGESTIONS OR EVEN SOURCE PATCHES TO THE AUTHOR OR OTHER PEOPLE 54 | YOU ARE STRONGLY ADVISED TO PAY CLOSE ATTENTION TO ANY EXPORT/IMPORT AND/OR 55 | USE LAWS WHICH APPLY TO YOU. THE AUTHORS OF DEC ARE NOT LIABLE FOR ANY 56 | VIOLATIONS YOU MAKE HERE. SO BE CAREFUL, IT IS YOUR RESPONSIBILITY. 57 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | The following versions are currently supported with security fixes: 6 | 7 | | Version | Supported | 8 | | -------- | ------------------ | 9 | | 6.4 | :white_check_mark: | 10 | 11 | ## Reporting a Vulnerability 12 | 13 | If you think you identified a security vulnerability in DEC 14 | please write an e-mail to the person listed as main contact in notice.txt 15 | and report the issue with as much detail as possible. 16 | 17 | For instace add these details: 18 | 19 | * description of the issue 20 | * circumstances under which the issue occurs 21 | * steps to reproduce the issue 22 | * Delphi or FPC version used 23 | * if possible supply a small demo application showing the issue 24 | * if you have any idea about how to fix it feel free to suggest it 25 | -------------------------------------------------------------------------------- /Source/BuildAll.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cls 3 | setlocal enableextensions 4 | setlocal enabledelayedexpansion 5 | 6 | echo. 7 | echo Compiles for all Delphis in %ProgramFiles(x86)%\Embarcadero 8 | echo TODO : switch to paths read out of registry 9 | echo HKCU\Software\Embarcadero\BDS\*.0 : RootDir 10 | echo. 11 | echo Compiles as well for Lazarus/FPC in C:\lazarus 12 | echo. 13 | echo creates one directory per DelphiVersion+ProjectConfig with the DCUs 14 | echo ..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_$(Config) 15 | echo. 16 | 17 | title CLEAR 18 | echo. 19 | echo ##### CLEAR ##### 20 | echo. 21 | echo delete "..\Compiled" 22 | echo. 23 | del "%~dpn0.log" 24 | rd /s /q "%~dp0..\Compiled" 25 | 26 | cd /d "%ProgramFiles(x86)%\Embarcadero" 27 | for /r %%X in (rsvars*.bat) do call :run_compiler "%%X" 28 | 29 | echo. 30 | title %comspec% 31 | type "%~dpn0.log" 32 | echo. 33 | find /c "FAIL " "%~dpn0.log" >nul 34 | if not errorlevel 1 pause 35 | exit /b 36 | 37 | 38 | :run_compiler 39 | title COMPILE 40 | echo. 41 | echo ##### %~dp1 ##### 42 | echo. 43 | 44 | setlocal 45 | call "%~1" 46 | set IDEVER=unknown 47 | for /f "delims=" %%E in ("%BDS%") do set IDEVER=%%~nxE 48 | echo. >> "%~dpn0.log" 49 | echo ### Delphi %IDEVER% ### >> "%~dpn0.log" 50 | echo. >> "%~dpn0.log" 51 | 52 | ::::: Lazarus-DCUs ::::: 53 | title COMPILE Lazarus x86_64 win64 : Source\DEC60Lazarus.lpk 54 | echo ### Lazarus x86_64 win64 # Source\DEC60Lazarus.lpk 55 | C:\lazarus\lazbuild.exe --build-all --cpu=x86_64 --build-mode=Default "%~dp0\DEC60Lazarus.lpk" 56 | if errorlevel 1 ( 57 | echo FAIL Source\DEC60Lazarus.lpk : x86_64 win64 >> "%~dpn0.log" 58 | rundll32 user32.dll,MessageBeep 59 | timeout 11 60 | ) else ( 61 | echo OK Source\DEC60Lazarus.lpk : x86_64 win64 >> "%~dpn0.log" 62 | ) 63 | echo. 64 | 65 | title COMPILE Lazarus i386 win32 : Source\DEC60Lazarus.lpk 66 | echo ### Lazarus i386 win32 # Source\DEC60Lazarus.lpk 67 | C:\lazarus\lazbuild.exe --build-all --cpu=i386 --build-mode=Default "%~dp0\DEC60Lazarus.lpk" 68 | if errorlevel 1 ( 69 | echo FAIL Source\DEC60Lazarus.lpk : i386 win32 >> "%~dpn0.log" 70 | rundll32 user32.dll,MessageBeep 71 | timeout 11 72 | ) else ( 73 | echo OK Source\DEC60Lazarus.lpk : i386 win32 >> "%~dpn0.log" 74 | ) 75 | echo. 76 | 77 | ::::: Delphi-DCUs ::::: 78 | for %%P in (Win32,Win64,Linux64,Android,Android64,iOSDevice64,iOSSimulator,OSX32,OSX64) do ( 79 | for %%C in (Debug,Release) do ( 80 | call :do_compile "Source\DEC60.dproj" %%P %%C 81 | ) 82 | ) 83 | 84 | ::::: TestApps ::::: 85 | echo. >> "%~dpn0.log" 86 | for %%P in (Win32) do ( 87 | for %%C in (Debug,Console) do ( 88 | call :do_compile "Unit Tests\DECDUnitTestSuite.dproj" %%P %%C 89 | ) 90 | for %%C in (Debug,GUI,MobileGUI,TestInsight) do ( 91 | call :do_compile "Unit Tests\DECDUnitXTestSuite.dproj" %%P %%C 92 | ) 93 | ) 94 | 95 | ::::: DemoApps ::::: 96 | echo. >> "%~dpn0.log" 97 | call :do_compile "Demos\Cipher_Console\Cipher_Console.dproj" 98 | call :do_compile "Demos\Cipher_FMX\Cipher_FMX.dproj" 99 | call :do_compile "Demos\Format_Console\Format_Console.dproj" 100 | call :do_compile "Demos\Hash_Console\Hash_Console.dproj" 101 | call :do_compile "Demos\Hash_FMX\Hash_FMX.dproj" 102 | call :do_compile "Demos\Progress_VCL\Progress_VCL.dproj" 103 | call :do_compile "Demos\Random_Console\Random_Console.dproj" 104 | call :do_compile "Demos\HashBenchmark_FMX\HashBenchmark.dproj" 105 | 106 | echo. >> "%~dpn0.log" 107 | title RUN Tests 108 | echo ##### RUN Tests ##### 109 | echo. 110 | REM for %%C in (Debug,Console,GUI) do ( 111 | REM for %%P in (Win32) do ( 112 | REM call :do_execute DECDUnitTestSuite.exe %%P %%C 113 | REM call :do_execute DECDUnitXTestSuite.exe %%P %%C 114 | REM ) 115 | REM ) 116 | call :do_execute DECDUnitTestSuite.exe Win32 Console 117 | call :do_execute DECDUnitTestSuite.exe Win32 Debug 118 | call :do_execute DECDUnitXTestSuite.exe Win32 Debug 119 | call :do_execute DECDUnitXTestSuite.exe Win32 GUI 120 | 121 | endlocal 122 | exit /b 123 | 124 | 125 | :do_compile 126 | title COMPILE %IDEVER% %2 %3 : %~1 127 | echo ### %IDEVER% %2 %3 # %~1 128 | set params= 129 | if not "%2" == "" set params=/p:Platform=%2 /p:Config=%3 130 | REM msbuild "%~dp0..\%~1" /t:Rebuild %params% :: $(ProductVersion) is missing in msbuild, but is present in InlineCompiler of the IDE 131 | msbuild "%~dp0..\%~1" /t:Rebuild %params% /p:ProductVersion=%IDEVER% 132 | if errorlevel 1 ( 133 | echo FAIL %~1 : %2 %3 >> "%~dpn0.log" 134 | rundll32 user32.dll,MessageBeep 135 | timeout 11 136 | ) else ( 137 | echo OK %~1 : %2 %3 >> "%~dpn0.log" 138 | ) 139 | :: remove dir if empty 140 | if not "%2" == "" ( 141 | rd /q "%~dp0..\Compiled\BIN_IDE%IDEVER%_%2_%3" >nul 142 | rd /q "%~dp0..\Compiled\DCP_IDE%IDEVER%_%2_%3" >nul 143 | rd /q "%~dp0..\Compiled\DCU_IDE%IDEVER%_%2_%3" >nul 144 | ) 145 | echo. 146 | exit /b 147 | 148 | 149 | :do_execute 150 | title EXECUTE %IDEVER% %2 %3 : %~1 151 | echo ### %IDEVER% %2 %3 # %~1 152 | "%~dp0..\Compiled\BIN_IDE%IDEVER%_%2_%3\%~1" 153 | set "ERR=%ERRORLEVEL% " 154 | echo RUN:%ERR:~0,6% %~1 : %2 %3 >> "%~dpn0.log" 155 | echo EXITCODE:%ERR% 156 | echo. 157 | exit /b -------------------------------------------------------------------------------- /Source/DEC60.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory 6 | of this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | // Simple project group for easier DEC development 19 | program DEC60; 20 | 21 | {$APPTYPE CONSOLE} 22 | 23 | {$R *.res} 24 | 25 | uses 26 | System.SysUtils, 27 | DECBaseClass in 'DECBaseClass.pas', 28 | DECCipherBase in 'DECCipherBase.pas', 29 | DECCipherFormats in 'DECCipherFormats.pas', 30 | DECCipherModes in 'DECCipherModes.pas', 31 | DECCipherInterface in 'DECCipherInterface.pas', 32 | DECCiphers in 'DECCiphers.pas', 33 | DECCRC in 'DECCRC.pas', 34 | DECData in 'DECData.pas', 35 | DECDataCipher in 'DECDataCipher.pas', 36 | DECDataHash in 'DECDataHash.pas', 37 | DECFormat in 'DECFormat.pas', 38 | DECFormatBase in 'DECFormatBase.pas', 39 | DECHash in 'DECHash.pas', 40 | DECHashBase in 'DECHashBase.pas', 41 | DECHashInterface in 'DECHashInterface.pas', 42 | DECRandom in 'DECRandom.pas', 43 | DECTypes in 'DECTypes.pas', 44 | DECUtil in 'DECUtil.pas', 45 | DECUtilRawByteStringHelper in 'DECUtilRawByteStringHelper.pas', 46 | DECHashAuthentication in 'DECHashAuthentication.pas', 47 | DECHashBitBase in 'DECHashBitBase.pas', 48 | DECCipherModesGCM in 'DECCipherModesGCM.pas', 49 | DECZIPHelper in 'DECZIPHelper.pas', 50 | DECCipherPaddings in 'DECCipherPaddings.pas'; 51 | 52 | begin 53 | try 54 | { TODO -oUser -cConsole Main : Insert code here } 55 | except 56 | on E: Exception do 57 | WriteLn(E.ClassName, ': ', E.Message); 58 | end; 59 | end. 60 | -------------------------------------------------------------------------------- /Source/DEC60.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/DEC60.res -------------------------------------------------------------------------------- /Source/DEC60.todo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Source/DEC60Complete_prjgroup.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Source/DEC60Lazarus.lpk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 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 | -------------------------------------------------------------------------------- /Source/DEC60Lazarus.pas: -------------------------------------------------------------------------------- 1 | { This file was automatically created by Lazarus. Do not edit! 2 | This source is only used to compile and install the package. 3 | } 4 | 5 | unit DEC60Lazarus; 6 | 7 | {$warn 5023 off : no warning about unused units} 8 | interface 9 | 10 | uses 11 | DECBaseClass, DECCipherBase, DECCipherFormats, DECCipherInterface, 12 | DECCipherModes, DECCiphers, DECCRC, DECData, DECDataCipher, DECDataHash, 13 | DECFormat, DECFormatBase, DECHash, DECHashBase, DECHashInterface, DECRandom, 14 | DECTypes, DECUtil, DECUtilRawByteStringHelper; 15 | 16 | implementation 17 | 18 | end. -------------------------------------------------------------------------------- /Source/DEC60_project.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Source/DECCRC.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/DECCRC.pas -------------------------------------------------------------------------------- /Source/DECCiphers.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/DECCiphers.pas -------------------------------------------------------------------------------- /Source/DECHashBitBase.pas: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory 6 | of this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Base unit for all the hash algorithms which can operate on bit sized 20 | /// messsages as well. 21 | /// 22 | unit DECHashBitBase; 23 | 24 | interface 25 | 26 | {$INCLUDE DECOptions.inc} 27 | 28 | uses 29 | {$IFDEF FPC} 30 | SysUtils, Classes, 31 | {$ELSE} 32 | System.SysUtils, System.Classes, 33 | {$ENDIF} 34 | DECHashAuthentication, DECHashInterface, DECTypes; 35 | 36 | type 37 | /// 38 | /// Meta class for the class containing the additional property for hashes 39 | /// supporting a last byte with less than 8 bit size. 40 | /// 41 | TDECHashBitClass = class of TDECHashBit; 42 | 43 | /// 44 | /// Base class for all hash algorithms which can operate on bit sized 45 | /// messsages as well. 46 | /// 47 | TDECHashBit = class(TDECHashExtended, IDECHashBitsized) 48 | strict private 49 | /// 50 | /// Returns the number of bits the final byte of the message consists of 51 | /// 52 | function GetFinalByteLength: UInt8; 53 | /// 54 | /// Sets the number of bits the final byte of the message consists of 55 | /// 56 | /// 57 | /// Exception raised if Value is higher than 7. 58 | /// 59 | procedure SetFinalByteLength(const Value: UInt8); 60 | public 61 | /// 62 | /// Setting this to a number of bits allows to process messages which have 63 | /// a length which is not a exact multiple of bytes. 64 | /// 65 | /// 66 | /// Exception raised if Value is higher than 7. 67 | /// 68 | property FinalByteLength : UInt8 69 | read GetFinalByteLength 70 | write SetFinalByteLength; 71 | end; 72 | 73 | implementation 74 | 75 | resourcestring 76 | /// 77 | /// Exception message for the exception raised when a to long final byte 78 | /// length is specified. 79 | /// 80 | rFinalByteLengthTooBig = 'Final byte length too big (%0:d) must be 0..7'; 81 | 82 | { TDECHashBit } 83 | 84 | function TDECHashBit.GetFinalByteLength: UInt8; 85 | begin 86 | Result := FFinalByteLength; 87 | end; 88 | 89 | procedure TDECHashBit.SetFinalByteLength(const Value: UInt8); 90 | begin 91 | // if length of final byte is 8 this value shall be 0 as the normal specification 92 | // of message length is good enough then. 93 | 94 | if (Value > 7) then 95 | raise EDECHashException.CreateResFmt(@rFinalByteLengthTooBig, [Value]); 96 | 97 | FFinalByteLength := Value; 98 | end; 99 | 100 | end. 101 | -------------------------------------------------------------------------------- /Source/DECTypes.pas: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory 6 | of this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Declarations of various datatypes, some of those have not been 20 | /// declared for certain platforms but are used in DEC and some do change 21 | /// meanings between platforms like PLongWord where LongWord is 32 bit on 22 | /// Windows and Android but 64 bit on iOS for instance 23 | /// 24 | unit DECTypes; 25 | 26 | interface 27 | 28 | {$INCLUDE DECOptions.inc} 29 | 30 | uses 31 | {$IFDEF FPC} 32 | SysUtils; 33 | {$ELSE} 34 | System.SysUtils; 35 | {$ENDIF} 36 | 37 | type 38 | /// 39 | /// Replacement for PByteArray 40 | /// 41 | PUInt8Array = ^TInt8Array; 42 | TInt8Array = array[0..MaxInt-1] of Byte; 43 | 44 | PUInt32Array = ^TUInt32Array; 45 | TUInt32Array = array[0..1023] of UInt32; 46 | 47 | /// 48 | /// Replacement for PLongWord, as LongWord changes between platforms from 49 | /// 32 to 64 bit 50 | /// 51 | PUInt32 = ^UINT32; 52 | 53 | PUInt64Array = ^TUInt64Array; 54 | TUInt64Array = array[0..1023] of UInt64; 55 | 56 | /// 57 | /// Declared here because it is used by Blowfish cipher and BCrypt hash 58 | /// 59 | PBlowfish = ^TBlowfishMatrix; 60 | TBlowfishMatrix = array[0..3, 0..255] of UInt32; 61 | TBlowfishKey = array[0..17] of UInt32; 62 | 63 | /// 64 | /// List of standard bit lengths defined in the official standard for some 65 | /// algorithm property which allows a variable bit length. 66 | /// 67 | TStandardBitLengths = array of UInt16; 68 | 69 | /// 70 | /// Reason for calling the progress event 71 | /// 72 | TDECProgressState = (Started, Processing, Finished); 73 | 74 | /// 75 | /// Event type used by several hash- and cipher methods to display their 76 | /// progress. It can be implemented as regular method, procedure and as 77 | /// anonymous method, means: in place. 78 | /// 79 | /// 80 | /// Number of bytes to process. For files this is usually the file size. For 81 | /// streams this can be less than the stream size if the stream is not being 82 | /// processed from the beginning. 83 | /// 84 | /// 85 | /// Position within size in byte. For streams this may be a position 86 | /// relative to the starting position for processing. 87 | /// 88 | {$ifdef HAVE_LAMBDAS} 89 | TDECProgressEvent = reference to procedure(Size, Pos: Int64; State: TDECProgressState); 90 | {$else} 91 | TDECProgressEvent = procedure(Size, Pos: Int64; State: TDECProgressState); 92 | {$endif} 93 | 94 | // Exception Classes 95 | 96 | /// 97 | /// Base exception class for all DEC specific exceptions, 98 | /// 99 | EDECException = class(Exception) 100 | public 101 | {$IFDEF FMXTranslateableExceptions} 102 | /// 103 | /// Creates the exception instance and makes the exception message translateable 104 | /// via Firemonkey's TLang translation mechanism. Normal ressource strings 105 | /// are not translated in the same way on mobile platforms as they are on 106 | /// Win32/Win64. 107 | /// 108 | /// 109 | /// String with a failure message to be output or logged 110 | /// 111 | constructor Create(const Msg: string); reintroduce; overload; 112 | /// 113 | /// Creates the exception instance and makes the exception message translateable 114 | /// via Firemonkey's TLang translation mechanism. Normal ressource strings 115 | /// are not translated in the same way on mobile platforms as they are on 116 | /// Win32/Win64. 117 | /// 118 | /// 119 | /// String with a failure message to be output or logged 120 | /// 121 | /// 122 | /// Array with values for the parameters specified in the format string 123 | /// 124 | constructor CreateFmt(const Msg: string; 125 | const Args: array of const); reintroduce; overload; 126 | {$ENDIF} 127 | end; 128 | 129 | /// 130 | /// Exception class used when reporting that a class searched in a list is 131 | /// not contained in that list, e.g. when searching for a non existant 132 | /// formatting class. 133 | /// 134 | EDECClassNotRegisteredException = class(EDECException); 135 | /// 136 | /// Exception class for reporting formatting related exceptions 137 | /// 138 | EDECFormatException = class(EDECException); 139 | /// 140 | /// Exception class for reporting exceptions related to hash functions 141 | /// 142 | EDECHashException = class(EDECException); 143 | /// 144 | /// Exception class for reporting encryption/decryption caused exceptions 145 | /// 146 | EDECCipherException = class(EDECException); 147 | /// 148 | /// Exception class for reporting calculation of a wrong authentication 149 | /// value when decrypting using a cipher supporting authentication 150 | /// 151 | EDECCipherAuthenticationException = class(EDECException); 152 | 153 | /// 154 | /// Exception class for reporting the use of abstract things which cannot 155 | /// be called directly 156 | /// 157 | EDECAbstractError = class(EDECException) 158 | /// 159 | /// Create the exception using a meaningfull error message 160 | /// 161 | constructor Create(ClassName: string); overload; 162 | end; 163 | 164 | const 165 | { TODO : Check why this is a constant, which is immediately used by the 166 | resource string. Is this because of the lack of resource string support 167 | of FMX on some platforms?} 168 | cAbstractError = 'Abstract Error: %s is not implemented'; 169 | 170 | resourcestring 171 | sAbstractError = cAbstractError; 172 | 173 | implementation 174 | 175 | { EDECException } 176 | 177 | {$IFDEF FMXTranslateableExceptions} 178 | constructor EDECException.Create(const Msg: string); 179 | begin 180 | inherited Create(Translate(msg)); 181 | end; 182 | 183 | constructor EDECException.CreateFmt(const Msg: string; 184 | const Args: array of const); 185 | begin 186 | inherited Create(Format(Translate(Msg), Args)); 187 | end; 188 | 189 | constructor EDECAbstractError.Create(ClassName: string); 190 | begin 191 | inherited Create(Format(Translate(sAbstractError), [ClassName])); 192 | end; 193 | {$ELSE} 194 | constructor EDECAbstractError.Create(ClassName: string); 195 | begin 196 | inherited CreateResFmt(@sAbstractError, [ClassName]); 197 | end; 198 | {$ENDIF} 199 | 200 | end. 201 | -------------------------------------------------------------------------------- /Source/DECUtilRawByteStringHelper.pas: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | unit DECUtilRawByteStringHelper; 18 | 19 | interface 20 | 21 | {$INCLUDE DECOptions.inc} 22 | 23 | /// 24 | /// System.pas does not contain a RawByteString compatible version of this 25 | /// routine so we created our own, copying and adapting code from system.pas 26 | /// for the NextGen compiler and using a solution from Remy Lebeau for the 27 | /// Win32/Win64 compiler. 28 | /// 29 | /// 30 | /// String to be processed 31 | /// 32 | procedure UniqueString(var Str: RawByteString); 33 | 34 | implementation 35 | 36 | uses 37 | {$IFDEF FPC} 38 | SysUtils; 39 | {$ELSE} 40 | System.SysUtils; 41 | {$ENDIF} 42 | 43 | type 44 | // Duplicate of the System.pas internal declaration. Needs to be kept in sync. 45 | PStrRec = ^StrRec; 46 | StrRec = packed record 47 | {$IFDEF CPU64BITS} 48 | _Padding: Integer; // Make 16 byte align for payload.. 49 | {$ENDIF} 50 | codePage: Word; 51 | elemSize: Word; 52 | refCnt: Integer; 53 | length: Integer; 54 | end; 55 | 56 | function _NewAnsiString(CharLength: Integer; CodePage: Word): Pointer; 57 | var 58 | P: PStrRec; 59 | begin 60 | Result := nil; 61 | if CharLength > 0 then 62 | begin 63 | // Alloc an extra null for strings with even length. This has no actual 64 | // cost since the allocator will round up the request to an even size 65 | // anyway. All _WideStr allocations have even length, and need a double 66 | // null terminator. 67 | if CharLength >= MaxInt - SizeOf(StrRec) then 68 | raise EIntOverflow.Create( 69 | 'IntOverflow in _NewAnsiString. CharLength: ' + IntToStr(CharLength)); 70 | 71 | GetMem(P, CharLength + SizeOf(StrRec) + 1 + ((CharLength + 1) and 1)); 72 | Result := Pointer(PByte(P) + SizeOf(StrRec)); 73 | P.length := CharLength; 74 | P.refcnt := 1; 75 | if CodePage = 0 then 76 | {$IFDEF NEXTGEN} 77 | CodePage := Word(CP_UTF8); 78 | {$ELSE NEXTGEN} 79 | CodePage := Word(DefaultSystemCodePage); 80 | {$ENDIF NEXTGEN} 81 | P.codePage := CodePage; 82 | P.elemSize := 1; 83 | PWideChar(Result)[CharLength div 2] := #0; // length guaranteed >= 2 84 | end; 85 | end; 86 | 87 | function _LStrClr(var S): Pointer; 88 | var 89 | P: PStrRec; 90 | begin 91 | if Pointer(S) <> nil then 92 | begin 93 | P := Pointer(PByte(S) - SizeOf(StrRec)); 94 | Pointer(S) := nil; 95 | if P.refCnt > 0 then 96 | begin 97 | {$IFDEF FPC} 98 | if InterlockedDecrement(P.refCnt) = 0 then 99 | {$ELSE} 100 | {$IF CompilerVersion >= 24.0} 101 | if AtomicDecrement(P.refCnt) = 0 then 102 | {$ELSE} 103 | Dec(P.refCnt); 104 | if (P.refCnt = 0) then 105 | {$IFEND} 106 | {$ENDIF} 107 | FreeMem(P); 108 | end; 109 | end; 110 | Result := @S; 111 | end; 112 | 113 | function InternalUniqueStringA(var Str: RawByteString): Pointer; 114 | var 115 | P: PStrRec; 116 | begin 117 | Result := Pointer(Str); 118 | if Result <> nil then 119 | begin 120 | Result := Pointer(Str); 121 | P := Pointer(PByte(Str) - sizeof(StrRec)); 122 | if P.refCnt <> 1 then 123 | begin 124 | Result := _NewAnsiString(P.length, P.codePage); 125 | Move(Pointer(Str)^, Pointer(Result)^, P.length); 126 | _LStrClr(Str); 127 | Pointer(Str) := Result; 128 | end; 129 | end; 130 | end; 131 | 132 | procedure UniqueString(var Str: RawByteString); 133 | begin 134 | InternalUniqueStringA(Str); 135 | end; 136 | 137 | end. 138 | -------------------------------------------------------------------------------- /Source/DECZIPHelper.pas: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Routines etc. for use with encrypted ZIP files 20 | /// 21 | unit DECZIPHelper; 22 | 23 | interface 24 | 25 | uses 26 | DECCiphers, 27 | DECCipherFormats; 28 | 29 | /// 30 | /// Creates an instance for encrypting or decrypting the algorithm specified 31 | /// by the ZIP Algorithm ID documented in chapter 7.2.3.2 found in 32 | /// https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT 33 | /// 34 | /// 35 | /// Unique ID for a crypto algorithm as specified in the documentation 36 | /// 37 | /// 38 | /// Created instance of the cipher class 39 | /// 40 | /// 41 | /// Exception raised if called with an unknown/unsupported AlgorithmID 42 | /// 43 | function CreateZIPCryptoAlgorithmInstance(AlgorithmID: UInt16):TDECFormattedCipher; 44 | 45 | resourcestring 46 | /// 47 | /// Exception text for attempts to create an instance for an unknown 48 | /// algorithm ID 49 | /// 50 | rUnknownZIPAlgorithmID = 'Unknown ZIP cypher algorithm ID %0:d'; 51 | 52 | implementation 53 | 54 | uses 55 | System.SysUtils, 56 | DECTypes, 57 | DECCipherBase; 58 | 59 | function CreateZIPCryptoAlgorithmInstance(AlgorithmID: UInt16):TDECFormattedCipher; 60 | begin 61 | case AlgorithmID of 62 | $6601 : Result := TCipher_1DES.Create; 63 | // $6602 : Result := TCipher_RC2.Create; // (version needed to extract < 5.2) 64 | // // This has to do with a faulty RC2 65 | // // implementation in XP SP1 and earlier 66 | // // Unsupported as we do not know the 67 | // // details of the fault 68 | $6603 : Result := TCipher_3DES.Create; // 3DES 168 69 | $6609 : Result := TCipher_2DES.Create; // 3DES 112 70 | $660E : Result := TCipher_AES128.Create; 71 | $660F : Result := TCipher_AES192.Create; 72 | $6610 : Result := TCipher_AES256.Create; 73 | $6702 : Result := TCipher_RC2.Create; // (version needed to extract >= 5.2) 74 | $6720 : Result := TCipher_Blowfish.Create; 75 | $6721 : Result := TCipher_Twofish.Create; 76 | $6801 : Result := TCipher_RC4.Create; 77 | $FFFF : raise EDECClassNotRegisteredException.CreateResFmt(@rUnknownZIPAlgorithmID, 78 | [AlgorithmID]); 79 | else 80 | raise EDECClassNotRegisteredException.CreateResFmt(@rUnknownZIPAlgorithmID, 81 | [AlgorithmID]); 82 | end; 83 | 84 | Result.Mode := cmCBCx; // as per ZIP documentation the only supported mode 85 | end; 86 | 87 | end. 88 | -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/DECBaseClass/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/DECBaseClass/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/GUITestRunner/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/GUITestRunner/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/SysInit/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/SysInit/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/System/Classes/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/System/Classes/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/System/Generics/Collections/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/System/Generics/Collections/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/System/Generics/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/System/Generics/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/System/SysUtils/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/System/SysUtils/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/System/TypInfo/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/System/TypInfo/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/System/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/System/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/TestFramework/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/TestFramework/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/TextTestRunner/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/TextTestRunner/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/Vcl/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/Vcl/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/Winapi/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/Winapi/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Source/LibrarySupport/DelphiWin32/default.txaPackage -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Source/LibrarySupport/DelphiWin32/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Source/SearchPaths-Demo.optset: -------------------------------------------------------------------------------- 1 |  2 | 3 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 4 | .\..\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)__Demos 5 | .\..\..\Compiled\BIN_IDExx.x_$(Platform)__Demos 6 | .\..\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 7 | .\..\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)__Demos 8 | .\..\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 9 | .\..\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_$(Config);$(DCC_UnitSearchPath) 10 | .\..\..\Compiled\BIN_IDExx.x_$(Platform)__Demos 11 | .\..\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 12 | 1031 13 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 14 | 15 | 16 | 17 | Delphi.Personality.12 18 | OptionSet 19 | 20 | 21 | 22 | 12 23 | 24 | 25 | -------------------------------------------------------------------------------- /Source/SearchPaths-Source.optset: -------------------------------------------------------------------------------- 1 |  2 | 3 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 4 | .\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_$(Config) 5 | .\..\Compiled\BIN_IDE$(ProductVersion)_$(Platform)_$(Config) 6 | .\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 7 | .\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_$(Config) 8 | .\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 9 | .\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_$(Config);$(DCC_UnitSearchPath) 10 | .\..\Compiled\BIN_IDE$(ProductVersion)_$(Platform)_$(Config) 11 | .\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 12 | 1031 13 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 14 | DEC60 15 | 16 | 17 | Delphi.Personality.12 18 | OptionSet 19 | 20 | 21 | 22 | 12 23 | 24 | 25 | -------------------------------------------------------------------------------- /Source/SearchPaths-Test.optset: -------------------------------------------------------------------------------- 1 |  2 | 3 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 4 | .\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)__Demos 5 | .\..\Compiled\BIN_IDE$(ProductVersion)_$(Platform)_$(Config) 6 | .\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 7 | .\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)__Demos 8 | .\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 9 | .\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_$(Config);.\..\Compiled\DCU_IDE$(ProductVersion)_$(Platform)_Debug;$(DCC_UnitSearchPath) 10 | .\..\Compiled\BIN_IDE$(ProductVersion)_$(Platform)_$(Config) 11 | .\..\Compiled\DCP_IDE$(ProductVersion)_$(Platform)_$(Config) 12 | 1031 13 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 14 | DECDUnitTestSuite 15 | 16 | 17 | Delphi.Personality.12 18 | OptionSet 19 | 20 | 21 | 22 | 12 23 | 24 | 25 | -------------------------------------------------------------------------------- /Source/fpc/DECUtil.inc: -------------------------------------------------------------------------------- 1 | 2 | {$define SwapUInt32_asm} 3 | function SwapUInt32(Source: UInt32): UInt32; 4 | begin 5 | result := SwapEndian(Source); 6 | end; 7 | 8 | {$define SwapInt64_asm} 9 | function SwapInt64(Source: Int64): Int64; 10 | begin 11 | result := SwapEndian(Source); 12 | end; 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/fpc/dec.lpk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 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 | 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 | -------------------------------------------------------------------------------- /Source/fpc/dec.pas: -------------------------------------------------------------------------------- 1 | { This file was automatically created by Lazarus. Do not edit! 2 | This source is only used to compile and install the package. 3 | } 4 | 5 | unit DEC; 6 | 7 | {$warn 5023 off : no warning about unused units} 8 | interface 9 | 10 | uses 11 | DECCRC, DECData, DECHash, DECRandom, DECUtil, DECBaseClass, DECCipherBase, 12 | DECCipherFormats, DECCipherInterface, DECCipherModes, DECCipherModesGCM, 13 | DECCiphers, DECDataCipher, DECDataHash, DECFormat, DECFormatBase, 14 | DECHashAuthentication, DECHashBase, DECHashBitBase, DECHashInterface, 15 | DECTypes, DECUtilRawByteStringHelper; 16 | 17 | implementation 18 | 19 | end. 20 | -------------------------------------------------------------------------------- /Source/x86/DECUtil.inc: -------------------------------------------------------------------------------- 1 | {$ifdef FPC} 2 | {$ASMMODE intel} 3 | {$endif} 4 | 5 | {$ifndef SwapUInt32_asm} 6 | {$define SwapUInt32_asm} 7 | function SwapUInt32(Source: UInt32): UInt32; 8 | asm 9 | BSWAP EAX 10 | end; 11 | {$endif} 12 | 13 | {$ifndef SwapInt64_asm} 14 | {$define SwapInt64_asm} 15 | function SwapInt64(Source: Int64): Int64; 16 | asm 17 | MOV EDX,Source.DWord[0] 18 | MOV EAX,Source.DWord[4] 19 | BSWAP EDX 20 | BSWAP EAX 21 | end; 22 | {$endif} 23 | 24 | -------------------------------------------------------------------------------- /Source/x86_64/DECUtil.inc: -------------------------------------------------------------------------------- 1 | {$ifdef FPC} 2 | {$ASMMODE intel} 3 | {$endif} 4 | 5 | {$ifndef SwapUInt32_asm} 6 | {$define SwapUInt32_asm} 7 | function SwapUInt32(Source: UInt32): UInt32; 8 | asm 9 | MOV RAX, Source 10 | BSWAP RAX 11 | SHR RAX, 32 12 | end; 13 | {$endif} 14 | 15 | {$ifndef SwapInt64_asm} 16 | {$define SwapInt64_asm} 17 | function SwapInt64(Source: Int64): Int64; 18 | asm 19 | MOV RAX, Source 20 | BSWAP RAX 21 | end; 22 | {$endif} 23 | 24 | 25 | -------------------------------------------------------------------------------- /Unit Tests/AndroidManifest.template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | <%uses-permission%> 12 | 13 | 21 | 22 | <%application-meta-data%> 23 | <%services%> 24 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | <%activity%> 39 | <%receivers%> 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/DECCodeCoverage.dccp: -------------------------------------------------------------------------------- 1 | 2 | 3 | V2.0.0 build 4 4 | 1 5 | 6 | 7 | D:\Projekte\DECGitMaster\Source\ 8 | DEC60Lazarus.pas 9 | DECBaseClass.pas 10 | DECCipherBase.pas 11 | DECCipherFormats.pas 12 | DECCipherInterface.pas 13 | DECCipherModes.pas 14 | DECCipherModesGCM.pas 15 | DECCiphers.pas 16 | DECCRC.pas 17 | DECData.pas 18 | DECDataCipher.pas 19 | DECDataHash.pas 20 | DECFormat.pas 21 | DECFormatBase.pas 22 | DECHash.pas 23 | DECHashAuthentication.pas 24 | DECHashBase.pas 25 | DECHashBitBase.pas 26 | DECHashInterface.pas 27 | DECRandom.pas 28 | DECTypes.pas 29 | DECUtil.pas 30 | DECUtilRawByteStringHelper.pas 31 | 0 32 | 33 | 34 | ofHTML 35 | D:\Projekte\DECGitMaster\Unit Tests\CodeCoverage 36 | D:\Projekte\DECGitMaster\Unit Tests\CodeCoverage\Output 37 | False 38 | False 39 | False 40 | False 41 | False 42 | False 43 | 44 | 45 | D:\Projekte\DECGitMaster\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.exe 46 | 47 | False 48 | D:\Projekte\DECGitMaster\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.map 49 | D:\Projekte\DelphiCodeCoverageWizardNew\Binaries\CodeCoverage.exe 50 | 51 | 52 | True 53 | 54 | 0 55 | True 56 | False 57 | False 58 | 59 | 60 | -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/DECCodeCoverage_dcov_execute.bat: -------------------------------------------------------------------------------- 1 | "..\..\..\DelphiCodeCoverageWizardNew\Binaries\CodeCoverage.exe" -e "..\..\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.exe" -m "..\..\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.map" -sd "..\..\Source\" -ife -uf "DECCodeCoverage_dcov_units.lst" -spf "DECCodeCoverage_dcov_paths.lst" -od "Output" -v -lt "Output\DECCodeCoverage_DelphiCodeCoverageDebug.log" -html -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/DECCodeCoverage_dcov_paths.lst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/CodeCoverage/DECCodeCoverage_dcov_paths.lst -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/DECCodeCoverage_dcov_units.lst: -------------------------------------------------------------------------------- 1 | DEC60Lazarus 2 | DECBaseClass 3 | DECCipherBase 4 | DECCipherFormats 5 | DECCipherInterface 6 | DECCipherModes 7 | DECCipherModesGCM 8 | DECCiphers 9 | DECCRC 10 | DECData 11 | DECDataCipher 12 | DECDataHash 13 | DECFormat 14 | DECFormatBase 15 | DECHash 16 | DECHashAuthentication 17 | DECHashBase 18 | DECHashBitBase 19 | DECHashInterface 20 | DECRandom 21 | DECTypes 22 | DECUtil 23 | DECUtilRawByteStringHelper 24 | -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/Output/CodeCoverage_summary.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Delphi CodeCoverage Coverage Report 6 | 44 | 45 | 46 |

Summary Coverage Report

47 |

Generated at 30.11.2022 22:06:19 by DelphiCodeCoverage - an open source tool for Delphi Code Coverage.

48 |

Aggregate statistics for all modules

50 |
Unit NameNumber of linesPercent(s) covered
CoveredNot CoveredWhich generated code 49 |
DECBaseClass62062100.0 % 51 |
DECCipherBase1334417775.1 % 52 |
DECCipherFormats1512017188.3 % 53 |
DECCipherModes3827545783.6 % 54 |
DECCipherModesGCM123312697.6 % 55 |
DECCiphers3147110325796.6 % 56 |
DECCRC150515596.8 % 57 |
DECFormat7271374098.2 % 58 |
DECFormatBase971711485.1 % 59 |
DECHash261920263999.2 % 60 |
DECHashAuthentication3042933391.3 % 61 |
DECHashBase1521917188.9 % 62 |
DECHashBitBase808100.0 % 63 |
DECRandom9139496.8 % 64 |
DECTypes303100.0 % 65 |
DECUtil1160116100.0 % 66 |
DECUtilRawByteStringHelper3443889.5 % 67 |
Aggregated for all units8299362866195.8 % 68 |
69 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/U/CodeCoverage_summary.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Delphi CodeCoverage Coverage Report 6 | 32 | 33 | 34 |

Summary Coverage Report

35 |

Generated at 29.10.2021 18:49:29 by DelphiCodeCoverage - an open source tool for Delphi Code Coverage.

36 |

Aggregate statistics for all modules

37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
Unit NameNumber of covered linesNumber of lines (which generated code)Percent(s) covered
DECBaseClass7878100%
DECCipherBase13317775%
DECCipherFormats14116187%
DECCipherModes37845782%
DECCipherModesGCM12012397%
DECCiphers3260337096%
DECCRC22524492%
DECFormat57859297%
DECFormatBase9711485%
DECHash293962941499%
DECHashAuthentication17717998%
DECHashBase18621686%
DECHashBitBase88100%
DECRandom919496%
DECTypes030%
DECUtil146146100%
DECUtilRawByteStringHelper343889%
Aggregated for all units350483541498%
58 | 59 | 60 | -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/U/DECBaseClass.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Delphi CodeCoverage Coverage Report 6 | 32 | 33 | 34 |

Coverage report for DECBaseClass.

35 |

Generated at 29.10.2021 18:49:29 by DelphiCodeCoverage - an open source tool for Delphi Code Coverage.

36 |

Aggregate statistics for all units

37 | 38 | 39 | 40 | 41 | 42 |
Source File NameNumber of covered linesNumber of lines (which generated code)Percent(s) covered
DECBaseClass.pas7777100%
System.Generics.Defaults.pas11100%
Aggregated for all files7878100%
43 | 44 | 45 | -------------------------------------------------------------------------------- /Unit Tests/CodeCoverage/U/DECHash.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Delphi CodeCoverage Coverage Report 6 | 32 | 33 | 34 |

Coverage report for DECHash.

35 |

Generated at 29.10.2021 18:49:30 by DelphiCodeCoverage - an open source tool for Delphi Code Coverage.

36 |

Aggregate statistics for all units

37 | 38 | 39 | 40 | 41 | 42 | 43 |
Source File NameNumber of covered linesNumber of lines (which generated code)Percent(s) covered
DECHash.asm86.inc2830828308100%
DECHash.pas75076897%
DECHash.sha3_mmx.inc338338100%
Aggregated for all files293962941499%
44 | 45 | 46 | -------------------------------------------------------------------------------- /Unit Tests/DECDUnitTestSuite.dpr: -------------------------------------------------------------------------------- 1 | program DECDUnitTestSuite; 2 | 3 | { 4 | 5 | Delphi DUnit Test Project 6 | ------------------------- 7 | This project contains the DUnit test framework and the GUI/Console test runners. 8 | Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options 9 | to use the console test runner. Otherwise the GUI test runner will be used by 10 | default. 11 | 12 | } 13 | 14 | {$IFDEF CONSOLE_TESTRUNNER} 15 | {$APPTYPE CONSOLE} 16 | {$ENDIF} 17 | 18 | uses 19 | Vcl.Forms, 20 | {$IFDEF TESTINSIGHT} 21 | TestInsight.Client, 22 | {$ELSE} 23 | TestFramework, 24 | GUITestRunner, 25 | TextTestRunner, 26 | {$ENDIF } 27 | TestDECUtil in 'Tests\TestDECUtil.pas', 28 | TestDECFormatBase in 'Tests\TestDECFormatBase.pas', 29 | TestDECFormat in 'Tests\TestDECFormat.pas', 30 | TestDECHash in 'Tests\TestDECHash.pas', 31 | TestDECHashKDF in 'Tests\TestDECHashKDF.pas', 32 | TestDECCRC in 'Tests\TestDECCRC.pas', 33 | TestDECCipher in 'Tests\TestDECCipher.pas', 34 | TestDECRandom in 'Tests\TestDECRandom.pas', 35 | TestDECCipherModes in 'Tests\TestDECCipherModes.pas', 36 | TestDECBaseClass in 'Tests\TestDECBaseClass.pas', 37 | TestDECTestDataContainer in 'Tests\TestDECTestDataContainer.pas', 38 | TestDECCipherFormats in 'Tests\TestDECCipherFormats.pas', 39 | TestDECHashMAC in 'Tests\TestDECHashMAC.pas', 40 | TestDECHashSHA3 in 'Tests\TestDECHashSHA3.pas', 41 | TestDECCipherModesGCM in 'Tests\TestDECCipherModesGCM.pas', 42 | TestDECZIPHelper in 'Tests\TestDECZIPHelper.pas', 43 | TestDECCipherPaddings in 'Tests\TestDECCipherPaddings.pas'; 44 | 45 | {$R *.RES} 46 | 47 | function IsTestInsightRunning: Boolean; 48 | {$IFDEF TESTINSIGHT} 49 | var 50 | client: ITestInsightClient; 51 | begin 52 | client := TTestInsightRestClient.Create; 53 | client.StartedTesting(0); 54 | Result := not client.HasError; 55 | end; 56 | {$ELSE} 57 | begin 58 | result := false; 59 | end; 60 | {$ENDIF} 61 | 62 | begin 63 | ReportMemoryLeaksOnShutdown := True; 64 | Application.Initialize; 65 | 66 | if IsTestInsightRunning then 67 | {$IFDEF TESTINSIGHT} 68 | TestInsight.DUnit.RunRegisteredTests 69 | {$ENDIF} 70 | else 71 | {$IFNDEF TESTINSIGHT} 72 | if IsConsole then 73 | TextTestRunner.RunRegisteredTests.Free 74 | else 75 | GUITestRunner.RunRegisteredTests; 76 | {$ENDIF} 77 | end. 78 | 79 | -------------------------------------------------------------------------------- /Unit Tests/DECDUnitTestSuite.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/DECDUnitTestSuite.res -------------------------------------------------------------------------------- /Unit Tests/DECDUnitTestSuite_project.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Unit Tests/DECDUnitXTestSuite.deployproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 12 5 | 6 | 7 | CB512EA59X 8 | 9 | 10 | 11 | DECDUnitXTestSuite\ 12 | DECOptions.inc 13 | ProjectFile 14 | 0 15 | 16 | 17 | True 18 | 19 | 20 | DECDUnitXTestSuite\ 21 | TestDefines.inc 22 | ProjectFile 23 | 0 24 | 25 | 26 | True 27 | 28 | 29 | DECDUnitXTestSuite\ 30 | DECDUnitXTestSuite.exe 31 | ProjectOutput 32 | 0 33 | 34 | 35 | True 36 | True 37 | 38 | 39 | 40 | 41 | 42 | DECDUnitXTestSuite\assets\internal\ 43 | TestDefines.inc 44 | ProjectFile 45 | 0 46 | 47 | 48 | True 49 | 50 | 51 | DECDUnitXTestSuite\ 52 | AndroidManifest.xml 53 | ProjectAndroidManifest 54 | 1 55 | 56 | 57 | True 58 | 59 | 60 | DECDUnitXTestSuite\library\lib\armeabi\ 61 | libDECDUnitXTestSuite.so 62 | AndroidLibnativeArmeabiFile 63 | 1 64 | 65 | 66 | True 67 | 68 | 69 | DECDUnitXTestSuite\library\lib\armeabi-v7a\ 70 | libDECDUnitXTestSuite.so 71 | ProjectOutput 72 | 1 73 | 74 | 75 | True 76 | True 77 | 78 | 79 | DECDUnitXTestSuite\assets\internal\ 80 | DECOptions.inc 81 | ProjectFile 82 | 0 83 | 84 | 85 | True 86 | 87 | 88 | DECDUnitXTestSuite\library\lib\mips\ 89 | libDECDUnitXTestSuite.so 90 | AndroidLibnativeMipsFile 91 | 1 92 | 93 | 94 | True 95 | 96 | 97 | DECDUnitXTestSuite\library\lib\armeabi-v7a\ 98 | gdbserver 99 | AndroidGDBServer 100 | 1 101 | 102 | 103 | True 104 | 105 | 106 | DECDUnitXTestSuite\classes\ 107 | classes.dex 108 | AndroidClassesDexFile 109 | 1 110 | 111 | 112 | True 113 | 114 | 115 | DECDUnitXTestSuite\res\drawable\ 116 | splash_image_def.xml 117 | AndroidSplashImageDef 118 | 1 119 | 120 | 121 | True 122 | 123 | 124 | DECDUnitXTestSuite\res\values\ 125 | styles.xml 126 | AndroidSplashStyles 127 | 1 128 | 129 | 130 | True 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /Unit Tests/DECDUnitXTestSuite.dpr: -------------------------------------------------------------------------------- 1 | {$UNDEF GUI} 2 | {.$DEFINE GUI} 3 | {.$DEFINE MobileGUI} 4 | program DECDUnitXTestSuite; 5 | 6 | // In order to run DEC Unit tests via DUnitX framework the $DEFINE DUnitX define 7 | // in TestDefines.inc must be enabled, as it makes all the unit test units DUnitX 8 | // compatible 9 | {$INCLUDE Tests\TestDefines.inc} 10 | 11 | {$IFNDEF GUI} 12 | {$IFNDEF TESTINSIGHT} 13 | {$APPTYPE CONSOLE} 14 | {$ENDIF} 15 | {$ENDIF} 16 | 17 | {$STRONGLINKTYPES ON} 18 | uses 19 | System.SysUtils, 20 | {$IFDEF TESTINSIGHT} 21 | TestInsight.Client, 22 | {$ENDIF } 23 | DUnitX.Loggers.Console, 24 | DUnitX.Loggers.Xml.NUnit, 25 | DUnitX.TestFramework, 26 | TestDECCRC in 'Tests\TestDECCRC.pas', 27 | TestDECFormatBase in 'Tests\TestDECFormatBase.pas', 28 | TestDECFormat in 'Tests\TestDECFormat.pas', 29 | TestDECUtil in 'Tests\TestDECUtil.pas', 30 | TestDECHash in 'Tests\TestDECHash.pas', 31 | TestDECCipher in 'Tests\TestDECCipher.pas', 32 | TestDECCipherModes in 'Tests\TestDECCipherModes.pas', 33 | TestDECTestDataContainer in 'Tests\TestDECTestDataContainer.pas', 34 | TestDECBaseClass in 'Tests\TestDECBaseClass.pas', 35 | TestDECCipherFormats in 'Tests\TestDECCipherFormats.pas', 36 | TestDECHashKDF in 'Tests\TestDECHashKDF.pas', 37 | TestDECRandom in 'Tests\TestDECRandom.pas', 38 | TestDECHashMAC in 'Tests\TestDECHashMAC.pas', 39 | TestDECHashSHA3 in 'Tests\TestDECHashSHA3.pas', 40 | TestDECCipherModesGCM in 'Tests\TestDECCipherModesGCM.pas', 41 | TestDECCipherPaddings in 'Tests\TestDECCipherPaddings.pas'; 42 | 43 | function IsTestInsightRunning: Boolean; 44 | {$IFDEF TESTINSIGHT} 45 | var 46 | client: ITestInsightClient; 47 | begin 48 | client := TTestInsightRestClient.Create; 49 | client.StartedTesting(0); 50 | Result := not client.HasError; 51 | end; 52 | {$ELSE} 53 | begin 54 | result := false; 55 | end; 56 | {$ENDIF} 57 | 58 | var 59 | runner : ITestRunner; 60 | results : IRunResults; 61 | logger : ITestLogger; 62 | nunitLogger : ITestLogger; 63 | begin 64 | 65 | //{$IFDEF GUI} 66 | // // DUnitX.Loggers.GUIX.GUIXTestRunner.Run.Execute; 67 | //// DUnitX.Loggers.GUIX.GUIXTestRunner.Run; 68 | // DUnitX.Loggers.GUI.VCL.Run; 69 | // exit; 70 | //{$ENDIF} 71 | 72 | try 73 | if IsTestInsightRunning then 74 | {$IFDEF TESTINSIGHT} 75 | TestInsight.DUnitX.RunRegisteredTests 76 | {$ENDIF} 77 | else 78 | begin 79 | //Check command line options, will exit if invalid 80 | TDUnitX.CheckCommandLine; 81 | //Create the test runner 82 | runner := TDUnitX.CreateRunner; 83 | //Tell the runner to use RTTI to find Fixtures 84 | runner.UseRTTI := True; 85 | //tell the runner how we will log things 86 | //Log to the console window 87 | // {$IFDEF GUI} 88 | // logger := TGUIXTestRunner.Create(nil); 89 | // {$ELSE} 90 | logger := TDUnitXConsoleLogger.Create(true); 91 | // {$ENDIF} 92 | runner.AddLogger(logger); 93 | //Generate an NUnit compatible XML File 94 | nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile); 95 | runner.AddLogger(nunitLogger); 96 | runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests; 97 | 98 | //Run tests 99 | results := runner.Execute; 100 | if not results.AllPassed then 101 | System.ExitCode := EXIT_ERRORS; 102 | 103 | {$IFNDEF CI} 104 | //We don't want this happening when running under CI. 105 | if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then 106 | begin 107 | System.Write('Done.. press key to quit.'); 108 | System.Readln; 109 | end; 110 | {$ENDIF} 111 | end; 112 | except 113 | on E: Exception do 114 | System.Writeln(E.ClassName, ': ', E.Message); 115 | end; 116 | end. 117 | -------------------------------------------------------------------------------- /Unit Tests/DECDUnitXTestSuite.dproj.local: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Unit Tests/DECDUnitXTestSuite.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/DECDUnitXTestSuite.res -------------------------------------------------------------------------------- /Unit Tests/DECDUnitXTestSuite.stat: -------------------------------------------------------------------------------- 1 | [Stats] 2 | EditorSecs=4416 3 | DesignerSecs=25 4 | InspectorSecs=10 5 | CompileSecs=245111 6 | OtherSecs=1393 7 | StartTime=14.01.2017 18:46:16 8 | RealKeys=0 9 | EffectiveKeys=0 10 | DebugSecs=642 11 | -------------------------------------------------------------------------------- /Unit Tests/Data/GCM128AuthenticationFailures.rsp: -------------------------------------------------------------------------------- 1 | # GCM Encrypt with keysize 128 test information 2 | # Test data set up to test authentication failures 3 | 4 | [Keylen = 128] 5 | [IVlen = 96] 6 | [PTlen = 128] 7 | [AADlen = 160] 8 | [Taglen = 128] 9 | 10 | # wrong AAD, first byte 11 | Count = 0 12 | Key = d4a22488f8dd1d5c6c19a7d6ca17964c 13 | IV = f3d5837f22ac1a0425e0d1d5 14 | PT = 7b43016a16896497fb457be6d2a54122 15 | AAD = f1c5d424b83f96c6ad8cb28ca0d20e475e023b5a 16 | CT = c2bd67eef5e95cac27e3b06e3031d0a8 17 | ModAAD = f2c5d424b83f96c6ad8cb28ca0d20e475e023b5a 18 | ModCT = c2bd67eef5e95cac27e3b06e3031d0a8 19 | Tag = f23eacf9d1cdf8737726c58648826e9c 20 | 21 | # wrong AAD, last byte 22 | Count = 1 23 | Key = e8899345e4d89b76f7695ddf2a24bb3c 24 | IV = 9dfaeb5d73372ceb06ca7bbe 25 | PT = c2807e403e9babf645268c92bc9d1de6 26 | AAD = fed0b45a9a7b07c6da5474907f5890e317e74a42 27 | CT = 8e44bf07454255aa9e36eb34cdfd0036 28 | ModAAD = fed0b45a9a7b07c6da5474907f5890e317e74a43 29 | ModCT = 8e44bf07454255aa9e36eb34cdfd0036 30 | Tag = 2f501e5249aa595a53e1985e90346a22 31 | 32 | # wrong CT, first byte, adapted PT 33 | Count = 2 34 | Key = c1629d6320b9da80a23c81be53f0ef57 35 | IV = b8615f6ffa30668947556cd8 36 | PT = 64771ab52532c9cdfcb3a9eb7b8193df 37 | AAD = 5f2955e4301852a70684f978f89e7a61531f0861 38 | CT = c2a72d693181c819f69b42b52088d3a2 39 | ModAAD = 5f2955e4301852a70684f978f89e7a61531f0861 40 | ModCT = c3a72d693181c819f69b42b52088d3a2 41 | Tag = cadaee305d8bb6d70259a6503280d99a 42 | 43 | # wrong CT, last byte, adapted PT 44 | Count = 3 45 | Key = 196ed78281bb7543d60e68cca2aaa941 46 | IV = 6e7d2c8f135715532a075c50 47 | PT = 15b42e7ea21a8ad5dcd7a9bba0253d47 48 | AAD = d6fc98c632d2e2641041ff7384d92a8358ae9abe 49 | CT = 06e5cc81c2d022cb2b5de5a881c62d09 50 | ModAAD = d6fc98c632d2e2641041ff7384d92a8358ae9abe 51 | ModCT = 06e5cc81c2d022cb2b5de5a881c62d0A 52 | Tag = 28e8cad3346ce583d5eebaa796e50974 53 | 54 | # wrong key first byte, adapted PT 55 | Count = 4 56 | Key = 56fe8a1bdc6806ed2f4a84891db943a0 57 | IV = af4d0ba0a90f1e713d71ae94 58 | PT = 725261716b1330ea2491313510479ec8 59 | AAD = 677cd4e6c0a67913085dba4cc2a778b894e174ad 60 | CT = c47bcb27c5a8d9beb19fee38b90861b7 61 | ModAAD = 677cd4e6c0a67913085dba4cc2a778b894e174ad 62 | ModCT = c47bcb27c5a8d9beb19fee38b90861b7 63 | Tag = e061ee4868edf2d969e875b8685ca8a9 64 | 65 | # wrong key last byte, adapted PT 66 | Count = 5 67 | Key = 6d86a855508657f804091be2290a17e1 68 | IV = 65dce18a4461afd83f1480f5 69 | PT = 4f256638c5ac1bc81b8f0fa9404d64a2 70 | AAD = e0ef8f0e1f442a2c090568d2af336ec59f57c896 71 | CT = 53505d449369c9bcd8a138740ea6602e 72 | ModAAD = e0ef8f0e1f442a2c090568d2af336ec59f57c896 73 | ModCT = 53505d449369c9bcd8a138740ea6602e 74 | Tag = 86f928b4532825af9cac3820234afe73 75 | 76 | # wrong IV first byte, adapted PT 77 | Count = 6 78 | Key = 66bd7b5dfd0aaaed8bb8890eee9b9c9a 79 | IV = 6f92bf7e8fd0fb932451fdf2 80 | PT = 726bf3aaa625d2ab41b00b7a2d2d985e 81 | AAD = 60459c681bda631ece1aacca4a7b1b369c56d2bb 82 | CT = 83b99253de05625aa8e68490bb368bb9 83 | ModAAD = 60459c681bda631ece1aacca4a7b1b369c56d2bb 84 | ModCT = 83b99253de05625aa8e68490bb368bb9 85 | Tag = 65d444b02a23e854a85423217562d07f 86 | 87 | # wrong IV last byte, adapted PT 88 | Count = 7 89 | Key = e7e825707c5b7ccf6cfc009dd134f166 90 | IV = dd0c7a9c68d14e073f16a7a1 91 | PT = 4e186908ddb289cebcc57e86f1662c46 92 | AAD = 11c69ed187f165160683e7f0103038b77512460b 93 | CT = 550fa499a7cb4783c1957288a5cc557f 94 | ModAAD = 11c69ed187f165160683e7f0103038b77512460b 95 | ModCT = 550fa499a7cb4783c1957288a5cc557f 96 | Tag = 5d2c2f71a2e6ad9b3001bdbf04690093 97 | 98 | # wrong AAD "middle" byte 99 | Count = 8 100 | Key = 92591b15e28ce471316c575f3963103a 101 | IV = 2c30d215e5c950f1fe9184f6 102 | PT = dc8842b3c146678627600742126ea714 103 | AAD = 46e1bd5fa646e4605e2fbec700fa592a714bc7ef 104 | CT = a541d3d8f079bfe053ba8835e02b349d 105 | ModAAD = 46e2bd5fa646e4605e2fbec700fa592a714bc7ef 106 | ModCT = a541d3d8f079bfe053ba8835e02b349d 107 | Tag = d322a924bf44809cb8cfe8c4b972a307 108 | 109 | # wrong AAD "middle" byte 110 | Count = 9 111 | Key = 74f08353d4139ddad46691da888ee897 112 | IV = e2619217dc8b093e2c7c5b78 113 | PT = 1690d6c8f95ef5ac35c56e3129717b44 114 | AAD = 92277cf78abe24720ce219bba3a7a339a2e011b2 115 | CT = b413557c0df29e3072bb1b326e2002dc 116 | ModAAD = 92277cf78abe24620ce219bba3a7a339a2e011b2 117 | ModCT = b413557c0df29e3072bb1b326e2002dc 118 | Tag = 3bb6273687ec6a3f4a0366f1b54bd318 119 | 120 | # wrong AAD "middle" byte 121 | Count = 10 122 | Key = 5c951cd038a3c65cd65325bfdde86964 123 | IV = 3bf5623fd1155f1036ea893f 124 | PT = b609ec6673e394176dd982b981a5436b 125 | AAD = dc34014513fd0eede8e9ca44a16e400a5f89cdd0 126 | CT = 009cf623e57a3129626a30489b730607 127 | ModAAD = dc34014513fd0eede8e9ca43a16e400a5f89cdd0 128 | ModCT = 009cf623e57a3129626a30489b730607 129 | Tag = 1d202825db813c0fc521c284dd543fff 130 | 131 | # wrong CT "middle" byte, adapted PT 132 | Count = 11 133 | Key = 72301c093ba804671c44a6bf52839d9c 134 | IV = 87cc7e6579cc92822f5744f6 135 | PT = d59bbae4ff3e3755c0a62a9b6d3e234c 136 | AAD = f461946c4feba79c18366555d85311248d269c87 137 | CT = ee743d29dcbaa084fda91eb48b3be961 138 | ModAAD = f461946c4feba79c18366555d85311248d269c87 139 | ModCT = ee743d29dcbaa084fda92eb48b3be961 140 | Tag = 07934a5372d41928f2ee7d4bb8c18982 141 | 142 | # wrong AAD "middle" byte 143 | Count = 12 144 | Key = 39b4f826b520830941b3b1bcd57e41d5 145 | IV = ca32ac523fe7dfefe415cba1 146 | PT = aa2b7a6c918ed6715441d046858b525f 147 | AAD = c586cd939b27821695b4ee4dd799fb0e3449a80e 148 | CT = 8b64f5ea9a8cb521c66df9c74d4b7ecd 149 | ModAAD = c586cd939b27821685b4ee4dd799fb0e3449a80e 150 | ModCT = 8b64f5ea9a8cb521c66df9c74d4b7ecd 151 | Tag = 3db56a792b67ac6d0c4001e17f446111 152 | 153 | # wrong CT "middle" byte 154 | Count = 13 155 | Key = 79449e5f670d55ee2d91ca994a267a8c 156 | IV = c779da00d672811d8a5124f1 157 | PT = 767e120debd8a1dc8dddb8b7f4750741 158 | AAD = 54780846dc3df77c8d90c9f2decb0738da36fbda 159 | CT = eb864412add08abb4f89d72d412d0085 160 | ModAAD = 54780846dc3df77c8d90c9f2decb0738da36fbda 161 | ModCT = eb864412add08abb4f79d72d412d0085 162 | Tag = 494a547f617840267d3fed5280e3eb30 163 | 164 | # wrong Key "middle" byte 165 | Count = 14 166 | Key = cc90c2f37f870f97ac97e3e3b88e8ae3 167 | IV = 67bcc08f223f12107e4d9122 168 | PT = f4d80e4944385cebd9af5e5e70cb8d05 169 | AAD = 065acdc19233af4be7c067744aabab024c677c5e 170 | CT = 501cda2c954f830e8922c3d7405b5ee1 171 | ModAAD = 065acdc19233af4be7c067744aabab024c677c5e 172 | ModCT = 501cda2c954f830e8922c3d7405b5ee1 173 | Tag = 9deee5d0e4778a9f770367f19c74daef 174 | -------------------------------------------------------------------------------- /Unit Tests/Data/GCM192AuthenticationFailures.rsp: -------------------------------------------------------------------------------- 1 | # GCM Encrypt with keysize 192 test information 2 | # Test data set up to test authentication failures 3 | 4 | [Keylen = 192] 5 | [IVlen = 96] 6 | [PTlen = 128] 7 | [AADlen = 160] 8 | [Taglen = 128] 9 | 10 | # wrong AAD, first byte 11 | Count = 0 12 | Key = 95e5c8dcee4ef17571e1becc3f2d4ac8d5aa73e74b3f1115 13 | IV = e3b91649120f92b4f712644b 14 | PT = eca3606b9e2a0c7a1c6c4b765176f643 15 | AAD = 68b093733bd1e77448fe5687b74796834d1797cf 16 | CT = 0ff6d858cf0f5309c0f4b2747f6b551f 17 | ModAAD = 69b093733bd1e77448fe5687b74796834d1797cf 18 | ModCT = 0ff6d858cf0f5309c0f4b2747f6b551f 19 | Tag = 94d6ac2796a9b9901933a0f9e5377979 20 | 21 | # wrong AAD, last byte 22 | Count = 1 23 | Key = 48b82b72fc81be86860f72065efa62186f9da596bdf95158 24 | IV = 24da67aef74be3338589ccb6 25 | PT = f86a57a30c06efb10ecbeb3d5a9d97b5 26 | AAD = c1f7f5c8f8cc5137a53991941f388ffd2b27f0dd 27 | CT = 4be58cd06378c03878d4f1659443c5d1 28 | ModAAD = c1f7f5c8f8cc5137a53991941f388ffd2b27f0dc 29 | ModCT = 4be58cd06378c03878d4f1659443c5d1 30 | Tag = 84dd00b8b03acb9219ec5116e3de7362 31 | 32 | # wrong CT, first byte, adapted PT 33 | Count = 2 34 | Key = e61d09d6b0ae050174246a3c2a2cab0e721a28e80fba2a5a 35 | IV = 728efe71da22d20c123fdc12 36 | PT = 476dd6a8b0e8cc27de66c057de1640d7 37 | AAD = 467d50ea72c46588314eb534ed492c2bba3a922c 38 | CT = bb42279bbb9cb98347a75328639a2f3b 39 | ModAAD = 467d50ea72c46588314eb534ed492c2bba3a922c 40 | ModCT = bc42279bbb9cb98347a75328639a2f3b 41 | Tag = a892fb8169de7ba2e8cbf215340b2bc9 42 | 43 | # wrong CT, last byte, adapted PT 44 | Count = 3 45 | Key = 15dee564b868b716f4f413424224d5c203404f73070bd536 46 | IV = 64bd0c03f8777b3e4f625a28 47 | PT = 9d73be1fb2e4ca35bc84dccd4bef48b7 48 | AAD = 43028f3eb8d814af65599b1d75ea9e2cd5b6620d 49 | CT = a8197b8f75daf3ad6fa1ed18baa6f623 50 | ModAAD = 43028f3eb8d814af65599b1d75ea9e2cd5b6620d 51 | ModCT = a8197b8f75daf3ad6fa1ed18baa6f624 52 | Tag = 3d018209c945ab324edda59a454ca233 53 | 54 | # wrong key first byte, adapted PT 55 | Count = 4 56 | Key = 2e530d65a90549d89fe91880799eee4863128c2937b26db3 57 | IV = 06684bdbea2344e06d57373b 58 | PT = 793ed0f64edd6532ef82baace3645db6 59 | AAD = 556239791fff36fafc5783e291f142c36c29af70 60 | CT = 786c514df4d030d1798914a9d28353a3 61 | ModAAD = 556239791fff36fafc5783e291f142c36c29af70 62 | ModCT = 786c514df4d030d1798914a9d28353a3 63 | Tag = acba85fafe26e1971cec39414ae1440a 64 | 65 | # wrong key last byte, adapted PT 66 | Count = 5 67 | Key = fac90528b639d0a1353192dc0de29f1cd9b46cd5ee314e11 68 | IV = 78d7ba9d78940b7f0bfd6e9b 69 | PT = e51a41cf8b382cb599a80a4b6ec46b2d 70 | AAD = e4ce785b1b1aafe21c6ca2ce54b2118810cca01f 71 | CT = 6c940aade9a7b45cfaed784d8952bcf8 72 | ModAAD = e4ce785b1b1aafe21c6ca2ce54b2118810cca01f 73 | ModCT = 6c940aade9a7b45cfaed784d8952bcf8 74 | Tag = b5be187d456751ca589bcddc654b0b02 75 | 76 | # wrong IV first byte, adapted PT 77 | Count = 6 78 | Key = 466acd78e42fde6ff455e562756d1313cee15d1089d1a4d2 79 | IV = 008d02efd7d2efc7e7cecc42 80 | PT = a5cb0aa76464feed09961347be3dd1a9 81 | AAD = f20551086e4c46161b312a7cb6c373c4a7dc4647 82 | CT = e281b825b34e0cd53e91e9260074b9a3 83 | ModAAD = f20551086e4c46161b312a7cb6c373c4a7dc4647 84 | ModCT = e281b825b34e0cd53e91e9260074b9a3 85 | Tag = 84c2d75dab4d6cf7de0b7c41c6115646 86 | 87 | # wrong IV last byte, adapted PT 88 | Count = 7 89 | Key = d998dfeeca62107b4a916d831d91d8c4551de15d08f2dcfb 90 | IV = dd52c5f471eeaa798b9bf3ab 91 | PT = 57312e27bc520feb662e401f719fe08a 92 | AAD = 8836495f03f6a2963bb18fcca390d0e32d778e13 93 | CT = b66a928bb272524ddd1ed1fd331e8c01 94 | ModAAD = 8836495f03f6a2963bb18fcca390d0e32d778e13 95 | ModCT = b66a928bb272524ddd1ed1fd331e8c01 96 | Tag = 8782356421e555c33ded92bf79aad130 97 | 98 | # wrong AAD "middle" byte 99 | Count = 8 100 | Key = f8846e9e3cc7e8d4f08028fe0c5cf030a57eb108fa3ecd4c 101 | IV = b6d77bb321e23b364614847e 102 | PT = c4e4ccc135d0ad00785d273a45652968 103 | AAD = 55882abdabbede1cecf412c8b387a9173aa4285e 104 | CT = adc15c4bb08e75377f07d6b7ea578daa 105 | ModAAD = 55882abdabbede1ce11412c8b387a9173aa4285e 106 | ModCT = adc15c4bb08e75377f07d6b7ea578daa 107 | Tag = eecc6ebd564caef221ce1d9850004832 108 | 109 | # wrong AAD "middle" byte 110 | Count = 9 111 | Key = aab1d3e93b0e081200510cf468134920f9a6ae32fef34a0f 112 | IV = 3f26812688196a6ea1a06ed4 113 | PT = cc21170db29c67dc239944b4aa51a78a 114 | AAD = 4a8ce870127715223dd774bf2593144d97bb8452 115 | CT = 8befe087c5c5e76393e0f1b7e43d2bfe 116 | ModAAD = 4a8ce87012771522300774bf2593144d97bb8452 117 | ModCT = 8befe087c5c5e76393e0f1b7e43d2bfe 118 | Tag = 8549867ed6445117a216da230beb54cd 119 | 120 | # wrong AAD "middle" byte 121 | Count = 10 122 | Key = 4f6650a2f7a328acf4b05e7e84dc271b781788f620dfa44b 123 | IV = 9c8db0a99fe1d0c7357ecbae 124 | PT = fa8371188c73b206ff3e2714249ab906 125 | AAD = 91e9013e9b7a7bb95525b5303fd315a98593e6af 126 | CT = b82da87c67b564a6bbbe3022446eba6c 127 | ModAAD = 91e9013e9b7b7ab95525b5303fd315a98593e6af 128 | ModCT = b82da87c67b564a6bbbe3022446eba6c 129 | Tag = 37ef882f00767da46efc80b52adfedf3 130 | 131 | # wrong CT "middle" byte, adapted PT 132 | Count = 11 133 | Key = 83e01276aa3ccba7eb799549d1184460e10d75f60db7126d 134 | IV = 211b4754695b37c79d62bb6a 135 | PT = eb10eb9fef1c248f42b5e0fb0c9ecf99 136 | AAD = 2de1ff8e51af6d8434cd2bddeb9e0778a78c98cc 137 | CT = 7d85ee71f54480213034c4210121d013 138 | ModAAD = 2de1ff8e51af6d8434cd2bddeb9e0778a78c98cc 139 | ModCT = 7d85ee71f54480123034c4210121d013 140 | Tag = ebcbb96f9bd5334a73341d566949911b 141 | 142 | # wrong AAD "middle" byte 143 | Count = 12 144 | Key = d1ee8fcd902da5754aa835d8332c9ea312ef50f4c2b8a5ff 145 | IV = 5b4be5afb5e1990d8e1668f4 146 | PT = bc860f8fa741c42e8a5cb5e85a4f2c9a 147 | AAD = c101ea086c862b5869298d0f2df7e10ac18248ad 148 | CT = 3012135b62a253e6815b1cbb65dc0548 149 | ModAAD = c101ea086c862b4869298d0f2df7e10ac18248ad 150 | ModCT = 3012135b62a253e6815b1cbb65dc0548 151 | Tag = 0c4bbb16d97cd2fab895fbb0bd9f85e4 152 | 153 | # wrong CT "middle" byte 154 | Count = 13 155 | Key = 9df8afc4801009cc0ef7922deba528bcba12e3c91b632c74 156 | IV = 9bef19d43b2772f6aae99d13 157 | PT = a2ef7803e1b023e3c7e588c57e7d996d 158 | AAD = 1a7d0b9ae1d2f8854c2e85d42fd0541657b7d6c8 159 | CT = e9708d64ba8d3fed9d690ebf6fbdd69f 160 | ModAAD = 1a7d0b9ae1d2f8854c2e85d42fd0541657b7d6c8 161 | ModCT = e9708d64ba8d3fde9d690ebf6fbdd69f 162 | Tag = 7ab28b61ac7b030e2ab61cf95a98ebe7 163 | 164 | # wrong Key "middle" byte 165 | Count = 14 166 | Key = 772c8a3f06d812e3b4437c36b09e264eaf584e7e01f3530e 167 | IV = a58cd3e867a855b6df995a3c 168 | PT = 66ce06868e326d1c44fa33ff6edceb37 169 | AAD = eb17a37f81150f4bddd9a1c7bc6cb635d0e422db 170 | CT = 7ea02275bdfa333a5dbf8dd57b5e1103 171 | ModAAD = eb17a37f81150f4bddd9a1c7bc6cb635d0e422db 172 | ModCT = 7ea02275bdfa333a5dbf8dd57b5e1103 173 | Tag = 51d7f95df150cdcf33fb5dde0b5757f2 -------------------------------------------------------------------------------- /Unit Tests/Data/GCM256AuthenticationFailures.rsp: -------------------------------------------------------------------------------- 1 | # GCM Encrypt with keysize 256 test information 2 | # Test data set up to test authentication failures 3 | 4 | [Keylen = 256] 5 | [IVlen = 96] 6 | [PTlen = 128] 7 | [AADlen = 128] 8 | [Taglen = 120] 9 | 10 | # wrong AAD, first byte 11 | Count = 0 12 | Key = 7f7168a406e7c1ef0fd47ac922c5ec5f659765fb6aaa048f7056f6c6b5d8513d 13 | IV = b8b5e407adc0e293e3e7e991 14 | PT = b706194bb0b10c474e1b2d7b2278224c 15 | AAD = ff7628f6427fbcef1f3b82b37404e116 16 | CT = 8fada0b8e777a829ca9680d3bf4f3574 17 | ModAAD = fe7628f6427fbcef1f3b82b37404e116 18 | ModCT = 8fada0b8e777a829ca9680d3bf4f3574 19 | Tag = daca354277f6335fc8bec90886da70 20 | 21 | # wrong AAD, last byte 22 | Count = 1 23 | Key = 08d06446341e296b5fd3b7f45cb4ee096079e6e71a17df390f55b86719707673 24 | IV = f2f5f36174fd1b2bfc1305af 25 | PT = ef4ed2d0d3ae9acef5e00a55bc62baef 26 | AAD = d30e4208567bf56842843e342c345db7 27 | CT = b9e73049d86393d00ad0fd5d7a455e10 28 | ModAAD = d30e4208567bf56842843e342c345db8 29 | ModCT = b9e73049d86393d00ad0fd5d7a455e10 30 | Tag = cc9711f06f5c6b6cfe2a864c0a7653 31 | 32 | # wrong CT, first byte, adapted PT 33 | Count = 2 34 | Key = 4dbc7340aa4b24b2774c840d84df676813fcf397143877b97d7ddd196789447b 35 | IV = 9a588605ed2452406c033011 36 | PT = 169585b9efb0bef68affcfcf08ba99a5 37 | AAD = 5a0c2fc8821c69fd2c4d21387eca8689 38 | CT = 9fd772fe36ff3de176ee4824311d9b01 39 | ModAAD = 5a0c2fc8821c69fd2c4d21387eca8689 40 | ModCT = 9ed772fe36ff3de176ee4824311d9b01 41 | Tag = 03d8423faa460bd3482a3a6b399ded 42 | 43 | # wrong CT, last byte, adapted PT 44 | Count = 3 45 | Key = 3951af0c7457aa1b51cd75be7aff65716e333183b27787599e5140fef41519d2 46 | IV = ac30bf9c00bd91079041c5d6 47 | PT = b7bb418ecacc0c4920741839d5d04fcb 48 | AAD = cc478ca0c3e3fc2553aaac504fa5b376 49 | CT = 7fd7c2da77bce369a4396efb1c1690a5 50 | ModAAD = cc478ca0c3e3fc2553aaac504fa5b376 51 | ModCT = 7fd7c2da77bce369a4396efb1c1690a4 52 | Tag = 35f8e351e4e647c040ac2e0222d26d 53 | 54 | # wrong key first byte, adapted PT 55 | Count = 4 56 | Key = 2a7ee5ddd4840b0ce1d292fe227c34ae18d42da278645dc29988f1d8d9df4f76 57 | IV = adc18c3ee6dd1df169e8d46e 58 | PT = f4c1db06c426a0c8cf33713631340f74 59 | AAD = 11ad7f708554ad845465d1948b659789 60 | CT = 68e8474bfc5574aa7fb5cffb7a884ab6 61 | ModAAD = 11ad7f708554ad845465d1948b659789 62 | ModCT = 68e8474bfc5574aa7fb5cffb7a884ab6 63 | Tag = 53af92d95cc40c4e62ac5b5ad5d9d0 64 | 65 | # wrong key last byte, adapted PT 66 | Count = 5 67 | Key = f1fcf9bbc9414f8df217c455e2bec44978efb912dfed209c95380a07b867fccd 68 | IV = c39d41221baee2b1ceddeb02 69 | PT = 3a35f044fce24074c4429d02b8ba8f19 70 | AAD = 8a09b01043f3b2c5d800fc221fcbeee9 71 | CT = 359a1a15acb8947bd8b6b3470c47f5b8 72 | ModAAD = 8a09b01043f3b2c5d800fc221fcbeee9 73 | ModCT = 359a1a15acb8947bd8b6b3470c47f5b8 74 | Tag = 450d77133b210700f6df8ac6f8410a 75 | 76 | # wrong IV first byte, adapted PT 77 | Count = 6 78 | Key = ed1a0fe0256c0f8af0c3927e3df158aaa2558a4389f2b93cbbf6f93a146e8156 79 | IV = 5e4e6993b6b9634c3c4ed9b1 80 | PT = 50fd8a992d649884676d1e1750c8a0be 81 | AAD = 5b8756983424742cd403b8288ad44c13 82 | CT = ca13e95f7ce407d345ef45ae8d0f425f 83 | ModAAD = 5b8756983424742cd403b8288ad44c13 84 | ModCT = ca13e95f7ce407d345ef45ae8d0f425f 85 | Tag = 61d4a42edefb6d96e1460618930670 86 | 87 | # wrong IV last byte, adapted PT 88 | Count = 7 89 | Key = 823079bd76250ff75c361043011a4ff96ebfce06640be754d244be7ed45a0967 90 | IV = a5d0dc91711fd7b3d405e434 91 | PT = 3143569691af7728d0a3889d7678df93 92 | AAD = c86a43ec7c441a337eca38e9c3055f08 93 | CT = a5befc840d112495050d03474a167942 94 | ModAAD = c86a43ec7c441a337eca38e9c3055f08 95 | ModCT = a5befc840d112495050d03474a167942 96 | Tag = fc4915f4312e7883c1b8cf9ae788c1 97 | 98 | # wrong AAD "middle" byte 99 | Count = 8 100 | Key = 64ce2754eb4b2c817bbec3c9f3f32573d5378d3ee7c7a65858ee602ed4055088 101 | IV = c81d898047a3f6433cd5e230 102 | PT = e45e578c0c813f0135c6ed81fc74088b 103 | AAD = b2a03629d09e77256e546abb4fffb526 104 | CT = 9870d261ee218e863ac4718c11cecc9a 105 | ModAAD = b2a03629d09e87256e546abb4fffb526 106 | ModCT = 9870d261ee218e863ac4718c11cecc9a 107 | Tag = b07121d3dae9d30fd3ae16a0e0f36c 108 | 109 | # wrong AAD "middle" byte 110 | Count = 9 111 | Key = 7ead2eb9af872c75f2784d3e64882d7d3c9d8db20762d573d43c2940b144ad75 112 | IV = da184dd78dce9fc446b25070 113 | PT = e570ce9852fa8c098bbf1d5947971656 114 | AAD = c5636b99835bab3e730734e8b47f9d52 115 | CT = ec86e8af6594b504133791f1d0564dca 116 | ModAAD = c5636b99835bab733e0734e8b47f9d52 117 | ModCT = ec86e8af6594b504133791f1d0564dca 118 | Tag = f689e90b32a1ce1f624670003e09fa 119 | 120 | # wrong AAD "middle" byte 121 | Count = 10 122 | Key = eaa9a76cbdeb411b6c5ff718164a99c02ba498b7150ef5c5b8b5a2c54e4132ca 123 | IV = b8ce05e0151fe6fd4a290032 124 | PT = 404597e21a397cf95625cf3a23218ca6 125 | AAD = ab541ff2511db7ebc53950f7d611e119 126 | CT = bf6d2fcf8970e206a5b027010ab427ae 127 | ModAAD = ab541ff2511bd7ebc53950f7d611e119 128 | ModCT = bf6d2fcf8970e206a5b027010ab427ae 129 | Tag = 32b2296cf8f5fccdf1809e5a27f33e 130 | 131 | # wrong CT "middle" byte, adapted PT 132 | Count = 11 133 | Key = c07a0e23a2f49b9b1a9ad12ba2c311bb6184cb52b1317e0a4c783f57e140a0ee 134 | IV = fd559a2ffb3a43fd3324eb8d 135 | PT = 7e5cbb985e07fbc0d148cfb6a372504d 136 | AAD = ab51b818245d50531b8a331d4b3c84f0 137 | CT = cae3b28aa3f99e624dca9e2d71def0bb 138 | ModAAD = ab51b818245d50531b8a331d4b3c84f0 139 | ModCT = cae3b28aa3f98e624dca9e2d71def0bb 140 | Tag = 20475aa44903fc361f8f8a95e9b701 141 | 142 | # wrong AAD "middle" byte 143 | Count = 12 144 | Key = 9a647ef6db87e96a395341b7a573fc78c583b9d95b7eda9d761e007ebd2fc375 145 | IV = c94b8943c7e8b948130fa031 146 | PT = 48bb7f2d7e85d19975072b0bc2418c4c 147 | AAD = a99ee575884f158b5e242bd30e626f1a 148 | CT = a6b71a575c8ac11bfa66fbe1a51b3f32 149 | ModAAD = a99ee575884f158b5e332bd30e626f1a 150 | ModCT = a6b71a575c8ac11bfa66fbe1a51b3f32 151 | Tag = a92c11f99d059d97c2c173c5921e05 152 | 153 | # wrong CT "middle" byte adapted PT 154 | Count = 13 155 | Key = 213d82694358beef03c162f66151e9d552ddf31a6939826417f1fd301eafee22 156 | IV = 2a4b5743b28f200016fd8f1b 157 | PT = a59283af6f665632276e875a8a8f1b28 158 | AAD = fe073635e4d4c47bbcb1a3d844afb110 159 | CT = 941d5a27c2d1f3f2bc3f037c279cad5e 160 | ModAAD = fe073635e4d4c47bbcb1a3d844afb110 161 | ModCT = 941d5a27c2d1f4e2bc3f037c279cad5e 162 | Tag = 4c2ac2d4c5e217f706ac975619ab0a 163 | 164 | # wrong Key "middle" byte adapted PT 165 | Count = 14 166 | Key = ffd5f776b1e5568df166be32118fffbe483a62c5825fcf6edbd12a2d17d3b5ef 167 | IV = 2ddbefa4756f8333f2267eb6 168 | PT = acd955226abc755a38b2ac2daac48b6b 169 | AAD = 553d3aa8bc875e1ab9576ca59272c4a9 170 | CT = 8fb7ee82a9df7e94a266c02341f9f04c 171 | ModAAD = 553d3aa8bc875e1ab9576ca59272c4a9 172 | ModCT = 8fb7ee82a9df7e94a266c02341f9f04c 173 | Tag = be9e5a3e2ac6ecbb2b8ffdd7b3a0d9 -------------------------------------------------------------------------------- /Unit Tests/HashTestDataGenerator/GenerateData.dpr: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | /// 19 | /// Test data generator for unit tests of hash classes which have a rounds property 20 | /// 21 | program GenerateData; 22 | 23 | {$APPTYPE CONSOLE} 24 | 25 | {$R *.res} 26 | 27 | uses 28 | System.SysUtils, 29 | DECFormat, 30 | DECHash, 31 | DECUtil; 32 | 33 | var 34 | Hash : THash_Snefru256; 35 | s : RawByteString; 36 | begin 37 | Hash := THash_Snefru256.Create; 38 | try 39 | try 40 | for var i := 2 to 8 do 41 | begin 42 | Hash.Rounds := i; 43 | 44 | s := ''; 45 | WriteLn(' lDataRow := FTestData.AddRow;'); 46 | WriteLn(' lDataRow.ExpectedOutput := ''' + Hash.CalcString(s, TFormat_HEXL) + ''';'); 47 | WriteLn(' lDataRow.ExpectedOutputUTFStrTest := ''' + Hash.CalcString(s, TFormat_HEXL) + ''';'); 48 | WriteLn(' lDataRow.PaddingByte := 1;'); 49 | WriteLn(' lDataRow.Rounds := ' + i.ToString + ';'); 50 | WriteLn(' lDataRow.AddInputVector('''');'); 51 | WriteLn(''); 52 | 53 | s := 'a'; 54 | WriteLn(' lDataRow := FTestData.AddRow;'); 55 | WriteLn(' lDataRow.ExpectedOutput := ''' + Hash.CalcString(s, TFormat_HEXL) + ''';'); 56 | 57 | WriteLn(' lDataRow.ExpectedOutputUTFStrTest := ''' + BytesToRawString( 58 | TFormat_HEXL.Encode( 59 | System.SysUtils.BytesOf(Hash.CalcString(string(RawByteString('a')))))) + ''';'); 60 | WriteLn(' lDataRow.PaddingByte := 1;'); 61 | WriteLn(' lDataRow.Rounds := ' + i.ToString + ';'); 62 | WriteLn(' lDataRow.AddInputVector(''a'');'); 63 | WriteLn(''); 64 | 65 | end; 66 | 67 | ReadLn; 68 | 69 | except 70 | on E: Exception do 71 | Writeln(E.ClassName, ': ', E.Message); 72 | end; 73 | finally 74 | Hash.Free; 75 | end; 76 | end. 77 | -------------------------------------------------------------------------------- /Unit Tests/HashTestDataGenerator/GenerateData.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/HashTestDataGenerator/GenerateData.res -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/DECDUnitTestSuite/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/DECDUnitTestSuite/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/DECDUnitTestSuite/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/DECDUnitTestSuite/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/Klassendiagramm.txvcls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/Klassendiagramm.txvcls -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/Klassendiagramm_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCRC/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCRC/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCRC/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCRC/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipher/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipher/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipher/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipher/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherFormats/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherFormats/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherFormats/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherFormats/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherModes/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherModes/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherModes/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECCipherModes/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormat/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormat/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormat/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormat/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormatBase/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormatBase/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormatBase/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECFormatBase/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHash/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHash/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHash/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHash/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashKDF/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashKDF/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashKDF/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashKDF/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashMAC/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashMAC/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashMAC/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECHashMAC/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECRandom/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECRandom/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECRandom/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECRandom/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECTestDataContainer/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECTestDataContainer/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECTestDataContainer/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECUtil/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECUtil/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECUtil/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/TestDECUtil/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/default.txaPackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/ModelSupport_DECDUnitTestSuite/default.txaPackage -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/default.txvpck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Unit Tests/ModelSupport_DECDUnitTestSuite/default_diagram.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit Tests/Tests/TestDECCRC.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/Tests/TestDECCRC.pas -------------------------------------------------------------------------------- /Unit Tests/Tests/TestDECCipher.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/Tests/TestDECCipher.pas -------------------------------------------------------------------------------- /Unit Tests/Tests/TestDECCipherModes.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/Tests/TestDECCipherModes.pas -------------------------------------------------------------------------------- /Unit Tests/Tests/TestDECCipherModesGCM.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHumm/DelphiEncryptionCompendium/e31afa5284a4b29f10e7c7cac29b3d2a8e0fbf4e/Unit Tests/Tests/TestDECCipherModesGCM.pas -------------------------------------------------------------------------------- /Unit Tests/Tests/TestDECZIPHelper.pas: -------------------------------------------------------------------------------- 1 | {***************************************************************************** 2 | The DEC team (see file NOTICE.txt) licenses this file 3 | to you under the Apache License, Version 2.0 (the 4 | "License"); you may not use this file except in compliance 5 | with the License. A copy of this licence is found in the root directory of 6 | this project in the file LICENCE.txt or alternatively at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, 11 | software distributed under the License is distributed on an 12 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | KIND, either express or implied. See the License for the 14 | specific language governing permissions and limitations 15 | under the License. 16 | *****************************************************************************} 17 | 18 | {$M+} // DUnitX would add it anyway 19 | unit TestDECZIPHelper; 20 | 21 | interface 22 | 23 | // Needs to be included before any other statements 24 | {$INCLUDE TestDefines.inc} 25 | 26 | uses 27 | System.SysUtils, System.Classes, 28 | {$IFDEF DUnitX} 29 | DUnitX.TestFramework,DUnitX.DUnitCompatibility, 30 | {$ELSE} 31 | TestFramework, 32 | {$ENDIF} 33 | DECUtil; 34 | 35 | type 36 | /// 37 | /// Test cases for the various helper functions 38 | /// 39 | TestZIPHelpers = class(TTestCase) 40 | strict private 41 | /// 42 | /// Perform a signle algorithm create test 43 | /// 44 | /// 45 | /// ID of the algorithm instance to create 46 | /// 47 | /// 48 | /// Short class name of the instance to be created, must match to pass 49 | /// 50 | procedure DoTestCreateZIPCryptoAlgorithmInstance(AlgorithmID: UInt16; 51 | const Name : string); 52 | /// 53 | /// Test for the "unknown" algorithm ID as parameter 54 | /// 55 | procedure DoTestCreateZIPUnknownCryptoAlgorithmException; 56 | /// 57 | /// Test for an arbitrary unknown algorithm ID as parameter 58 | /// 59 | procedure DoTestCreateZIPUnknCryptoAlgorithmException; 60 | published 61 | procedure TestCreateZIPCryptoAlgorithmInstance; 62 | procedure TestCreateZIPUnknownCryptoAlgorithmInstanceException; 63 | procedure TestCreateZIPUnknCryptoAlgorithmInstanceException; 64 | end; 65 | 66 | implementation 67 | 68 | uses 69 | DECTypes, 70 | DECCipherFormats, 71 | DECZIPHelper; 72 | 73 | procedure TestZIPHelpers.DoTestCreateZIPUnknCryptoAlgorithmException; 74 | var 75 | Instance : TDECFormattedCipher; 76 | begin 77 | Instance := CreateZIPCryptoAlgorithmInstance($1000); 78 | Instance.Free; // Should not be reached but suppresses compiler warning 79 | end; 80 | 81 | procedure TestZIPHelpers.DoTestCreateZIPUnknownCryptoAlgorithmException; 82 | var 83 | Instance : TDECFormattedCipher; 84 | begin 85 | Instance := CreateZIPCryptoAlgorithmInstance($FFFF); 86 | Instance.Free; // Should not be reached but suppresses compiler warning 87 | end; 88 | 89 | procedure TestZIPHelpers.DoTestCreateZIPCryptoAlgorithmInstance(AlgorithmID: UInt16; 90 | const Name: string); 91 | var 92 | Instance : TDECFormattedCipher; 93 | begin 94 | Instance := CreateZIPCryptoAlgorithmInstance(AlgorithmID); 95 | try 96 | CheckEquals(Name, Instance.GetShortClassName); 97 | finally 98 | Instance.Free; 99 | end; 100 | end; 101 | 102 | procedure TestZIPHelpers.TestCreateZIPCryptoAlgorithmInstance; 103 | begin 104 | DoTestCreateZIPCryptoAlgorithmInstance($6601, '1DES'); 105 | DoTestCreateZIPCryptoAlgorithmInstance($6603, '3DES'); 106 | DoTestCreateZIPCryptoAlgorithmInstance($6609, '2DES'); 107 | DoTestCreateZIPCryptoAlgorithmInstance($660E, 'AES128'); 108 | DoTestCreateZIPCryptoAlgorithmInstance($660F, 'AES192'); 109 | DoTestCreateZIPCryptoAlgorithmInstance($6610, 'AES256'); 110 | DoTestCreateZIPCryptoAlgorithmInstance($6702, 'RC2'); 111 | DoTestCreateZIPCryptoAlgorithmInstance($6720, 'Blowfish'); 112 | DoTestCreateZIPCryptoAlgorithmInstance($6721, 'Twofish'); 113 | DoTestCreateZIPCryptoAlgorithmInstance($6801, 'RC4'); 114 | 115 | // $6602 : Result := TCipher_RC2.Create; // (version needed to extract < 5.2) 116 | // // This has to do with a faulty RC2 117 | // // implementation in XP SP1 and earlier 118 | // // Unsupported as we do not know the 119 | // // details of the fault 120 | end; 121 | 122 | procedure TestZIPHelpers.TestCreateZIPUnknCryptoAlgorithmInstanceException; 123 | begin 124 | CheckException(DoTestCreateZIPUnknCryptoAlgorithmException, EDECClassNotRegisteredException); 125 | end; 126 | 127 | procedure TestZIPHelpers.TestCreateZIPUnknownCryptoAlgorithmInstanceException; 128 | begin 129 | CheckException(DoTestCreateZIPUnknownCryptoAlgorithmException, EDECClassNotRegisteredException); 130 | end; 131 | 132 | initialization 133 | // Register any test cases with the test runner 134 | {$IFDEF DUnitX} 135 | TDUnitX.RegisterTestFixture(TestZIPHelpers); 136 | {$ELSE} 137 | RegisterTest('DECZIPHelper', TestZIPHelpers.Suite); 138 | {$ENDIF} 139 | end. 140 | -------------------------------------------------------------------------------- /Unit Tests/Tests/TestDefines.inc: -------------------------------------------------------------------------------- 1 | /// 2 | /// When enabled the Unit tests can be run via DUnitX test framework but no 3 | /// longer via DUnit test framework. 4 | /// 5 | {.$DEFINE DUnitX} -------------------------------------------------------------------------------- /Unit Tests/deployedassets.txt: -------------------------------------------------------------------------------- 1 | .\assets\internal\defines.inc 2 | .\assets\internal\DECOptions.inc 3 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # DEC - Delphi Encryption Compendium 2 | 3 | ## What is DEC? 4 | DEC is a library for Embarcadero Delphi, containing different cryptographic algorithms. 5 | It contains algorithms for these categories: 6 | 7 | * Ciphers: encryption/decryption of data 8 | * Hashes: "cryptographic checksums" 9 | * Key derivation algorithms like Kdf1-Kdf3 and pbkdf2 10 | * HMAC message authentication 11 | * A cryptographic pseudo random number generator 12 | * CRCs: non cryptographic checksums based on CRC algorithms 13 | 14 | ## Which Delphi versions are compatible? 15 | The current version 6.4.1 is compatible with Delphi XE2 - Delphi 12.3 Athens. 16 | When defining the NO_ASM define in DECOptions.inc it is compatible with all 17 | platforms supported by Delphi! It might be compatible with FPC, but this has 18 | not been focus and is not tested. The development branch contains a more 19 | FPC compatible version already. 20 | 21 | If you need support for older Delphi versions use version 5.2, which is compatible 22 | with Delphi 7-2007 at least but lacks some hash implementations, HMAC and KDF 23 | improvements. While V5.2 can be made compatible with newer Delphi versions with 24 | small modifications we strongly recommend to better adapt your code to use the 25 | current version of DEC, given all these improvements made since then. 26 | A list of changes is available in the docs folder. 27 | 28 | ## What is the current status of this project? 29 | V6.0 was released shortly before Christmas 2020. Since then work continued 30 | by some users supplying code, reporting bugs (regressions) along with fixes 31 | and by adding SHA2-224, which was still missing. 32 | Further new algorithms like SHA3 have been added meanwhile. 33 | Details about the changes and additions in V6.4.1 can be found in the 34 | VersionHistory.pdf file in the docs subfolder of the development branch. 35 | 36 | In comparison to 5.2 we added some console, VCL and FMX based demo applications. 37 | The FMX based demos are even available via Google play as "DEC cipher demo" and 38 | "DEC hash demo". 39 | 40 | ## Where can I get further information? For example if I'd like to contribute? 41 | In the root folder of DEC V6.4.1 you will find further files with information about 42 | this project like *NOTICE.txt*, *CONTRIBUTING.md*, *SECURITY.md*. 43 | Also take the time to read DEC64.pdf in the *Docs* folder and look at the demos 44 | provided in the *Demos* subfolder. 45 | 46 | ## Has it been tested? 47 | DEC 5.2 came with some "arcane" test program testing the algoithms implemented 48 | using test data supplied via some text file. For many algorithms this test data 49 | stems from official documentation of the algorithms itsself. DEC 5.2 passes these 50 | tests. 51 | 52 | DEC 6.0 reworked these tests into DUnit and DUnitX tests. We also added some more 53 | tests and with this replaced the "arcane" test program which used hard to understand 54 | code. A few of the implemented unit tests may still fail, but this is simply because 55 | they are empty sceletons at this point in time waiting to be filled in. We first 56 | need to work out how to implement these tests and maybe look for test data. 57 | Why don't you help out by researching useful test data for those few tests? 58 | We're talking at block chaining mode tests for the ciphers specifically. 59 | 60 | In DEC 6.2 the unit tests for the hash classes were looked at and where not already 61 | used original test data vectors (as far as we could find them - for most we could) 62 | have been added to improve test coverage. V6.3 added further synthesized tests for 63 | some hash classes. For SHA3 and for the GCM block chaining method the original test 64 | vectors provided by NIST are used for the unit tests. 65 | 66 | ## Contained hash algorithms 67 | * MD2 68 | * MD4 69 | * MD5 70 | * RipeMD128 71 | * RipeMD160 72 | * RipeMD256 73 | * RipeMD320 74 | * SHA0 75 | * SHA1 76 | * SHA224 77 | * SHA256 78 | * SHA384 79 | * SHA512 80 | * SHA3_224 81 | * SHA3_256 82 | * SHA3_384 83 | * SHA3_512 84 | * Shake128 85 | * Shake256 86 | * Haval128 87 | * Haval160 88 | * Haval192 89 | * Haval224 90 | * Haval256 91 | * Tiger 92 | * Panama 93 | * Whirlpool0 94 | * Whirlpool1 95 | * WhirlpoolT 96 | * Square 97 | * Snefru128 98 | * Snefru256 99 | * Sapphire 100 | 101 | ## Contained cipher algorithms 102 | * Null 103 | * Blowfish 104 | * Twofish 105 | * IDEA 106 | * Cast256 107 | * Mars 108 | * RC4 109 | * RC6 110 | * AES 111 | * Square 112 | * SCOP 113 | * Sapphire 114 | * 1DES 115 | * 2DES 116 | * 3DES 117 | * 2DDES 118 | * 3DDES 119 | * 3TDES 120 | * 3Way 121 | * Cast128 122 | * Gost 123 | * Magma 124 | * Misty 125 | * NewDES 126 | * Q128 127 | * RC2 128 | * RC5 129 | * SAFER 130 | * Shark 131 | * Skipjack 132 | * TEA 133 | * XTEA 134 | * TEAN 135 | 136 | ## Contained block concatenating modes 137 | Modes ending on x have been invented by the original developer of DEC 138 | * ECBx 139 | * CBCx 140 | * CTSx 141 | * CTS3 142 | * CFB8 143 | * CFBx 144 | * OFB8 145 | * OFBx 146 | * CFS8 147 | * CFSx 148 | * GCM 149 | 150 | ## Contained key derivation algorithms: 151 | * KDF1 152 | * KDF2 153 | * KDF3 154 | * MGF1 155 | * PBKDF2 156 | 157 | ## Contained message authentication algorithms 158 | * HMAC 159 | 160 | ## Contained formattings 161 | * Copy 162 | * HEX 163 | * HEXL 164 | * Base16 165 | * Base16L 166 | * DECMIME32 167 | * Base64 168 | * MIME64 169 | * Radix64 170 | * PGP 171 | * UU 172 | * XX 173 | * ESCAPE 174 | * BigEndian16 175 | * BigEndian32 176 | * BigEndian64 177 | 178 | ## Contained CRCs 179 | * 8 180 | * 10 181 | * 12 182 | * 16 183 | * 16CCITT 184 | * 16XModem 185 | * 24 186 | * 32 187 | * 32CCITT 188 | * 32ZModem 189 | * 8ATMHEC 190 | * 8SMBus 191 | * 15CAN 192 | * 16ZMODEM --------------------------------------------------------------------------------