3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/stdlib.h>
14 #include <ac/signal.h>
15 #include <ac/socket.h>
16 #include <ac/string.h>
24 * Password Test Program
27 static char *hash[] = {
28 #ifdef SLAP_AUTHPASSWD
41 static struct berval pw[] = {
42 { sizeof("secret")-1, "secret" },
43 { sizeof("binary\0secret")-1, "binary\0secret" },
48 main( int argc, char *argv[] )
51 struct berval *passwd;
52 #ifdef SLAP_AUTHPASSWD
56 bad.bv_val = "bad password";
57 bad.bv_len = sizeof("bad password")-1;
59 for( i= 0; hash[i]; i++ ) {
60 for( j = 0; pw[j].bv_len; j++ ) {
61 #ifdef SLAP_AUTHPASSWD
62 rc = lutil_authpasswd_hash( &pw[j],
63 &passwd, &salt, hash[i] );
67 passwd = lutil_passwd_hash( &pw[j], hash[i] );
72 printf("%s generate fail: %s (%d)\n",
73 hash[i], pw[j].bv_val, pw[j].bv_len );
78 #ifdef SLAP_AUTHPASSWD
79 rc = lutil_authpasswd( &pw[j], passwd, salt, NULL );
81 rc = lutil_passwd( passwd, &pw[j], NULL );
84 printf("%s (%d): %s (%d)\t(%d) %s\n",
85 pw[j].bv_val, pw[j].bv_len, passwd->bv_val, passwd->bv_len,
86 rc, rc == 0 ? "OKAY" : "BAD" );
88 #ifdef SLAP_AUTHPASSWD
89 rc = lutil_authpasswd( passwd, salt, &bad, NULL );
91 rc = lutil_passwd( passwd, &bad, NULL );
94 printf("%s (%d): %s (%d)\t(%d) %s\n",
95 bad.bv_val, bad.bv_len, passwd->bv_val, passwd->bv_len,
96 rc, rc != 0 ? "OKAY" : "BAD" );