blowfish(n) | Blowfish Block Cipher | blowfish(n) |
blowfish - Implementation of the Blowfish block cipher
package require Tcl 8.4
package require blowfish ?1.0.4?
::blowfish::blowfish ?-mode [ecb|cbc]? ?-dir [encrypt|decrypt]? -key keydata ?-iv vector? ?-out channel? ?-chunksize size? ?-pad padchar? [ -in channel | ?--? data ]
::blowfish::Init mode keydata iv
::blowfish::Encrypt Key data
::blowfish::Decrypt Key data
::blowfish::Reset Key iv
::blowfish::Final Key
This package is an implementation in Tcl of the Blowfish algorithm developed by Bruce Schneier [1]. Blowfish is a 64-bit block cipher designed to operate quickly on 32 bit architectures and accepting a variable key length. This implementation supports ECB and CBC mode blowfish encryption.
The -key option must be given. This parameter takes a binary string of variable length and is used to generate the blowfish key schedule. You should be aware that creating a key schedule is quite an expensive operation in blowfish so it is worth reusing the key where possible. See Reset.
The -mode and -dir options are optional and default to cbc mode and encrypt respectively. The initialization vector -iv takes an 8 byte binary argument which defaults to 8 zeros. See MODES OF OPERATION for more about available modes and their uses.
Blowfish is a 64-bit block cipher. This means that the data must be provided in units that are a multiple of 8 bytes. The blowfish command will by default add nul characters to pad the input data to a multiple of 8 bytes if necessary. The programming api commands will never add padding and instead will raise an error if the input is not a multiple of the block size. The -pad option can be used to change the padding character or to disable padding if the empty string is provided as the argument.
% blowfish::blowfish -hex -mode ecb -dir encrypt -key secret01 "hello, world!" d0d8f27e7a374b9e2dbd9938dd04195a
set Key [blowfish::Init cbc $eight_bytes_key_data $eight_byte_iv]
append ciphertext [blowfish::Encrypt $Key $plaintext]
append ciphertext [blowfish::Encrypt $Key $additional_plaintext]
blowfish::Final $Key
Frank Pilhofer, Pat Thoyts
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category blowfish of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation.
3des, des, rc4
block cipher, blowfish, cryptography, encryption, security
Hashes, checksums, and encryption
Copyright (c) 2003, Pat Thoyts <patthoyts@users.sourceforge.net>
1.0.3 | blowfish |