-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement HMACStream and HMACFile #62
Comments
Thanks for the suggested methods! I'll try to look at those in a timely manner. But one request upfront: would you be able to provide at least a simplistic unit test for those? In case you don't know how to write a unit test just tell me and I'll teach you. |
Actually, I have never written a testcase for Delphi, so it would be great if you give me a few information about it. Thank you! |
Ok, let's start like this: I hope you have installed DUnit along with Delphi. If not add it by going to Tools/Manage features and add the "Unit testing" feature. As next step open the DEC60 projetct group and there activate the DECDUnitTestSuite project. |
Expand the tests node and open TestDECHMAC.pas or TestDECHash.pas, not sure at the moment where it fits into. Search for the class where the test belongs to means, the test class for the class you added your methods above to (sorry, I'll leaving in a few minutes, thus just a few generic pointers at the moment). In that class add a new published method TestXYZ (select a proper name ;-) ). In this method you put the code performing your test into. Have a look at other such methods and you'll see that such methods always set up data first (if that's not already done in SetUp method, which is run prior to each run of any of the TestXXX methods). Then the test uses your method to do someting with the data and afterwards the result is checked via CheckEquals, CHeckGreater and similar methonds provided by the test framework. |
After you implemented your test method press F9 and you should see a GUI with a tree of all tests. You might want to untick all those nodes not applying to your test and then press F9 to run your test. if the test works as it should it will be green, otherwise it will be magenta telling you that the test failed and providing a failure message. Then you have to check if your method works as it should or if the test still has a failure... ;-) If these instructions aren't good enough yet tell me and I'll guide you further. |
Thank you very much for the time you have taken to explain all this to me :-) I have installed DUnit and am now testing it a little. Just for fun I ran all tests, but I am surprised that I got hundreds of Exceptions of all kinds where the debugger stops. Is this normal? I guess the Exceptions are expected for the testcase, but I don't want that the compiler halts on every one, but I also don't want to exclude the Exception type, because my productive code needs to halt on these Exceptions. |
The exceptions are expected (when run from the IDE, you can get rid of them when running this outside the IDE or using TestInsight IDE plugin from Stefan Glienke, which can run the tests in the background). DEC can throw exceptions, e.g. if you pass invalid parameters and the unit tests test whether they are actually raised. |
I want to suggest a combination of the following methods:
Background information: I want to encrypt a large file which does not fit into the memory, and I would like to do "Encrypt-then-HMAC". So I need to HMAC the whole file or stream. (Pre-hasing is not a solution, because it is insecure)
Here is the code I wrote (actually copied and modified) and tested.
The text was updated successfully, but these errors were encountered: