Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 773E41AEBA97 for ; Tue, 24 Jan 2012 17:34:56 -0400 (AST) Received: from madness.at ([217.196.146.217] helo=cronos.madness.at) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rpo12-0002Rh-1A for pgsql-bugs@postgresql.org; Tue, 24 Jan 2012 21:34:57 +0000 Received: from gatekeeper.kaltenbrunner.cc ([83.215.243.9] helo=[192.168.8.22]) by cronos.madness.at with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1Rpo0m-0005CX-60 for pgsql-bugs@postgresql.org; Tue, 24 Jan 2012 22:34:42 +0100 Message-ID: <4F1F23E8.80100@kaltenbrunner.cc> Date: Tue, 24 Jan 2012 22:34:32 +0100 From: Stefan Kaltenbrunner User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Postgres-Bugs Subject: Re: pgcrypto decrypt_iv() issue References: <4F1DB7BF.60304@kaltenbrunner.cc> In-Reply-To: <4F1DB7BF.60304@kaltenbrunner.cc> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/163 X-Sequence-Number: 32230 On 01/23/2012 08:40 PM, Stefan Kaltenbrunner wrote: > We are using the raw decryption features of contrib/pgcrypto here to > decode certain AES128 encrypted data. However depending on the data to > decode and what statements have been executed in the same session before > we are seeing different (and sometimes completely wrong) answers > > this is 9.1.2 on Debian/amd64 compiled with -enable-debug (note that the > the first and the third query do not result in the same answer): > > [examples snipped] > > which seems even more of a "wtf"?! from some looking at the code in pgcrypto.c it seems to me that the coding pattern in most functions there only checks for errors from the corresponding initialization function, in the case of say decrypt_iv() that means only the IV and the key are actually "validated" because that is what the init function sees(it never sees that data!), if the actual decrypt call fails (because the data is maybe a bit weird^broken) it will happily ignore that and return random data. Stefan