5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rack/pubcookie/des.rb', line 5
def des_decrypt bytes, index1, index2
ivec = @key[index2, 8]
ivec = ivec.map{ |i| i ^ 0x4c }
key = @key[index1, 8]
c = OpenSSL::Cipher.new('des-cfb')
c.decrypt
c.key = key.pack('c*')
c.iv = ivec.pack('c*')
signature = c.update(bytes[0..127].pack('c*'))
decrypted = c.update(bytes[128..-1].pack('c*'))
if @granting.public_key.verify(OpenSSL::Digest::MD5.new, signature, decrypted)
decrypted
else
nil
end
end
|