See #3183: Pad the plain text before trying DES on it.
git-svn-id: file:///home/svn/framework3/trunk@12033 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
d45b2aaa20
commit
12ea375d25
|
@ -44,6 +44,9 @@ class Cipher
|
||||||
def self.encrypt(plain, password)
|
def self.encrypt(plain, password)
|
||||||
key = self.mangle_password(password)
|
key = self.mangle_password(password)
|
||||||
|
|
||||||
|
# pad the plain to 16 chars
|
||||||
|
plain << ("\x00" * (16 - plain.length)) if plain.length < 16
|
||||||
|
|
||||||
# VNC auth does two 8-byte blocks individually instead supporting some block mode
|
# VNC auth does two 8-byte blocks individually instead supporting some block mode
|
||||||
cipher = ''
|
cipher = ''
|
||||||
2.times { |x|
|
2.times { |x|
|
||||||
|
@ -63,6 +66,9 @@ class Cipher
|
||||||
def self.decrypt(cipher, password = "\x17\x52\x6b\x06\x23\x4e\x58\x07")
|
def self.decrypt(cipher, password = "\x17\x52\x6b\x06\x23\x4e\x58\x07")
|
||||||
key = self.mangle_password(password)
|
key = self.mangle_password(password)
|
||||||
|
|
||||||
|
# pad the cipher text to 9 bytes
|
||||||
|
cipher << ("\x00" * (9 - cipher.length)) if cipher.length < 9
|
||||||
|
|
||||||
# NOTE: This only does one 8 byte block
|
# NOTE: This only does one 8 byte block
|
||||||
plain = ''
|
plain = ''
|
||||||
c = OpenSSL::Cipher::Cipher.new('des')
|
c = OpenSSL::Cipher::Cipher.new('des')
|
||||||
|
|
Loading…
Reference in New Issue