]> git.sur5r.net Git - openldap/blob - libraries/liblutil/ptest.c
Eliminate second session protocol version field.
[openldap] / libraries / liblutil / ptest.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include <stdio.h>
10
11 #include <ac/stdlib.h>
12
13 #include <ac/ctype.h>
14 #include <ac/signal.h>
15 #include <ac/socket.h>
16 #include <ac/string.h>
17 #include <ac/time.h>
18
19 #include <lber.h>
20
21 #include "lutil.h"
22
23 /*
24  * Password Test Program
25  */
26
27 char *hash[] = {
28         "{SMD5}", "{SSHA}",
29         "{MD5}", "{SHA}",
30 #ifdef SLAPD_CRYPT
31         "{CRYPT}",
32 #endif
33         NULL
34 };
35
36 static struct berval pw[] = {
37         { sizeof("secret")-1,                   "secret" },
38         { sizeof("binary\0secret")-1,   "secret\0binary" },
39         { 0, NULL }
40 };
41
42 int
43 main( int argc, char *argv[] )
44 {
45         int i, j, rc;
46         struct berval *passwd;
47
48         for( i= 0; hash[i]; i++ ) {
49                 for( j = 0; pw[j].bv_len; j++ ) {
50                         passwd = lutil_passwd_hash( &pw[j], hash[i] );
51                         rc = lutil_passwd( passwd, &pw[j], NULL );
52
53                         printf("%s (%d): %s (%d) %s\n",
54                                 pw[j].bv_val, pw[j].bv_len, passwd->bv_val, passwd->bv_len,
55                                 rc == 0 ? "OKAY" : "BAD" );
56                 }
57         }
58         return EXIT_SUCCESS;
59 }