Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5AA162E2DD2 for ; Tue, 11 Dec 2007 09:12:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 11812-10 for ; Tue, 11 Dec 2007 09:12:17 -0400 (AST) Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by postgresql.org (Postfix) with ESMTP id 92FCD2E004A for ; Tue, 11 Dec 2007 09:12:22 -0400 (AST) Received: from 219-89-36-140.dialup.xtra.co.nz ([219.89.36.140] helo=[192.168.1.2]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1J24uG-0003Ud-2U; Wed, 12 Dec 2007 02:12:16 +1300 Message-ID: <475E8CAF.5000504@opencloud.com> Date: Wed, 12 Dec 2007 02:12:15 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: sulfinu@gmail.com CC: pgsql-jdbc@postgresql.org Subject: Re: JDBC driver patch for non-ASCII users References: <200712071448.21411.sulfinu@gmail.com> <200712082027.17731.sulfinu@gmail.com> <475B047B.5020100@opencloud.com> <200712111421.47161.sulfinu@gmail.com> In-Reply-To: <200712111421.47161.sulfinu@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/71 X-Sequence-Number: 17926 sulfinu@gmail.com wrote: > On Saturday 08 December 2007, Oliver Jowett wrote: > >> Can you explain what this change does, then? >> >>> String result = UnixCrypt.crypt(salt, password); >>> - byte[] encodedResult = >>> result.getBytes("US-ASCII"); + byte[] >>> encodedResult = result.getBytes(Encoding.AUTHENTICATION_PHASE_ENCODING); >> AFAIK UnixCrypt.crypt() should only be returning ASCII anyway, right? > Wrong, it returns a String, in other words a series of Unicode points, not > necessarily ASCII characters. A general String certainly might contain non-ASCII, but all Strings returned by UnixCrypt.crypt() contain only ASCII. See the implementation of UnixCrypt.crypt(), and in particular the UnixCrypt.cov_2char array. So I still do not understand why the change quoted above is necessary. Can you explain why it is necessary? >> Same thing re. salt decoding, doesn't the server only ever send ASCII? > The server never bothers about any encoding during the authentication phase. > The server simply treats everything as byte arrays and compares what is > received from the client to the result of its own byte-wise computation, > based on stored user name and password. The server only ever sends a subset of ASCII as crypt salt characters (specifically, the 62 characters a-z A-Z 0-9), so US-ASCII is just fine for decoding. See postmaster.c, RandomSalt() / RemapChar(). So I still do not understand why a change to the encoding used to decode crypt salt characters is necessary. Can you explain why it is necessary? -O