//============================================================================== // // Copyright (C) 2007 Dick van Oudheusden // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this program; if not, write to the Free // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // //============================================================================== // // $Date: 2007/07/12 17:24:27 $ $Revision: 1.2 $ // //============================================================================== #include #include "ofc/config.h" #include "ofc/DSHA256.h" #include "ofc/DText.h" #include "DInc.h" #include "DTest.h" //-Wrappers-------------------------------------------------------------------- void DSHA256_test(void) { DSHA256 *sha = [DSHA256 alloc]; long l; STARTTEST(); [sha init :""]; TEST([[sha hexdigest] icompare :"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"] == 0); [sha free]; sha = [DSHA256 new]; [sha update :"abc"]; TEST([[sha hexdigest] icompare :"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD"] == 0); [sha update :"dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"]; TEST([[sha hexdigest] icompare :"248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1"] == 0); [sha reset]; for (l = 0; l < 31250; l++) [sha update :"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]; // a million 'a's TEST([[sha hexdigest] icompare :"CDC76E5C9914FB9281A1C7E284D73E67F1809A48A497200E046D39CCC7112CD0"] == 0); [sha free]; STOPTEST(); }