pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: sulfinu@gmail.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JDBC driver patch for non-ASCII users
Date: Wed, 12 Dec 2007 02:12:15 +1300
Message-ID: <475E8CAF.5000504@opencloud.com> (raw)
In-Reply-To: <200712111421.47161.sulfinu@gmail.com>
References: <200712071448.21411.sulfinu@gmail.com>
	<200712082027.17731.sulfinu@gmail.com>
	<475B047B.5020100@opencloud.com>
	<200712111421.47161.sulfinu@gmail.com>

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




view thread (17+ messages)  latest in thread

Message-ID: <475E8CAF.5000504@opencloud.com>
Permalink:  ../475E8CAF.5000504@opencloud.com/
Also on:    postgresql.org/message-id/475E8CAF.5000504@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, sulfinu@gmail.com
  Subject: Re: JDBC driver patch for non-ASCII users
  In-Reply-To: <475E8CAF.5000504@opencloud.com>
  References: <200712071448.21411.sulfinu@gmail.com> <200712082027.17731.sulfinu@gmail.com> <475B047B.5020100@opencloud.com> <200712111421.47161.sulfinu@gmail.com> <475E8CAF.5000504@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox