Index: doc/tls.html ================================================================== --- doc/tls.html +++ doc/tls.html @@ -40,10 +40,11 @@
tls::digest type ?-bin|-hex? ?-key hmac_key? [-file filename | -chan channel | ?-data? data]
tls::md4 data
tls::md5 data
tls::sha1 data
tls::sha256 data
+
tls::sha512 data
COMMANDS
CALLBACK OPTIONS
HTTPS EXAMPLE
@@ -81,10 +82,11 @@ tls::digest type ?-bin|-hex? ?-key hmac_key? [-file filename | -chan channel | ?-data? data]
tls::md4 data
tls::md5 data
tls::sha1 data
tls::sha256 data
+tls::sha512 data

DESCRIPTION

This extension provides a generic binding to tls::sha1 data

Returns the SHA1 secure hash algorithm digest for data as a hex string.
tls::sha256 data
Returns the SHA-2 SHA256 secure hash algorithm digest for data as a hex string.
+ +
tls::sha512 data
+
Returns the SHA-2 SHA512 secure hash algorithm digest for data as a hex string.

CALLBACK OPTIONS

Index: generic/tlsDigest.c ================================================================== --- generic/tlsDigest.c +++ generic/tlsDigest.c @@ -948,10 +948,14 @@ } int DigestSHA256Cmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { return DigestHashFunction(interp, objc, objv, EVP_sha256(), HEX_FORMAT, NULL); } + +int DigestSHA512Cmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { + return DigestHashFunction(interp, objc, objv, EVP_sha512(), HEX_FORMAT, NULL); +} /* *------------------------------------------------------------------- * * Tls_DigestCommands -- @@ -970,9 +974,10 @@ Tcl_CreateObjCommand(interp, "tls::digest", DigestObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::md4", DigestMD4Cmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::md5", DigestMD5Cmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::sha1", DigestSHA1Cmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::sha256", DigestSHA256Cmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "tls::sha512", DigestSHA512Cmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "tls::unstack", UnstackObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); return TCL_OK; } Index: tests/ciphers.csv ================================================================== --- tests/ciphers.csv +++ tests/ciphers.csv @@ -52,33 +52,37 @@ command,# Test digest commands,,,,,,,,, Digest Cmds,md4 cmd,,,"tls::md4 ""Example string for message digest tests.""",,,181CDCF9DB9B6FA8FC0A3BF9C34E29D9,,, Digest Cmds,md5 cmd,,,"tls::md5 ""Example string for message digest tests.""",,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest Cmds,sha1 cmd,,,"tls::sha1 ""Example string for message digest tests.""",,,3AEFE840CA492C387E903F15ED6019E7AD833B47,,, Digest Cmds,sha256 cmd,,,"tls::sha256 ""Example string for message digest tests.""",,,B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491,,, +Digest Cmds,sha512 cmd,,,"tls::sha512 ""Example string for message digest tests.""",,,B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F,,, ,,,,,,,,,, command,# Test digest command for data,,,,,,,,, Digest Data,md4,,,"tls::digest md4 ""Example string for message digest tests.""",,,181CDCF9DB9B6FA8FC0A3BF9C34E29D9,,, Digest Data,md5,,,"tls::digest md5 ""Example string for message digest tests.""",,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest Data,sha1,,,"tls::digest sha1 ""Example string for message digest tests.""",,,3AEFE840CA492C387E903F15ED6019E7AD833B47,,, Digest Data,sha256,,,"tls::digest sha256 ""Example string for message digest tests.""",,,B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491,,, +Digest Data,sha512,,,"tls::digest sha512 ""Example string for message digest tests.""",,,B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F,,, Digest Data,md5 bin,,,"string toupper [binary encode hex [tls::digest md5 -bin ""Example string for message digest tests.""]]",,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest Data,md5 hex,,,"tls::digest md5 -hex ""Example string for message digest tests.""",,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest Data,md5 with arg,,,"tls::digest md5 -data ""Example string for message digest tests.""",,,CCB1BE2E11D8183E843FF73DA8C6D206,,, ,,,,,,,,,, command,# Test digest command for files,,,,,,,,, Digest File,md4,,,tls::digest md4 -file md_data.dat,,,181CDCF9DB9B6FA8FC0A3BF9C34E29D9,,, Digest File,md5,,,tls::digest md5 -file md_data.dat,,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest File,sha1,,,tls::digest sha1 -file md_data.dat,,,3AEFE840CA492C387E903F15ED6019E7AD833B47,,, Digest File,sha256,,,tls::digest sha256 -file md_data.dat,,,B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491,,, +Digest File,sha512,,,tls::digest sha512 -file md_data.dat,,,B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F,,, Digest File,md5 bin,,,string toupper [binary encode hex [tls::digest md5 -bin -file md_data.dat]],,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest File,md5 hex,,,tls::digest md5 -hex -file md_data.dat,,,CCB1BE2E11D8183E843FF73DA8C6D206,,, ,,,,,,,,,, command,# Test digest command for channel,,,,,,,,, Digest Chan,md4,,,read_chan md4 md_data.dat,,,181CDCF9DB9B6FA8FC0A3BF9C34E29D9,,, Digest Chan,md5,,,read_chan md5 md_data.dat,,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest Chan,sha1,,,read_chan sha1 md_data.dat,,,3AEFE840CA492C387E903F15ED6019E7AD833B47,,, Digest Chan,sha256,,,read_chan sha256 md_data.dat,,,B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491,,, +Digest Chan,sha512,,,read_chan sha512 md_data.dat,,,B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F,,, Digest Chan,md5 bin,,,string toupper [binary encode hex [read_chan md5 md_data.dat -bin]],,,CCB1BE2E11D8183E843FF73DA8C6D206,,, Digest Chan,md5 hex,,,read_chan md5 md_data.dat -hex,,,CCB1BE2E11D8183E843FF73DA8C6D206,,, ,,,,,,,,,, command,# Test HMAC,,,,,,,,, Digest HMAC,data,,,"tls::digest md5 -key ""Example key"" -data ""Example string for message digest tests.""",,,901DA6E6976A71650C77443C37FF9C7F,,, Index: tests/ciphers.test ================================================================== --- tests/ciphers.test +++ tests/ciphers.test @@ -131,10 +131,14 @@ } -result {3AEFE840CA492C387E903F15ED6019E7AD833B47} test Digest_Cmds-6.4 {sha256 cmd} -body { tls::sha256 "Example string for message digest tests." } -result {B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491} + +test Digest_Cmds-6.5 {sha512 cmd} -body { + tls::sha512 "Example string for message digest tests." + } -result {B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F} # Test digest command for data test Digest_Data-7.1 {md4} -body { tls::digest md4 "Example string for message digest tests." @@ -150,19 +154,23 @@ test Digest_Data-7.4 {sha256} -body { tls::digest sha256 "Example string for message digest tests." } -result {B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491} -test Digest_Data-7.5 {md5 bin} -body { +test Digest_Data-7.5 {sha512} -body { + tls::digest sha512 "Example string for message digest tests." + } -result {B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F} + +test Digest_Data-7.6 {md5 bin} -body { string toupper [binary encode hex [tls::digest md5 -bin "Example string for message digest tests."]] } -result {CCB1BE2E11D8183E843FF73DA8C6D206} -test Digest_Data-7.6 {md5 hex} -body { +test Digest_Data-7.7 {md5 hex} -body { tls::digest md5 -hex "Example string for message digest tests." } -result {CCB1BE2E11D8183E843FF73DA8C6D206} -test Digest_Data-7.7 {md5 with arg} -body { +test Digest_Data-7.8 {md5 with arg} -body { tls::digest md5 -data "Example string for message digest tests." } -result {CCB1BE2E11D8183E843FF73DA8C6D206} # Test digest command for files @@ -180,15 +188,19 @@ test Digest_File-8.4 {sha256} -body { tls::digest sha256 -file md_data.dat } -result {B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491} -test Digest_File-8.5 {md5 bin} -body { +test Digest_File-8.5 {sha512} -body { + tls::digest sha512 -file md_data.dat + } -result {B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F} + +test Digest_File-8.6 {md5 bin} -body { string toupper [binary encode hex [tls::digest md5 -bin -file md_data.dat]] } -result {CCB1BE2E11D8183E843FF73DA8C6D206} -test Digest_File-8.6 {md5 hex} -body { +test Digest_File-8.7 {md5 hex} -body { tls::digest md5 -hex -file md_data.dat } -result {CCB1BE2E11D8183E843FF73DA8C6D206} # Test digest command for channel @@ -206,15 +218,19 @@ test Digest_Chan-9.4 {sha256} -body { read_chan sha256 md_data.dat } -result {B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491} -test Digest_Chan-9.5 {md5 bin} -body { +test Digest_Chan-9.5 {sha512} -body { + read_chan sha512 md_data.dat + } -result {B56EC55E33193E17B61D669FB7B04AD2483DE93FE847C411BBEAE6440ECEA6C7CFDD2E6F35A06CB189FC62D799E785CDB7A23178323789D001BC8E44A0B5907F} + +test Digest_Chan-9.6 {md5 bin} -body { string toupper [binary encode hex [read_chan md5 md_data.dat -bin]] } -result {CCB1BE2E11D8183E843FF73DA8C6D206} -test Digest_Chan-9.6 {md5 hex} -body { +test Digest_Chan-9.7 {md5 hex} -body { read_chan md5 md_data.dat -hex } -result {CCB1BE2E11D8183E843FF73DA8C6D206} # Test HMAC