Lines 51-56
typedef unsigned char des_data_block[8];
Link Here
|
51 |
typedef PK11Context *des_context[1]; |
51 |
typedef PK11Context *des_context[1]; |
52 |
#define DES_ENCRYPT CKA_ENCRYPT |
52 |
#define DES_ENCRYPT CKA_ENCRYPT |
53 |
|
53 |
|
|
|
54 |
#elif defined(HAVE_GNUTLS_GNUTLS_H) && !defined(DES_ENCRYPT) |
55 |
# include <gcrypt.h> |
56 |
|
54 |
#endif |
57 |
#endif |
55 |
|
58 |
|
56 |
#endif /* SLAPD_LMHASH */ |
59 |
#endif /* SLAPD_LMHASH */ |
Lines 651-657
static int chk_md5(
Link Here
|
651 |
|
654 |
|
652 |
#ifdef SLAPD_LMHASH |
655 |
#ifdef SLAPD_LMHASH |
653 |
|
656 |
|
654 |
#if defined(HAVE_OPENSSL) |
657 |
#if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS_GNUTLS_H) |
655 |
|
658 |
|
656 |
/* |
659 |
/* |
657 |
* abstract away setting the parity. |
660 |
* abstract away setting the parity. |
Lines 808-813
des_finish(des_key *key, des_context ctx
Link Here
|
808 |
* } |
811 |
* } |
809 |
*/ |
812 |
*/ |
810 |
|
813 |
|
|
|
814 |
#if defined(HAVE_GNUTLS_GNUTLS_H) && !defined(DES_ENCRYPT) |
815 |
static int gcrypt_init = 0; |
816 |
|
817 |
typedef const void* des_key; |
818 |
typedef unsigned char des_cblock[8]; |
819 |
typedef des_cblock des_data_block; |
820 |
typedef int des_key_schedule; /* unused */ |
821 |
typedef des_key_schedule des_context; /* unused */ |
822 |
#define des_failed(encrypted) 0 |
823 |
#define des_finish(key, schedule) |
824 |
|
825 |
#define des_set_key_unchecked( key, key_sched ) \ |
826 |
gcry_cipher_setkey( hd, key, 8 ) |
827 |
|
828 |
#define des_ecb_encrypt( input, output, key_sched, enc ) \ |
829 |
gcry_cipher_encrypt( hd, *output, 8, *input, 8 ) |
830 |
|
831 |
#define des_set_odd_parity( key ) do {} while(0) |
832 |
|
833 |
#endif /* HAVE_GNUTLS_GNUTLS_H && !DES_ENCRYPT */ |
834 |
|
811 |
static void lmPasswd_to_key( |
835 |
static void lmPasswd_to_key( |
812 |
const char *lmPasswd, |
836 |
const char *lmPasswd, |
813 |
des_key *key) |
837 |
des_key *key) |
Lines 841-846
static int chk_lanman(
Link Here
|
841 |
des_data_block StdText = "KGS!@#$%"; |
865 |
des_data_block StdText = "KGS!@#$%"; |
842 |
des_data_block PasswordHash1, PasswordHash2; |
866 |
des_data_block PasswordHash1, PasswordHash2; |
843 |
char PasswordHash[33], storedPasswordHash[33]; |
867 |
char PasswordHash[33], storedPasswordHash[33]; |
|
|
868 |
|
869 |
#if defined(HAVE_GNUTLS_GNUTLS_H) && !defined(DES_ENCRYPT) |
870 |
gcry_cipher_hd_t hd; |
871 |
|
872 |
if ( !gcrypt_init ) { |
873 |
gcry_check_version( GCRYPT_VERSION ); |
874 |
gcrypt_init = 1; |
875 |
} |
876 |
|
877 |
schedule = schedule; /* unused - avoid warning */ |
878 |
|
879 |
gcry_cipher_open( &hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0 ); |
880 |
#endif /* HAVE_GNUTLS_GNUTLS_H && !DES_ENCRYPT */ |
844 |
|
881 |
|
845 |
for( i=0; i<cred->bv_len; i++) { |
882 |
for( i=0; i<cred->bv_len; i++) { |
846 |
if(cred->bv_val[i] == '\0') { |
883 |
if(cred->bv_val[i] == '\0') { |
Lines 883-888
static int chk_lanman(
Link Here
|
883 |
strncpy( storedPasswordHash, passwd->bv_val, 32 ); |
920 |
strncpy( storedPasswordHash, passwd->bv_val, 32 ); |
884 |
storedPasswordHash[32] = '\0'; |
921 |
storedPasswordHash[32] = '\0'; |
885 |
ldap_pvt_str2lower( storedPasswordHash ); |
922 |
ldap_pvt_str2lower( storedPasswordHash ); |
|
|
923 |
|
924 |
#if defined(HAVE_GNUTLS_GNUTLS_H) && !defined(DES_ENCRYPT) |
925 |
gcry_cipher_close( hd ); |
926 |
#endif /* HAVE_GNUTLS_GNUTLS_H && !DES_ENCRYPT */ |
886 |
|
927 |
|
887 |
return memcmp( PasswordHash, storedPasswordHash, 32) ? LUTIL_PASSWD_ERR : LUTIL_PASSWD_OK; |
928 |
return memcmp( PasswordHash, storedPasswordHash, 32) ? LUTIL_PASSWD_ERR : LUTIL_PASSWD_OK; |
888 |
} |
929 |
} |
Lines 1138-1143
static int hash_lanman(
Link Here
|
1138 |
des_data_block PasswordHash1, PasswordHash2; |
1179 |
des_data_block PasswordHash1, PasswordHash2; |
1139 |
char PasswordHash[33]; |
1180 |
char PasswordHash[33]; |
1140 |
|
1181 |
|
|
|
1182 |
#if defined(HAVE_GNUTLS_GNUTLS_H) && !defined(DES_ENCRYPT) |
1183 |
gcry_cipher_hd_t hd; |
1184 |
|
1185 |
if ( !gcrypt_init ) { |
1186 |
gcry_check_version( GCRYPT_VERSION ); |
1187 |
gcrypt_init = 1; |
1188 |
} |
1189 |
|
1190 |
schedule = schedule; /* unused - avoid warning */ |
1191 |
|
1192 |
gcry_cipher_open( &hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0 ); |
1193 |
#endif /* HAVE_GNUTLS_GNUTLS_H && !DES_ENCRYPT */ |
1194 |
|
1141 |
for( i=0; i<passwd->bv_len; i++) { |
1195 |
for( i=0; i<passwd->bv_len; i++) { |
1142 |
if(passwd->bv_val[i] == '\0') { |
1196 |
if(passwd->bv_val[i] == '\0') { |
1143 |
return LUTIL_PASSWD_ERR; /* NUL character in password */ |
1197 |
return LUTIL_PASSWD_ERR; /* NUL character in password */ |
Lines 1168-1173
static int hash_lanman(
Link Here
|
1168 |
|
1222 |
|
1169 |
hash->bv_val = PasswordHash; |
1223 |
hash->bv_val = PasswordHash; |
1170 |
hash->bv_len = 32; |
1224 |
hash->bv_len = 32; |
|
|
1225 |
|
1226 |
#if defined(HAVE_GNUTLS_GNUTLS_H) && !defined(DES_ENCRYPT) |
1227 |
gcry_cipher_close( hd ); |
1228 |
#endif /* HAVE_GNUTLS_GNUTLS_H && !DES_ENCRYPT */ |
1171 |
|
1229 |
|
1172 |
return pw_string( scheme, hash ); |
1230 |
return pw_string( scheme, hash ); |
1173 |
} |
1231 |
} |