3 * Copyright 1998-2000 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>
23 // #define SLAP_AUTHPASSWD 1
26 * Password Test Program
30 #ifdef SLAP_AUTHPASSWD
43 static struct berval pw[] = {
44 { sizeof("secret")-1, "secret" },
45 { sizeof("binary\0secret")-1, "binary\0secret" },
50 main( int argc, char *argv[] )
53 struct berval *passwd;
54 #ifdef SLAP_AUTHPASSWD
58 bad.bv_val = "bad password";
59 bad.bv_len = sizeof("bad password")-1;
61 for( i= 0; hash[i]; i++ ) {
62 for( j = 0; pw[j].bv_len; j++ ) {
63 #ifdef SLAP_AUTHPASSWD
64 rc = lutil_authpasswd_hash( &pw[j],
65 &passwd, &salt, hash[i] );
69 passwd = lutil_passwd_hash( &pw[j], hash[i] );
74 printf("%s generate fail: %s (%d)\n",
75 hash[i], pw[j].bv_val, pw[j].bv_len );
80 #ifdef SLAP_AUTHPASSWD
81 rc = lutil_authpasswd( &pw[j], passwd, salt, NULL );
83 rc = lutil_passwd( passwd, &pw[j], NULL );
86 printf("%s (%d): %s (%d)\t(%d) %s\n",
87 pw[j].bv_val, pw[j].bv_len, passwd->bv_val, passwd->bv_len,
88 rc, rc == 0 ? "OKAY" : "BAD" );
90 #ifdef SLAP_AUTHPASSWD
91 rc = lutil_authpasswd( passwd, salt, &bad, NULL );
93 rc = lutil_passwd( passwd, &bad, NULL );
96 printf("%s (%d): %s (%d)\t(%d) %s\n",
97 bad.bv_val, bad.bv_len, passwd->bv_val, passwd->bv_len,
98 rc, rc != 0 ? "OKAY" : "BAD" );