Software Algorithms and Programs - ANS Forth for 32 bit PC Forths

 

I hope you find them useful – Howerd 2011 Apr 20

 

Feedback or bug reports to howerd@inventio.co.uk

 

wsa.f    wsa.zip

\ wsa.f  Howerd Oakford 2008 Jul 12
\ Windows Sockets API ( Berkeley-like interface )
\ Also a simple TCP/IP client terminal, and an HTTP interface.
\ Written in ANS Forth using the SwiftForth, VFX and Win32Forth Windows interfaces.

 

isqrt.f    isqrt.zip

\ isqrt.f  Howerd Oakford  2008 Jun 04
\ Square Root of unsigned 32 bit integer 
\ from James Ulery's Computing Integer Square Roots
\ http://www.azillionmonkeys.com/qed/ulerysqroot.pdf

 

tiff.f   tiff.zip

\ So far this just displays the TIFF and BigTIFF headers – there is no display of the image yet.
\ I include it here in case anyone else has time to work on it.
\ tiff.f 2008 Apr 29 TIFF and BigTIFF file reader
\ Howerd Oakford www.inventio.co.uk
\ Tag Image File Format (TIFF) Rev 6.0
\ TIFF is an extensible image file format
\ BigTIFF is TIFF expanded to 64 bits
\ To do : find out where the image data is, add decompression and display code... 
\ To do : find out why BigTIFF requires Big Endian changes compared to TIFF, and why 
\ the STRIPOFFSETS and STRIPBYTECOUNTS in the btf file are longs, but look like they are shorts...

 

md5.f   md5.zip

\ md5.f V1.0  Howerd Oakford 2006 Jul 01

\ The MD5 secure hash algorithm

\ 32 bit little endian ANS Forth version for the PC

\ Tested on SwiftForth, Win32Forth and VFXForth

\ *************************************************************

\ Bug notice 2006 Jul 01 :

\ All my previous versions of md5.f and md5.fth have a bug :

\ The "55 >" was incorrectly " 1+ $38 < 0=" and gave an

\ incorrect hash for strings of length 55 ( modulo 64 ).

\ *************************************************************

crc16hdlc.f   crc16hdlc.zip

\ *****************************************************************************

\ CRC16HDLC.f  2011 Apr 20

\ CRC-16 for HDLC calculation using a table

\ 16 bit FCS lookup table per RFC1331

\ Thanks to :

\ http://www.mavi1.org/web_security/cryptography/hashes/crc/crc-16-hdlc.c

\ Note that this code defines "#define FCSGOOD 0xF0B8"

\ wheras I define "$0F47 constant CRC_VALID"  which is bitwise inverted.

\ This is because CRC16 returns the actual value to be sent in an HDLC packet

\ Also note that at least one online CRC calculator does not include this CRC.

\ *****************************************************************************

 

crc32.f   crc32.zip

\ crc32.f 2006 Jan 04 Howerd Oakford,

\ based on code by Petrus Prawirodidjojo and Wil Baden - thanks!

\

\ The International Standard 32-bit cyclical redundancy check defined by :

\ [ITU-T-V42] International Telecommunications Union, "Error-correcting

\ Procedures for DCEs Using Asynchronous-to-Synchronous Conversion",

\ ITU-T Recommendation V.42, 1994, Rev. 1.

\ and

\ [ISO-3309]

\ International Organization for Standardization,

\ "Information Processing Systems--Data Communication High-Level Data Link

\ Control Procedure--Frame Structure", IS 3309, October 1984, 3rd Edition.

\

\ This is a 32 bit Little Endian ANS Forth version ( PC ).

 

tean.f   tean.zip

\ tean.f 2006 Jan 04

\ TEA is the Tiny Encryption Algorithm - a shared private key system

\ based on many iterations of a simple hashing function.

\ Created by David J. Wheeler and Roger M. Needham.

\ TEAN ( TEA New ) is an improved version of TEA which includes modifications

\ to TEA made after David Wagner discovered weaknesses in the key scheduling.

\ Based on C code from http://www.simonshepherd.supanet.com/source.htm#new_ansi

\ See also http://www.ftp.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html

\ TEA and TEAN are 64-bit block Feistel cyphers using a 128-bit key.

 

tea26.f   tea26.zip

\ tea26.f  Tiny Encryption Algorithm limited to 26 bits. 2006 Jan 04

\ The 26 bit value is split into two 13 bit numbers.

\ Each calculation is performed modulo 2**13 , then the two 13 bit results

\ are converted back to 26 bits.

\ An 8 digit decimal number can be used to describe the 26 bit value.

\ Some of the 26 bits ( say 10 ) should be used to make random guesses

\ unlikely. This could be used to encrypt a 16 bit number with a 0.1%

\ chance that a random number appears as valid - equivalent to a

\ three digit PIN code.