crypto.lsp

Module index

source download

Module: crypto.lsp

SSL crypto functions for MD5 and SHA-1 hashing

Version: 1.01 - initial release
Version: 1.02 - renamed to crypto, new lib detection
Version: 1.04 - added hmac encryption from amazon.com query API
Version: 1.05 - added added gnuwin32/bin/libeay32.dll for crypto on Win32
Version: 1.06 - added ripemd160
Version: 1.07 - added libcrypto for OpenBSD and tested for 64-bit
Version: 1.08 - help text corrections
Version: 1.09 - added lib path for Windows 7
Version: 1.10 - added SHA256
Version: 1.11 - added path for UBUNTU Linux 13.04
Version: 1.12 - added path for UBUNTU Linux 12.04 and CentOS, removed old
Version: 1.13 - fix for crypto:hmac. Thanks Cormullion, March 2014
Version: 1.14 - starting v10.6.3 import using "cdecl" on Windows
Version: 1.15 - added path for Debian Jessie
Author: Lutz Mueller 2007, Martin Quiroga 2007, Norman Deppenbroek 2009,
Author: Marc Hildman, 2011


Module for SSL lib crypto bindings

This modules imports functions for the MD5 and SHA-1 hashing algorithms described here: http://www.ietf.org/rfc/rfc3174.txt . The crypto library is part of the OpenSSL libraries.

To use this module include the following load statement at the beginning of the program file:
 (load "/usr/share/newlisp/modules/crypto.lsp")
 ; or as a shorter alternative
 (module "crypto.lsp")
 

Requirements:

On Mac OS X, UBUNTU and many other Linux, BSDs and other UNIX installations libcrypto.so is installed by default as part of the OpenSSL libraries in usr/lib/libcrypto.so. If loading this module finishes with an error message the path of the library should be corrected. For MS Windows a library is available at http://gnuwin32.sourceforge.net/ .

This module has been tested on Mac OS X, UBUNTU Linux and FreeBSD.

§

crypto:md5

syntax: (crypto:md5 string bool-raw)
parameter: string - The string buffer for which to calculate a MD5 hash
parameter: bool-raw - Return the raw binay buffer when true.

return: The 16 Byte MD5 hash as a 32 Byte long hex string or as a 16 byte binary buffer.

Example:
 (crypto:md5 "ABC") => "902fbdd2b1df0c4f70b4a5d23525e932"

 (crypto:md5 (read-file "newlisp-9.1.0.tgz")) => "46c79c93e904df35c6a8474ace406c92"


§

crypto:sha1

syntax: (crypto:sha1 string bool-raw)
parameter: string - The string buffer for which to calculate a SHA-1 hash
parameter: bool-raw - Return the raw binay buffer when true.

return: The 20 Byte SHA-1 hash as a 40 Byte long hex string or as a 20 byte binary buffer.

Example:
 (crypto:sha1 "ABC") => "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8"

 (crypto:sha1 (read-file "newlisp-9.1.0.tgz")) => "2127a9c487f338b00f36cfd60b5f33d27b8d0010"


§

crypto:sha256

syntax: (crypto:sha256 string bool-raw)
parameter: string - The string buffer for which to calculate a SHA-256 hash
parameter: bool-raw - Return the raw binay buffer when true.

return: The 32 Byte SHA-1 hash as a 64 Byte long hex string or as a 32 byte binary buffer.

Example:
 (crypto:sha256 "ABC") => "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78" 


§

crypto:hmac

syntax: (crypto:hmac func-hash str-message str-key)
parameter: func-hash - The hash function to use.
parameter: str-message - The message to encrypt.
parameter: str-key - The encryption key.


This function is part of the amazon.com Query-API and based on RFC2104 - HMAC: Keyed-Hashing for Message Authentication.

Example:
 (set 'output (crypto:hmac crypto:md5 "Hello World" "secret"))
 (unpack (dup "c" (length output)) output)
 => (107 59 -76 66 117 -119 -35 -31 -7 -121 90 55 -109 -68 32 98)


§

crypto:ripemd160

syntax: (crypto:ripemd160 string bool-raw)
parameter: string - The string buffer for which to calculate a RIPEMD160 hash
parameter: bool-raw - Return the raw binay buffer when true.

return: The 20 Byte RIPEMD160 hash as a 40 Byte long hex string or as a 20 byte binary buffer.

Example:
 (crypto:ripemd160 "ABC") => "df62d400e51d3582d53c2d89cfeb6e10d32a3ca6" 
 
 (crypto:ripemd160 (read-file "newlisp.exe")) => "9c1185a5c5e9fc54612808977ee8f548b2258d31" 


- ∂ -

generated with newLISP  and newLISPdoc