sunterlib/scsh/encryption/blowfish.scm

1347 lines
56 KiB
Scheme

;;; blowfish.scm - blowfish encrypt and decrypt
;;;
;;; Copyright (c) 2012 Johan Ceuppens
;;;
;;; All rights reserved.
;;;
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;; 1. Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;; 2. Redistributions in binary form must reproduce the above copyright
;;; notice, this list of conditions and the following disclaimer in the
;;; documentation and/or other materials provided with the distribution.
;;; 3. The name of the authors may not be used to endorse or promote products
;;; derived from this software without specific prior written permission.
;;;
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
;;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
;;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
;;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
;;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
;;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(load "dictionary.scm")
(define BIG-ENDIAN-HOST (if (getenv BIG_ENDIAN_HOST)
(getenv BIG_ENDIAN_HOST)
#t) ;; NOTE : Do not forget to set this !
(define blowfish-ks0 (make-dictionary))
(dictionary-add! blowfish-ks0 '0xD1310BA6)
(dictionary-add! blowfish-ks0 '0x98DFB5AC)
(dictionary-add! blowfish-ks0 '0x2FFD72DB)
(dictionary-add! blowfish-ks0 '0xD01ADFB7)
(dictionary-add! blowfish-ks0 '0xB8E1AFED)
(dictionary-add! blowfish-ks0 '0x6A267E96)
(dictionary-add! blowfish-ks0 '0xBA7C9045)
(dictionary-add! blowfish-ks0 '0xF12C7F99)
(dictionary-add! blowfish-ks0 '0x24A19947)
(dictionary-add! blowfish-ks0 '0xB3916CF7)
(dictionary-add! blowfish-ks0 '0x0801F2E2)
(dictionary-add! blowfish-ks0 '0x858EFC16)
(dictionary-add! blowfish-ks0 '0x636920D8)
(dictionary-add! blowfish-ks0 '0x71574E69)
(dictionary-add! blowfish-ks0 '0xA458FEA3)
(dictionary-add! blowfish-ks0 '0xF4933D7E)
(dictionary-add! blowfish-ks0 '0x0D95748F)
(dictionary-add! blowfish-ks0 '0x728EB658)
(dictionary-add! blowfish-ks0 '0x718BCD58)
(dictionary-add! blowfish-ks0 '0x82154AEE)
(dictionary-add! blowfish-ks0 '0x7B54A41D)
(dictionary-add! blowfish-ks0 '0xC25A59B5)
(dictionary-add! blowfish-ks0 '0x9C30D539)
(dictionary-add! blowfish-ks0 '0x2AF26013)
(dictionary-add! blowfish-ks0 '0xC5D1B023)
(dictionary-add! blowfish-ks0 '0x286085F0)
(dictionary-add! blowfish-ks0 '0xCA417918)
(dictionary-add! blowfish-ks0 '0xB8DB38EF)
(dictionary-add! blowfish-ks0 '0x8E79DCB0)
(dictionary-add! blowfish-ks0 '0x603A180E)
(dictionary-add! blowfish-ks0 '0x6C9E0E8B)
(dictionary-add! blowfish-ks0 '0xB01E8A3E)
(dictionary-add! blowfish-ks0 '0xD71577C1)
(dictionary-add! blowfish-ks0 '0xBD314B27)
(dictionary-add! blowfish-ks0 '0x78AF2FDA)
(dictionary-add! blowfish-ks0 '0x55605C60)
(dictionary-add! blowfish-ks0 '0xE65525F3)
(dictionary-add! blowfish-ks0 '0xAA55AB94)
(dictionary-add! blowfish-ks0 '0x57489862)
(dictionary-add! blowfish-ks0 '0x63E81440)
(dictionary-add! blowfish-ks0 '0x55CA396A)
(dictionary-add! blowfish-ks0 '0x2AAB10B6)
(dictionary-add! blowfish-ks0 '0xB4CC5C34)
(dictionary-add! blowfish-ks0 '0x1141E8CE)
(dictionary-add! blowfish-ks0 '0xA15486AF)
(dictionary-add! blowfish-ks0 '0x7C72E993)
(dictionary-add! blowfish-ks0 '0xB3EE1411)
(dictionary-add! blowfish-ks0 '0x636FBC2A)
(dictionary-add! blowfish-ks0 '0x2BA9C55D)
(dictionary-add! blowfish-ks0 '0x741831F6)
(dictionary-add! blowfish-ks0 '0xCE5C3E16)
(dictionary-add! blowfish-ks0 '0x9B87931E)
(dictionary-add! blowfish-ks0 '0xAFD6BA33)
(dictionary-add! blowfish-ks0 '0x6C24CF5C)
(dictionary-add! blowfish-ks0 '0x7A325381)
(dictionary-add! blowfish-ks0 '0x28958677)
(dictionary-add! blowfish-ks0 '0x3B8F4898)
(dictionary-add! blowfish-ks0 '0x6B4BB9AF)
(dictionary-add! blowfish-ks0 '0xC4BFE81B)
(dictionary-add! blowfish-ks0 '0x66282193)
(dictionary-add! blowfish-ks0 '0x61D809CC)
(dictionary-add! blowfish-ks0 '0xFB21A991)
(dictionary-add! blowfish-ks0 '0x487CAC60)
(dictionary-add! blowfish-ks0 '0x5DEC8032)
(dictionary-add! blowfish-ks0 '0xEF845D5D)
(dictionary-add! blowfish-ks0 '0xE98575B1)
(dictionary-add! blowfish-ks0 '0xDC262302)
(dictionary-add! blowfish-ks0 '0xEB651B88)
(dictionary-add! blowfish-ks0 '0x23893E81)
(dictionary-add! blowfish-ks0 '0xD396ACC5)
(dictionary-add! blowfish-ks0 '0x0F6D6FF3)
(dictionary-add! blowfish-ks0 '0x83F44239)
(dictionary-add! blowfish-ks0 '0x2E0B4482)
(dictionary-add! blowfish-ks0 '0xA4842004)
(dictionary-add! blowfish-ks0 '0x69C8F04A)
(dictionary-add! blowfish-ks0 '0x9E1F9B5E)
(dictionary-add! blowfish-ks0 '0x21C66842)
(dictionary-add! blowfish-ks0 '0xF6E96C9A)
(dictionary-add! blowfish-ks0 '0x670C9C61)
(dictionary-add! blowfish-ks0 '0xABD388F0)
(dictionary-add! blowfish-ks0 '0x6A51A0D2)
(dictionary-add! blowfish-ks0 '0xD8542F68)
(dictionary-add! blowfish-ks0 '0x960FA728)
(dictionary-add! blowfish-ks0 '0xAB5133A3)
(dictionary-add! blowfish-ks0 '0x6EEF0B6C)
(dictionary-add! blowfish-ks0 '0x137A3BE4)
(dictionary-add! blowfish-ks0 '0xBA3BF050)
(dictionary-add! blowfish-ks0 '0x7EFB2A98)
(dictionary-add! blowfish-ks0 '0xA1F1651D)
(dictionary-add! blowfish-ks0 '0x39AF0176)
(dictionary-add! blowfish-ks0 '0x66CA593E)
(dictionary-add! blowfish-ks0 '0x82430E88)
(dictionary-add! blowfish-ks0 '0x8CEE8619)
(dictionary-add! blowfish-ks0 '0x456F9FB4)
(dictionary-add! blowfish-ks0 '0x7D84A5C3)
(dictionary-add! blowfish-ks0 '0x3B8B5EBE)
(dictionary-add! blowfish-ks0 '0xE06F75D8)
(dictionary-add! blowfish-ks0 '0x85C12073)
(dictionary-add! blowfish-ks0 '0x401A449F)
(dictionary-add! blowfish-ks0 '0x56C16AA6)
(dictionary-add! blowfish-ks0 '0x4ED3AA62)
(dictionary-add! blowfish-ks0 '0x363F7706)
(dictionary-add! blowfish-ks0 '0x1BFEDF72)
(dictionary-add! blowfish-ks0 '0x429B023D)
(dictionary-add! blowfish-ks0 '0x37D0D724)
(dictionary-add! blowfish-ks0 '0xD00A1248)
(dictionary-add! blowfish-ks0 '0xDB0FEAD3)
(dictionary-add! blowfish-ks0 '0x49F1C09B)
(dictionary-add! blowfish-ks0 '0x075372C9)
(dictionary-add! blowfish-ks0 '0x80991B7B)
(dictionary-add! blowfish-ks0 '0x25D479D8)
(dictionary-add! blowfish-ks0 '0xF6E8DEF7)
(dictionary-add! blowfish-ks0 '0xE3FE501A)
(dictionary-add! blowfish-ks0 '0xB6794C3B)
(dictionary-add! blowfish-ks0 '0x976CE0BD)
(dictionary-add! blowfish-ks0 '0x04C006BA)
(dictionary-add! blowfish-ks0 '0xC1A94FB6)
(dictionary-add! blowfish-ks0 '0x409F60C4)
(dictionary-add! blowfish-ks0 '0x5E5C9EC2)
(dictionary-add! blowfish-ks0 '0x196A2463)
(dictionary-add! blowfish-ks0 '0x68FB6FAF)
(dictionary-add! blowfish-ks0 '0x3E6C53B5)
(dictionary-add! blowfish-ks0 '0x1339B2EB)
(dictionary-add! blowfish-ks0 '0x3B52EC6F)
(dictionary-add! blowfish-ks0 '0x6DFC511F)
(dictionary-add! blowfish-ks0 '0x9B30952C)
(dictionary-add! blowfish-ks0 '0xCC814544)
(dictionary-add! blowfish-ks0 '0xAF5EBD09)
(dictionary-add! blowfish-ks0 '0xBEE3D004)
(dictionary-add! blowfish-ks0 '0xDE334AFD)
(dictionary-add! blowfish-ks0 '0x660F2807)
(dictionary-add! blowfish-ks0 '0x192E4BB3)
(dictionary-add! blowfish-ks0 '0xC0CBA857)
(dictionary-add! blowfish-ks0 '0x45C8740F)
(dictionary-add! blowfish-ks0 '0xD20B5F39)
(dictionary-add! blowfish-ks0 '0xB9D3FBDB)
(dictionary-add! blowfish-ks0 '0x5579C0BD)
(dictionary-add! blowfish-ks0 '0x1A60320A)
(dictionary-add! blowfish-ks0 '0xD6A100C6)
(dictionary-add! blowfish-ks0 '0x402C7279)
(dictionary-add! blowfish-ks0 '0x679F25FE)
(dictionary-add! blowfish-ks0 '0xFB1FA3CC)
(dictionary-add! blowfish-ks0 '0x8EA5E9F8)
(dictionary-add! blowfish-ks0 '0xDB3222F8)
(dictionary-add! blowfish-ks0 '0x3C7516DF)
(dictionary-add! blowfish-ks0 '0xFD616B15)
(dictionary-add! blowfish-ks0 '0x2F501EC8)
(dictionary-add! blowfish-ks0 '0xAD0552AB)
(dictionary-add! blowfish-ks0 '0x323DB5FA)
(dictionary-add! blowfish-ks0 '0xFD238760)
(dictionary-add! blowfish-ks0 '0x53317B48)
(dictionary-add! blowfish-ks0 '0x3E00DF82)
(dictionary-add! blowfish-ks0 '0x9E5C57BB)
(dictionary-add! blowfish-ks0 '0xCA6F8CA0)
(dictionary-add! blowfish-ks0 '0x1A87562E)
(dictionary-add! blowfish-ks0 '0xDF1769DB)
(dictionary-add! blowfish-ks0 '0xD542A8F6)
(dictionary-add! blowfish-ks0 '0x287EFFC3)
(dictionary-add! blowfish-ks0 '0xAC6732C6)
(dictionary-add! blowfish-ks0 '0x8C4F5573)
(dictionary-add! blowfish-ks0 '0x695B27B0)
(dictionary-add! blowfish-ks0 '0xBBCA58C8)
(dictionary-add! blowfish-ks0 '0xE1FFA35D)
(dictionary-add! blowfish-ks0 '0xB8F011A0)
(dictionary-add! blowfish-ks0 '0x10FA3D98)
(dictionary-add! blowfish-ks0 '0xFD2183B8)
(dictionary-add! blowfish-ks0 '0x4AFCB56C)
(dictionary-add! blowfish-ks0 '0x2DD1D35B)
(dictionary-add! blowfish-ks0 '0x9A53E479)
(dictionary-add! blowfish-ks0 '0xB6F84565)
(dictionary-add! blowfish-ks0 '0xD28E49BC)
(dictionary-add! blowfish-ks0 '0x4BFB9790)
(dictionary-add! blowfish-ks0 '0xE1DDF2DA)
(dictionary-add! blowfish-ks0 '0xA4CB7E33)
(dictionary-add! blowfish-ks0 '0x62FB1341)
(dictionary-add! blowfish-ks0 '0xCEE4C6E8)
(dictionary-add! blowfish-ks0 '0xEF20CADA)
(dictionary-add! blowfish-ks0 '0x36774C01)
(dictionary-add! blowfish-ks0 '0xD07E9EFE)
(dictionary-add! blowfish-ks0 '0x2BF11FB4)
(dictionary-add! blowfish-ks0 '0x95DBDA4D)
(dictionary-add! blowfish-ks0 '0xAE909198)
(dictionary-add! blowfish-ks0 '0xEAAD8E71)
(dictionary-add! blowfish-ks0 '0x6B93D5A0)
(dictionary-add! blowfish-ks0 '0xD08ED1D0)
(dictionary-add! blowfish-ks0 '0xAFC725E0)
(dictionary-add! blowfish-ks0 '0x8E3C5B2F)
(dictionary-add! blowfish-ks0 '0x8E7594B7)
(dictionary-add! blowfish-ks0 '0x8FF6E2FB)
(dictionary-add! blowfish-ks0 '0xF2122B64)
(dictionary-add! blowfish-ks0 '0x8888B812)
(dictionary-add! blowfish-ks0 '0x900DF01C)
(dictionary-add! blowfish-ks0 '0x4FAD5EA0)
(dictionary-add! blowfish-ks0 '0x688FC31C)
(dictionary-add! blowfish-ks0 '0xD1CFF191)
(dictionary-add! blowfish-ks0 '0xB3A8C1AD)
(dictionary-add! blowfish-ks0 '0x2F2F2218)
(dictionary-add! blowfish-ks0 '0xBE0E1777)
(dictionary-add! blowfish-ks0 '0xEA752DFE)
(dictionary-add! blowfish-ks0 '0x8B021FA1)
(dictionary-add! blowfish-ks0 '0xE5A0CC0F)
(dictionary-add! blowfish-ks0 '0xB56F74E8)
(dictionary-add! blowfish-ks0 '0x18ACF3D6)
(dictionary-add! blowfish-ks0 '0xCE89E299)
(dictionary-add! blowfish-ks0 '0xB4A84FE0)
(dictionary-add! blowfish-ks0 '0xFD13E0B7)
(dictionary-add! blowfish-ks0 '0x7CC43B81)
(dictionary-add! blowfish-ks0 '0xD2ADA8D9)
(dictionary-add! blowfish-ks0 '0x165FA266)
(dictionary-add! blowfish-ks0 '0x80957705)
(dictionary-add! blowfish-ks0 '0x93CC7314)
(dictionary-add! blowfish-ks0 '0x211A1477)
(dictionary-add! blowfish-ks0 '0xE6AD2065)
(dictionary-add! blowfish-ks0 '0x77B5FA86)
(dictionary-add! blowfish-ks0 '0xC75442F5)
(dictionary-add! blowfish-ks0 '0xFB9D35CF)
(dictionary-add! blowfish-ks0 '0xEBCDAF0C)
(dictionary-add! blowfish-ks0 '0x7B3E89A0)
(dictionary-add! blowfish-ks0 '0xD6411BD3)
(dictionary-add! blowfish-ks0 '0xAE1E7E49)
(dictionary-add! blowfish-ks0 '0x00250E2D)
(dictionary-add! blowfish-ks0 '0x2071B35E)
(dictionary-add! blowfish-ks0 '0x226800BB)
(dictionary-add! blowfish-ks0 '0x57B8E0AF)
(dictionary-add! blowfish-ks0 '0x2464369B)
(dictionary-add! blowfish-ks0 '0xF009B91E)
(dictionary-add! blowfish-ks0 '0x5563911D)
(dictionary-add! blowfish-ks0 '0x59DFA6AA)
(dictionary-add! blowfish-ks0 '0x78C14389)
(dictionary-add! blowfish-ks0 '0xD95A537F)
(dictionary-add! blowfish-ks0 '0x207D5BA2)
(dictionary-add! blowfish-ks0 '0x02E5B9C5)
(dictionary-add! blowfish-ks0 '0x83260376)
(dictionary-add! blowfish-ks0 '0x6295CFA9)
(dictionary-add! blowfish-ks0 '0x11C81968)
(dictionary-add! blowfish-ks0 '0x4E734A41)
(dictionary-add! blowfish-ks0 '0xB3472DCA)
(dictionary-add! blowfish-ks0 '0x7B14A94A)
(dictionary-add! blowfish-ks0 '0x1B510052)
(dictionary-add! blowfish-ks0 '0x9A532915)
(dictionary-add! blowfish-ks0 '0xD60F573F)
(dictionary-add! blowfish-ks0 '0xBC9BC6E4)
(dictionary-add! blowfish-ks0 '0x2B60A476)
(dictionary-add! blowfish-ks0 '0x81E67400)
(dictionary-add! blowfish-ks0 '0x08BA6FB5)
(dictionary-add! blowfish-ks0 '0x571BE91F)
(dictionary-add! blowfish-ks0 '0xF296EC6B)
(dictionary-add! blowfish-ks0 '0x2A0DD915)
(dictionary-add! blowfish-ks0 '0xB6636521)
(dictionary-add! blowfish-ks0 '0xE7B9F9B6)
(dictionary-add! blowfish-ks0 '0xFF34052E)
(dictionary-add! blowfish-ks0 '0xC5855664)
(dictionary-add! blowfish-ks0 '0x53B02D5D)
(dictionary-add! blowfish-ks0 '0xA99F8FA1)
(dictionary-add! blowfish-ks0 '0x08BA4799)
(dictionary-add! blowfish-ks0 '0x6E85076A)
(define blowfish-ks1(make-dictionary))
(dictionary-add! blowfish-ks1 '0x4B7A70E9)
(dictionary-add! blowfish-ks1 '0xB5B32944)
(dictionary-add! blowfish-ks1 '0xDB75092E)
(dictionary-add! blowfish-ks1 '0xC4192623)
(dictionary-add! blowfish-ks1 '0xAD6EA6B0)
(dictionary-add! blowfish-ks1 '0x49A7DF7D)
(dictionary-add! blowfish-ks1 '0x9CEE60B8)
(dictionary-add! blowfish-ks1 '0x8FEDB266)
(dictionary-add! blowfish-ks1 '0xECAA8C71)
(dictionary-add! blowfish-ks1 '0x699A17FF)
(dictionary-add! blowfish-ks1 '0x5664526C)
(dictionary-add! blowfish-ks1 '0xC2B19EE1)
(dictionary-add! blowfish-ks1 '0x193602A5)
(dictionary-add! blowfish-ks1 '0x75094C29)
(dictionary-add! blowfish-ks1 '0xA0591340)
(dictionary-add! blowfish-ks1 '0xE4183A3E)
(dictionary-add! blowfish-ks1 '0x3F54989A)
(dictionary-add! blowfish-ks1 '0x5B429D65)
(dictionary-add! blowfish-ks1 '0x6B8FE4D6)
(dictionary-add! blowfish-ks1 '0x99F73FD6)
(dictionary-add! blowfish-ks1 '0xA1D29C07)
(dictionary-add! blowfish-ks1 '0xEFE830F5)
(dictionary-add! blowfish-ks1 '0x4D2D38E6)
(dictionary-add! blowfish-ks1 '0xF0255DC1)
(dictionary-add! blowfish-ks1 '0x4CDD2086)
(dictionary-add! blowfish-ks1 '0x8470EB26)
(dictionary-add! blowfish-ks1 '0x6382E9C6)
(dictionary-add! blowfish-ks1 '0x021ECC5E)
(dictionary-add! blowfish-ks1 '0x09686B3F)
(dictionary-add! blowfish-ks1 '0x3EBAEFC9)
(dictionary-add! blowfish-ks1 '0x3C971814)
(dictionary-add! blowfish-ks1 '0x6B6A70A1)
(dictionary-add! blowfish-ks1 '0x687F3584)
(dictionary-add! blowfish-ks1 '0x52A0E286)
(dictionary-add! blowfish-ks1 '0xB79C5305)
(dictionary-add! blowfish-ks1 '0xAA500737)
(dictionary-add! blowfish-ks1 '0x3E07841C)
(dictionary-add! blowfish-ks1 '0x7FDEAE5C)
(dictionary-add! blowfish-ks1 '0x8E7D44EC)
(dictionary-add! blowfish-ks1 '0x5716F2B8)
(dictionary-add! blowfish-ks1 '0xB03ADA37)
(dictionary-add! blowfish-ks1 '0xF0500C0D)
(dictionary-add! blowfish-ks1 '0xF01C1F04)
(dictionary-add! blowfish-ks1 '0x0200B3FF)
(dictionary-add! blowfish-ks1 '0xAE0CF51A)
(dictionary-add! blowfish-ks1 '0x3CB574B2)
(dictionary-add! blowfish-ks1 '0x25837A58)
(dictionary-add! blowfish-ks1 '0xDC0921BD)
(dictionary-add! blowfish-ks1 '0xD19113F9)
(dictionary-add! blowfish-ks1 '0x7CA92FF6)
(dictionary-add! blowfish-ks1 '0x94324773)
(dictionary-add! blowfish-ks1 '0x22F54701)
(dictionary-add! blowfish-ks1 '0x3AE5E581)
(dictionary-add! blowfish-ks1 '0x37C2DADC)
(dictionary-add! blowfish-ks1 '0xC8B57634)
(dictionary-add! blowfish-ks1 '0x9AF3DDA7)
(dictionary-add! blowfish-ks1 '0xA9446146)
(dictionary-add! blowfish-ks1 '0x0FD0030E)
(dictionary-add! blowfish-ks1 '0xECC8C73E)
(dictionary-add! blowfish-ks1 '0xA4751E41)
(dictionary-add! blowfish-ks1 '0xE238CD99)
(dictionary-add! blowfish-ks1 '0x3BEA0E2F)
(dictionary-add! blowfish-ks1 '0x3280BBA1)
(dictionary-add! blowfish-ks1 '0x183EB331)
(dictionary-add! blowfish-ks1 '0x4E548B38)
(dictionary-add! blowfish-ks1 '0x4F6DB908)
(dictionary-add! blowfish-ks1 '0x6F420D03)
(dictionary-add! blowfish-ks1 '0xF60A04BF)
(dictionary-add! blowfish-ks1 '0x2CB81290)
(dictionary-add! blowfish-ks1 '0x24977C79)
(dictionary-add! blowfish-ks1 '0x5679B072)
(dictionary-add! blowfish-ks1 '0xBCAF89AF)
(dictionary-add! blowfish-ks1 '0xDE9A771F)
(dictionary-add! blowfish-ks1 '0xD9930810)
(dictionary-add! blowfish-ks1 '0xB38BAE12)
(dictionary-add! blowfish-ks1 '0xDCCF3F2E)
(dictionary-add! blowfish-ks1 '0x5512721F)
(dictionary-add! blowfish-ks1 '0x2E6B7124)
(dictionary-add! blowfish-ks1 '0x501ADDE6)
(dictionary-add! blowfish-ks1 '0x9F84CD87)
(dictionary-add! blowfish-ks1 '0x7A584718)
(dictionary-add! blowfish-ks1 '0x7408DA17)
(dictionary-add! blowfish-ks1 '0xBC9F9ABC)
(dictionary-add! blowfish-ks1 '0xE94B7D8C)
(dictionary-add! blowfish-ks1 '0xEC7AEC3A)
(dictionary-add! blowfish-ks1 '0xDB851DFA)
(dictionary-add! blowfish-ks1 '0x63094366)
(dictionary-add! blowfish-ks1 '0xC464C3D2)
(dictionary-add! blowfish-ks1 '0xEF1C1847)
(dictionary-add! blowfish-ks1 '0x3215D908)
(dictionary-add! blowfish-ks1 '0xDD433B37)
(dictionary-add! blowfish-ks1 '0x24C2BA16)
(dictionary-add! blowfish-ks1 '0x12A14D43)
(dictionary-add! blowfish-ks1 '0x2A65C451)
(dictionary-add! blowfish-ks1 '0x50940002)
(dictionary-add! blowfish-ks1 '0x133AE4DD)
(dictionary-add! blowfish-ks1 '0x71DFF89E)
(dictionary-add! blowfish-ks1 '0x10314E55)
(dictionary-add! blowfish-ks1 '0x81AC77D6)
(dictionary-add! blowfish-ks1 '0x5F11199B)
(dictionary-add! blowfish-ks1 '0x043556F1)
(dictionary-add! blowfish-ks1 '0xD7A3C76B)
(dictionary-add! blowfish-ks1 '0x3C11183B)
(dictionary-add! blowfish-ks1 '0x5924A509)
(dictionary-add! blowfish-ks1 '0xF28FE6ED)
(dictionary-add! blowfish-ks1 '0x97F1FBFA)
(dictionary-add! blowfish-ks1 '0x9EBABF2C)
(dictionary-add! blowfish-ks1 '0x1E153C6E)
(dictionary-add! blowfish-ks1 '0x86E34570)
(dictionary-add! blowfish-ks1 '0xEAE96FB1)
(dictionary-add! blowfish-ks1 '0x860E5E0A)
(dictionary-add! blowfish-ks1 '0x5A3E2AB3)
(dictionary-add! blowfish-ks1 '0x771FE71C)
(dictionary-add! blowfish-ks1 '0x4E3D06FA)
(dictionary-add! blowfish-ks1 '0x2965DCB9)
(dictionary-add! blowfish-ks1 '0x99E71D0F)
(dictionary-add! blowfish-ks1 '0x803E89D6)
(dictionary-add! blowfish-ks1 '0x5266C825)
(dictionary-add! blowfish-ks1 '0x2E4CC978)
(dictionary-add! blowfish-ks1 '0x9C10B36A)
(dictionary-add! blowfish-ks1 '0xC6150EBA)
(dictionary-add! blowfish-ks1 '0x94E2EA78)
(dictionary-add! blowfish-ks1 '0xA5FC3C53)
(dictionary-add! blowfish-ks1 '0x1E0A2DF4)
(dictionary-add! blowfish-ks1 '0xF2F74EA7)
(dictionary-add! blowfish-ks1 '0x361D2B3D)
(dictionary-add! blowfish-ks1 '0x1939260F)
(dictionary-add! blowfish-ks1 '0x19C27960)
(dictionary-add! blowfish-ks1 '0x5223A708)
(dictionary-add! blowfish-ks1 '0xF71312B6)
(dictionary-add! blowfish-ks1 '0xEBADFE6E)
(dictionary-add! blowfish-ks1 '0xEAC31F66)
(dictionary-add! blowfish-ks1 '0xE3BC4595)
(dictionary-add! blowfish-ks1 '0xA67BC883)
(dictionary-add! blowfish-ks1 '0xB17F37D1)
(dictionary-add! blowfish-ks1 '0x018CFF28)
(dictionary-add! blowfish-ks1 '0xC332DDEF)
(dictionary-add! blowfish-ks1 '0xBE6C5AA5)
(dictionary-add! blowfish-ks1 '0x65582185)
(dictionary-add! blowfish-ks1 '0x68AB9802)
(dictionary-add! blowfish-ks1 '0xEECEA50F)
(dictionary-add! blowfish-ks1 '0xDB2F953B)
(dictionary-add! blowfish-ks1 '0x2AEF7DAD)
(dictionary-add! blowfish-ks1 '0x5B6E2F84)
(dictionary-add! blowfish-ks1 '0x1521B628)
(dictionary-add! blowfish-ks1 '0x29076170)
(dictionary-add! blowfish-ks1 '0xECDD4775)
(dictionary-add! blowfish-ks1 '0x619F1510)
(dictionary-add! blowfish-ks1 '0x13CCA830)
(dictionary-add! blowfish-ks1 '0xEB61BD96)
(dictionary-add! blowfish-ks1 '0x0334FE1E)
(dictionary-add! blowfish-ks1 '0xAA0363CF)
(dictionary-add! blowfish-ks1 '0xB5735C90)
(dictionary-add! blowfish-ks1 '0x4C70A239)
(dictionary-add! blowfish-ks1 '0xD59E9E0B)
(dictionary-add! blowfish-ks1 '0xCBAADE14)
(dictionary-add! blowfish-ks1 '0xEECC86BC)
(dictionary-add! blowfish-ks1 '0x60622CA7)
(dictionary-add! blowfish-ks1 '0x9CAB5CAB)
(dictionary-add! blowfish-ks1 '0xB2F3846E)
(dictionary-add! blowfish-ks1 '0x648B1EAF)
(dictionary-add! blowfish-ks1 '0x19BDF0CA)
(dictionary-add! blowfish-ks1 '0xA02369B9)
(dictionary-add! blowfish-ks1 '0x655ABB50)
(dictionary-add! blowfish-ks1 '0x40685A32)
(dictionary-add! blowfish-ks1 '0x3C2AB4B3)
(dictionary-add! blowfish-ks1 '0x319EE9D5)
(dictionary-add! blowfish-ks1 '0xC021B8F7)
(dictionary-add! blowfish-ks1 '0x9B540B19)
(dictionary-add! blowfish-ks1 '0x875FA099)
(dictionary-add! blowfish-ks1 '0x95F7997E)
(dictionary-add! blowfish-ks1 '0x623D7DA8)
(dictionary-add! blowfish-ks1 '0xF837889A)
(dictionary-add! blowfish-ks1 '0x97E32D77)
(dictionary-add! blowfish-ks1 '0x11ED935F)
(dictionary-add! blowfish-ks1 '0x16681281)
(dictionary-add! blowfish-ks1 '0x0E358829)
(dictionary-add! blowfish-ks1 '0xC7E61FD6)
(dictionary-add! blowfish-ks1 '0x96DEDFA1)
(dictionary-add! blowfish-ks1 '0x7858BA99)
(dictionary-add! blowfish-ks1 '0x57F584A5)
(dictionary-add! blowfish-ks1 '0x1B227263)
(dictionary-add! blowfish-ks1 '0x9B83C3FF)
(dictionary-add! blowfish-ks1 '0x1AC24696)
(dictionary-add! blowfish-ks1 '0xCDB30AEB)
(dictionary-add! blowfish-ks1 '0x532E3054)
(dictionary-add! blowfish-ks1 '0x8FD948E4)
(dictionary-add! blowfish-ks1 '0x6DBC3128)
(dictionary-add! blowfish-ks1 '0x58EBF2EF)
(dictionary-add! blowfish-ks1 '0x34C6FFEA)
(dictionary-add! blowfish-ks1 '0xFE28ED61)
(dictionary-add! blowfish-ks1 '0xEE7C3C73)
(dictionary-add! blowfish-ks1 '0x5D4A14D9)
(dictionary-add! blowfish-ks1 '0xE864B7E3)
(dictionary-add! blowfish-ks1 '0x42105D14)
(dictionary-add! blowfish-ks1 '0x203E13E0)
(dictionary-add! blowfish-ks1 '0x45EEE2B6)
(dictionary-add! blowfish-ks1 '0xA3AAABEA)
(dictionary-add! blowfish-ks1 '0xDB6C4F15)
(dictionary-add! blowfish-ks1 '0xFACB4FD0)
(dictionary-add! blowfish-ks1 '0xC742F442)
(dictionary-add! blowfish-ks1 '0xEF6ABBB5)
(dictionary-add! blowfish-ks1 '0x654F3B1D)
(dictionary-add! blowfish-ks1 '0x41CD2105)
(dictionary-add! blowfish-ks1 '0xD81E799E)
(dictionary-add! blowfish-ks1 '0x86854DC7)
(dictionary-add! blowfish-ks1 '0xE44B476A)
(dictionary-add! blowfish-ks1 '0x3D816250)
(dictionary-add! blowfish-ks1 '0xCF62A1F2)
(dictionary-add! blowfish-ks1 '0x5B8D2646)
(dictionary-add! blowfish-ks1 '0xFC8883A0)
(dictionary-add! blowfish-ks1 '0xC1C7B6A3)
(dictionary-add! blowfish-ks1 '0x7F1524C3)
(dictionary-add! blowfish-ks1 '0x69CB7492)
(dictionary-add! blowfish-ks1 '0x47848A0B)
(dictionary-add! blowfish-ks1 '0x5692B285)
(dictionary-add! blowfish-ks1 '0x095BBF00)
(dictionary-add! blowfish-ks1 '0xAD19489D)
(dictionary-add! blowfish-ks1 '0x1462B174)
(dictionary-add! blowfish-ks1 '0x23820E00)
(dictionary-add! blowfish-ks1 '0x58428D2A)
(dictionary-add! blowfish-ks1 '0x0C55F5EA)
(dictionary-add! blowfish-ks1 '0x1DADF43E)
(dictionary-add! blowfish-ks1 '0x233F7061)
(dictionary-add! blowfish-ks1 '0x3372F092)
(dictionary-add! blowfish-ks1 '0x8D937E41)
(dictionary-add! blowfish-ks1 '0xD65FECF1)
(dictionary-add! blowfish-ks1 '0x6C223BDB)
(dictionary-add! blowfish-ks1 '0x7CDE3759)
(dictionary-add! blowfish-ks1 '0xCBEE7460)
(dictionary-add! blowfish-ks1 '0x4085F2A7)
(dictionary-add! blowfish-ks1 '0xCE77326E)
(dictionary-add! blowfish-ks1 '0xA6078084)
(dictionary-add! blowfish-ks1 '0x19F8509E)
(dictionary-add! blowfish-ks1 '0xE8EFD855)
(dictionary-add! blowfish-ks1 '0x61D99735)
(dictionary-add! blowfish-ks1 '0xA969A7AA)
(dictionary-add! blowfish-ks1 '0xC50C06C2)
(dictionary-add! blowfish-ks1 '0x5A04ABFC)
(dictionary-add! blowfish-ks1 '0x800BCADC)
(dictionary-add! blowfish-ks1 '0x9E447A2E)
(dictionary-add! blowfish-ks1 '0xC3453484)
(dictionary-add! blowfish-ks1 '0xFDD56705)
(dictionary-add! blowfish-ks1 '0x0E1E9EC9)
(dictionary-add! blowfish-ks1 '0xDB73DBD3)
(dictionary-add! blowfish-ks1 '0x105588CD)
(dictionary-add! blowfish-ks1 '0x675FDA79)
(dictionary-add! blowfish-ks1 '0xE3674340)
(dictionary-add! blowfish-ks1 '0xC5C43465)
(dictionary-add! blowfish-ks1 '0x713E38D8)
(dictionary-add! blowfish-ks1 '0x3D28F89E)
(dictionary-add! blowfish-ks1 '0xF16DFF20)
(dictionary-add! blowfish-ks1 '0x153E21E7)
(dictionary-add! blowfish-ks1 '0x8FB03D4A)
(dictionary-add! blowfish-ks1 '0xE6E39F2B)
(dictionary-add! blowfish-ks1 '0xDB83ADF7)
(define ks2-blowfish (make-dictionary))
(dictionary-add! blowfish-ks2 '0xE93D5A68)
(dictionary-add! blowfish-ks2 '0x948140F7)
(dictionary-add! blowfish-ks2 '0xF64C261C)
(dictionary-add! blowfish-ks2 '0x94692934)
(dictionary-add! blowfish-ks2 '0x411520F7)
(dictionary-add! blowfish-ks2 '0x7602D4F7)
(dictionary-add! blowfish-ks2 '0xBCF46B2E)
(dictionary-add! blowfish-ks2 '0xD4A20068)
(dictionary-add! blowfish-ks2 '0xD4082471)
(dictionary-add! blowfish-ks2 '0x3320F46A)
(dictionary-add! blowfish-ks2 '0x43B7D4B7)
(dictionary-add! blowfish-ks2 '0x500061AF)
(dictionary-add! blowfish-ks2 '0x1E39F62E)
(dictionary-add! blowfish-ks2 '0x97244546)
(dictionary-add! blowfish-ks2 '0x14214F74)
(dictionary-add! blowfish-ks2 '0xBF8B8840)
(dictionary-add! blowfish-ks2 '0x4D95FC1D)
(dictionary-add! blowfish-ks2 '0x96B591AF)
(dictionary-add! blowfish-ks2 '0x70F4DDD3)
(dictionary-add! blowfish-ks2 '0x66A02F45)
(dictionary-add! blowfish-ks2 '0xBFBC09EC)
(dictionary-add! blowfish-ks2 '0x03BD9785)
(dictionary-add! blowfish-ks2 '0x7FAC6DD0)
(dictionary-add! blowfish-ks2 '0x31CB8504)
(dictionary-add! blowfish-ks2 '0x96EB27B3)
(dictionary-add! blowfish-ks2 '0x55FD3941)
(dictionary-add! blowfish-ks2 '0xDA2547E6)
(dictionary-add! blowfish-ks2 '0xABCA0A9A)
(dictionary-add! blowfish-ks2 '0x28507825)
(dictionary-add! blowfish-ks2 '0x530429F4)
(dictionary-add! blowfish-ks2 '0x0A2C86DA)
(dictionary-add! blowfish-ks2 '0xE9B66DFB)
(dictionary-add! blowfish-ks2 '0x68DC1462)
(dictionary-add! blowfish-ks2 '0xD7486900)
(dictionary-add! blowfish-ks2 '0x680EC0A4)
(dictionary-add! blowfish-ks2 '0x27A18DEE)
(dictionary-add! blowfish-ks2 '0x4F3FFEA2)
(dictionary-add! blowfish-ks2 '0xE887AD8C)
(dictionary-add! blowfish-ks2 '0xB58CE006)
(dictionary-add! blowfish-ks2 '0x7AF4D6B6)
(dictionary-add! blowfish-ks2 '0xAACE1E7C)
(dictionary-add! blowfish-ks2 '0xD3375FEC)
(dictionary-add! blowfish-ks2 '0xCE78A399)
(dictionary-add! blowfish-ks2 '0x406B2A42)
(dictionary-add! blowfish-ks2 '0x20FE9E35)
(dictionary-add! blowfish-ks2 '0xD9F385B9)
(dictionary-add! blowfish-ks2 '0xEE39D7AB)
(dictionary-add! blowfish-ks2 '0x3B124E8B)
(dictionary-add! blowfish-ks2 '0x1DC9FAF7)
(dictionary-add! blowfish-ks2 '0x4B6D1856)
(dictionary-add! blowfish-ks2 '0x26A36631)
(dictionary-add! blowfish-ks2 '0xEAE397B2)
(dictionary-add! blowfish-ks2 '0x3A6EFA74)
(dictionary-add! blowfish-ks2 '0xDD5B4332)
(dictionary-add! blowfish-ks2 '0x6841E7F7)
(dictionary-add! blowfish-ks2 '0xCA7820FB)
(dictionary-add! blowfish-ks2 '0xFB0AF54E)
(dictionary-add! blowfish-ks2 '0xD8FEB397)
(dictionary-add! blowfish-ks2 '0x454056AC)
(dictionary-add! blowfish-ks2 '0xBA489527)
(dictionary-add! blowfish-ks2 '0x55533A3A)
(dictionary-add! blowfish-ks2 '0x20838D87)
(dictionary-add! blowfish-ks2 '0xFE6BA9B7)
(dictionary-add! blowfish-ks2 '0xD096954B)
(dictionary-add! blowfish-ks2 '0x55A867BC)
(dictionary-add! blowfish-ks2 '0xA1159A58)
(dictionary-add! blowfish-ks2 '0xCCA92963)
(dictionary-add! blowfish-ks2 '0x99E1DB33)
(dictionary-add! blowfish-ks2 '0xA62A4A56)
(dictionary-add! blowfish-ks2 '0x3F3125F9)
(dictionary-add! blowfish-ks2 '0x5EF47E1C)
(dictionary-add! blowfish-ks2 '0x9029317C)
(dictionary-add! blowfish-ks2 '0xFDF8E802)
(dictionary-add! blowfish-ks2 '0x04272F70)
(dictionary-add! blowfish-ks2 '0x80BB155C)
(dictionary-add! blowfish-ks2 '0x05282CE3)
(dictionary-add! blowfish-ks2 '0x95C11548)
(dictionary-add! blowfish-ks2 '0xE4C66D22)
(dictionary-add! blowfish-ks2 '0x48C1133F)
(dictionary-add! blowfish-ks2 '0xC70F86DC)
(dictionary-add! blowfish-ks2 '0x07F9C9EE)
(dictionary-add! blowfish-ks2 '0x41041F0F)
(dictionary-add! blowfish-ks2 '0x404779A4)
(dictionary-add! blowfish-ks2 '0x5D886E17)
(dictionary-add! blowfish-ks2 '0x325F51EB)
(dictionary-add! blowfish-ks2 '0xD59BC0D1)
(dictionary-add! blowfish-ks2 '0xF2BCC18F)
(dictionary-add! blowfish-ks2 '0x41113564)
(dictionary-add! blowfish-ks2 '0x257B7834)
(dictionary-add! blowfish-ks2 '0x602A9C60)
(dictionary-add! blowfish-ks2 '0xDFF8E8A3)
(dictionary-add! blowfish-ks2 '0x1F636C1B)
(dictionary-add! blowfish-ks2 '0x0E12B4C2)
(dictionary-add! blowfish-ks2 '0x02E1329E)
(dictionary-add! blowfish-ks2 '0xAF664FD1)
(dictionary-add! blowfish-ks2 '0xCAD18115)
(dictionary-add! blowfish-ks2 '0x6B2395E0)
(dictionary-add! blowfish-ks2 '0x333E92E1)
(dictionary-add! blowfish-ks2 '0x3B240B62)
(dictionary-add! blowfish-ks2 '0xEEBEB922)
(dictionary-add! blowfish-ks2 '0x85B2A20E)
(dictionary-add! blowfish-ks2 '0xE6BA0D99)
(dictionary-add! blowfish-ks2 '0xDE720C8C)
(dictionary-add! blowfish-ks2 '0x2DA2F728)
(dictionary-add! blowfish-ks2 '0xD0127845)
(dictionary-add! blowfish-ks2 '0x95B794FD)
(dictionary-add! blowfish-ks2 '0x647D0862)
(dictionary-add! blowfish-ks2 '0xE7CCF5F0)
(dictionary-add! blowfish-ks2 '0x5449A36F)
(dictionary-add! blowfish-ks2 '0x877D48FA)
(dictionary-add! blowfish-ks2 '0xC39DFD27)
(dictionary-add! blowfish-ks2 '0xF33E8D1E)
(dictionary-add! blowfish-ks2 '0x0A476341)
(dictionary-add! blowfish-ks2 '0x992EFF74)
(dictionary-add! blowfish-ks2 '0x3A6F6EAB)
(dictionary-add! blowfish-ks2 '0xF4F8FD37)
(dictionary-add! blowfish-ks2 '0xA812DC60)
(dictionary-add! blowfish-ks2 '0xA1EBDDF8)
(dictionary-add! blowfish-ks2 '0x991BE14C)
(dictionary-add! blowfish-ks2 '0xDB6E6B0D)
(dictionary-add! blowfish-ks2 '0xC67B5510)
(dictionary-add! blowfish-ks2 '0x6D672C37)
(dictionary-add! blowfish-ks2 '0x2765D43B)
(dictionary-add! blowfish-ks2 '0xDCD0E804)
(dictionary-add! blowfish-ks2 '0xF1290DC7)
(dictionary-add! blowfish-ks2 '0xCC00FFA3)
(dictionary-add! blowfish-ks2 '0xB5390F92)
(dictionary-add! blowfish-ks2 '0x690FED0B)
(dictionary-add! blowfish-ks2 '0x667B9FFB)
(dictionary-add! blowfish-ks2 '0xCEDB7D9C)
(dictionary-add! blowfish-ks2 '0xA091CF0B)
(dictionary-add! blowfish-ks2 '0xD9155EA3)
(dictionary-add! blowfish-ks2 '0xBB132F88)
(dictionary-add! blowfish-ks2 '0x515BAD24)
(dictionary-add! blowfish-ks2 '0x7B9479BF)
(dictionary-add! blowfish-ks2 '0x763BD6EB)
(dictionary-add! blowfish-ks2 '0x37392EB3)
(dictionary-add! blowfish-ks2 '0xCC115979)
(dictionary-add! blowfish-ks2 '0x8026E297)
(dictionary-add! blowfish-ks2 '0xF42E312D)
(dictionary-add! blowfish-ks2 '0x6842ADA7)
(dictionary-add! blowfish-ks2 '0xC66A2B3B)
(dictionary-add! blowfish-ks2 '0x12754CCC)
(dictionary-add! blowfish-ks2 '0x782EF11C)
(dictionary-add! blowfish-ks2 '0x6A124237)
(dictionary-add! blowfish-ks2 '0xB79251E7)
(dictionary-add! blowfish-ks2 '0x06A1BBE6)
(dictionary-add! blowfish-ks2 '0x4BFB6350)
(dictionary-add! blowfish-ks2 '0x1A6B1018)
(dictionary-add! blowfish-ks2 '0x11CAEDFA)
(dictionary-add! blowfish-ks2 '0x3D25BDD8)
(dictionary-add! blowfish-ks2 '0xE2E1C3C9)
(dictionary-add! blowfish-ks2 '0x44421659)
(dictionary-add! blowfish-ks2 '0x0A121386)
(dictionary-add! blowfish-ks2 '0xD90CEC6E)
(dictionary-add! blowfish-ks2 '0xD5ABEA2A)
(dictionary-add! blowfish-ks2 '0x64AF674E)
(dictionary-add! blowfish-ks2 '0xDA86A85F)
(dictionary-add! blowfish-ks2 '0xBEBFE988)
(dictionary-add! blowfish-ks2 '0x64E4C3FE)
(dictionary-add! blowfish-ks2 '0x9DBC8057)
(dictionary-add! blowfish-ks2 '0xF0F7C086)
(dictionary-add! blowfish-ks2 '0x60787BF8)
(dictionary-add! blowfish-ks2 '0x6003604D)
(dictionary-add! blowfish-ks2 '0xD1FD8346)
(dictionary-add! blowfish-ks2 '0xF6381FB0)
(dictionary-add! blowfish-ks2 '0x7745AE04)
(dictionary-add! blowfish-ks2 '0xD736FCCC)
(dictionary-add! blowfish-ks2 '0x83426B33)
(dictionary-add! blowfish-ks2 '0xF01EAB71)
(dictionary-add! blowfish-ks2 '0xB0804187)
(dictionary-add! blowfish-ks2 '0x3C005E5F)
(dictionary-add! blowfish-ks2 '0x77A057BE)
(dictionary-add! blowfish-ks2 '0xBDE8AE24)
(dictionary-add! blowfish-ks2 '0x55464299)
(dictionary-add! blowfish-ks2 '0xBF582E61)
(dictionary-add! blowfish-ks2 '0x4E58F48F)
(dictionary-add! blowfish-ks2 '0xF2DDFDA2)
(dictionary-add! blowfish-ks2 '0xF474EF38)
(dictionary-add! blowfish-ks2 '0x8789BDC2)
(dictionary-add! blowfish-ks2 '0x5366F9C3)
(dictionary-add! blowfish-ks2 '0xC8B38E74)
(dictionary-add! blowfish-ks2 '0xB475F255)
(dictionary-add! blowfish-ks2 '0x46FCD9B9)
(dictionary-add! blowfish-ks2 '0x7AEB2661)
(dictionary-add! blowfish-ks2 '0x8B1DDF84)
(dictionary-add! blowfish-ks2 '0x846A0E79)
(dictionary-add! blowfish-ks2 '0x915F95E2)
(dictionary-add! blowfish-ks2 '0x466E598E)
(dictionary-add! blowfish-ks2 '0x20B45770)
(dictionary-add! blowfish-ks2 '0x8CD55591)
(dictionary-add! blowfish-ks2 '0xC902DE4C)
(dictionary-add! blowfish-ks2 '0xB90BACE1)
(dictionary-add! blowfish-ks2 '0xBB8205D0)
(dictionary-add! blowfish-ks2 '0x11A86248)
(dictionary-add! blowfish-ks2 '0x7574A99E)
(dictionary-add! blowfish-ks2 '0xB77F19B6)
(dictionary-add! blowfish-ks2 '0xE0A9DC09)
(dictionary-add! blowfish-ks2 '0x662D09A1)
(dictionary-add! blowfish-ks2 '0xC4324633)
(dictionary-add! blowfish-ks2 '0xE85A1F02)
(dictionary-add! blowfish-ks2 '0x09F0BE8C)
(dictionary-add! blowfish-ks2 '0x4A99A025)
(dictionary-add! blowfish-ks2 '0x1D6EFE10)
(dictionary-add! blowfish-ks2 '0x1AB93D1D)
(dictionary-add! blowfish-ks2 '0x0BA5A4DF)
(dictionary-add! blowfish-ks2 '0xA186F20F)
(dictionary-add! blowfish-ks2 '0x2868F169)
(dictionary-add! blowfish-ks2 '0xDCB7DA83)
(dictionary-add! blowfish-ks2 '0x573906FE)
(dictionary-add! blowfish-ks2 '0xA1E2CE9B)
(dictionary-add! blowfish-ks2 '0x4FCD7F52)
(dictionary-add! blowfish-ks2 '0x50115E01)
(dictionary-add! blowfish-ks2 '0xA70683FA)
(dictionary-add! blowfish-ks2 '0xA002B5C4)
(dictionary-add! blowfish-ks2 '0x0DE6D027)
(dictionary-add! blowfish-ks2 '0x9AF88C27)
(dictionary-add! blowfish-ks2 '0x773F8641)
(dictionary-add! blowfish-ks2 '0xC3604C06)
(dictionary-add! blowfish-ks2 '0x61A806B5)
(dictionary-add! blowfish-ks2 '0xF0177A28)
(dictionary-add! blowfish-ks2 '0xC0F586E0)
(dictionary-add! blowfish-ks2 '0x006058AA)
(dictionary-add! blowfish-ks2 '0x30DC7D62)
(dictionary-add! blowfish-ks2 '0x11E69ED7)
(dictionary-add! blowfish-ks2 '0x2338EA63)
(dictionary-add! blowfish-ks2 '0x53C2DD94)
(dictionary-add! blowfish-ks2 '0xC2C21634)
(dictionary-add! blowfish-ks2 '0xBBCBEE56)
(dictionary-add! blowfish-ks2 '0x90BCB6DE)
(dictionary-add! blowfish-ks2 '0xEBFC7DA1)
(dictionary-add! blowfish-ks2 '0xCE591D76)
(dictionary-add! blowfish-ks2 '0x6F05E409)
(dictionary-add! blowfish-ks2 '0x4B7C0188)
(dictionary-add! blowfish-ks2 '0x39720A3D)
(dictionary-add! blowfish-ks2 '0x7C927C24)
(dictionary-add! blowfish-ks2 '0x86E3725F)
(dictionary-add! blowfish-ks2 '0x724D9DB9)
(dictionary-add! blowfish-ks2 '0x1AC15BB4)
(dictionary-add! blowfish-ks2 '0xD39EB8FC)
(dictionary-add! blowfish-ks2 '0xED545578)
(dictionary-add! blowfish-ks2 '0x08FCA5B5)
(dictionary-add! blowfish-ks2 '0xD83D7CD3)
(dictionary-add! blowfish-ks2 '0x4DAD0FC4)
(dictionary-add! blowfish-ks2 '0x1E50EF5E)
(dictionary-add! blowfish-ks2 '0xB161E6F8)
(dictionary-add! blowfish-ks2 '0xA28514D9)
(dictionary-add! blowfish-ks2 '0x6C51133C)
(dictionary-add! blowfish-ks2 '0x6FD5C7E7)
(dictionary-add! blowfish-ks2 '0x56E14EC4)
(dictionary-add! blowfish-ks2 '0x362ABFCE)
(dictionary-add! blowfish-ks2 '0xDDC6C837)
(dictionary-add! blowfish-ks2 '0xD79A3234)
(dictionary-add! blowfish-ks2 '0x92638212)
(dictionary-add! blowfish-ks2 '0x670EFA8E)
(dictionary-add! blowfish-ks2 '0x406000E0)
(define blowfish-ks3 (make-dictionary))
(dictionary-add! blowfish-ks3 '0x3A39CE37)
(dictionary-add! blowfish-ks3 '0xD3FAF5CF)
(dictionary-add! blowfish-ks3 '0xABC27737)
(dictionary-add! blowfish-ks3 '0x5AC52D1B)
(dictionary-add! blowfish-ks3 '0x5CB0679E)
(dictionary-add! blowfish-ks3 '0x4FA33742)
(dictionary-add! blowfish-ks3 '0xD3822740)
(dictionary-add! blowfish-ks3 '0x99BC9BBE)
(dictionary-add! blowfish-ks3 '0xD5118E9D)
(dictionary-add! blowfish-ks3 '0xBF0F7315)
(dictionary-add! blowfish-ks3 '0xD62D1C7E)
(dictionary-add! blowfish-ks3 '0xC700C47B)
(dictionary-add! blowfish-ks3 '0xB78C1B6B)
(dictionary-add! blowfish-ks3 '0x21A19045)
(dictionary-add! blowfish-ks3 '0xB26EB1BE)
(dictionary-add! blowfish-ks3 '0x6A366EB4)
(dictionary-add! blowfish-ks3 '0x5748AB2F)
(dictionary-add! blowfish-ks3 '0xBC946E79)
(dictionary-add! blowfish-ks3 '0xC6A376D2)
(dictionary-add! blowfish-ks3 '0x6549C2C8)
(dictionary-add! blowfish-ks3 '0x530FF8EE)
(dictionary-add! blowfish-ks3 '0x468DDE7D)
(dictionary-add! blowfish-ks3 '0xD5730A1D)
(dictionary-add! blowfish-ks3 '0x4CD04DC6)
(dictionary-add! blowfish-ks3 '0x2939BBDB)
(dictionary-add! blowfish-ks3 '0xA9BA4650)
(dictionary-add! blowfish-ks3 '0xAC9526E8)
(dictionary-add! blowfish-ks3 '0xBE5EE304)
(dictionary-add! blowfish-ks3 '0xA1FAD5F0)
(dictionary-add! blowfish-ks3 '0x6A2D519A)
(dictionary-add! blowfish-ks3 '0x63EF8CE2)
(dictionary-add! blowfish-ks3 '0x9A86EE22)
(dictionary-add! blowfish-ks3 '0xC089C2B8)
(dictionary-add! blowfish-ks3 '0x43242EF6)
(dictionary-add! blowfish-ks3 '0xA51E03AA)
(dictionary-add! blowfish-ks3 '0x9CF2D0A4)
(dictionary-add! blowfish-ks3 '0x83C061BA)
(dictionary-add! blowfish-ks3 '0x9BE96A4D)
(dictionary-add! blowfish-ks3 '0x8FE51550)
(dictionary-add! blowfish-ks3 '0xBA645BD6)
(dictionary-add! blowfish-ks3 '0x2826A2F9)
(dictionary-add! blowfish-ks3 '0xA73A3AE1)
(dictionary-add! blowfish-ks3 '0x4BA99586)
(dictionary-add! blowfish-ks3 '0xEF5562E9)
(dictionary-add! blowfish-ks3 '0xC72FEFD3)
(dictionary-add! blowfish-ks3 '0xF752F7DA)
(dictionary-add! blowfish-ks3 '0x3F046F69)
(dictionary-add! blowfish-ks3 '0x77FA0A59)
(dictionary-add! blowfish-ks3 '0x80E4A915)
(dictionary-add! blowfish-ks3 '0x87B08601)
(dictionary-add! blowfish-ks3 '0x9B09E6AD)
(dictionary-add! blowfish-ks3 '0x3B3EE593)
(dictionary-add! blowfish-ks3 '0xE990FD5A)
(dictionary-add! blowfish-ks3 '0x9E34D797)
(dictionary-add! blowfish-ks3 '0x2CF0B7D9)
(dictionary-add! blowfish-ks3 '0x022B8B51)
(dictionary-add! blowfish-ks3 '0x96D5AC3A)
(dictionary-add! blowfish-ks3 '0x017DA67D)
(dictionary-add! blowfish-ks3 '0xD1CF3ED6)
(dictionary-add! blowfish-ks3 '0x7C7D2D28)
(dictionary-add! blowfish-ks3 '0x1F9F25CF)
(dictionary-add! blowfish-ks3 '0xADF2B89B)
(dictionary-add! blowfish-ks3 '0x5AD6B472)
(dictionary-add! blowfish-ks3 '0x5A88F54C)
(dictionary-add! blowfish-ks3 '0xE029AC71)
(dictionary-add! blowfish-ks3 '0xE019A5E6)
(dictionary-add! blowfish-ks3 '0x47B0ACFD)
(dictionary-add! blowfish-ks3 '0xED93FA9B)
(dictionary-add! blowfish-ks3 '0xE8D3C48D)
(dictionary-add! blowfish-ks3 '0x283B57CC)
(dictionary-add! blowfish-ks3 '0xF8D56629)
(dictionary-add! blowfish-ks3 '0x79132E28)
(dictionary-add! blowfish-ks3 '0x785F0191)
(dictionary-add! blowfish-ks3 '0xED756055)
(dictionary-add! blowfish-ks3 '0xF7960E44)
(dictionary-add! blowfish-ks3 '0xE3D35E8C)
(dictionary-add! blowfish-ks3 '0x15056DD4)
(dictionary-add! blowfish-ks3 '0x88F46DBA)
(dictionary-add! blowfish-ks3 '0x03A16125)
(dictionary-add! blowfish-ks3 '0x0564F0BD)
(dictionary-add! blowfish-ks3 '0xC3EB9E15)
(dictionary-add! blowfish-ks3 '0x3C9057A2)
(dictionary-add! blowfish-ks3 '0x97271AEC)
(dictionary-add! blowfish-ks3 '0xA93A072A)
(dictionary-add! blowfish-ks3 '0x1B3F6D9B)
(dictionary-add! blowfish-ks3 '0x1E6321F5)
(dictionary-add! blowfish-ks3 '0xF59C66FB)
(dictionary-add! blowfish-ks3 '0x26DCF319)
(dictionary-add! blowfish-ks3 '0x7533D928)
(dictionary-add! blowfish-ks3 '0xB155FDF5)
(dictionary-add! blowfish-ks3 '0x03563482)
(dictionary-add! blowfish-ks3 '0x8ABA3CBB)
(dictionary-add! blowfish-ks3 '0x28517711)
(dictionary-add! blowfish-ks3 '0xC20AD9F8)
(dictionary-add! blowfish-ks3 '0xABCC5167)
(dictionary-add! blowfish-ks3 '0xCCAD925F)
(dictionary-add! blowfish-ks3 '0x4DE81751)
(dictionary-add! blowfish-ks3 '0x3830DC8E)
(dictionary-add! blowfish-ks3 '0x379D5862)
(dictionary-add! blowfish-ks3 '0x9320F991)
(dictionary-add! blowfish-ks3 '0xEA7A90C2)
(dictionary-add! blowfish-ks3 '0xFB3E7BCE)
(dictionary-add! blowfish-ks3 '0x5121CE64)
(dictionary-add! blowfish-ks3 '0x774FBE32)
(dictionary-add! blowfish-ks3 '0xA8B6E37E)
(dictionary-add! blowfish-ks3 '0xC3293D46)
(dictionary-add! blowfish-ks3 '0x48DE5369)
(dictionary-add! blowfish-ks3 '0x6413E680)
(dictionary-add! blowfish-ks3 '0xA2AE0810)
(dictionary-add! blowfish-ks3 '0xDD6DB224)
(dictionary-add! blowfish-ks3 '0x69852DFD)
(dictionary-add! blowfish-ks3 '0x09072166)
(dictionary-add! blowfish-ks3 '0xB39A460A)
(dictionary-add! blowfish-ks3 '0x6445C0DD)
(dictionary-add! blowfish-ks3 '0x586CDECF)
(dictionary-add! blowfish-ks3 '0x1C20C8AE)
(dictionary-add! blowfish-ks3 '0x5BBEF7DD)
(dictionary-add! blowfish-ks3 '0x1B588D40)
(dictionary-add! blowfish-ks3 '0xCCD2017F)
(dictionary-add! blowfish-ks3 '0x6BB4E3BB)
(dictionary-add! blowfish-ks3 '0xDDA26A7E)
(dictionary-add! blowfish-ks3 '0x3A59FF45)
(dictionary-add! blowfish-ks3 '0x3E350A44)
(dictionary-add! blowfish-ks3 '0xBCB4CDD5)
(dictionary-add! blowfish-ks3 '0x72EACEA8)
(dictionary-add! blowfish-ks3 '0xFA6484BB)
(dictionary-add! blowfish-ks3 '0x8D6612AE)
(dictionary-add! blowfish-ks3 '0xBF3C6F47)
(dictionary-add! blowfish-ks3 '0xD29BE463)
(dictionary-add! blowfish-ks3 '0x542F5D9E)
(dictionary-add! blowfish-ks3 '0xAEC2771B)
(dictionary-add! blowfish-ks3 '0xF64E6370)
(dictionary-add! blowfish-ks3 '0x740E0D8D)
(dictionary-add! blowfish-ks3 '0xE75B1357)
(dictionary-add! blowfish-ks3 '0xF8721671)
(dictionary-add! blowfish-ks3 '0xAF537D5D)
(dictionary-add! blowfish-ks3 '0x4040CB08)
(dictionary-add! blowfish-ks3 '0x4EB4E2CC)
(dictionary-add! blowfish-ks3 '0x34D2466A)
(dictionary-add! blowfish-ks3 '0x0115AF84)
(dictionary-add! blowfish-ks3 '0xE1B00428)
(dictionary-add! blowfish-ks3 '0x95983A1D)
(dictionary-add! blowfish-ks3 '0x06B89FB4)
(dictionary-add! blowfish-ks3 '0xCE6EA048)
(dictionary-add! blowfish-ks3 '0x6F3F3B82)
(dictionary-add! blowfish-ks3 '0x3520AB82)
(dictionary-add! blowfish-ks3 '0x011A1D4B)
(dictionary-add! blowfish-ks3 '0x277227F8)
(dictionary-add! blowfish-ks3 '0x611560B1)
(dictionary-add! blowfish-ks3 '0xE7933FDC)
(dictionary-add! blowfish-ks3 '0xBB3A792B)
(dictionary-add! blowfish-ks3 '0x344525BD)
(dictionary-add! blowfish-ks3 '0xA08839E1)
(dictionary-add! blowfish-ks3 '0x51CE794B)
(dictionary-add! blowfish-ks3 '0x2F32C9B7)
(dictionary-add! blowfish-ks3 '0xA01FBAC9)
(dictionary-add! blowfish-ks3 '0xE01CC87E)
(dictionary-add! blowfish-ks3 '0xBCC7D1F6)
(dictionary-add! blowfish-ks3 '0xCF0111C3)
(dictionary-add! blowfish-ks3 '0xA1E8AAC7)
(dictionary-add! blowfish-ks3 '0x1A908749)
(dictionary-add! blowfish-ks3 '0xD44FBD9A)
(dictionary-add! blowfish-ks3 '0xD0DADECB)
(dictionary-add! blowfish-ks3 '0xD50ADA38)
(dictionary-add! blowfish-ks3 '0x0339C32A)
(dictionary-add! blowfish-ks3 '0xC6913667)
(dictionary-add! blowfish-ks3 '0x8DF9317C)
(dictionary-add! blowfish-ks3 '0xE0B12B4F)
(dictionary-add! blowfish-ks3 '0xF79E59B7)
(dictionary-add! blowfish-ks3 '0x43F5BB3A)
(dictionary-add! blowfish-ks3 '0xF2D519FF)
(dictionary-add! blowfish-ks3 '0x27D9459C)
(dictionary-add! blowfish-ks3 '0xBF97222C)
(dictionary-add! blowfish-ks3 '0x15E6FC2A)
(dictionary-add! blowfish-ks3 '0x0F91FC71)
(dictionary-add! blowfish-ks3 '0x9B941525)
(dictionary-add! blowfish-ks3 '0xFAE59361)
(dictionary-add! blowfish-ks3 '0xCEB69CEB)
(dictionary-add! blowfish-ks3 '0xC2A86459)
(dictionary-add! blowfish-ks3 '0x12BAA8D1)
(dictionary-add! blowfish-ks3 '0xB6C1075E)
(dictionary-add! blowfish-ks3 '0xE3056A0C)
(dictionary-add! blowfish-ks3 '0x10D25065)
(dictionary-add! blowfish-ks3 '0xCB03A442)
(dictionary-add! blowfish-ks3 '0xE0EC6E0E)
(dictionary-add! blowfish-ks3 '0x1698DB3B)
(dictionary-add! blowfish-ks3 '0x4C98A0BE)
(dictionary-add! blowfish-ks3 '0x3278E964)
(dictionary-add! blowfish-ks3 '0x9F1F9532)
(dictionary-add! blowfish-ks3 '0xE0D392DF)
(dictionary-add! blowfish-ks3 '0xD3A0342B)
(dictionary-add! blowfish-ks3 '0x8971F21E)
(dictionary-add! blowfish-ks3 '0x1B0A7441)
(dictionary-add! blowfish-ks3 '0x4BA3348C)
(dictionary-add! blowfish-ks3 '0xC5BE7120)
(dictionary-add! blowfish-ks3 '0xC37632D8)
(dictionary-add! blowfish-ks3 '0xDF359F8D)
(dictionary-add! blowfish-ks3 '0x9B992F2E)
(dictionary-add! blowfish-ks3 '0xE60B6F47)
(dictionary-add! blowfish-ks3 '0x0FE3F11D)
(dictionary-add! blowfish-ks3 '0xE54CDA54)
(dictionary-add! blowfish-ks3 '0x1EDAD891)
(dictionary-add! blowfish-ks3 '0xCE6279CF)
(dictionary-add! blowfish-ks3 '0xCD3E7E6F)
(dictionary-add! blowfish-ks3 '0x1618B166)
(dictionary-add! blowfish-ks3 '0xFD2C1D05)
(dictionary-add! blowfish-ks3 '0x848FD2C5)
(dictionary-add! blowfish-ks3 '0xF6FB2299)
(dictionary-add! blowfish-ks3 '0xF523F357)
(dictionary-add! blowfish-ks3 '0xA6327623)
(dictionary-add! blowfish-ks3 '0x93A83531)
(dictionary-add! blowfish-ks3 '0x56CCCD02)
(dictionary-add! blowfish-ks3 '0xACF08162)
(dictionary-add! blowfish-ks3 '0x5A75EBB5)
(dictionary-add! blowfish-ks3 '0x6E163697)
(dictionary-add! blowfish-ks3 '0x88D273CC)
(dictionary-add! blowfish-ks3 '0xDE966292)
(dictionary-add! blowfish-ks3 '0x81B949D0)
(dictionary-add! blowfish-ks3 '0x4C50901B)
(dictionary-add! blowfish-ks3 '0x71C65614)
(dictionary-add! blowfish-ks3 '0xE6C6C7BD)
(dictionary-add! blowfish-ks3 '0x327A140A)
(dictionary-add! blowfish-ks3 '0x45E1D006)
(dictionary-add! blowfish-ks3 '0xC3F27B9A)
(dictionary-add! blowfish-ks3 '0xC9AA53FD)
(dictionary-add! blowfish-ks3 '0x62A80F00)
(dictionary-add! blowfish-ks3 '0xBB25BFE2)
(dictionary-add! blowfish-ks3 '0x35BDD2F6)
(dictionary-add! blowfish-ks3 '0x71126905)
(dictionary-add! blowfish-ks3 '0xB2040222)
(dictionary-add! blowfish-ks3 '0xB6CBCF7C)
(dictionary-add! blowfish-ks3 '0xCD769C2B)
(dictionary-add! blowfish-ks3 '0x53113EC0)
(dictionary-add! blowfish-ks3 '0x1640E3D3)
(dictionary-add! blowfish-ks3 '0x38ABBD60)
(dictionary-add! blowfish-ks3 '0x2547ADF0)
(dictionary-add! blowfish-ks3 '0xBA38209C)
(dictionary-add! blowfish-ks3 '0xF746CE76)
(dictionary-add! blowfish-ks3 '0x77AFA1C5)
(dictionary-add! blowfish-ks3 '0x20756060)
(dictionary-add! blowfish-ks3 '0x85CBFE4E)
(dictionary-add! blowfish-ks3 '0x8AE88DD8)
(dictionary-add! blowfish-ks3 '0x7AAAF9B0)
(dictionary-add! blowfish-ks3 '0x4CF9AA7E)
(dictionary-add! blowfish-ks3 '0x1948C25C)
(dictionary-add! blowfish-ks3 '0x02FB8A8C)
(dictionary-add! blowfish-ks3 '0x01C36AE4)
(dictionary-add! blowfish-ks3 '0xD6EBE1F9)
(dictionary-add! blowfish-ks3 '0x90D4F869)
(dictionary-add! blowfish-ks3 '0xA65CDEA0)
(dictionary-add! blowfish-ks3 '0x3F09252D)
(dictionary-add! blowfish-ks3 '0xC208E69F)
(dictionary-add! blowfish-ks3 '0xB74E6132)
(dictionary-add! blowfish-ks3 '0xCE77E25B)
(dictionary-add! blowfish-ks3 '0x578FDFE3)
(dictionary-add! blowfish-ks3 '0x3AC372E6)
(define (blowfish-hex-symbol->number sy) ;; FIXME refactor
(let ((colornumber 0))
(do ((i (- (string-length sy) 1) (- i 1)))
((< i 0) (- colornumber 1))
(let ((c (string-ref (string sy) i)))
(let ((n (cond ((or (eq? c #\a)(eq? c #\A))
10)
((or (eq? c #\b)(eq? c #\B))
11)
((or (eq? c #\c)(eq? c #\C))
12)
((or (eq? c #\d)(eq? c #\D))
13)
((or (eq? c #\e)(eq? c #\E))
14)
((or (eq? c #\f)(eq? c #\F))
15)
(else (string->number (string c))))))
(set! colornumber (+ (* (+ n 1) 16 i) colornumber)))))))
(define :blowfish-record
(make-record-type 'blowfish-record
'(blowfish-s0 blowfish-s1 blowfish-s2 blowfish-s3 blowfish-p)))
(define blowfish-record
(record-constructor :blowfish-record
'(blowfish-s0 blowfish-s1 blowfish-s2 blowfish-s3 blowfish-p)))
(define blowfish-s0 (record-accessor :blowfish-record 'blowfish-s0))
(define blowfish-s1 (record-accessor :blowfish-record 'blowfish-s1))
(define blowfish-s2 (record-accessor :blowfish-record 'blowfish-s2))
(define blowfish-s3 (record-accessor :blowfish-record 'blowfish-s3))
(define blowfish-p (record-accessor :blowfish-record 'blowfish-p))
(define blowfish-rounds 16) ;;
(define blowfish-context (make-blowfish-record
(make-vector 256)
(make-vector 256)
(make-vector 256)
(make-vector 256)
(make-vector (+ blowfish-rounds) 2)))
(define blowfish-ps (make-table))
(table-set! blowfish-ps 0 '0x243F6A88)
(table-set! blowfish-ps 1 '0x85A308D3)
(table-set! blowfish-ps 2 '0x13198A2E)
(table-set! blowfish-ps 3 '0x03707344)
(table-set! blowfish-ps 4 '0xA4093822)
(table-set! blowfish-ps 5 '0x299F31D0)
(table-set! blowfish-ps 6 '0x082EFA98)
(table-set! blowfish-ps 7 '0xEC4E6C89)
(table-set! blowfish-ps 8 '0x452821E6)
(table-set! blowfish-ps 9 '0x38D01377)
(table-set! blowfish-ps 10 '0xBE5466CF)
(table-set! blowfish-ps 11 '0x34E90C6C)
(table-set! blowfish-ps 12 '0xC0AC29B7)
(table-set! blowfish-ps 13 '0xC97C50DD)
(table-set! blowfish-ps 14 '0x3F84D5B5)
(table-set! blowfish-ps 15 '0xB5470917)
(table-set! blowfish-ps 16 '0x9216D5D9)
(table-set! blowfish-ps 17 '0x8979FB1B)
(define (blowfish-F-be x)
(bitwise-xor (+ (vector-ref (blowfish-s0 blowfish-context) 0)
(vector-ref (blowfish-s1 blowfish-context) 1))
(+ (vector-ref (blowfish-s2 blowfish-context) 2)
(vector-ref (blowfish-s3 blowfish-context) 3))))
(define (blowfish-F-le x)
(bitwise-xor (+ (vector-ref (blowfish-s0 blowfish-context) 3)
(vector-ref (blowfish-s1 blowfish-context) 2))
(+ (vector-ref (blowfish-s2 blowfish-context) 1)
(vector-ref (blowfish-s3 blowfish-context) 0))))
(define blowfish-F (if BIG-ENDIAN-HOST blowfish-F-be blowfish-F-le)) ;; FIXME default is big endian
(define (blowfish-R l r i)
(let ((l (bitwise-xor l (dictionary-ref (blowfish-p blowfish-context) i)))
(r (bitwise-xor r ((dictionary-ref (blowfish-p blowfish-context) blowfish_F l)))))
))
;; blowfish-rounds == 16 ->
(define (blowfish-encrypt bc ret_xl ret_xr) ;; NOTE bc = blowfish-context
(let ((xl ret_xl)
(xr ret_xr)
(p (blowfish-p bc))
(s0 (blowfish-s0 bc))
(s1 (blowfish-s1 bc))
(s2 (blowfish-s2 bc))
(s3 (blowfish-s3 bc)))
(blowfish-R xl xr 0)
(blowfish-R xr xl 1)
(blowfish-R xl xr 2)
(blowfish-R xr xl 3)
(blowfish-R xl xr 4)
(blowfish-R xr xl 5)
(blowfish-R xl xr 6)
(blowfish-R xr xl 7)
(blowfish-R xl xr 8)
(blowfish-R xr xl 9)
(blowfish-R xl xr 10)
(blowfish-R xr xl 11)
(blowfish-R xl xr 12)
(blowfish-R xr xl 13)
(blowfish-R xl xr 14)
(blowfish-R xr xl 15)
(let ((xl (bitwise-xor xl (vector-ref p blowfish-rounds)))
(xr (bitwise-xor xr (vector-ref p (+ blowfish-rounds)))))
(set! ret_xl xr)
(set! ret_xr xl)
)))
(define (blowfish-decrypt bc ret_xl ret_xr) ;; NOTE bc = blowfish-context
(let ((xl ret_xl)
(xr ret_xr)
(p (blowfish-p bc))
(s0 (blowfish-s0 bc))
(s1 (blowfish-s1 bc))
(s2 (blowfish-s2 bc))
(s3 (blowfish-s3 bc)))
(blowfish-R xl xr 17)
(blowfish-R xr xl 16)
(blowfish-R xl xr 15)
(blowfish-R xr xl 14)
(blowfish-R xl xr 13)
(blowfish-R xr xl 12)
(blowfish-R xl xr 11)
(blowfish-R xr xl 10)
(blowfish-R xl xr 9)
(blowfish-R xr xl 8)
(blowfish-R xl xr 7)
(blowfish-R xr xl 6)
(blowfish-R xl xr 5)
(blowfish-R xr xl 4)
(blowfish-R xl xr 3)
(blowfish-R xr xl 2)
(let ((xl (bitwise-xor xl (vector-ref p 1)))
(xr (bitwise-xor xr (vector-ref p 0))))
(set! ret_xl xr)
(set! ret_xr xl)
)))
(define (blowfish-set-key bc key keylen) ;; NOTE key is a table
(let ((data (make-table)))
(do ((i 0 (+ i 1)))
((=> i (+ blowfish-rounds 2))0)
(set! (vector-ref (blowfish-p bc) i) (table-ref blowfish-ps i)))
(do ((i 0 (+ i 1)))
((>= i 256)0)
(((blowfish-s0 bc) 'set-with-index) i (((blowfish-ks0 'get-with-index) i)))
(((blowfish-s1 bc) 'set-with-index) i (((blowfish-ks1 'get-with-index) i)))
(((blowfish-s2 bc) 'set-with-index) i (((blowfish-ks2 'get-with-index) i)))
(((blowfish-s3 bc) 'set-with-index) i (((blowfish-ks3 'get-with-index) i)))
)
(do ((i 0 (+ i 1))
(j 0 (+ j 1)))
((>= i (+ blowfish-rounds 2))0)
(if BIG-ENDIAN-HOST
(begin
(table-set! data 0 (table-ref key j))
(table-set! data 1 (table-ref key (remainder (+ j 1) keylen)))
(table-set! data 2 (table-ref key (remainder (+ j 2) keylen)))
(table-set! data 3 (table-ref key (remainder (+ j 3) keylen)))
)
(begin
(table-set! data 3 (table-ref key j))
(table-set! data 2 (table-ref key (remainder (+ j 1) keylen)))
(table-set! data 1 (table-ref key (remainder (+ j 2) keylen)))
(table-set! data 0 (table-ref key (remainder (+ j 3) keylen)))
))
(vector-set! (blowfish-p bc) i (bitwise-xor
(vector-ref (blowfish-p bc) i)
(+ (table-ref data 0)
(table-ref data 1)
(table-ref data 2)
(table-ref data 3))))
)
(let ((datal 0)
(datar 0))
(do ((i 0 (+ 2)))
((>= i (+ blowfish-rounds 2))0)
(blowfish-encrypt bc datal datar)
(vector-set! (blowfish-p bc) i datal)
(vector-set! (blowfish-p bc) (+ i 1) datar)
)
(do ((i 0 (+ 2)))
((>= i 256)0)
(vector-set! (blowfish-s0 bc) i datal)
(vector-set! (blowfish-s0 bc) (+ i 1) datar))
(do ((i 0 (+ 2)))
((>= i 256)0)
(vector-set! (blowfish-s1 bc) i datal)
(vector-set! (blowfish-s1 bc) (+ i 1) datar))
(do ((i 0 (+ 2)))
((>= i 256)0)
(vector-set! (blowfish-s2 bc) i datal)
(vector-set! (blowfish-s2 bc) (+ i 1) datar))
(do ((i 0 (+ 2)))
((>= i 256)0)
(vector-set! (blowfish-s3 bc) i datal)
(vector-set! (blowfish-s3 bc) (+ i 1) datar))
(do ((i 0 (+ i 1)))
((>= i 255)0);;
(do ((j (+ i 1) (+ j 1)))
(if (or (= (vector-ref (blowfish-s0 bc) i)
(vector-ref (blowfish-s0 bc) j))
(= (vector-ref (blowfish-s1 bc) i)
(vector-ref (blowfish-s1 bc) j))
(= (vector-ref (blowfish-s2 bc) i)
(vector-ref (blowfish-s2 bc) j))
(= (vector-ref (blowfish-s3 bc) i)
(vector-ref (blowfish-s3 bc) j)))
(begin
(display "Weak key.")
-1))
)))))
;; outbuf and inbuf are vectors
(define (blowfish-encrypt-block bc outbuf inbuf)
(let ((d1 0)
(d2 0))
(set! d1 (bitwise-ior (arithmetic-shift (vector-ref inbuf 0) 24)
(arithmetic-shift (vector-ref inbuf 1) 16)
(arithmetic-shift (vector-ref inbuf 2) 8)
(vector-ref inbuf 3)))
(set! d2 (bitwise-ior (arithmetic-shift (vector-ref inbuf 4) 24)
(arithmetic-shift (vector-ref inbuf 5) 16)
(arithmetic-shift (vector-ref inbuf 6) 8)
(vector-ref inbuf 7)))
(blowfish-encrypt bc d1 d2)
(vector-set! outbuf 0 (bitwise-and (arithmetic-shift d1 -24) 271)) ;;271==0xff
(vector-set! outbuf 1 (bitwise-and (arithmetic-shift d1 -16) 271)) ;;271==0xff
(vector-set! outbuf 2 (bitwise-and (arithmetic-shift d1 -8) 271)) ;;271==0xff
(vector-set! outbuf 3 (bitwise-and d1 271)) ;;271==0xff
(vector-set! outbuf 4 (bitwise-and (arithmetic-shift d2 -24) 271)) ;;271==0xff
(vector-set! outbuf 5 (bitwise-and (arithmetic-shift d2 -16) 271)) ;;271==0xff
(vector-set! outbuf 6 (bitwise-and (arithmetic-shift d2 -8) 271)) ;;271==0xff
(vector-set! outbuf 7 (bitwise-and d2 271)) ;;271==0xff
))
;; outbuf and inbuf are vectors
(define (blowfish-decrypt-block bc outbuf inbuf)
(let ((d1 0)
(d2 0))
(set! d1 (bitwise-ior (arithmetic-shift (vector-ref inbuf 0) 24)
(arithmetic-shift (vector-ref inbuf 1) 16)
(arithmetic-shift (vector-ref inbuf 2) 8)
(vector-ref inbuf 3)))
(set! d2 (bitwise-ior (arithmetic-shift (vector-ref inbuf 4) 24)
(arithmetic-shift (vector-ref inbuf 5) 16)
(arithmetic-shift (vector-ref inbuf 6) 8)
(vector-ref inbuf 7)))
(blowfish-decrypt bc d1 d2)
(vector-set! outbuf 0 (bitwise-and (arithmetic-shift d1 -24) 271)) ;;271==0xff
(vector-set! outbuf 1 (bitwise-and (arithmetic-shift d1 -16) 271)) ;;271==0xff
(vector-set! outbuf 2 (bitwise-and (arithmetic-shift d1 -8) 271)) ;;271==0xff
(vector-set! outbuf 3 (bitwise-and d1 271)) ;;271==0xff
(vector-set! outbuf 4 (bitwise-and (arithmetic-shift d2 -24) 271)) ;;271==0xff
(vector-set! outbuf 5 (bitwise-and (arithmetic-shift d2 -16) 271)) ;;271==0xff
(vector-set! outbuf 6 (bitwise-and (arithmetic-shift d2 -8) 271)) ;;271==0xff
(vector-set! outbuf 7 (bitwise-and d2 271)) ;;271==0xff
))
(define (blowfish-selftest)
(let ((bc blowfish-context))
(blowfish-set-key bc "abcdefghijklmnopqrstuvwxyz" 26)
(blowfish-encrypt-block bc buffer plain)))