Re: [kitten] New Version Notification for draft-kaduk-kitten-gss-loop-02.txt (fwd)

mrex@sap.com (Martin Rex) Tue, 21 January 2014 01:11 UTC

Return-Path: <mrex@sap.com>
X-Original-To: kitten@ietfa.amsl.com
Delivered-To: kitten@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 77B2E1A0002 for <kitten@ietfa.amsl.com>; Mon, 20 Jan 2014 17:11:04 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.552
X-Spam-Level:
X-Spam-Status: No, score=-6.552 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HELO_EQ_DE=0.35, RCVD_IN_DNSWL_HI=-5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oArZN2h0UpJx for <kitten@ietfa.amsl.com>; Mon, 20 Jan 2014 17:11:01 -0800 (PST)
Received: from smtpde02.sap-ag.de (smtpde02.sap-ag.de [155.56.68.140]) by ietfa.amsl.com (Postfix) with ESMTP id 9B6171A027A for <kitten@ietf.org>; Mon, 20 Jan 2014 17:11:00 -0800 (PST)
Received: from mail05.wdf.sap.corp by smtpde02.sap-ag.de (26) with ESMTP id s0L1Av7P003288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 21 Jan 2014 02:10:57 +0100 (MET)
In-Reply-To: <1390252044.31766.134.camel@minbar.fac.cs.cmu.edu>
To: Jeffrey Hutzelman <jhutz@cmu.edu>
Date: Tue, 21 Jan 2014 02:10:57 +0100
X-Mailer: ELM [version 2.4ME+ PL125 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="US-ASCII"
Message-Id: <20140121011057.C21EE1ABBD@ld9781.wdf.sap.corp>
From: mrex@sap.com
X-SAP: out
Cc: kitten@ietf.org
Subject: Re: [kitten] New Version Notification for draft-kaduk-kitten-gss-loop-02.txt (fwd)
X-BeenThere: kitten@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: mrex@sap.com
List-Id: Common Authentication Technologies - Next Generation <kitten.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/kitten>, <mailto:kitten-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/kitten/>
List-Post: <mailto:kitten@ietf.org>
List-Help: <mailto:kitten-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/kitten>, <mailto:kitten-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 21 Jan 2014 01:11:04 -0000

Jeffrey Hutzelman wrote:
> On Mon, 2014-01-20 at 20:32 +0100, Martin Rex wrote:
> > Nico Williams wrote:
> > > 
> > > Nonetheless, it seems clear that the intention is that calling a
> > > gss_release/delete_*() function will modify the input/output parameter
> > > so that calling it again is safe, so that releasing a zero-length,
> > > non-zero valued buffer ought to be safe.
> > 
> > In theory yes, but practice may differ.
> > 
> > What I'm afraid of is wrapper functions that look like this:
> 
> Well, if an app has such a wrapper, then the _wrapper_ is not safe to
> call twice.  That really has nothing to do with whether
> gss_release_buffer is safe to call twice, and the spec for the latter
> pretty clearly says it modifies its output.

I disagree.

Potentially we're fighting about the difference of
"call-by-value" vs. "call-by-reference" in C, and what exactly 
is the meaning of "same foo" when call-by-reference is used.

Does "same same" apply when the value is the same. or only when both
value and reference/address are the same?

With that in mind, a comment like

>
> /* It is safe to call gss_release_buffer twice on the same buffer. */

is ambiguous and wrong.  Discounting empty buffers, calling
gss_release_buffer with the same buffer (=same value) more than
once is very very probably unsafe. 

And the fact that gss_release_buffer() is supposed to *CHANGE* the
buffer (struct) value should make it clear that the concept of
"same buffer" is somewhat unnatural to the GSS-API C-Bindings.


What should be safe is calling gss_release_buffer() with an empty
buffer.  So the important guidance would be to *ALWAYS* create
gss_buffer_desc structures initialized with {0, 0} in C.


The notion that gss_unwrap() could return a zero-length token is
also somewhat flawed.  gss_unwrap() returns a message (=app data)
if anything. There are no such things as zero-length tokens anywhere
throughout GSS-API.  And a gssapi mechanism should definitely not
rely on the application caller to call gss_release_buffer() on a
zero-length message returned from gss_unwrap().  The only sane
representation of an empty buffer _output_ value from a gssapi mech
is {0, 0}, i.e. be conservative in what you send (=give out).


> 
> > > The API can output zero-length buffers from gss_unwrap(),
> > > so the question comes up of whether such buffers can have
> > > non-zero values -- the RFC doesn't say.
> > 
> > correct -- gss_unwrap() may return a zero-length output buffer.
> > The length of the buffer must be zero for obvious reasons.
> > The value of the pointer is then irrelevant, and the gssapi
> > mechanism must be able to cope safely with whatever it returns
> > along with a zero length.
> 
> Right.  If the mech returns a buffer with zero length and a non-NULL
> value pointer, then it must be able to cope with gss_release_buffer
> being called on that buffer.
> 
> 
> > 
> > 
> > >
> > > The other places where the API can output a zero-length token in
> > > non-error conditions are gss_init/accept_sec_context() and
> > > gss_delete_sec_context,
> > 
> > Nope, neither of these three calls can return a zero-length output token,
> 
> You know, we've discussed that question on several occasions, and I
> can't remember ever being able to find something in RFC2743 that says
> that.  The C bindings happen to make it impossible to tell the
> difference between no token and an empty token, which makes using empty
> tokens impractical, but if you can find text that prohibits them, please
> do point it out.

As mentioned above, the GSS-API does not have the concept of
zero-length _tokens_.  Either there is a token, or there is no token.
The reason is simple: you can not securely convey a zero-length token
over an insecure communication channel.  This is why gss_get_mic()
and gss_wrap() must produce non-zero tokens even for zero-length
messages.


-Martin