Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Ng
OpenLDAP
Commits
13457efb
Commit
13457efb
authored
26 years ago
by
Dave Storey
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanups. MD5 and SHA1 routines should be a little faster and easier to read.
parent
a64c2a39
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
clients/tools/ldappasswd.c
+8
-40
8 additions, 40 deletions
clients/tools/ldappasswd.c
with
8 additions
and
40 deletions
clients/tools/ldappasswd.c
+
8
−
40
View file @
13457efb
...
...
@@ -195,30 +195,14 @@ hash_md5 (const char *pw_in, Salt * salt)
{
lutil_MD5_CTX
MD5context
;
unsigned
char
MD5digest
[
16
];
unsigned
char
*
hashing_pw
=
(
unsigned
char
*
)
pw_in
;
char
*
base64digest
=
NULL
;
int
tot_len
=
strlen
(
pw_in
);
int
salted
=
(
salt
&&
salt
->
salt
&&
salt
->
len
);
/* append salt to password */
if
(
salted
)
{
hashing_pw
=
(
unsigned
char
*
)
malloc
(
tot_len
+
salt
->
len
);
memcpy
(
hashing_pw
,
pw_in
,
tot_len
);
memcpy
(
&
hashing_pw
[
tot_len
],
salt
->
salt
,
salt
->
len
);
tot_len
+=
salt
->
len
;
}
lutil_MD5Init
(
&
MD5context
);
lutil_MD5Update
(
&
MD5context
,
hashing_pw
,
tot_len
);
lutil_MD5Update
(
&
MD5context
,
pw_in
,
strlen
(
pw_in
));
if
(
salt
&&
salt
->
salt
&&
salt
->
len
)
lutil_MD5Update
(
&
MD5context
,
salt
->
salt
,
salt
->
len
);
lutil_MD5Final
(
MD5digest
,
&
MD5context
);
base64digest
=
pw_encode
(
MD5digest
,
salt
,
sizeof
(
MD5digest
));
if
(
salted
)
free
(
hashing_pw
);
return
(
base64digest
);
return
(
pw_encode
(
MD5digest
,
salt
,
sizeof
(
MD5digest
)));
}
char
*
...
...
@@ -226,30 +210,14 @@ hash_sha1 (const char *pw_in, Salt * salt)
{
lutil_SHA1_CTX
SHA1context
;
unsigned
char
SHA1digest
[
20
];
unsigned
char
*
hashing_pw
=
(
unsigned
char
*
)
pw_in
;
char
*
base64digest
=
NULL
;
int
tot_len
=
strlen
(
pw_in
);
int
salted
=
(
salt
&&
salt
->
salt
);
/* append salt to password */
if
(
salted
)
{
hashing_pw
=
(
unsigned
char
*
)
malloc
(
tot_len
+
salt
->
len
);
memcpy
(
hashing_pw
,
pw_in
,
tot_len
);
memcpy
(
&
hashing_pw
[
tot_len
],
salt
->
salt
,
salt
->
len
);
tot_len
+=
salt
->
len
;
}
lutil_SHA1Init
(
&
SHA1context
);
lutil_SHA1Update
(
&
SHA1context
,
hashing_pw
,
tot_len
);
lutil_SHA1Update
(
&
SHA1context
,
pw_in
,
strlen
(
pw_in
));
if
(
salt
&&
salt
->
salt
&&
salt
->
len
)
lutil_SHA1Update
(
&
SHA1context
,
salt
->
salt
,
salt
->
len
);
lutil_SHA1Final
(
SHA1digest
,
&
SHA1context
);
base64digest
=
pw_encode
(
SHA1digest
,
salt
,
sizeof
(
SHA1digest
));
if
(
salted
)
free
(
hashing_pw
);
return
(
base64digest
);
return
(
pw_encode
(
SHA1digest
,
salt
,
sizeof
(
SHA1digest
)));
}
static
Hash
hashes
[]
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment