gsasl  1.8.0
anonymous/server.c
Go to the documentation of this file.
00001 /* server.c --- ANONYMOUS mechanism as defined in RFC 2245, server side.
00002  * Copyright (C) 2002-2012 Simon Josefsson
00003  *
00004  * This file is part of GNU SASL Library.
00005  *
00006  * GNU SASL Library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation; either version 2.1 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * GNU SASL Library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with GNU SASL Library; if not, write to the Free
00018  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026 
00027 /* Get specification. */
00028 #include "anonymous.h"
00029 
00030 int
00031 _gsasl_anonymous_server_step (Gsasl_session * sctx,
00032                               void *mech_data,
00033                               const char *input, size_t input_len,
00034                               char **output, size_t * output_len)
00035 {
00036   *output = NULL;
00037   *output_len = 0;
00038 
00039   if (!input)
00040     return GSASL_NEEDS_MORE;
00041 
00042   /* token       = 1*255TCHAR
00043      The <token> production is restricted to 255 UTF-8 encoded Unicode
00044      characters.   As the encoding of a characters uses a sequence of 1
00045      to 4 octets, a token may be long as 1020 octets. */
00046   if (input_len == 0 || input_len > 1020)
00047     return GSASL_MECHANISM_PARSE_ERROR;
00048 
00049   /* FIXME: Validate that input is UTF-8. */
00050 
00051   gsasl_property_set_raw (sctx, GSASL_ANONYMOUS_TOKEN, input, input_len);
00052 
00053   return gsasl_callback (NULL, sctx, GSASL_VALIDATE_ANONYMOUS);
00054 }