2020extern crate crypto;
2121#[ macro_use]
2222extern crate sandstorm;
23+ extern crate openssl;
24+
25+ use openssl:: aes:: { aes_ige, AesKey } ;
26+ use openssl:: symm:: Mode ;
2327
2428use crypto:: bcrypt:: bcrypt;
2529
@@ -55,6 +59,11 @@ pub fn init(db: Rc<DB>) -> Box<Generator<Yield = u64, Return = u64>> {
5559 let mut status = INVALIDARG ;
5660 let mut username: Vec < u8 > = Vec :: with_capacity ( 30 ) ;
5761 let mut password: Vec < u8 > = Vec :: with_capacity ( 72 ) ;
62+ let key = b"\x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0A \x0B \x0C \x0D \x0E \x0F " ;
63+ let mut iv = * b"\x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0A \x0B \x0C \x0D \x0E \x0F \
64+ \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1F ";
65+ let ekey = AesKey :: new_decrypt ( key) . unwrap ( ) ;
66+ let mut output = [ 0u8 ; 16 ] ;
5867
5968 {
6069 // First off, retrieve the arguments to the extension.
@@ -76,6 +85,8 @@ pub fn init(db: Rc<DB>) -> Box<Generator<Yield = u64, Return = u64>> {
7685 let ( userid, pass) = remain_args. split_at ( 30 ) ;
7786 username. extend_from_slice ( userid) ;
7887 password. extend_from_slice ( pass) ;
88+ aes_ige ( & password[ 0 ..16 ] , & mut output, & ekey, & mut iv, Mode :: Decrypt ) ;
89+ password[ 0 ..16 ] . copy_from_slice ( & output[ 0 ..16 ] ) ;
7990
8091 // Get the table id from the unwrapped arguments.
8192 for ( idx, e) in s_table. iter ( ) . enumerate ( ) {
0 commit comments