* tests/langapi.prg
* tests/rto_get.prg
* tests/lnlenli2.prg
* tests/fortest.prg
* tests/memory.prg
* tests/rto_tb.prg
* tests/statinit.prg
* tests/memfile.prg
* tests/vec1.prg
* tests/lnlenli1.prg
* doc/cmdline.txt
* doc/en-EN/hb_date.txt
* doc/en-EN/terminal.txt
* doc/en-EN/hb_apiln.txt
* doc/en-EN/hb_compa.txt
* doc/howtosvn.txt
* INSTALL
* bin/postinst.cmd
* bin/postinst.bat
* include/hbvmpub.h
* include/vm.api
* include/extend.api
* include/item.api
* include/hbapilng.h
* include/rdd.api
* include/gt.api
* include/hbundoc.api
* include/error.api
* include/hbsetup.ch
* include/hblang.ch
* include/hbsetup.h
* include/hbapigt.h
* include/hbmemory.ch
* include/clipdefs.h
* include/hboo.ch
* include/hbver.ch
* include/hbzlib.h
* include/fm.api
* include/hbdate.h
* include/extend.h
* ChangeLog
* harbour.spec
* make_gnu.bat
* make_gnu.sh
* contrib/hbmysql/mysqlold.c
* contrib/hbct/charmix.c
* contrib/hbct/charevod.c
* contrib/hbct/ctchksum.c
* contrib/hbct/pos1.c
* contrib/hbct/ctmisc.prg
* contrib/hbct/ctcrypt.c
* contrib/hbct/getinfo.prg
* contrib/hbct/ctdummy.prg
* contrib/hbct/readme.txt
* contrib/hbodbc/odbcold.c
* contrib/hbodbc/browodbc.prg
* contrib/hbodbc/odbc.c
* contrib/xhb/datesxhb.c
* contrib/xhb/xhbat.c
* contrib/xhb/xhbver.prg
* contrib/xhb/xhbcomp.prg
* contrib/hbziparc/hbziparc.prg
* contrib/hbnf/iamidle.c
* contrib/hbnf/fttext.c
* contrib/hbnf/setkeys.c
* contrib/hbnf/ftisprn.c
* contrib/hbnf/setlastk.c
* contrib/hbcurl/hbcurl.c
* contrib/hbcurl/hbcurl.ch
* contrib/hbcurl/hbcurlm.c
* contrib/rddads/adsextrn.ch
* contrib/rddads/adsmgmnt.c
* contrib/hbmisc/strfmt.c
* contrib/hbmisc/numtxthu.prg
* contrib/hbmisc/doc/en/ht_str.txt
* contrib/hbtip/utils.c
* contrib/hbwin/win_reg.prg
* contrib/hbwin/legacyc.c
* contrib/hbwin/win_misc.c
* contrib/hbwin/wapi_winbase.c
* contrib/hbwin/wapi_winuser.c
* contrib/hbwin/hbwinole.h
* contrib/hbwin/hbwin.ch
* contrib/hbwin/tests/testdll.prg
* contrib/hbwin/tests/testole.prg
* contrib/hbwin/win_regc.c
* contrib/hbvpdf/hbvpsup.prg
* contrib/hbssl/sslsess.c
* contrib/hbssl/hbssl.h
* contrib/hbssl/sslctx.c
* contrib/hbssl/tests/test.prg
* contrib/hbssl/ssl.c
* contrib/hbssl/hbssl.ch
* contrib/hbssl/sslciph.c
* contrib/hbssl/sslrand.c
* contrib/hbcrypt/tests/testsha2.prg
* contrib/hbcrypt/hbsha2.c
* contrib/hbcrypt/hbsha2hm.c
* source/lang/msghuiso.c
* source/lang/msghuwin.c
* source/lang/msgro.c
* source/lang/msghriso.c
* source/lang/msghrwin.c
* source/lang/msghe862.c
* source/lang/msgcskam.c
* source/lang/msgbgiso.c
* source/lang/msgbgwin.c
* source/lang/msgcs852.c
* source/lang/msgfr.c
* source/lang/msgis850.c
* source/lang/msghu852.c
* source/lang/msgbg866.c
* source/lang/msghr852.c
* source/lang/msghewin.c
* source/lang/msghucwi.c
* source/lang/msgcsiso.c
* source/lang/msgcswin.c
* source/vm/harbinit.prg
* source/vm/asort.c
* source/vm/itemapi.c
* source/vm/hvm.c
* source/vm/cmdarg.c
* source/vm/arrays.c
* source/vm/fm.c
* source/vm/extrap.c
* source/vm/proc.c
* source/vm/memvars.c
* source/vm/memvclip.c
* source/vm/main.c
* source/vm/eval.c
* source/vm/extend.c
* source/vm/set.c
* source/vm/classes.c
* source/common/hbver.c
* source/common/hbfsapi.c
* source/common/hbstr.c
* source/common/hbdate.c
* source/rtl/lennum.c
* source/rtl/gtdos/gtdos.c
* source/rtl/diskspac.c
* source/rtl/setposbs.c
* source/rtl/mousehb.c
* source/rtl/console.c
* source/rtl/fscopy.c
* source/rtl/gtwin/gtwin.c
* source/rtl/mousex.c
* source/rtl/philes.c
* source/rtl/adir.prg
* source/rtl/oldclear.c
* source/rtl/tbcolumn.prg
* source/rtl/hbgtcore.c
* source/rtl/fieldbl.prg
* source/rtl/dirdrive.c
* source/rtl/dateshb.c
* source/rtl/philesx.c
* source/rtl/fnsplit.c
* source/rtl/box.c
* source/rtl/datesx.c
* source/rtl/filehb.c
* source/rtl/hbfile.c
* source/rtl/gtapiu.c
* source/rtl/fstemp.c
* source/rtl/accept.c
* source/rtl/radiobhb.prg
* source/rtl/tgethb.prg
* source/rtl/oemansix.c
* source/rtl/strmatch.c
* source/rtl/readkey.prg
* source/rtl/ampm.c
* source/rtl/oemansi.c
* source/rtl/xsavescr.c
* source/rtl/gtstd/gtstd.c
* source/rtl/gtsln/mousesln.c
* source/rtl/disksphb.c
* source/rtl/xhelp.c
* source/rtl/getlist.prg
* source/rtl/net.c
* source/rtl/hbntos.c
* source/rtl/tgetx.prg
* source/rtl/samples.c
* source/rtl/idlex.c
* source/rtl/tget.prg
* source/rtl/alert.prg
* source/rtl/inkey.c
* source/rtl/gete.c
* source/rtl/readvar.prg
* source/rtl/fkmax.c
* source/rtl/strzero.c
* source/rtl/typefilx.prg
* source/rtl/langapi.c
* source/rtl/word.c
* source/rtl/gtcgi/gtcgi.c
* source/rtl/fmhb.c
* source/rtl/natmsgu.c
* source/rtl/errapi.c
* source/rtl/version.c
* source/rtl/natmsg.c
* source/rtl/mouse53.c
* source/rtl/errint.c
* source/rtl/fssize.c
* source/rtl/errapiu.c
* source/rtl/colorind.c
* source/rtl/gt.c
* source/rtl/gx.c
* source/rtl/binnumx.c
* source/rtl/mouseapi.c
* source/rtl/soundex.c
* source/rtl/memofile.c
* source/rtl/errintlo.c
* source/rtl/hbffind.c
* source/rtl/gtapi.c
* source/rtl/pad.c
* source/rtl/hbstrsh.c
* source/rtl/filesys.c
* source/rtl/file.c
* source/rtl/lang.c
* source/rtl/val.c
* source/rtl/isprint.c
* source/rtl/tbrowse.prg
* source/codepage/ucmacce.c
* source/codepage/uc885910.c
* source/codepage/ucmacice.c
* source/codepage/uc885914.c
* source/codepage/uc874.c
* source/codepage/cpes850.c
* source/codepage/uc1258.c
* source/codepage/cphu852.c
* source/codepage/cpsk852.c
* source/codepage/uc424.c
* source/codepage/ucmacrom.c
* source/codepage/uc862.c
* source/codepage/cpesisoc.c
* source/codepage/cpbg866.c
* source/codepage/cphu852s.c
* source/codepage/uc8859_3.c
* source/codepage/uc8859_7.c
* source/codepage/ucmacgrk.c
* source/codepage/uc037.c
* source/codepage/cpesiso.c
* source/codepage/uc885911.c
* source/codepage/uc885915.c
* source/codepage/uc875.c
* source/codepage/uc1255.c
* source/codepage/cphuisos.c
* source/codepage/cpfriso.c
* source/codepage/uc863.c
* source/codepage/cpfrwin.c
* source/codepage/uc1026.c
* source/codepage/cpbgiso.c
* source/codepage/uc8859_4.c
* source/codepage/cpskkam.c
* source/codepage/cpbgwin.c
* source/codepage/uc8859_8.c
* source/codepage/uc855.c
* source/codepage/uc885916.c
* source/codepage/cproiso.c
* source/codepage/ucascii.c
* source/codepage/cprowin.c
* source/codepage/uc1256.c
* source/codepage/ucatari.c
* source/codepage/uc860.c
* source/codepage/ucmaccyr.c
* source/codepage/uc864.c
* source/codepage/uc1006.c
* source/codepage/cpsviso.c
* source/codepage/uc8859_5.c
* source/codepage/uc8859_9.c
* source/codepage/cphuwins.c
* source/codepage/ucnext.c
* source/codepage/ucmactrk.c
* source/codepage/uc885913.c
* source/codepage/cphuiso.c
* source/codepage/uc775.c
* source/codepage/uc856.c
* source/codepage/cpskiso.c
* source/codepage/cphuwin.c
* source/codepage/cpskwin.c
* source/codepage/uc500.c
* source/codepage/cpro852.c
* source/codepage/uc861.c
* source/codepage/uc865.c
* source/codepage/cpitwin.c
* source/codepage/uc869.c
* source/codepage/uc8859_6.c
* source/rdd/dbjoinx.prg
* source/rdd/dbnubs.c
* source/rdd/dblistx.prg
* source/rdd/dbtotalx.prg
* source/rdd/dbstruxx.prg
* source/rdd/dbsortx.prg
* source/rdd/dbupdatx.prg
* source/rdd/dbfuncsx.prg
* source/rdd/dbcmdhb.c
* source/compiler/cmdcheck.c
* source/compiler/hbusage.c
* source/hbzlib/ChangeLog
* utils/hbmk2/hbmk2.prg
* utils/hbtest/rt_main.h
* utils/hbtest/hbtest.prg
* utils/hbtest/rt_main.ch
* utils/hbtest/rt_trans.prg
* utils/hbtest/rt_miscc.c
* utils/hbtest/rt_math.prg
* utils/hbtest/rt_hvm.prg
* utils/hbtest/rt_hvma.prg
* utils/hbtest/rt_misc.prg
* utils/hbtest/make_c5x.bat
* utils/hbtest/rt_init.ch
* utils/hbtest/rt_str.prg
* utils/hbtest/rt_stra.prg
* utils/hbtest/rt_date.prg
* utils/hbtest/rt_vars.ch
* utils/hbtest/rt_array.prg
* utils/hbtest/rt_file.prg
* examples/pp/hbppcore.c
* examples/superlib/hbsuper.prg
* My e-mail address corrected to the same one using the
same format in all files. Corrected mistyped ones.
139 lines
6.5 KiB
Plaintext
139 lines
6.5 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
*
|
|
* Rewritten from C: Viktor Szakats (harbour.01 syenar.hu)
|
|
* www - http://www.harbour-project.org
|
|
*/
|
|
|
|
PROCEDURE Main()
|
|
|
|
? "SHA-2 FIPS 180-2 Validation tests"
|
|
Test_SHA2()
|
|
|
|
? "HMAC-SHA-2 IETF Validation tests"
|
|
Test_SHA2_HMAC()
|
|
|
|
RETURN
|
|
|
|
STATIC PROCEDURE Test_SHA2()
|
|
|
|
LOCAL cMsg1 := "abc"
|
|
LOCAL cMsg2a := "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
|
LOCAL cMsg2b := "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
|
|
LOCAL cMsg3 := Replicate( "a", 1000000 )
|
|
|
|
LOCAL results := {;
|
|
{; /* SHA-224 */
|
|
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" ,;
|
|
"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" ,;
|
|
"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" },;
|
|
{; /* SHA-256 */
|
|
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" ,;
|
|
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" ,;
|
|
"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" },;
|
|
{; /* SHA-384 */
|
|
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" ,;
|
|
"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039" ,;
|
|
"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985" },;
|
|
{; /* SHA-512 */
|
|
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" ,;
|
|
"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" ,;
|
|
"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" } }
|
|
|
|
? StrToHex( HB_SHA224( cMsg1 ) ) == results[ 1 ][ 1 ]
|
|
? StrToHex( HB_SHA224( cMsg2a ) ) == results[ 1 ][ 2 ]
|
|
? StrToHex( HB_SHA224( cMsg3 ) ) == results[ 1 ][ 3 ]
|
|
|
|
? StrToHex( HB_SHA256( cMsg1 ) ) == results[ 2 ][ 1 ]
|
|
? StrToHex( HB_SHA256( cMsg2a ) ) == results[ 2 ][ 2 ]
|
|
? StrToHex( HB_SHA256( cMsg3 ) ) == results[ 2 ][ 3 ]
|
|
|
|
? StrToHex( HB_SHA384( cMsg1 ) ) == results[ 3 ][ 1 ]
|
|
? StrToHex( HB_SHA384( cMsg2b ) ) == results[ 3 ][ 2 ]
|
|
? StrToHex( HB_SHA384( cMsg3 ) ) == results[ 3 ][ 3 ]
|
|
|
|
? StrToHex( HB_SHA512( cMsg1 ) ) == results[ 4 ][ 1 ]
|
|
? StrToHex( HB_SHA512( cMsg2b ) ) == results[ 4 ][ 2 ]
|
|
? StrToHex( HB_SHA512( cMsg3 ) ) == results[ 4 ][ 3 ]
|
|
|
|
RETURN
|
|
|
|
STATIC PROCEDURE Test_SHA2_HMAC()
|
|
LOCAL aMsg := {;
|
|
"Hi There",;
|
|
"what do ya want for nothing?",;
|
|
Replicate( Chr( 0xdd ), 50 ),;
|
|
Replicate( Chr( 0xcd ), 50 ),;
|
|
"Test With Truncation",;
|
|
"Test Using Larger Than Block-Size Key - Hash Key First",;
|
|
"This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm." }
|
|
|
|
LOCAL results := {;
|
|
"896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22",; /* HMAC-SHA-224 */
|
|
"a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44",;
|
|
"7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea",;
|
|
"6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a",;
|
|
"0e2aea68a90c8d37c988bcdb9fca6fa8",;
|
|
"95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e",;
|
|
"3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1",;
|
|
"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7",; /* HMAC-SHA-256 */
|
|
"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843",;
|
|
"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe",;
|
|
"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b",;
|
|
"a3b6167473100ee06e0c796c2955552b",;
|
|
"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54",;
|
|
"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2",;
|
|
"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6",; /* HMAC-SHA-384 */
|
|
"af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649",;
|
|
"88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27",;
|
|
"3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb",;
|
|
"3abf34c3503b2a23a46efc619baef897",;
|
|
"4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952",;
|
|
"6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e",;
|
|
"87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854",; /* HMAC-SHA-512 */
|
|
"164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737",;
|
|
"fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb",;
|
|
"b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd",;
|
|
"415fad6271580a531d4179bc891d87a6",;
|
|
"80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598",;
|
|
"e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58"}
|
|
|
|
LOCAL keys := {;
|
|
Replicate( Chr( 0x0b ), 20 ),;
|
|
"Jefe",;
|
|
Replicate( Chr( 0xaa ), 20 ),;
|
|
"",;
|
|
Replicate( Chr( 0x0c ), 20 ),;
|
|
Replicate( Chr( 0xaa ), 131 ),;
|
|
Replicate( Chr( 0xaa ), 131 ) }
|
|
|
|
LOCAL tmp
|
|
|
|
FOR tmp := 1 TO 25
|
|
keys[ 4 ] += Chr( tmp )
|
|
NEXT
|
|
|
|
FOR tmp := 1 TO 7
|
|
IF tmp != 5
|
|
? StrToHex( HB_HMAC_SHA224( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp ]
|
|
? StrToHex( HB_HMAC_SHA256( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp + 7 ]
|
|
? StrToHex( HB_HMAC_SHA384( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp + 14 ]
|
|
? StrToHex( HB_HMAC_SHA512( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp + 21 ]
|
|
/* We don't support these MAC sizes */
|
|
/* ELSE
|
|
mac_224_size = 128 / 8;
|
|
mac_256_size = 128 / 8;
|
|
mac_384_size = 128 / 8;
|
|
mac_512_size = 128 / 8; */
|
|
ENDIF
|
|
NEXT
|
|
|
|
RETURN
|
|
|
|
STATIC FUNCTION StrToHex( cString )
|
|
RETURN Lower( hb_StrToHex( cString ) )
|