sunterlib/scsh/encryption/blowfish.scm

1364 lines
54 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 'D1310BA6)
(dictionary-add! blowfish-ks0 '98DFB5AC)
(dictionary-add! blowfish-ks0 '2FFD72DB)
(dictionary-add! blowfish-ks0 'D01ADFB7)
(dictionary-add! blowfish-ks0 'B8E1AFED)
(dictionary-add! blowfish-ks0 '6A267E96)
(dictionary-add! blowfish-ks0 'BA7C9045)
(dictionary-add! blowfish-ks0 'F12C7F99)
(dictionary-add! blowfish-ks0 '24A19947)
(dictionary-add! blowfish-ks0 'B3916CF7)
(dictionary-add! blowfish-ks0 '0801F2E2)
(dictionary-add! blowfish-ks0 '858EFC16)
(dictionary-add! blowfish-ks0 '636920D8)
(dictionary-add! blowfish-ks0 '71574E69)
(dictionary-add! blowfish-ks0 'A458FEA3)
(dictionary-add! blowfish-ks0 'F4933D7E)
(dictionary-add! blowfish-ks0 '0D95748F)
(dictionary-add! blowfish-ks0 '728EB658)
(dictionary-add! blowfish-ks0 '718BCD58)
(dictionary-add! blowfish-ks0 '82154AEE)
(dictionary-add! blowfish-ks0 '7B54A41D)
(dictionary-add! blowfish-ks0 'C25A59B5)
(dictionary-add! blowfish-ks0 '9C30D539)
(dictionary-add! blowfish-ks0 '2AF26013)
(dictionary-add! blowfish-ks0 'C5D1B023)
(dictionary-add! blowfish-ks0 '286085F0)
(dictionary-add! blowfish-ks0 'CA417918)
(dictionary-add! blowfish-ks0 'B8DB38EF)
(dictionary-add! blowfish-ks0 '8E79DCB0)
(dictionary-add! blowfish-ks0 '603A180E)
(dictionary-add! blowfish-ks0 '6C9E0E8B)
(dictionary-add! blowfish-ks0 'B01E8A3E)
(dictionary-add! blowfish-ks0 'D71577C1)
(dictionary-add! blowfish-ks0 'BD314B27)
(dictionary-add! blowfish-ks0 '78AF2FDA)
(dictionary-add! blowfish-ks0 '55605C60)
(dictionary-add! blowfish-ks0 'E65525F3)
(dictionary-add! blowfish-ks0 'AA55AB94)
(dictionary-add! blowfish-ks0 '57489862)
(dictionary-add! blowfish-ks0 '63E81440)
(dictionary-add! blowfish-ks0 '55CA396A)
(dictionary-add! blowfish-ks0 '2AAB10B6)
(dictionary-add! blowfish-ks0 'B4CC5C34)
(dictionary-add! blowfish-ks0 '1141E8CE)
(dictionary-add! blowfish-ks0 'A15486AF)
(dictionary-add! blowfish-ks0 '7C72E993)
(dictionary-add! blowfish-ks0 'B3EE1411)
(dictionary-add! blowfish-ks0 '636FBC2A)
(dictionary-add! blowfish-ks0 '2BA9C55D)
(dictionary-add! blowfish-ks0 '741831F6)
(dictionary-add! blowfish-ks0 'CE5C3E16)
(dictionary-add! blowfish-ks0 '9B87931E)
(dictionary-add! blowfish-ks0 'AFD6BA33)
(dictionary-add! blowfish-ks0 '6C24CF5C)
(dictionary-add! blowfish-ks0 '7A325381)
(dictionary-add! blowfish-ks0 '28958677)
(dictionary-add! blowfish-ks0 '3B8F4898)
(dictionary-add! blowfish-ks0 '6B4BB9AF)
(dictionary-add! blowfish-ks0 'C4BFE81B)
(dictionary-add! blowfish-ks0 '66282193)
(dictionary-add! blowfish-ks0 '61D809CC)
(dictionary-add! blowfish-ks0 'FB21A991)
(dictionary-add! blowfish-ks0 '487CAC60)
(dictionary-add! blowfish-ks0 '5DEC8032)
(dictionary-add! blowfish-ks0 'EF845D5D)
(dictionary-add! blowfish-ks0 'E98575B1)
(dictionary-add! blowfish-ks0 'DC262302)
(dictionary-add! blowfish-ks0 'EB651B88)
(dictionary-add! blowfish-ks0 '23893E81)
(dictionary-add! blowfish-ks0 'D396ACC5)
(dictionary-add! blowfish-ks0 '0F6D6FF3)
(dictionary-add! blowfish-ks0 '83F44239)
(dictionary-add! blowfish-ks0 '2E0B4482)
(dictionary-add! blowfish-ks0 'A4842004)
(dictionary-add! blowfish-ks0 '69C8F04A)
(dictionary-add! blowfish-ks0 '9E1F9B5E)
(dictionary-add! blowfish-ks0 '21C66842)
(dictionary-add! blowfish-ks0 'F6E96C9A)
(dictionary-add! blowfish-ks0 '670C9C61)
(dictionary-add! blowfish-ks0 'ABD388F0)
(dictionary-add! blowfish-ks0 '6A51A0D2)
(dictionary-add! blowfish-ks0 'D8542F68)
(dictionary-add! blowfish-ks0 '960FA728)
(dictionary-add! blowfish-ks0 'AB5133A3)
(dictionary-add! blowfish-ks0 '6EEF0B6C)
(dictionary-add! blowfish-ks0 '137A3BE4)
(dictionary-add! blowfish-ks0 'BA3BF050)
(dictionary-add! blowfish-ks0 '7EFB2A98)
(dictionary-add! blowfish-ks0 'A1F1651D)
(dictionary-add! blowfish-ks0 '39AF0176)
(dictionary-add! blowfish-ks0 '66CA593E)
(dictionary-add! blowfish-ks0 '82430E88)
(dictionary-add! blowfish-ks0 '8CEE8619)
(dictionary-add! blowfish-ks0 '456F9FB4)
(dictionary-add! blowfish-ks0 '7D84A5C3)
(dictionary-add! blowfish-ks0 '3B8B5EBE)
(dictionary-add! blowfish-ks0 'E06F75D8)
(dictionary-add! blowfish-ks0 '85C12073)
(dictionary-add! blowfish-ks0 '401A449F)
(dictionary-add! blowfish-ks0 '56C16AA6)
(dictionary-add! blowfish-ks0 '4ED3AA62)
(dictionary-add! blowfish-ks0 '363F7706)
(dictionary-add! blowfish-ks0 '1BFEDF72)
(dictionary-add! blowfish-ks0 '429B023D)
(dictionary-add! blowfish-ks0 '37D0D724)
(dictionary-add! blowfish-ks0 'D00A1248)
(dictionary-add! blowfish-ks0 'DB0FEAD3)
(dictionary-add! blowfish-ks0 '49F1C09B)
(dictionary-add! blowfish-ks0 '075372C9)
(dictionary-add! blowfish-ks0 '80991B7B)
(dictionary-add! blowfish-ks0 '25D479D8)
(dictionary-add! blowfish-ks0 'F6E8DEF7)
(dictionary-add! blowfish-ks0 'E3FE501A)
(dictionary-add! blowfish-ks0 'B6794C3B)
(dictionary-add! blowfish-ks0 '976CE0BD)
(dictionary-add! blowfish-ks0 '04C006BA)
(dictionary-add! blowfish-ks0 'C1A94FB6)
(dictionary-add! blowfish-ks0 '409F60C4)
(dictionary-add! blowfish-ks0 '5E5C9EC2)
(dictionary-add! blowfish-ks0 '196A2463)
(dictionary-add! blowfish-ks0 '68FB6FAF)
(dictionary-add! blowfish-ks0 '3E6C53B5)
(dictionary-add! blowfish-ks0 '1339B2EB)
(dictionary-add! blowfish-ks0 '3B52EC6F)
(dictionary-add! blowfish-ks0 '6DFC511F)
(dictionary-add! blowfish-ks0 '9B30952C)
(dictionary-add! blowfish-ks0 'CC814544)
(dictionary-add! blowfish-ks0 'AF5EBD09)
(dictionary-add! blowfish-ks0 'BEE3D004)
(dictionary-add! blowfish-ks0 'DE334AFD)
(dictionary-add! blowfish-ks0 '660F2807)
(dictionary-add! blowfish-ks0 '192E4BB3)
(dictionary-add! blowfish-ks0 'C0CBA857)
(dictionary-add! blowfish-ks0 '45C8740F)
(dictionary-add! blowfish-ks0 'D20B5F39)
(dictionary-add! blowfish-ks0 'B9D3FBDB)
(dictionary-add! blowfish-ks0 '5579C0BD)
(dictionary-add! blowfish-ks0 '1A60320A)
(dictionary-add! blowfish-ks0 'D6A100C6)
(dictionary-add! blowfish-ks0 '402C7279)
(dictionary-add! blowfish-ks0 '679F25FE)
(dictionary-add! blowfish-ks0 'FB1FA3CC)
(dictionary-add! blowfish-ks0 '8EA5E9F8)
(dictionary-add! blowfish-ks0 'DB3222F8)
(dictionary-add! blowfish-ks0 '3C7516DF)
(dictionary-add! blowfish-ks0 'FD616B15)
(dictionary-add! blowfish-ks0 '2F501EC8)
(dictionary-add! blowfish-ks0 'AD0552AB)
(dictionary-add! blowfish-ks0 '323DB5FA)
(dictionary-add! blowfish-ks0 'FD238760)
(dictionary-add! blowfish-ks0 '53317B48)
(dictionary-add! blowfish-ks0 '3E00DF82)
(dictionary-add! blowfish-ks0 '9E5C57BB)
(dictionary-add! blowfish-ks0 'CA6F8CA0)
(dictionary-add! blowfish-ks0 '1A87562E)
(dictionary-add! blowfish-ks0 'DF1769DB)
(dictionary-add! blowfish-ks0 'D542A8F6)
(dictionary-add! blowfish-ks0 '287EFFC3)
(dictionary-add! blowfish-ks0 'AC6732C6)
(dictionary-add! blowfish-ks0 '8C4F5573)
(dictionary-add! blowfish-ks0 '695B27B0)
(dictionary-add! blowfish-ks0 'BBCA58C8)
(dictionary-add! blowfish-ks0 'E1FFA35D)
(dictionary-add! blowfish-ks0 'B8F011A0)
(dictionary-add! blowfish-ks0 '10FA3D98)
(dictionary-add! blowfish-ks0 'FD2183B8)
(dictionary-add! blowfish-ks0 '4AFCB56C)
(dictionary-add! blowfish-ks0 '2DD1D35B)
(dictionary-add! blowfish-ks0 '9A53E479)
(dictionary-add! blowfish-ks0 'B6F84565)
(dictionary-add! blowfish-ks0 'D28E49BC)
(dictionary-add! blowfish-ks0 '4BFB9790)
(dictionary-add! blowfish-ks0 'E1DDF2DA)
(dictionary-add! blowfish-ks0 'A4CB7E33)
(dictionary-add! blowfish-ks0 '62FB1341)
(dictionary-add! blowfish-ks0 'CEE4C6E8)
(dictionary-add! blowfish-ks0 'EF20CADA)
(dictionary-add! blowfish-ks0 '36774C01)
(dictionary-add! blowfish-ks0 'D07E9EFE)
(dictionary-add! blowfish-ks0 '2BF11FB4)
(dictionary-add! blowfish-ks0 '95DBDA4D)
(dictionary-add! blowfish-ks0 'AE909198)
(dictionary-add! blowfish-ks0 'EAAD8E71)
(dictionary-add! blowfish-ks0 '6B93D5A0)
(dictionary-add! blowfish-ks0 'D08ED1D0)
(dictionary-add! blowfish-ks0 'AFC725E0)
(dictionary-add! blowfish-ks0 '8E3C5B2F)
(dictionary-add! blowfish-ks0 '8E7594B7)
(dictionary-add! blowfish-ks0 '8FF6E2FB)
(dictionary-add! blowfish-ks0 'F2122B64)
(dictionary-add! blowfish-ks0 '8888B812)
(dictionary-add! blowfish-ks0 '900DF01C)
(dictionary-add! blowfish-ks0 '4FAD5EA0)
(dictionary-add! blowfish-ks0 '688FC31C)
(dictionary-add! blowfish-ks0 'D1CFF191)
(dictionary-add! blowfish-ks0 'B3A8C1AD)
(dictionary-add! blowfish-ks0 '2F2F2218)
(dictionary-add! blowfish-ks0 'BE0E1777)
(dictionary-add! blowfish-ks0 'EA752DFE)
(dictionary-add! blowfish-ks0 '8B021FA1)
(dictionary-add! blowfish-ks0 'E5A0CC0F)
(dictionary-add! blowfish-ks0 'B56F74E8)
(dictionary-add! blowfish-ks0 '18ACF3D6)
(dictionary-add! blowfish-ks0 'CE89E299)
(dictionary-add! blowfish-ks0 'B4A84FE0)
(dictionary-add! blowfish-ks0 'FD13E0B7)
(dictionary-add! blowfish-ks0 '7CC43B81)
(dictionary-add! blowfish-ks0 'D2ADA8D9)
(dictionary-add! blowfish-ks0 '165FA266)
(dictionary-add! blowfish-ks0 '80957705)
(dictionary-add! blowfish-ks0 '93CC7314)
(dictionary-add! blowfish-ks0 '211A1477)
(dictionary-add! blowfish-ks0 'E6AD2065)
(dictionary-add! blowfish-ks0 '77B5FA86)
(dictionary-add! blowfish-ks0 'C75442F5)
(dictionary-add! blowfish-ks0 'FB9D35CF)
(dictionary-add! blowfish-ks0 'EBCDAF0C)
(dictionary-add! blowfish-ks0 '7B3E89A0)
(dictionary-add! blowfish-ks0 'D6411BD3)
(dictionary-add! blowfish-ks0 'AE1E7E49)
(dictionary-add! blowfish-ks0 '00250E2D)
(dictionary-add! blowfish-ks0 '2071B35E)
(dictionary-add! blowfish-ks0 '226800BB)
(dictionary-add! blowfish-ks0 '57B8E0AF)
(dictionary-add! blowfish-ks0 '2464369B)
(dictionary-add! blowfish-ks0 'F009B91E)
(dictionary-add! blowfish-ks0 '5563911D)
(dictionary-add! blowfish-ks0 '59DFA6AA)
(dictionary-add! blowfish-ks0 '78C14389)
(dictionary-add! blowfish-ks0 'D95A537F)
(dictionary-add! blowfish-ks0 '207D5BA2)
(dictionary-add! blowfish-ks0 '02E5B9C5)
(dictionary-add! blowfish-ks0 '83260376)
(dictionary-add! blowfish-ks0 '6295CFA9)
(dictionary-add! blowfish-ks0 '11C81968)
(dictionary-add! blowfish-ks0 '4E734A41)
(dictionary-add! blowfish-ks0 'B3472DCA)
(dictionary-add! blowfish-ks0 '7B14A94A)
(dictionary-add! blowfish-ks0 '1B510052)
(dictionary-add! blowfish-ks0 '9A532915)
(dictionary-add! blowfish-ks0 'D60F573F)
(dictionary-add! blowfish-ks0 'BC9BC6E4)
(dictionary-add! blowfish-ks0 '2B60A476)
(dictionary-add! blowfish-ks0 '81E67400)
(dictionary-add! blowfish-ks0 '08BA6FB5)
(dictionary-add! blowfish-ks0 '571BE91F)
(dictionary-add! blowfish-ks0 'F296EC6B)
(dictionary-add! blowfish-ks0 '2A0DD915)
(dictionary-add! blowfish-ks0 'B6636521)
(dictionary-add! blowfish-ks0 'E7B9F9B6)
(dictionary-add! blowfish-ks0 'FF34052E)
(dictionary-add! blowfish-ks0 'C5855664)
(dictionary-add! blowfish-ks0 '53B02D5D)
(dictionary-add! blowfish-ks0 'A99F8FA1)
(dictionary-add! blowfish-ks0 '08BA4799)
(dictionary-add! blowfish-ks0 '6E85076A)
(define blowfish-ks1(make-dictionary))
(dictionary-add! blowfish-ks1 '4B7A70E9)
(dictionary-add! blowfish-ks1 'B5B32944)
(dictionary-add! blowfish-ks1 'DB75092E)
(dictionary-add! blowfish-ks1 'C4192623)
(dictionary-add! blowfish-ks1 'AD6EA6B0)
(dictionary-add! blowfish-ks1 '49A7DF7D)
(dictionary-add! blowfish-ks1 '9CEE60B8)
(dictionary-add! blowfish-ks1 '8FEDB266)
(dictionary-add! blowfish-ks1 'ECAA8C71)
(dictionary-add! blowfish-ks1 '699A17FF)
(dictionary-add! blowfish-ks1 '5664526C)
(dictionary-add! blowfish-ks1 'C2B19EE1)
(dictionary-add! blowfish-ks1 '193602A5)
(dictionary-add! blowfish-ks1 '75094C29)
(dictionary-add! blowfish-ks1 'A0591340)
(dictionary-add! blowfish-ks1 'E4183A3E)
(dictionary-add! blowfish-ks1 '3F54989A)
(dictionary-add! blowfish-ks1 '5B429D65)
(dictionary-add! blowfish-ks1 '6B8FE4D6)
(dictionary-add! blowfish-ks1 '99F73FD6)
(dictionary-add! blowfish-ks1 'A1D29C07)
(dictionary-add! blowfish-ks1 'EFE830F5)
(dictionary-add! blowfish-ks1 '4D2D38E6)
(dictionary-add! blowfish-ks1 'F0255DC1)
(dictionary-add! blowfish-ks1 '4CDD2086)
(dictionary-add! blowfish-ks1 '8470EB26)
(dictionary-add! blowfish-ks1 '6382E9C6)
(dictionary-add! blowfish-ks1 '021ECC5E)
(dictionary-add! blowfish-ks1 '09686B3F)
(dictionary-add! blowfish-ks1 '3EBAEFC9)
(dictionary-add! blowfish-ks1 '3C971814)
(dictionary-add! blowfish-ks1 '6B6A70A1)
(dictionary-add! blowfish-ks1 '687F3584)
(dictionary-add! blowfish-ks1 '52A0E286)
(dictionary-add! blowfish-ks1 'B79C5305)
(dictionary-add! blowfish-ks1 'AA500737)
(dictionary-add! blowfish-ks1 '3E07841C)
(dictionary-add! blowfish-ks1 '7FDEAE5C)
(dictionary-add! blowfish-ks1 '8E7D44EC)
(dictionary-add! blowfish-ks1 '5716F2B8)
(dictionary-add! blowfish-ks1 'B03ADA37)
(dictionary-add! blowfish-ks1 'F0500C0D)
(dictionary-add! blowfish-ks1 'F01C1F04)
(dictionary-add! blowfish-ks1 '0200B3FF)
(dictionary-add! blowfish-ks1 'AE0CF51A)
(dictionary-add! blowfish-ks1 '3CB574B2)
(dictionary-add! blowfish-ks1 '25837A58)
(dictionary-add! blowfish-ks1 'DC0921BD)
(dictionary-add! blowfish-ks1 'D19113F9)
(dictionary-add! blowfish-ks1 '7CA92FF6)
(dictionary-add! blowfish-ks1 '94324773)
(dictionary-add! blowfish-ks1 '22F54701)
(dictionary-add! blowfish-ks1 '3AE5E581)
(dictionary-add! blowfish-ks1 '37C2DADC)
(dictionary-add! blowfish-ks1 'C8B57634)
(dictionary-add! blowfish-ks1 '9AF3DDA7)
(dictionary-add! blowfish-ks1 'A9446146)
(dictionary-add! blowfish-ks1 '0FD0030E)
(dictionary-add! blowfish-ks1 'ECC8C73E)
(dictionary-add! blowfish-ks1 'A4751E41)
(dictionary-add! blowfish-ks1 'E238CD99)
(dictionary-add! blowfish-ks1 '3BEA0E2F)
(dictionary-add! blowfish-ks1 '3280BBA1)
(dictionary-add! blowfish-ks1 '183EB331)
(dictionary-add! blowfish-ks1 '4E548B38)
(dictionary-add! blowfish-ks1 '4F6DB908)
(dictionary-add! blowfish-ks1 '6F420D03)
(dictionary-add! blowfish-ks1 'F60A04BF)
(dictionary-add! blowfish-ks1 '2CB81290)
(dictionary-add! blowfish-ks1 '24977C79)
(dictionary-add! blowfish-ks1 '5679B072)
(dictionary-add! blowfish-ks1 'BCAF89AF)
(dictionary-add! blowfish-ks1 'DE9A771F)
(dictionary-add! blowfish-ks1 'D9930810)
(dictionary-add! blowfish-ks1 'B38BAE12)
(dictionary-add! blowfish-ks1 'DCCF3F2E)
(dictionary-add! blowfish-ks1 '5512721F)
(dictionary-add! blowfish-ks1 '2E6B7124)
(dictionary-add! blowfish-ks1 '501ADDE6)
(dictionary-add! blowfish-ks1 '9F84CD87)
(dictionary-add! blowfish-ks1 '7A584718)
(dictionary-add! blowfish-ks1 '7408DA17)
(dictionary-add! blowfish-ks1 'BC9F9ABC)
(dictionary-add! blowfish-ks1 'E94B7D8C)
(dictionary-add! blowfish-ks1 'EC7AEC3A)
(dictionary-add! blowfish-ks1 'DB851DFA)
(dictionary-add! blowfish-ks1 '63094366)
(dictionary-add! blowfish-ks1 'C464C3D2)
(dictionary-add! blowfish-ks1 'EF1C1847)
(dictionary-add! blowfish-ks1 '3215D908)
(dictionary-add! blowfish-ks1 'DD433B37)
(dictionary-add! blowfish-ks1 '24C2BA16)
(dictionary-add! blowfish-ks1 '12A14D43)
(dictionary-add! blowfish-ks1 '2A65C451)
(dictionary-add! blowfish-ks1 '50940002)
(dictionary-add! blowfish-ks1 '133AE4DD)
(dictionary-add! blowfish-ks1 '71DFF89E)
(dictionary-add! blowfish-ks1 '10314E55)
(dictionary-add! blowfish-ks1 '81AC77D6)
(dictionary-add! blowfish-ks1 '5F11199B)
(dictionary-add! blowfish-ks1 '043556F1)
(dictionary-add! blowfish-ks1 'D7A3C76B)
(dictionary-add! blowfish-ks1 '3C11183B)
(dictionary-add! blowfish-ks1 '5924A509)
(dictionary-add! blowfish-ks1 'F28FE6ED)
(dictionary-add! blowfish-ks1 '97F1FBFA)
(dictionary-add! blowfish-ks1 '9EBABF2C)
(dictionary-add! blowfish-ks1 '1E153C6E)
(dictionary-add! blowfish-ks1 '86E34570)
(dictionary-add! blowfish-ks1 'EAE96FB1)
(dictionary-add! blowfish-ks1 '860E5E0A)
(dictionary-add! blowfish-ks1 '5A3E2AB3)
(dictionary-add! blowfish-ks1 '771FE71C)
(dictionary-add! blowfish-ks1 '4E3D06FA)
(dictionary-add! blowfish-ks1 '2965DCB9)
(dictionary-add! blowfish-ks1 '99E71D0F)
(dictionary-add! blowfish-ks1 '803E89D6)
(dictionary-add! blowfish-ks1 '5266C825)
(dictionary-add! blowfish-ks1 '2E4CC978)
(dictionary-add! blowfish-ks1 '9C10B36A)
(dictionary-add! blowfish-ks1 'C6150EBA)
(dictionary-add! blowfish-ks1 '94E2EA78)
(dictionary-add! blowfish-ks1 'A5FC3C53)
(dictionary-add! blowfish-ks1 '1E0A2DF4)
(dictionary-add! blowfish-ks1 'F2F74EA7)
(dictionary-add! blowfish-ks1 '361D2B3D)
(dictionary-add! blowfish-ks1 '1939260F)
(dictionary-add! blowfish-ks1 '19C27960)
(dictionary-add! blowfish-ks1 '5223A708)
(dictionary-add! blowfish-ks1 'F71312B6)
(dictionary-add! blowfish-ks1 'EBADFE6E)
(dictionary-add! blowfish-ks1 'EAC31F66)
(dictionary-add! blowfish-ks1 'E3BC4595)
(dictionary-add! blowfish-ks1 'A67BC883)
(dictionary-add! blowfish-ks1 'B17F37D1)
(dictionary-add! blowfish-ks1 '018CFF28)
(dictionary-add! blowfish-ks1 'C332DDEF)
(dictionary-add! blowfish-ks1 'BE6C5AA5)
(dictionary-add! blowfish-ks1 '65582185)
(dictionary-add! blowfish-ks1 '68AB9802)
(dictionary-add! blowfish-ks1 'EECEA50F)
(dictionary-add! blowfish-ks1 'DB2F953B)
(dictionary-add! blowfish-ks1 '2AEF7DAD)
(dictionary-add! blowfish-ks1 '5B6E2F84)
(dictionary-add! blowfish-ks1 '1521B628)
(dictionary-add! blowfish-ks1 '29076170)
(dictionary-add! blowfish-ks1 'ECDD4775)
(dictionary-add! blowfish-ks1 '619F1510)
(dictionary-add! blowfish-ks1 '13CCA830)
(dictionary-add! blowfish-ks1 'EB61BD96)
(dictionary-add! blowfish-ks1 '0334FE1E)
(dictionary-add! blowfish-ks1 'AA0363CF)
(dictionary-add! blowfish-ks1 'B5735C90)
(dictionary-add! blowfish-ks1 '4C70A239)
(dictionary-add! blowfish-ks1 'D59E9E0B)
(dictionary-add! blowfish-ks1 'CBAADE14)
(dictionary-add! blowfish-ks1 'EECC86BC)
(dictionary-add! blowfish-ks1 '60622CA7)
(dictionary-add! blowfish-ks1 '9CAB5CAB)
(dictionary-add! blowfish-ks1 'B2F3846E)
(dictionary-add! blowfish-ks1 '648B1EAF)
(dictionary-add! blowfish-ks1 '19BDF0CA)
(dictionary-add! blowfish-ks1 'A02369B9)
(dictionary-add! blowfish-ks1 '655ABB50)
(dictionary-add! blowfish-ks1 '40685A32)
(dictionary-add! blowfish-ks1 '3C2AB4B3)
(dictionary-add! blowfish-ks1 '319EE9D5)
(dictionary-add! blowfish-ks1 'C021B8F7)
(dictionary-add! blowfish-ks1 '9B540B19)
(dictionary-add! blowfish-ks1 '875FA099)
(dictionary-add! blowfish-ks1 '95F7997E)
(dictionary-add! blowfish-ks1 '623D7DA8)
(dictionary-add! blowfish-ks1 'F837889A)
(dictionary-add! blowfish-ks1 '97E32D77)
(dictionary-add! blowfish-ks1 '11ED935F)
(dictionary-add! blowfish-ks1 '16681281)
(dictionary-add! blowfish-ks1 '0E358829)
(dictionary-add! blowfish-ks1 'C7E61FD6)
(dictionary-add! blowfish-ks1 '96DEDFA1)
(dictionary-add! blowfish-ks1 '7858BA99)
(dictionary-add! blowfish-ks1 '57F584A5)
(dictionary-add! blowfish-ks1 '1B227263)
(dictionary-add! blowfish-ks1 '9B83C3FF)
(dictionary-add! blowfish-ks1 '1AC24696)
(dictionary-add! blowfish-ks1 'CDB30AEB)
(dictionary-add! blowfish-ks1 '532E3054)
(dictionary-add! blowfish-ks1 '8FD948E4)
(dictionary-add! blowfish-ks1 '6DBC3128)
(dictionary-add! blowfish-ks1 '58EBF2EF)
(dictionary-add! blowfish-ks1 '34C6FFEA)
(dictionary-add! blowfish-ks1 'FE28ED61)
(dictionary-add! blowfish-ks1 'EE7C3C73)
(dictionary-add! blowfish-ks1 '5D4A14D9)
(dictionary-add! blowfish-ks1 'E864B7E3)
(dictionary-add! blowfish-ks1 '42105D14)
(dictionary-add! blowfish-ks1 '203E13E0)
(dictionary-add! blowfish-ks1 '45EEE2B6)
(dictionary-add! blowfish-ks1 'A3AAABEA)
(dictionary-add! blowfish-ks1 'DB6C4F15)
(dictionary-add! blowfish-ks1 'FACB4FD0)
(dictionary-add! blowfish-ks1 'C742F442)
(dictionary-add! blowfish-ks1 'EF6ABBB5)
(dictionary-add! blowfish-ks1 '654F3B1D)
(dictionary-add! blowfish-ks1 '41CD2105)
(dictionary-add! blowfish-ks1 'D81E799E)
(dictionary-add! blowfish-ks1 '86854DC7)
(dictionary-add! blowfish-ks1 'E44B476A)
(dictionary-add! blowfish-ks1 '3D816250)
(dictionary-add! blowfish-ks1 'CF62A1F2)
(dictionary-add! blowfish-ks1 '5B8D2646)
(dictionary-add! blowfish-ks1 'FC8883A0)
(dictionary-add! blowfish-ks1 'C1C7B6A3)
(dictionary-add! blowfish-ks1 '7F1524C3)
(dictionary-add! blowfish-ks1 '69CB7492)
(dictionary-add! blowfish-ks1 '47848A0B)
(dictionary-add! blowfish-ks1 '5692B285)
(dictionary-add! blowfish-ks1 '095BBF00)
(dictionary-add! blowfish-ks1 'AD19489D)
(dictionary-add! blowfish-ks1 '1462B174)
(dictionary-add! blowfish-ks1 '23820E00)
(dictionary-add! blowfish-ks1 '58428D2A)
(dictionary-add! blowfish-ks1 '0C55F5EA)
(dictionary-add! blowfish-ks1 '1DADF43E)
(dictionary-add! blowfish-ks1 '233F7061)
(dictionary-add! blowfish-ks1 '3372F092)
(dictionary-add! blowfish-ks1 '8D937E41)
(dictionary-add! blowfish-ks1 'D65FECF1)
(dictionary-add! blowfish-ks1 '6C223BDB)
(dictionary-add! blowfish-ks1 '7CDE3759)
(dictionary-add! blowfish-ks1 'CBEE7460)
(dictionary-add! blowfish-ks1 '4085F2A7)
(dictionary-add! blowfish-ks1 'CE77326E)
(dictionary-add! blowfish-ks1 'A6078084)
(dictionary-add! blowfish-ks1 '19F8509E)
(dictionary-add! blowfish-ks1 'E8EFD855)
(dictionary-add! blowfish-ks1 '61D99735)
(dictionary-add! blowfish-ks1 'A969A7AA)
(dictionary-add! blowfish-ks1 'C50C06C2)
(dictionary-add! blowfish-ks1 '5A04ABFC)
(dictionary-add! blowfish-ks1 '800BCADC)
(dictionary-add! blowfish-ks1 '9E447A2E)
(dictionary-add! blowfish-ks1 'C3453484)
(dictionary-add! blowfish-ks1 'FDD56705)
(dictionary-add! blowfish-ks1 '0E1E9EC9)
(dictionary-add! blowfish-ks1 'DB73DBD3)
(dictionary-add! blowfish-ks1 '105588CD)
(dictionary-add! blowfish-ks1 '675FDA79)
(dictionary-add! blowfish-ks1 'E3674340)
(dictionary-add! blowfish-ks1 'C5C43465)
(dictionary-add! blowfish-ks1 '713E38D8)
(dictionary-add! blowfish-ks1 '3D28F89E)
(dictionary-add! blowfish-ks1 'F16DFF20)
(dictionary-add! blowfish-ks1 '153E21E7)
(dictionary-add! blowfish-ks1 '8FB03D4A)
(dictionary-add! blowfish-ks1 'E6E39F2B)
(dictionary-add! blowfish-ks1 'DB83ADF7)
(define ks2-blowfish (make-dictionary))
(dictionary-add! blowfish-ks2 'E93D5A68)
(dictionary-add! blowfish-ks2 '948140F7)
(dictionary-add! blowfish-ks2 'F64C261C)
(dictionary-add! blowfish-ks2 '94692934)
(dictionary-add! blowfish-ks2 '411520F7)
(dictionary-add! blowfish-ks2 '7602D4F7)
(dictionary-add! blowfish-ks2 'BCF46B2E)
(dictionary-add! blowfish-ks2 'D4A20068)
(dictionary-add! blowfish-ks2 'D4082471)
(dictionary-add! blowfish-ks2 '3320F46A)
(dictionary-add! blowfish-ks2 '43B7D4B7)
(dictionary-add! blowfish-ks2 '500061AF)
(dictionary-add! blowfish-ks2 '1E39F62E)
(dictionary-add! blowfish-ks2 '97244546)
(dictionary-add! blowfish-ks2 '14214F74)
(dictionary-add! blowfish-ks2 'BF8B8840)
(dictionary-add! blowfish-ks2 '4D95FC1D)
(dictionary-add! blowfish-ks2 '96B591AF)
(dictionary-add! blowfish-ks2 '70F4DDD3)
(dictionary-add! blowfish-ks2 '66A02F45)
(dictionary-add! blowfish-ks2 'BFBC09EC)
(dictionary-add! blowfish-ks2 '03BD9785)
(dictionary-add! blowfish-ks2 '7FAC6DD0)
(dictionary-add! blowfish-ks2 '31CB8504)
(dictionary-add! blowfish-ks2 '96EB27B3)
(dictionary-add! blowfish-ks2 '55FD3941)
(dictionary-add! blowfish-ks2 'DA2547E6)
(dictionary-add! blowfish-ks2 'ABCA0A9A)
(dictionary-add! blowfish-ks2 '28507825)
(dictionary-add! blowfish-ks2 '530429F4)
(dictionary-add! blowfish-ks2 '0A2C86DA)
(dictionary-add! blowfish-ks2 'E9B66DFB)
(dictionary-add! blowfish-ks2 '68DC1462)
(dictionary-add! blowfish-ks2 'D7486900)
(dictionary-add! blowfish-ks2 '680EC0A4)
(dictionary-add! blowfish-ks2 '27A18DEE)
(dictionary-add! blowfish-ks2 '4F3FFEA2)
(dictionary-add! blowfish-ks2 'E887AD8C)
(dictionary-add! blowfish-ks2 'B58CE006)
(dictionary-add! blowfish-ks2 '7AF4D6B6)
(dictionary-add! blowfish-ks2 'AACE1E7C)
(dictionary-add! blowfish-ks2 'D3375FEC)
(dictionary-add! blowfish-ks2 'CE78A399)
(dictionary-add! blowfish-ks2 '406B2A42)
(dictionary-add! blowfish-ks2 '20FE9E35)
(dictionary-add! blowfish-ks2 'D9F385B9)
(dictionary-add! blowfish-ks2 'EE39D7AB)
(dictionary-add! blowfish-ks2 '3B124E8B)
(dictionary-add! blowfish-ks2 '1DC9FAF7)
(dictionary-add! blowfish-ks2 '4B6D1856)
(dictionary-add! blowfish-ks2 '26A36631)
(dictionary-add! blowfish-ks2 'EAE397B2)
(dictionary-add! blowfish-ks2 '3A6EFA74)
(dictionary-add! blowfish-ks2 'DD5B4332)
(dictionary-add! blowfish-ks2 '6841E7F7)
(dictionary-add! blowfish-ks2 'CA7820FB)
(dictionary-add! blowfish-ks2 'FB0AF54E)
(dictionary-add! blowfish-ks2 'D8FEB397)
(dictionary-add! blowfish-ks2 '454056AC)
(dictionary-add! blowfish-ks2 'BA489527)
(dictionary-add! blowfish-ks2 '55533A3A)
(dictionary-add! blowfish-ks2 '20838D87)
(dictionary-add! blowfish-ks2 'FE6BA9B7)
(dictionary-add! blowfish-ks2 'D096954B)
(dictionary-add! blowfish-ks2 '55A867BC)
(dictionary-add! blowfish-ks2 'A1159A58)
(dictionary-add! blowfish-ks2 'CCA92963)
(dictionary-add! blowfish-ks2 '99E1DB33)
(dictionary-add! blowfish-ks2 'A62A4A56)
(dictionary-add! blowfish-ks2 '3F3125F9)
(dictionary-add! blowfish-ks2 '5EF47E1C)
(dictionary-add! blowfish-ks2 '9029317C)
(dictionary-add! blowfish-ks2 'FDF8E802)
(dictionary-add! blowfish-ks2 '04272F70)
(dictionary-add! blowfish-ks2 '80BB155C)
(dictionary-add! blowfish-ks2 '05282CE3)
(dictionary-add! blowfish-ks2 '95C11548)
(dictionary-add! blowfish-ks2 'E4C66D22)
(dictionary-add! blowfish-ks2 '48C1133F)
(dictionary-add! blowfish-ks2 'C70F86DC)
(dictionary-add! blowfish-ks2 '07F9C9EE)
(dictionary-add! blowfish-ks2 '41041F0F)
(dictionary-add! blowfish-ks2 '404779A4)
(dictionary-add! blowfish-ks2 '5D886E17)
(dictionary-add! blowfish-ks2 '325F51EB)
(dictionary-add! blowfish-ks2 'D59BC0D1)
(dictionary-add! blowfish-ks2 'F2BCC18F)
(dictionary-add! blowfish-ks2 '41113564)
(dictionary-add! blowfish-ks2 '257B7834)
(dictionary-add! blowfish-ks2 '602A9C60)
(dictionary-add! blowfish-ks2 'DFF8E8A3)
(dictionary-add! blowfish-ks2 '1F636C1B)
(dictionary-add! blowfish-ks2 '0E12B4C2)
(dictionary-add! blowfish-ks2 '02E1329E)
(dictionary-add! blowfish-ks2 'AF664FD1)
(dictionary-add! blowfish-ks2 'CAD18115)
(dictionary-add! blowfish-ks2 '6B2395E0)
(dictionary-add! blowfish-ks2 '333E92E1)
(dictionary-add! blowfish-ks2 '3B240B62)
(dictionary-add! blowfish-ks2 'EEBEB922)
(dictionary-add! blowfish-ks2 '85B2A20E)
(dictionary-add! blowfish-ks2 'E6BA0D99)
(dictionary-add! blowfish-ks2 'DE720C8C)
(dictionary-add! blowfish-ks2 '2DA2F728)
(dictionary-add! blowfish-ks2 'D0127845)
(dictionary-add! blowfish-ks2 '95B794FD)
(dictionary-add! blowfish-ks2 '647D0862)
(dictionary-add! blowfish-ks2 'E7CCF5F0)
(dictionary-add! blowfish-ks2 '5449A36F)
(dictionary-add! blowfish-ks2 '877D48FA)
(dictionary-add! blowfish-ks2 'C39DFD27)
(dictionary-add! blowfish-ks2 'F33E8D1E)
(dictionary-add! blowfish-ks2 '0A476341)
(dictionary-add! blowfish-ks2 '992EFF74)
(dictionary-add! blowfish-ks2 '3A6F6EAB)
(dictionary-add! blowfish-ks2 'F4F8FD37)
(dictionary-add! blowfish-ks2 'A812DC60)
(dictionary-add! blowfish-ks2 'A1EBDDF8)
(dictionary-add! blowfish-ks2 '991BE14C)
(dictionary-add! blowfish-ks2 'DB6E6B0D)
(dictionary-add! blowfish-ks2 'C67B5510)
(dictionary-add! blowfish-ks2 '6D672C37)
(dictionary-add! blowfish-ks2 '2765D43B)
(dictionary-add! blowfish-ks2 'DCD0E804)
(dictionary-add! blowfish-ks2 'F1290DC7)
(dictionary-add! blowfish-ks2 'CC00FFA3)
(dictionary-add! blowfish-ks2 'B5390F92)
(dictionary-add! blowfish-ks2 '690FED0B)
(dictionary-add! blowfish-ks2 '667B9FFB)
(dictionary-add! blowfish-ks2 'CEDB7D9C)
(dictionary-add! blowfish-ks2 'A091CF0B)
(dictionary-add! blowfish-ks2 'D9155EA3)
(dictionary-add! blowfish-ks2 'BB132F88)
(dictionary-add! blowfish-ks2 '515BAD24)
(dictionary-add! blowfish-ks2 '7B9479BF)
(dictionary-add! blowfish-ks2 '763BD6EB)
(dictionary-add! blowfish-ks2 '37392EB3)
(dictionary-add! blowfish-ks2 'CC115979)
(dictionary-add! blowfish-ks2 '8026E297)
(dictionary-add! blowfish-ks2 'F42E312D)
(dictionary-add! blowfish-ks2 '6842ADA7)
(dictionary-add! blowfish-ks2 'C66A2B3B)
(dictionary-add! blowfish-ks2 '12754CCC)
(dictionary-add! blowfish-ks2 '782EF11C)
(dictionary-add! blowfish-ks2 '6A124237)
(dictionary-add! blowfish-ks2 'B79251E7)
(dictionary-add! blowfish-ks2 '06A1BBE6)
(dictionary-add! blowfish-ks2 '4BFB6350)
(dictionary-add! blowfish-ks2 '1A6B1018)
(dictionary-add! blowfish-ks2 '11CAEDFA)
(dictionary-add! blowfish-ks2 '3D25BDD8)
(dictionary-add! blowfish-ks2 'E2E1C3C9)
(dictionary-add! blowfish-ks2 '44421659)
(dictionary-add! blowfish-ks2 '0A121386)
(dictionary-add! blowfish-ks2 'D90CEC6E)
(dictionary-add! blowfish-ks2 'D5ABEA2A)
(dictionary-add! blowfish-ks2 '64AF674E)
(dictionary-add! blowfish-ks2 'DA86A85F)
(dictionary-add! blowfish-ks2 'BEBFE988)
(dictionary-add! blowfish-ks2 '64E4C3FE)
(dictionary-add! blowfish-ks2 '9DBC8057)
(dictionary-add! blowfish-ks2 'F0F7C086)
(dictionary-add! blowfish-ks2 '60787BF8)
(dictionary-add! blowfish-ks2 '6003604D)
(dictionary-add! blowfish-ks2 'D1FD8346)
(dictionary-add! blowfish-ks2 'F6381FB0)
(dictionary-add! blowfish-ks2 '7745AE04)
(dictionary-add! blowfish-ks2 'D736FCCC)
(dictionary-add! blowfish-ks2 '83426B33)
(dictionary-add! blowfish-ks2 'F01EAB71)
(dictionary-add! blowfish-ks2 'B0804187)
(dictionary-add! blowfish-ks2 '3C005E5F)
(dictionary-add! blowfish-ks2 '77A057BE)
(dictionary-add! blowfish-ks2 'BDE8AE24)
(dictionary-add! blowfish-ks2 '55464299)
(dictionary-add! blowfish-ks2 'BF582E61)
(dictionary-add! blowfish-ks2 '4E58F48F)
(dictionary-add! blowfish-ks2 'F2DDFDA2)
(dictionary-add! blowfish-ks2 'F474EF38)
(dictionary-add! blowfish-ks2 '8789BDC2)
(dictionary-add! blowfish-ks2 '5366F9C3)
(dictionary-add! blowfish-ks2 'C8B38E74)
(dictionary-add! blowfish-ks2 'B475F255)
(dictionary-add! blowfish-ks2 '46FCD9B9)
(dictionary-add! blowfish-ks2 '7AEB2661)
(dictionary-add! blowfish-ks2 '8B1DDF84)
(dictionary-add! blowfish-ks2 '846A0E79)
(dictionary-add! blowfish-ks2 '915F95E2)
(dictionary-add! blowfish-ks2 '466E598E)
(dictionary-add! blowfish-ks2 '20B45770)
(dictionary-add! blowfish-ks2 '8CD55591)
(dictionary-add! blowfish-ks2 'C902DE4C)
(dictionary-add! blowfish-ks2 'B90BACE1)
(dictionary-add! blowfish-ks2 'BB8205D0)
(dictionary-add! blowfish-ks2 '11A86248)
(dictionary-add! blowfish-ks2 '7574A99E)
(dictionary-add! blowfish-ks2 'B77F19B6)
(dictionary-add! blowfish-ks2 'E0A9DC09)
(dictionary-add! blowfish-ks2 '662D09A1)
(dictionary-add! blowfish-ks2 'C4324633)
(dictionary-add! blowfish-ks2 'E85A1F02)
(dictionary-add! blowfish-ks2 '09F0BE8C)
(dictionary-add! blowfish-ks2 '4A99A025)
(dictionary-add! blowfish-ks2 '1D6EFE10)
(dictionary-add! blowfish-ks2 '1AB93D1D)
(dictionary-add! blowfish-ks2 '0BA5A4DF)
(dictionary-add! blowfish-ks2 'A186F20F)
(dictionary-add! blowfish-ks2 '2868F169)
(dictionary-add! blowfish-ks2 'DCB7DA83)
(dictionary-add! blowfish-ks2 '573906FE)
(dictionary-add! blowfish-ks2 'A1E2CE9B)
(dictionary-add! blowfish-ks2 '4FCD7F52)
(dictionary-add! blowfish-ks2 '50115E01)
(dictionary-add! blowfish-ks2 'A70683FA)
(dictionary-add! blowfish-ks2 'A002B5C4)
(dictionary-add! blowfish-ks2 '0DE6D027)
(dictionary-add! blowfish-ks2 '9AF88C27)
(dictionary-add! blowfish-ks2 '773F8641)
(dictionary-add! blowfish-ks2 'C3604C06)
(dictionary-add! blowfish-ks2 '61A806B5)
(dictionary-add! blowfish-ks2 'F0177A28)
(dictionary-add! blowfish-ks2 'C0F586E0)
(dictionary-add! blowfish-ks2 '006058AA)
(dictionary-add! blowfish-ks2 '30DC7D62)
(dictionary-add! blowfish-ks2 '11E69ED7)
(dictionary-add! blowfish-ks2 '2338EA63)
(dictionary-add! blowfish-ks2 '53C2DD94)
(dictionary-add! blowfish-ks2 'C2C21634)
(dictionary-add! blowfish-ks2 'BBCBEE56)
(dictionary-add! blowfish-ks2 '90BCB6DE)
(dictionary-add! blowfish-ks2 'EBFC7DA1)
(dictionary-add! blowfish-ks2 'CE591D76)
(dictionary-add! blowfish-ks2 '6F05E409)
(dictionary-add! blowfish-ks2 '4B7C0188)
(dictionary-add! blowfish-ks2 '39720A3D)
(dictionary-add! blowfish-ks2 '7C927C24)
(dictionary-add! blowfish-ks2 '86E3725F)
(dictionary-add! blowfish-ks2 '724D9DB9)
(dictionary-add! blowfish-ks2 '1AC15BB4)
(dictionary-add! blowfish-ks2 'D39EB8FC)
(dictionary-add! blowfish-ks2 'ED545578)
(dictionary-add! blowfish-ks2 '08FCA5B5)
(dictionary-add! blowfish-ks2 'D83D7CD3)
(dictionary-add! blowfish-ks2 '4DAD0FC4)
(dictionary-add! blowfish-ks2 '1E50EF5E)
(dictionary-add! blowfish-ks2 'B161E6F8)
(dictionary-add! blowfish-ks2 'A28514D9)
(dictionary-add! blowfish-ks2 '6C51133C)
(dictionary-add! blowfish-ks2 '6FD5C7E7)
(dictionary-add! blowfish-ks2 '56E14EC4)
(dictionary-add! blowfish-ks2 '362ABFCE)
(dictionary-add! blowfish-ks2 'DDC6C837)
(dictionary-add! blowfish-ks2 'D79A3234)
(dictionary-add! blowfish-ks2 '92638212)
(dictionary-add! blowfish-ks2 '670EFA8E)
(dictionary-add! blowfish-ks2 '406000E0)
(define blowfish-ks3 (make-dictionary))
(dictionary-add! blowfish-ks3 '3A39CE37)
(dictionary-add! blowfish-ks3 'D3FAF5CF)
(dictionary-add! blowfish-ks3 'ABC27737)
(dictionary-add! blowfish-ks3 '5AC52D1B)
(dictionary-add! blowfish-ks3 '5CB0679E)
(dictionary-add! blowfish-ks3 '4FA33742)
(dictionary-add! blowfish-ks3 'D3822740)
(dictionary-add! blowfish-ks3 '99BC9BBE)
(dictionary-add! blowfish-ks3 'D5118E9D)
(dictionary-add! blowfish-ks3 'BF0F7315)
(dictionary-add! blowfish-ks3 'D62D1C7E)
(dictionary-add! blowfish-ks3 'C700C47B)
(dictionary-add! blowfish-ks3 'B78C1B6B)
(dictionary-add! blowfish-ks3 '21A19045)
(dictionary-add! blowfish-ks3 'B26EB1BE)
(dictionary-add! blowfish-ks3 '6A366EB4)
(dictionary-add! blowfish-ks3 '5748AB2F)
(dictionary-add! blowfish-ks3 'BC946E79)
(dictionary-add! blowfish-ks3 'C6A376D2)
(dictionary-add! blowfish-ks3 '6549C2C8)
(dictionary-add! blowfish-ks3 '530FF8EE)
(dictionary-add! blowfish-ks3 '468DDE7D)
(dictionary-add! blowfish-ks3 'D5730A1D)
(dictionary-add! blowfish-ks3 '4CD04DC6)
(dictionary-add! blowfish-ks3 '2939BBDB)
(dictionary-add! blowfish-ks3 'A9BA4650)
(dictionary-add! blowfish-ks3 'AC9526E8)
(dictionary-add! blowfish-ks3 'BE5EE304)
(dictionary-add! blowfish-ks3 'A1FAD5F0)
(dictionary-add! blowfish-ks3 '6A2D519A)
(dictionary-add! blowfish-ks3 '63EF8CE2)
(dictionary-add! blowfish-ks3 '9A86EE22)
(dictionary-add! blowfish-ks3 'C089C2B8)
(dictionary-add! blowfish-ks3 '43242EF6)
(dictionary-add! blowfish-ks3 'A51E03AA)
(dictionary-add! blowfish-ks3 '9CF2D0A4)
(dictionary-add! blowfish-ks3 '83C061BA)
(dictionary-add! blowfish-ks3 '9BE96A4D)
(dictionary-add! blowfish-ks3 '8FE51550)
(dictionary-add! blowfish-ks3 'BA645BD6)
(dictionary-add! blowfish-ks3 '2826A2F9)
(dictionary-add! blowfish-ks3 'A73A3AE1)
(dictionary-add! blowfish-ks3 '4BA99586)
(dictionary-add! blowfish-ks3 'EF5562E9)
(dictionary-add! blowfish-ks3 'C72FEFD3)
(dictionary-add! blowfish-ks3 'F752F7DA)
(dictionary-add! blowfish-ks3 '3F046F69)
(dictionary-add! blowfish-ks3 '77FA0A59)
(dictionary-add! blowfish-ks3 '80E4A915)
(dictionary-add! blowfish-ks3 '87B08601)
(dictionary-add! blowfish-ks3 '9B09E6AD)
(dictionary-add! blowfish-ks3 '3B3EE593)
(dictionary-add! blowfish-ks3 'E990FD5A)
(dictionary-add! blowfish-ks3 '9E34D797)
(dictionary-add! blowfish-ks3 '2CF0B7D9)
(dictionary-add! blowfish-ks3 '022B8B51)
(dictionary-add! blowfish-ks3 '96D5AC3A)
(dictionary-add! blowfish-ks3 '017DA67D)
(dictionary-add! blowfish-ks3 'D1CF3ED6)
(dictionary-add! blowfish-ks3 '7C7D2D28)
(dictionary-add! blowfish-ks3 '1F9F25CF)
(dictionary-add! blowfish-ks3 'ADF2B89B)
(dictionary-add! blowfish-ks3 '5AD6B472)
(dictionary-add! blowfish-ks3 '5A88F54C)
(dictionary-add! blowfish-ks3 'E029AC71)
(dictionary-add! blowfish-ks3 'E019A5E6)
(dictionary-add! blowfish-ks3 '47B0ACFD)
(dictionary-add! blowfish-ks3 'ED93FA9B)
(dictionary-add! blowfish-ks3 'E8D3C48D)
(dictionary-add! blowfish-ks3 '283B57CC)
(dictionary-add! blowfish-ks3 'F8D56629)
(dictionary-add! blowfish-ks3 '79132E28)
(dictionary-add! blowfish-ks3 '785F0191)
(dictionary-add! blowfish-ks3 'ED756055)
(dictionary-add! blowfish-ks3 'F7960E44)
(dictionary-add! blowfish-ks3 'E3D35E8C)
(dictionary-add! blowfish-ks3 '15056DD4)
(dictionary-add! blowfish-ks3 '88F46DBA)
(dictionary-add! blowfish-ks3 '03A16125)
(dictionary-add! blowfish-ks3 '0564F0BD)
(dictionary-add! blowfish-ks3 'C3EB9E15)
(dictionary-add! blowfish-ks3 '3C9057A2)
(dictionary-add! blowfish-ks3 '97271AEC)
(dictionary-add! blowfish-ks3 'A93A072A)
(dictionary-add! blowfish-ks3 '1B3F6D9B)
(dictionary-add! blowfish-ks3 '1E6321F5)
(dictionary-add! blowfish-ks3 'F59C66FB)
(dictionary-add! blowfish-ks3 '26DCF319)
(dictionary-add! blowfish-ks3 '7533D928)
(dictionary-add! blowfish-ks3 'B155FDF5)
(dictionary-add! blowfish-ks3 '03563482)
(dictionary-add! blowfish-ks3 '8ABA3CBB)
(dictionary-add! blowfish-ks3 '28517711)
(dictionary-add! blowfish-ks3 'C20AD9F8)
(dictionary-add! blowfish-ks3 'ABCC5167)
(dictionary-add! blowfish-ks3 'CCAD925F)
(dictionary-add! blowfish-ks3 '4DE81751)
(dictionary-add! blowfish-ks3 '3830DC8E)
(dictionary-add! blowfish-ks3 '379D5862)
(dictionary-add! blowfish-ks3 '9320F991)
(dictionary-add! blowfish-ks3 'EA7A90C2)
(dictionary-add! blowfish-ks3 'FB3E7BCE)
(dictionary-add! blowfish-ks3 '5121CE64)
(dictionary-add! blowfish-ks3 '774FBE32)
(dictionary-add! blowfish-ks3 'A8B6E37E)
(dictionary-add! blowfish-ks3 'C3293D46)
(dictionary-add! blowfish-ks3 '48DE5369)
(dictionary-add! blowfish-ks3 '6413E680)
(dictionary-add! blowfish-ks3 'A2AE0810)
(dictionary-add! blowfish-ks3 'DD6DB224)
(dictionary-add! blowfish-ks3 '69852DFD)
(dictionary-add! blowfish-ks3 '09072166)
(dictionary-add! blowfish-ks3 'B39A460A)
(dictionary-add! blowfish-ks3 '6445C0DD)
(dictionary-add! blowfish-ks3 '586CDECF)
(dictionary-add! blowfish-ks3 '1C20C8AE)
(dictionary-add! blowfish-ks3 '5BBEF7DD)
(dictionary-add! blowfish-ks3 '1B588D40)
(dictionary-add! blowfish-ks3 'CCD2017F)
(dictionary-add! blowfish-ks3 '6BB4E3BB)
(dictionary-add! blowfish-ks3 'DDA26A7E)
(dictionary-add! blowfish-ks3 '3A59FF45)
(dictionary-add! blowfish-ks3 '3E350A44)
(dictionary-add! blowfish-ks3 'BCB4CDD5)
(dictionary-add! blowfish-ks3 '72EACEA8)
(dictionary-add! blowfish-ks3 'FA6484BB)
(dictionary-add! blowfish-ks3 '8D6612AE)
(dictionary-add! blowfish-ks3 'BF3C6F47)
(dictionary-add! blowfish-ks3 'D29BE463)
(dictionary-add! blowfish-ks3 '542F5D9E)
(dictionary-add! blowfish-ks3 'AEC2771B)
(dictionary-add! blowfish-ks3 'F64E6370)
(dictionary-add! blowfish-ks3 '740E0D8D)
(dictionary-add! blowfish-ks3 'E75B1357)
(dictionary-add! blowfish-ks3 'F8721671)
(dictionary-add! blowfish-ks3 'AF537D5D)
(dictionary-add! blowfish-ks3 '4040CB08)
(dictionary-add! blowfish-ks3 '4EB4E2CC)
(dictionary-add! blowfish-ks3 '34D2466A)
(dictionary-add! blowfish-ks3 '0115AF84)
(dictionary-add! blowfish-ks3 'E1B00428)
(dictionary-add! blowfish-ks3 '95983A1D)
(dictionary-add! blowfish-ks3 '06B89FB4)
(dictionary-add! blowfish-ks3 'CE6EA048)
(dictionary-add! blowfish-ks3 '6F3F3B82)
(dictionary-add! blowfish-ks3 '3520AB82)
(dictionary-add! blowfish-ks3 '011A1D4B)
(dictionary-add! blowfish-ks3 '277227F8)
(dictionary-add! blowfish-ks3 '611560B1)
(dictionary-add! blowfish-ks3 'E7933FDC)
(dictionary-add! blowfish-ks3 'BB3A792B)
(dictionary-add! blowfish-ks3 '344525BD)
(dictionary-add! blowfish-ks3 'A08839E1)
(dictionary-add! blowfish-ks3 '51CE794B)
(dictionary-add! blowfish-ks3 '2F32C9B7)
(dictionary-add! blowfish-ks3 'A01FBAC9)
(dictionary-add! blowfish-ks3 'E01CC87E)
(dictionary-add! blowfish-ks3 'BCC7D1F6)
(dictionary-add! blowfish-ks3 'CF0111C3)
(dictionary-add! blowfish-ks3 'A1E8AAC7)
(dictionary-add! blowfish-ks3 '1A908749)
(dictionary-add! blowfish-ks3 'D44FBD9A)
(dictionary-add! blowfish-ks3 'D0DADECB)
(dictionary-add! blowfish-ks3 'D50ADA38)
(dictionary-add! blowfish-ks3 '0339C32A)
(dictionary-add! blowfish-ks3 'C6913667)
(dictionary-add! blowfish-ks3 '8DF9317C)
(dictionary-add! blowfish-ks3 'E0B12B4F)
(dictionary-add! blowfish-ks3 'F79E59B7)
(dictionary-add! blowfish-ks3 '43F5BB3A)
(dictionary-add! blowfish-ks3 'F2D519FF)
(dictionary-add! blowfish-ks3 '27D9459C)
(dictionary-add! blowfish-ks3 'BF97222C)
(dictionary-add! blowfish-ks3 '15E6FC2A)
(dictionary-add! blowfish-ks3 '0F91FC71)
(dictionary-add! blowfish-ks3 '9B941525)
(dictionary-add! blowfish-ks3 'FAE59361)
(dictionary-add! blowfish-ks3 'CEB69CEB)
(dictionary-add! blowfish-ks3 'C2A86459)
(dictionary-add! blowfish-ks3 '12BAA8D1)
(dictionary-add! blowfish-ks3 'B6C1075E)
(dictionary-add! blowfish-ks3 'E3056A0C)
(dictionary-add! blowfish-ks3 '10D25065)
(dictionary-add! blowfish-ks3 'CB03A442)
(dictionary-add! blowfish-ks3 'E0EC6E0E)
(dictionary-add! blowfish-ks3 '1698DB3B)
(dictionary-add! blowfish-ks3 '4C98A0BE)
(dictionary-add! blowfish-ks3 '3278E964)
(dictionary-add! blowfish-ks3 '9F1F9532)
(dictionary-add! blowfish-ks3 'E0D392DF)
(dictionary-add! blowfish-ks3 'D3A0342B)
(dictionary-add! blowfish-ks3 '8971F21E)
(dictionary-add! blowfish-ks3 '1B0A7441)
(dictionary-add! blowfish-ks3 '4BA3348C)
(dictionary-add! blowfish-ks3 'C5BE7120)
(dictionary-add! blowfish-ks3 'C37632D8)
(dictionary-add! blowfish-ks3 'DF359F8D)
(dictionary-add! blowfish-ks3 '9B992F2E)
(dictionary-add! blowfish-ks3 'E60B6F47)
(dictionary-add! blowfish-ks3 '0FE3F11D)
(dictionary-add! blowfish-ks3 'E54CDA54)
(dictionary-add! blowfish-ks3 '1EDAD891)
(dictionary-add! blowfish-ks3 'CE6279CF)
(dictionary-add! blowfish-ks3 'CD3E7E6F)
(dictionary-add! blowfish-ks3 '1618B166)
(dictionary-add! blowfish-ks3 'FD2C1D05)
(dictionary-add! blowfish-ks3 '848FD2C5)
(dictionary-add! blowfish-ks3 'F6FB2299)
(dictionary-add! blowfish-ks3 'F523F357)
(dictionary-add! blowfish-ks3 'A6327623)
(dictionary-add! blowfish-ks3 '93A83531)
(dictionary-add! blowfish-ks3 '56CCCD02)
(dictionary-add! blowfish-ks3 'ACF08162)
(dictionary-add! blowfish-ks3 '5A75EBB5)
(dictionary-add! blowfish-ks3 '6E163697)
(dictionary-add! blowfish-ks3 '88D273CC)
(dictionary-add! blowfish-ks3 'DE966292)
(dictionary-add! blowfish-ks3 '81B949D0)
(dictionary-add! blowfish-ks3 '4C50901B)
(dictionary-add! blowfish-ks3 '71C65614)
(dictionary-add! blowfish-ks3 'E6C6C7BD)
(dictionary-add! blowfish-ks3 '327A140A)
(dictionary-add! blowfish-ks3 '45E1D006)
(dictionary-add! blowfish-ks3 'C3F27B9A)
(dictionary-add! blowfish-ks3 'C9AA53FD)
(dictionary-add! blowfish-ks3 '62A80F00)
(dictionary-add! blowfish-ks3 'BB25BFE2)
(dictionary-add! blowfish-ks3 '35BDD2F6)
(dictionary-add! blowfish-ks3 '71126905)
(dictionary-add! blowfish-ks3 'B2040222)
(dictionary-add! blowfish-ks3 'B6CBCF7C)
(dictionary-add! blowfish-ks3 'CD769C2B)
(dictionary-add! blowfish-ks3 '53113EC0)
(dictionary-add! blowfish-ks3 '1640E3D3)
(dictionary-add! blowfish-ks3 '38ABBD60)
(dictionary-add! blowfish-ks3 '2547ADF0)
(dictionary-add! blowfish-ks3 'BA38209C)
(dictionary-add! blowfish-ks3 'F746CE76)
(dictionary-add! blowfish-ks3 '77AFA1C5)
(dictionary-add! blowfish-ks3 '20756060)
(dictionary-add! blowfish-ks3 '85CBFE4E)
(dictionary-add! blowfish-ks3 '8AE88DD8)
(dictionary-add! blowfish-ks3 '7AAAF9B0)
(dictionary-add! blowfish-ks3 '4CF9AA7E)
(dictionary-add! blowfish-ks3 '1948C25C)
(dictionary-add! blowfish-ks3 '02FB8A8C)
(dictionary-add! blowfish-ks3 '01C36AE4)
(dictionary-add! blowfish-ks3 'D6EBE1F9)
(dictionary-add! blowfish-ks3 '90D4F869)
(dictionary-add! blowfish-ks3 'A65CDEA0)
(dictionary-add! blowfish-ks3 '3F09252D)
(dictionary-add! blowfish-ks3 'C208E69F)
(dictionary-add! blowfish-ks3 'B74E6132)
(dictionary-add! blowfish-ks3 'CE77E25B)
(dictionary-add! blowfish-ks3 '578FDFE3)
(dictionary-add! blowfish-ks3 '3AC372E6)
(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 '243F6A88)
(table-set! blowfish-ps 1 '85A308D3)
(table-set! blowfish-ps 2 '13198A2E)
(table-set! blowfish-ps 3 '03707344)
(table-set! blowfish-ps 4 'A4093822)
(table-set! blowfish-ps 5 '299F31D0)
(table-set! blowfish-ps 6 '082EFA98)
(table-set! blowfish-ps 7 'EC4E6C89)
(table-set! blowfish-ps 8 '452821E6)
(table-set! blowfish-ps 9 '38D01377)
(table-set! blowfish-ps 10 'BE5466CF)
(table-set! blowfish-ps 11 '34E90C6C)
(table-set! blowfish-ps 12 'C0AC29B7)
(table-set! blowfish-ps 13 'C97C50DD)
(table-set! blowfish-ps 14 '3F84D5B5)
(table-set! blowfish-ps 15 'B5470917)
(table-set! blowfish-ps 16 '9216D5D9)
(table-set! blowfish-ps 17 '8979FB1B)
(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 ((plain (list->vector (string->list "BLOWFISH")))
(buffer (make-vector 8))
(plain3 (vector 'FE 'DC 'BA '98 '76 '54 '32 '10))
(key3 (vector '41 '79' '6E 'A0 '52 '62 '6E 'E4))
(cipher3 (vector 'E1 '13 'F4 '10 '2C 'FC 'CE '43)))
(let ((bc blowfish-context))
(blowfish-set-key bc "abcdefghijklmnopqrstuvwxyz" 26)
(blowfish-encrypt-block bc buffer plain) ;; should give \x32\x4e\xd0\xfe\xf4\x13\xa2\x03
(blowfish-decrypt bc buffer buffer)
(if (not (eq? buffer plain))
(display "Blowfish selftest failed - 1."))
(blowfish-set-key bc key3)
(blowfish-encrypt-block bc buffer plain3) ;; should give
(blowfish-decrypt bc buffer buffer)
(if (not (eq? buffer plain3))
(display "Blowfish selftest failed - 2."))
)))