Menu

Tree [3763fc] default tip /
 History

Read Only access


File Date Author Commit
 test.dir 2020-05-27 Brad Lanam Brad Lanam [1e3336] remove debug
 .hgignore 2021-06-19 Eckhard Lehmann Eckhard Lehmann [fc13cf] added CMakeLists.txt and some ignores
 .hgtags 2020-05-28 Brad Lanam Brad Lanam [d489c6] Added tag 2.0 for changeset 33ffd5991204
 CMakeLists.txt 2021-06-19 Eckhard Lehmann Eckhard Lehmann [fc13cf] added CMakeLists.txt and some ignores
 Makefile 2020-05-28 Brad Lanam Brad Lanam [33ffd5] makefile fixes for win
 README.txt 2021-06-19 Eckhard Lehmann Eckhard Lehmann [3763fc] output in binary, hex (default as before) or ba...
 pkgIndex.tcl 2021-06-19 Eckhard Lehmann Eckhard Lehmann [fc13cf] added CMakeLists.txt and some ignores
 sha.c 2020-05-27 Brad Lanam Brad Lanam [a8866a] warning fixes
 sha.h 2020-05-27 Brad Lanam Brad Lanam [a8866a] warning fixes
 tclsha.c 2021-06-19 Eckhard Lehmann Eckhard Lehmann [3763fc] output in binary, hex (default as before) or ba...

Read Me

Version 2.1

Changes:
  2.1
    - added CMakeLists.txt for cmake build
    - added -keyhex/-datahex for hex encoded key resp. data
    - added -keybin/-databin for strictly binary key resp. data
    - added -output [hex|base64|binary] option. Hex is default as before
    - removed sha256 package provide from C code
  2.0
    - Added support for hmac.
    - Code cleanup.
    - Arguments no longer require a specific order.
    - Fixed missing cflags for 32-bit linux (large file support).
    - Cleaned up Makefile.

sha-2.0.zip : binary package
              Includes Linux 32 bit, Linux 64 bit,
              MacOS 64 bit, and Windows 64 bit
              Does not include the sha-256 binaries.

sha-src-2.0.zip : sources and NIST test suite.

Usage:

  package require sha
  set buffer abc123
  set sha512 [sha -bits 512 -data $buffer]
  set sha512 [sha -bits 512 -file pkgIndex.tcl]
  set sha384 [sha -bits 384 -file pkgIndex.tcl]
  set sha512_224 [sha -bits 512/224 -file pkgIndex.tcl]
  set sha512_256 [sha -bits 512/256 -file pkgIndex.tcl]

  package require sha
  set buffer abc123
  set key def456
  set hmac [sha -bits 512 -key $key -mac hmac -data $buffer]
  set hmac [sha -bits 512 -keyfile pkgIndex.tcl -mac hmac -file pkgIndex.tcl]
  set hmac [sha -bits 384 -keyfile pkgIndex.tcl -mac hmac -file pkgIndex.tcl]

  # Using the -data argument is not recommended for binary data.
  # It should only be used for simple textual data.

  # The sha and sha256 packages cannot both be loaded at the same time
  # due to internal naming conflicts.
  # These are not included in the binaries .zip file.
  package require sha256
  set buffer abc123
  set sha256 [sha -bits 256 -data $buffer]
  set sha224 [sha -bits 224 -file pkgIndex.tcl]

  set buffer abc123
  set key def456
  set hmac [sha -bits 256 -key $key -mac hmac -data $buffer]
  set hmac [sha -bits 224 -keyfile pkgIndex.tcl -mac hmac -file pkgIndex.tcl]
  set hmac [sha -bits 256 -keyfile pkgIndex.tcl -mac hmac -file pkgIndex.tcl]

Building:

Using cmake (recommended):

  1. install tcl-devel and cmake for your platform
  2. To build in the "build" directory:
    
    mkdir -p build && cd build
    cmake ..

    # for unix/linux/darwin
    make

    # for windows, requires the MSVC command prompt
    msbuild tcl-sha.sln /property:Configuration=Release

Using make:

unix/darwin:
    make
  
  make {linux|darwin|windows}
    make linux should work for freebsd also.

  To validate against the NIST data:
    cd test.dir
    tclsh testsha.tcl
    tclsh testsha.tcl 256