3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
8 * const struct berval *passwd,
9 * const struct berval *cred,
10 * const char **schemes )
12 * Returns true if user supplied credentials (cred) matches
13 * the stored password (passwd).
15 * Due to the use of the crypt(3) function
16 * this routine is NOT thread-safe.
22 #include <ac/stdlib.h>
23 #include <ac/string.h>
32 #include <ac/unistd.h>
44 #include "lutil_md5.h"
45 #include "lutil_sha1.h"
48 static const unsigned char crypt64[] =
49 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890./";
53 typedef int (*PASSWD_CHK_FUNC)(
54 const struct pw_scheme *scheme,
55 const struct berval *passwd,
56 const struct berval *cred );
58 typedef struct berval * (*PASSWD_HASH_FUNC) (
59 const struct pw_scheme *scheme,
60 const struct berval *passwd );
64 PASSWD_CHK_FUNC chk_fn;
65 PASSWD_HASH_FUNC hash_fn;
68 /* password check routines */
70 const struct pw_scheme *scheme,
71 const struct berval *passwd,
72 const struct berval *cred );
75 const struct pw_scheme *scheme,
76 const struct berval *passwd,
77 const struct berval *cred );
80 const struct pw_scheme *scheme,
81 const struct berval *passwd,
82 const struct berval *cred );
85 const struct pw_scheme *scheme,
86 const struct berval *passwd,
87 const struct berval *cred );
89 static int chk_kerberos(
90 const struct pw_scheme *scheme,
91 const struct berval *passwd,
92 const struct berval *cred );
95 const struct pw_scheme *scheme,
96 const struct berval *passwd,
97 const struct berval *cred );
100 const struct pw_scheme *scheme,
101 const struct berval *passwd,
102 const struct berval *cred );
105 /* password hash routines */
106 static struct berval *hash_sha1(
107 const struct pw_scheme *scheme,
108 const struct berval *passwd );
110 static struct berval *hash_ssha1(
111 const struct pw_scheme *scheme,
112 const struct berval *passwd );
114 static struct berval *hash_smd5(
115 const struct pw_scheme *scheme,
116 const struct berval *passwd );
118 static struct berval *hash_md5(
119 const struct pw_scheme *scheme,
120 const struct berval *passwd );
122 static struct berval *hash_crypt(
123 const struct pw_scheme *scheme,
124 const struct berval *passwd );
127 static const struct pw_scheme pw_schemes[] =
129 { {sizeof("{SSHA}")-1, "{SSHA}"}, chk_ssha1, hash_ssha1 },
130 { {sizeof("{SHA}")-1, "{SHA}"}, chk_sha1, hash_sha1 },
132 { {sizeof("{SMD5}")-1, "{SMD5}"}, chk_smd5, hash_smd5 },
133 { {sizeof("{MD5}")-1, "{MD5}"}, chk_md5, hash_md5 },
136 { {sizeof("{KERBEROS}")-1, "{KERBEROS}"}, chk_kerberos, NULL },
140 { {sizeof("{CRYPT}")-1, "{CRYPT}"}, chk_crypt, hash_crypt },
142 # if defined( HAVE_GETSPNAM ) \
143 || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
144 { {sizeof("{UNIX}")-1, "{UNIX}"}, chk_unix, NULL },
147 #ifdef SLAPD_CLEARTEXT
149 { {0, "{CLEARTEXT}"}, NULL, NULL },
152 { {0, NULL}, NULL, NULL }
155 static const struct pw_scheme *get_scheme(
160 for( i=0; pw_schemes[i].name.bv_val; i++) {
161 if( pw_schemes[i].name.bv_len == 0 ) continue;
163 if( strncasecmp(scheme, pw_schemes[i].name.bv_val,
164 pw_schemes[i].name.bv_len) == 0 )
166 return &pw_schemes[i];
173 int lutil_passwd_scheme(
176 if( scheme == NULL ) {
180 return get_scheme(scheme) != NULL;
184 static int is_allowed_scheme(
186 const char** schemes )
190 if( schemes == NULL ) return 1;
192 for( i=0; schemes[i] != NULL; i++ ) {
193 if( strcasecmp( scheme, schemes[i] ) == 0 ) {
200 static struct berval *passwd_scheme(
201 const struct pw_scheme *scheme,
202 const struct berval * passwd,
203 const char** allowed )
205 if( !is_allowed_scheme( scheme->name.bv_val, allowed ) ) {
209 if( passwd->bv_len >= scheme->name.bv_len ) {
210 if( strncasecmp( passwd->bv_val, scheme->name.bv_val, scheme->name.bv_len ) == 0 ) {
211 struct berval *bv = ber_memalloc( sizeof(struct berval) );
213 if( bv == NULL ) return NULL;
215 bv->bv_val = &passwd->bv_val[scheme->name.bv_len];
216 bv->bv_len = passwd->bv_len - scheme->name.bv_len;
226 * Return 0 if creds are good.
230 const struct berval *passwd, /* stored passwd */
231 const struct berval *cred, /* user cred */
232 const char **schemes )
236 if (cred == NULL || cred->bv_len == 0 ||
237 passwd == NULL || passwd->bv_len == 0 )
242 for( i=0; pw_schemes[i].name.bv_val != NULL; i++ ) {
243 if( pw_schemes[i].chk_fn ) {
244 struct berval *p = passwd_scheme( &pw_schemes[i],
248 int rc = (pw_schemes[i].chk_fn)( &pw_schemes[i], p, cred );
250 /* only free the berval structure as the bv_val points
251 * into passwd->bv_val
260 #ifdef SLAPD_CLEARTEXT
261 if( is_allowed_scheme("{CLEARTEXT}", schemes ) ) {
262 return passwd->bv_len == cred->bv_len
263 ? memcmp( passwd->bv_val, cred->bv_val, passwd->bv_len )
272 struct berval * lutil_passwd_generate( ber_len_t len )
276 if( len < 1 ) return NULL;
278 pw = ber_memalloc( sizeof( struct berval ) );
279 if( pw == NULL ) return NULL;
282 pw->bv_val = ber_memalloc( len + 1 );
284 if( pw->bv_val == NULL ) {
289 if( lutil_entropy( pw->bv_val, pw->bv_len) < 0 ) {
294 for( len = 0; len < pw->bv_len; len++ ) {
295 pw->bv_val[len] = crypt64[
296 pw->bv_val[len] % (sizeof(crypt64)-1) ];
299 pw->bv_val[len] = '\0';
304 struct berval * lutil_passwd_hash(
305 const struct berval * passwd,
306 const char * method )
308 const struct pw_scheme *sc = get_scheme( method );
310 if( sc == NULL ) return NULL;
311 if( ! sc->hash_fn ) return NULL;
313 return (sc->hash_fn)( sc, passwd );
316 static struct berval * pw_string(
317 const struct pw_scheme *sc,
318 const struct berval *passwd )
320 struct berval *pw = ber_memalloc( sizeof( struct berval ) );
321 if( pw == NULL ) return NULL;
323 pw->bv_len = sc->name.bv_len + passwd->bv_len;
324 pw->bv_val = ber_memalloc( pw->bv_len + 1 );
326 if( pw->bv_val == NULL ) {
331 memcpy( pw->bv_val, sc->name.bv_val, sc->name.bv_len );
332 memcpy( &pw->bv_val[sc->name.bv_len], passwd->bv_val, passwd->bv_len );
334 pw->bv_val[pw->bv_len] = '\0';
338 static struct berval * pw_string64(
339 const struct pw_scheme *sc,
340 const struct berval *hash,
341 const struct berval *salt )
344 struct berval string;
345 struct berval *b64 = ber_memalloc( sizeof(struct berval) );
348 if( b64 == NULL ) return NULL;
351 /* need to base64 combined string */
352 string.bv_len = hash->bv_len + salt->bv_len;
353 string.bv_val = ber_memalloc( string.bv_len + 1 );
355 if( string.bv_val == NULL ) {
360 memcpy( string.bv_val, hash->bv_val,
362 memcpy( &string.bv_val[hash->bv_len], salt->bv_val,
364 string.bv_val[string.bv_len] = '\0';
370 b64len = LUTIL_BASE64_ENCODE_LEN( string.bv_len ) + 1;
371 b64->bv_len = b64len + sc->name.bv_len;
372 b64->bv_val = ber_memalloc( b64->bv_len + 1 );
374 if( b64->bv_val == NULL ) {
375 if( salt ) ber_memfree( string.bv_val );
380 memcpy(b64->bv_val, sc->name.bv_val, sc->name.bv_len);
383 string.bv_val, string.bv_len,
384 &b64->bv_val[sc->name.bv_len], b64len );
386 b64->bv_val[b64->bv_len] = '\0';
388 if( salt ) ber_memfree( string.bv_val );
398 /* PASSWORD CHECK ROUTINES */
400 static int chk_ssha1(
401 const struct pw_scheme *sc,
402 const struct berval * passwd,
403 const struct berval * cred )
405 lutil_SHA1_CTX SHA1context;
406 unsigned char SHA1digest[LUTIL_SHA1_BYTES];
408 unsigned char *orig_pass = NULL;
410 /* base64 un-encode password */
411 orig_pass = (unsigned char *) ber_memalloc( (size_t) (
412 LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) );
414 if( orig_pass == NULL ) return -1;
416 rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len);
419 ber_memfree(orig_pass);
423 /* hash credentials with salt */
424 lutil_SHA1Init(&SHA1context);
425 lutil_SHA1Update(&SHA1context,
426 (const unsigned char *) cred->bv_val, cred->bv_len);
427 lutil_SHA1Update(&SHA1context,
428 (const unsigned char *) &orig_pass[sizeof(SHA1digest)],
429 rc - sizeof(SHA1digest));
430 lutil_SHA1Final(SHA1digest, &SHA1context);
433 rc = memcmp((char *)orig_pass, (char *)SHA1digest, sizeof(SHA1digest));
434 ber_memfree(orig_pass);
439 const struct pw_scheme *sc,
440 const struct berval * passwd,
441 const struct berval * cred )
443 lutil_SHA1_CTX SHA1context;
444 unsigned char SHA1digest[LUTIL_SHA1_BYTES];
446 unsigned char *orig_pass = NULL;
448 /* base64 un-encode password */
449 orig_pass = (unsigned char *) ber_memalloc( (size_t) (
450 LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) );
452 if( orig_pass == NULL ) return -1;
454 rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len);
456 if( rc != sizeof(SHA1digest) ) {
457 ber_memfree(orig_pass);
461 /* hash credentials with salt */
462 lutil_SHA1Init(&SHA1context);
463 lutil_SHA1Update(&SHA1context,
464 (const unsigned char *) cred->bv_val, cred->bv_len);
465 lutil_SHA1Final(SHA1digest, &SHA1context);
468 rc = memcmp((char *)orig_pass, (char *)SHA1digest, sizeof(SHA1digest));
469 ber_memfree(orig_pass);
474 const struct pw_scheme *sc,
475 const struct berval * passwd,
476 const struct berval * cred )
478 lutil_MD5_CTX MD5context;
479 unsigned char MD5digest[LUTIL_MD5_BYTES];
481 unsigned char *orig_pass = NULL;
483 /* base64 un-encode password */
484 orig_pass = (unsigned char *) ber_memalloc( (size_t) (
485 LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) );
487 if( orig_pass == NULL ) return -1;
489 rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len);
491 ber_memfree(orig_pass);
495 /* hash credentials with salt */
496 lutil_MD5Init(&MD5context);
497 lutil_MD5Update(&MD5context,
498 (const unsigned char *) cred->bv_val, cred->bv_len );
499 lutil_MD5Update(&MD5context,
500 (const unsigned char *) &orig_pass[sizeof(MD5digest)],
501 rc - sizeof(MD5digest));
502 lutil_MD5Final(MD5digest, &MD5context);
505 rc = memcmp((char *)orig_pass, (char *)MD5digest, sizeof(MD5digest));
506 ber_memfree(orig_pass);
511 const struct pw_scheme *sc,
512 const struct berval * passwd,
513 const struct berval * cred )
515 lutil_MD5_CTX MD5context;
516 unsigned char MD5digest[LUTIL_MD5_BYTES];
518 unsigned char *orig_pass = NULL;
520 /* base64 un-encode password */
521 orig_pass = (unsigned char *) ber_memalloc( (size_t) (
522 LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) );
524 if( orig_pass == NULL ) return -1;
526 rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len);
527 if ( rc != sizeof(MD5digest) ) {
528 ber_memfree(orig_pass);
532 /* hash credentials with salt */
533 lutil_MD5Init(&MD5context);
534 lutil_MD5Update(&MD5context,
535 (const unsigned char *) cred->bv_val, cred->bv_len );
536 lutil_MD5Final(MD5digest, &MD5context);
539 rc = memcmp((char *)orig_pass, (char *)MD5digest, sizeof(MD5digest));
540 ber_memfree(orig_pass);
545 static int chk_kerberos(
546 const struct pw_scheme *sc,
547 const struct berval * passwd,
548 const struct berval * cred )
553 for( i=0; i<cred->bv_len; i++) {
554 if(cred->bv_val[i] == '\0') {
555 return 1; /* NUL character in password */
559 if( cred->bv_val[i] != '\0' ) {
560 return 1; /* cred must behave like a string */
563 for( i=0; i<passwd->bv_len; i++) {
564 if(passwd->bv_val[i] == '\0') {
565 return 1; /* NUL character in password */
569 if( passwd->bv_val[i] != '\0' ) {
570 return 1; /* passwd must behave like a string */
575 #ifdef HAVE_KRB5 /* HAVE_HEIMDAL_KRB5 */
578 * Copyright (c) 1997, 1998, 1999 Kungliga Tekniska H\xf6gskolan
579 * (Royal Institute of Technology, Stockholm, Sweden).
580 * All rights reserved.
582 * Redistribution and use in source and binary forms, with or without
583 * modification, are permitted provided that the following conditions
586 * 1. Redistributions of source code must retain the above copyright
587 * notice, this list of conditions and the following disclaimer.
589 * 2. Redistributions in binary form must reproduce the above copyright
590 * notice, this list of conditions and the following disclaimer in the
591 * documentation and/or other materials provided with the distribution.
593 * 3. Neither the name of the Institute nor the names of its contributors
594 * may be used to endorse or promote products derived from this software
595 * without specific prior written permission.
597 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
598 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
599 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
600 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
601 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
602 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
603 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
604 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
605 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
606 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
610 krb5_context context;
613 krb5_get_init_creds_opt get_options;
614 krb5_verify_init_creds_opt verify_options;
615 krb5_principal client, server;
617 krb5_preauthtype pre_auth_types[] = {KRB5_PADATA_ENC_TIMESTAMP};
620 ret = krb5_init_context( &context );
626 krb5_get_init_creds_opt_set_preauth_list(&get_options,
630 krb5_get_init_creds_opt_init( &get_options );
632 krb5_verify_init_creds_opt_init( &verify_options );
634 ret = krb5_parse_name( context, passwd->bv_val, &client );
637 krb5_free_context( context );
641 ret = krb5_get_init_creds_password( context,
642 &creds, client, cred->bv_val, NULL,
643 NULL, 0, NULL, &get_options );
646 krb5_free_principal( context, client );
647 krb5_free_context( context );
652 char host[MAXHOSTNAMELEN];
654 if( gethostname( host, MAXHOSTNAMELEN ) != 0 ) {
655 krb5_free_principal( context, client );
656 krb5_free_context( context );
660 ret = krb5_sname_to_principal( context,
661 host, "ldap", KRB5_NT_SRV_HST, &server );
665 krb5_free_principal( context, client );
666 krb5_free_context( context );
670 ret = krb5_verify_init_creds( context,
671 &creds, server, NULL, NULL, &verify_options );
673 krb5_free_principal( context, client );
674 krb5_free_principal( context, server );
675 krb5_free_creds_contents( context, &creds );
676 krb5_free_context( context );
680 #elif defined(HAVE_KRB4)
682 /* Borrowed from Heimdal kpopper */
684 * Copyright (c) 1989 Regents of the University of California.
685 * All rights reserved. The Berkeley software License Agreement
686 * specifies the terms and conditions for redistribution.
690 char lrealm[REALM_SZ];
691 char tkt[MAXHOSTNAMELEN];
693 status = krb_get_lrealm(lrealm,1);
694 if (status == KFAILURE) {
698 snprintf(tkt, sizeof(tkt), "%s_slapd.%u",
699 TKT_ROOT, (unsigned)getpid());
700 krb_set_tkt_string (tkt);
702 status = krb_verify_user( passwd->bv_val, "", lrealm,
703 cred->bv_val, 1, "ldap");
705 dest_tkt(); /* no point in keeping the tickets */
707 return status == KFAILURE;
713 #endif /* SLAPD_KPASSWD */
716 static int chk_crypt(
717 const struct pw_scheme *sc,
718 const struct berval * passwd,
719 const struct berval * cred )
724 for( i=0; i<cred->bv_len; i++) {
725 if(cred->bv_val[i] == '\0') {
726 return 1; /* NUL character in password */
730 if( cred->bv_val[i] != '\0' ) {
731 return 1; /* cred must behave like a string */
734 if( passwd->bv_len < 2 ) {
735 return 1; /* passwd must be at least two characters long */
738 for( i=0; i<passwd->bv_len; i++) {
739 if(passwd->bv_val[i] == '\0') {
740 return 1; /* NUL character in password */
744 if( passwd->bv_val[i] != '\0' ) {
745 return 1; /* passwd must behave like a string */
748 cr = crypt( cred->bv_val, passwd->bv_val );
750 if( cr == NULL || cr[0] == '\0' ) {
751 /* salt must have been invalid */
755 return strcmp( passwd->bv_val, cr );
758 # if defined( HAVE_GETSPNAM ) \
759 || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
761 const struct pw_scheme *sc,
762 const struct berval * passwd,
763 const struct berval * cred )
768 for( i=0; i<cred->bv_len; i++) {
769 if(cred->bv_val[i] == '\0') {
770 return 1; /* NUL character in password */
773 if( cred->bv_val[i] != '\0' ) {
774 return 1; /* cred must behave like a string */
777 for( i=0; i<passwd->bv_len; i++) {
778 if(passwd->bv_val[i] == '\0') {
779 return 1; /* NUL character in password */
783 if( passwd->bv_val[i] != '\0' ) {
784 return 1; /* passwd must behave like a string */
787 # ifdef HAVE_GETSPNAM
789 struct spwd *spwd = getspnam(passwd->bv_val);
792 return 1; /* not found */
800 struct passwd *pwd = getpwnam(passwd->bv_val);
803 return 1; /* not found */
810 if( pw == NULL || pw[0] == '\0' || pw[1] == '\0' ) {
811 /* password must must be at least two characters long */
815 cr = crypt(cred->bv_val, pw);
817 if( cr == NULL || cr[0] == '\0' ) {
818 /* salt must have been invalid */
822 return strcmp(pw, cr);
828 /* PASSWORD GENERATION ROUTINES */
830 static struct berval *hash_ssha1(
831 const struct pw_scheme *scheme,
832 const struct berval *passwd )
834 lutil_SHA1_CTX SHA1context;
835 unsigned char SHA1digest[LUTIL_SHA1_BYTES];
836 unsigned char saltdata[4];
837 struct berval digest;
840 digest.bv_val = SHA1digest;
841 digest.bv_len = sizeof(SHA1digest);
842 salt.bv_val = saltdata;
843 salt.bv_len = sizeof(saltdata);
845 if( lutil_entropy( salt.bv_val, salt.bv_len) < 0 ) {
849 lutil_SHA1Init( &SHA1context );
850 lutil_SHA1Update( &SHA1context,
851 (const unsigned char *)passwd->bv_val, passwd->bv_len );
852 lutil_SHA1Update( &SHA1context,
853 (const unsigned char *)salt.bv_val, salt.bv_len );
854 lutil_SHA1Final( SHA1digest, &SHA1context );
856 return pw_string64( scheme, &digest, &salt);
859 static struct berval *hash_sha1(
860 const struct pw_scheme *scheme,
861 const struct berval *passwd )
863 lutil_SHA1_CTX SHA1context;
864 unsigned char SHA1digest[20];
865 struct berval digest;
866 digest.bv_val = SHA1digest;
867 digest.bv_len = sizeof(SHA1digest);
869 lutil_SHA1Init( &SHA1context );
870 lutil_SHA1Update( &SHA1context,
871 (const unsigned char *)passwd->bv_val, passwd->bv_len );
872 lutil_SHA1Final( SHA1digest, &SHA1context );
874 return pw_string64( scheme, &digest, NULL);
877 static struct berval *hash_smd5(
878 const struct pw_scheme *scheme,
879 const struct berval *passwd )
881 lutil_MD5_CTX MD5context;
882 unsigned char MD5digest[16];
883 unsigned char saltdata[4];
884 struct berval digest;
887 digest.bv_val = MD5digest;
888 digest.bv_len = sizeof(MD5digest);
889 salt.bv_val = saltdata;
890 salt.bv_len = sizeof(saltdata);
892 if( lutil_entropy( salt.bv_val, salt.bv_len) < 0 ) {
896 lutil_MD5Init( &MD5context );
897 lutil_MD5Update( &MD5context,
898 (const unsigned char *) passwd->bv_val, passwd->bv_len );
899 lutil_MD5Update( &MD5context,
900 (const unsigned char *) salt.bv_val, salt.bv_len );
901 lutil_MD5Final( MD5digest, &MD5context );
903 return pw_string64( scheme, &digest, &salt );
906 static struct berval *hash_md5(
907 const struct pw_scheme *scheme,
908 const struct berval *passwd )
910 lutil_MD5_CTX MD5context;
911 unsigned char MD5digest[16];
913 struct berval digest;
915 digest.bv_val = MD5digest;
916 digest.bv_len = sizeof(MD5digest);
918 lutil_MD5Init( &MD5context );
919 lutil_MD5Update( &MD5context,
920 (const unsigned char *) passwd->bv_val, passwd->bv_len );
921 lutil_MD5Final( MD5digest, &MD5context );
923 return pw_string64( scheme, &digest, NULL );
928 static struct berval *hash_crypt(
929 const struct pw_scheme *scheme,
930 const struct berval *passwd )
933 unsigned char salt[3];
936 for( i=0; i<passwd->bv_len; i++) {
937 if(passwd->bv_val[i] == '\0') {
938 return NULL; /* NUL character in password */
942 if( passwd->bv_val[i] != '\0' ) {
943 return NULL; /* passwd must behave like a string */
946 if( lutil_entropy( salt, sizeof(salt)) < 0 ) {
950 salt[0] = crypt64[ salt[0] % (sizeof(crypt64)-1) ];
951 salt[1] = crypt64[ salt[1] % (sizeof(crypt64)-1) ];
954 hash.bv_val = crypt( passwd->bv_val, salt );
956 if( hash.bv_val == NULL ) return NULL;
958 hash.bv_len = strlen( hash.bv_val );
960 if( hash.bv_len == 0 ) {
964 return pw_string( scheme, &hash );