From: Nobuyoshi Nakada Date: 2009-03-09T18:45:43+09:00 Subject: Re: Flaw in ruby-crypt's GOST implementation Hi, At Sun, 8 Mar 2009 01:39:32 +0900, Hartog C. de Mik wrote in [ruby-talk:330604]: > Please read my blog post (http://is.gd/m4K1) for more information. > http://www.coffeeaddict.nl/blog/20090306/171/ > I patched my version of gost.rb to use the key preparation I > found in the C# version of bouncycastle.org. Where the > original code has become: > > # derive the 32-byte key from the user-supplied key > if (userKey.length < 32) > userKey.length.upto(31) { userKey = userKey << "0" } > end > > # make the 8 sub keys > @key = [] > for i in (0..7) > @key[i] = bytesToInt(userKey,i*4); > end It can be done more concisely. @key = userKey[0...32].ljust(32, "\0").unpack("V*") -- Nobu Nakada