[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/tests
From: |
gsasl-commit |
Subject: |
CVS gsasl/tests |
Date: |
Wed, 13 Oct 2004 17:42:51 +0200 |
Update of /home/cvs/gsasl/tests
In directory dopio:/tmp/cvs-serv3403
Modified Files:
Makefile.am cram-md5.c utils.c
Added Files:
old-cram-md5.c
Log Message:
Add new cram-md5 test.
--- /home/cvs/gsasl/tests/Makefile.am 2004/09/29 01:45:53 1.25
+++ /home/cvs/gsasl/tests/Makefile.am 2004/10/13 15:42:50 1.26
@@ -29,6 +29,8 @@
TESTS_ENVIRONMENT = THREADSAFETY_FILES=$(top_srcdir)/lib/*/*.c
-TESTS = simple cram-md5 digest-md5 md5file threadsafety
-check_PROGRAMS = simple cram-md5 digest-md5 md5file
+TESTS = simple cram-md5 digest-md5 md5file threadsafety \
+ old-cram-md5
+check_PROGRAMS = simple cram-md5 digest-md5 md5file \
+ old-cram-md5
dist_check_SCRIPTS = threadsafety
--- /home/cvs/gsasl/tests/cram-md5.c 2004/09/22 23:49:44 1.12
+++ /home/cvs/gsasl/tests/cram-md5.c 2004/10/13 15:42:50 1.13
@@ -35,53 +35,32 @@
/* "Ali " "\xC2\xAD" "Bab" "\xC2\xAA" */
/* "Al\xC2\xAA""dd\xC2\xAD""in\xC2\xAE" */
-static int
-server_cb_retrieve (Gsasl_session_ctx * xctx,
- const char *authentication_id,
- const char *authorization_id,
- const char *realm, char *key, size_t * keylen)
-{
- size_t needlen = strlen (PASSWORD);
-
- if (key && *keylen < needlen)
- return GSASL_TOO_SMALL_BUFFER;
-
- *keylen = needlen;
- if (key)
- memcpy (key, PASSWORD, *keylen);
-
- return GSASL_OK;
-}
static int
-client_cb_authentication_id (Gsasl_session_ctx * xctx,
- char *out, size_t * outlen)
+callback (Gsasl * ctx, Gsasl_session * sctx, Gsasl_property prop)
{
- size_t needlen = strlen (USERNAME);
-
- if (out && *outlen < needlen)
- return GSASL_TOO_SMALL_BUFFER;
+ int rc = GSASL_NO_CALLBACK;
- *outlen = needlen;
- if (out)
- memcpy (out, USERNAME, *outlen);
-
- return GSASL_OK;
-}
+ /* Get user info from user. */
-static int
-client_cb_password (Gsasl_session_ctx * xctx, char *out, size_t * outlen)
-{
- size_t needlen = strlen (PASSWORD);
-
- if (out && *outlen < needlen)
- return GSASL_TOO_SMALL_BUFFER;
-
- *outlen = needlen;
- if (out)
- memcpy (out, PASSWORD, *outlen);
+ switch (prop)
+ {
+ case GSASL_PASSWORD:
+ gsasl_property_set (sctx, GSASL_PASSWORD, PASSWORD);
+ rc = GSASL_OK;
+ break;
+
+ case GSASL_AUTHID:
+ gsasl_property_set (sctx, GSASL_AUTHID, USERNAME);
+ rc = GSASL_OK;
+ break;
+
+ default:
+ fail ("Unknown callback property %d\n", prop);
+ break;
+ }
- return GSASL_OK;
+ return rc;
}
void
@@ -101,12 +80,7 @@
return;
}
- gsasl_server_callback_retrieve_set (ctx, server_cb_retrieve);
-
- gsasl_client_callback_authentication_id_set (ctx,
- client_cb_authentication_id);
- gsasl_client_callback_password_set (ctx, client_cb_password);
-
+ gsasl_callback_set (ctx, callback);
for (i = 0; i < 5; i++)
{
--- /home/cvs/gsasl/tests/utils.c 2004/09/29 01:45:53 1.6
+++ /home/cvs/gsasl/tests/utils.c 2004/10/13 15:42:50 1.7
@@ -28,7 +28,7 @@
#include "utils.h"
-int debug = 0;
+int debug = 1;
int error_count = 0;
int break_on_error = 0;
--- /home/cvs/gsasl/tests/old-cram-md5.c 2004/10/13 15:42:51 NONE
+++ /home/cvs/gsasl/tests/old-cram-md5.c 2004/10/13 15:42:51 1.1
/* cram-md5.c --- Test the CRAM-MD5 mechanism, using old callback API.
* Copyright (C) 2002, 2003, 2004 Simon Josefsson
*
* This file is part of GNU SASL.
*
* GNU SASL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GNU SASL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU SASL; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "utils.h"
#define PASSWORD "Open, Sesame"
#define USERNAME "Ali Baba"
/* "Ali " "\xC2\xAD" "Bab" "\xC2\xAA" */
/* "Al\xC2\xAA""dd\xC2\xAD""in\xC2\xAE" */
static int
server_cb_retrieve (Gsasl_session_ctx * xctx,
const char *authentication_id,
const char *authorization_id,
const char *realm, char *key, size_t * keylen)
{
size_t needlen = strlen (PASSWORD);
if (key && *keylen < needlen)
return GSASL_TOO_SMALL_BUFFER;
*keylen = needlen;
if (key)
memcpy (key, PASSWORD, *keylen);
return GSASL_OK;
}
static int
client_cb_authentication_id (Gsasl_session_ctx * xctx,
char *out, size_t * outlen)
{
size_t needlen = strlen (USERNAME);
if (out && *outlen < needlen)
return GSASL_TOO_SMALL_BUFFER;
*outlen = needlen;
if (out)
memcpy (out, USERNAME, *outlen);
return GSASL_OK;
}
static int
client_cb_password (Gsasl_session_ctx * xctx, char *out, size_t * outlen)
{
size_t needlen = strlen (PASSWORD);
if (out && *outlen < needlen)
return GSASL_TOO_SMALL_BUFFER;
*outlen = needlen;
if (out)
memcpy (out, PASSWORD, *outlen);
return GSASL_OK;
}
void
doit (void)
{
Gsasl_ctx *ctx = NULL;
Gsasl_session_ctx *server = NULL, *client = NULL;
char *s1, *s2;
size_t s1len, s2len;
size_t i;
int res;
res = gsasl_init (&ctx);
if (res != GSASL_OK)
{
fail ("gsasl_init() failed (%d):\n%s\n", res, gsasl_strerror (res));
return;
}
gsasl_server_callback_retrieve_set (ctx, server_cb_retrieve);
gsasl_client_callback_authentication_id_set (ctx,
client_cb_authentication_id);
gsasl_client_callback_password_set (ctx, client_cb_password);
for (i = 0; i < 5; i++)
{
res = gsasl_server_start (ctx, "CRAM-MD5", &server);
if (res != GSASL_OK)
{
fail ("gsasl_init() failed (%d):\n%s\n", res, gsasl_strerror (res));
return;
}
res = gsasl_client_start (ctx, "CRAM-MD5", &client);
if (res != GSASL_OK)
{
fail ("gsasl_init() failed (%d):\n%s\n", res, gsasl_strerror (res));
return;
}
res = gsasl_step (server, NULL, 0, &s1, &s1len);
if (res != GSASL_NEEDS_MORE)
{
fail ("gsasl_step() failed (%d):\n%s\n", res, gsasl_strerror (res));
return;
}
if (debug)
printf ("S: %.*s\n", s1len, s1);
res = gsasl_step (client, s1, s1len, &s2, &s2len);
free (s1);
if (res != GSASL_OK)
{
fail ("gsasl_step() failed (%d):\n%s\n", res, gsasl_strerror (res));
return;
}
if (debug)
printf ("C: %.*s\n", s2len, s2);
res = gsasl_step (server, s2, s2len, &s1, &s1len);
free (s2);
if (res != GSASL_OK)
{
fail ("gsasl_step() failed (%d):\n%s\n", res, gsasl_strerror (res));
return;
}
if (s1len != 0)
{
fail ("gsasl_step() failed, additional length=%d:\n", s1len);
fail ("%s\n", s1);
return;
}
free (s1);
if (debug)
printf ("\n");
gsasl_client_finish (client);
gsasl_server_finish (server);
}
gsasl_done (ctx);
}
- CVS gsasl/tests, gsasl-commit, 2004/10/13
- CVS gsasl/tests,
gsasl-commit <=
- CVS gsasl/tests, gsasl-commit, 2004/10/13
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14
- CVS gsasl/tests, gsasl-commit, 2004/10/14