Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Nadezhda Ivanova
OpenLDAP
Commits
f4a06993
Commit
f4a06993
authored
25 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
Add macros to compute base64 encode/decode lengths.
parent
92238e52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
clients/tools/ldappasswd.c
+3
-3
3 additions, 3 deletions
clients/tools/ldappasswd.c
include/lutil.h
+6
-0
6 additions, 0 deletions
include/lutil.h
libraries/liblutil/passwd.c
+6
-4
6 additions, 4 deletions
libraries/liblutil/passwd.c
with
15 additions
and
7 deletions
clients/tools/ldappasswd.c
+
3
−
3
View file @
f4a06993
...
...
@@ -41,8 +41,6 @@
#include
"ldap_defaults.h"
/* local macros */
#define CEILING(x) ((double)(x) > (int)(x) ? (int)(x) + 1 : (int)(x))
#define LDAP_PASSWD_ATTRIB "userPassword"
#define LDAP_PASSWD_CONF LDAP_SYSCONFDIR LDAP_DIRSEP "passwd.conf"
...
...
@@ -107,8 +105,10 @@ pw_encode (unsigned char *passwd, Salt * salt, unsigned int len)
len
+=
salt
->
len
;
}
b64_len
=
CEILING
(
len
/
3
)
*
4
+
1
;
b64_len
=
LUTIL_BASE64_ENCODE_LEN
(
len
)
+
1
;
base64digest
=
(
char
*
)
malloc
(
b64_len
);
if
(
lutil_b64_ntop
(
npasswd
,
len
,
base64digest
,
b64_len
)
<
0
)
{
free
(
base64digest
);
...
...
This diff is collapsed.
Click to expand it.
include/lutil.h
+
6
−
0
View file @
f4a06993
...
...
@@ -19,6 +19,12 @@
* Include file for LDAP utility routine
*/
/* n octets encode into ceiling(n/3) * 4 bytes */
/* Avoid floating point math by through extra padding */
#define LUTIL_BASE64_ENCODE_LEN(n) ((n)/3 * 4 + 4)
#define LUTIL_BASE64_DECODE_LEN(n) ((n)/4 * 3)
LDAP_BEGIN_DECL
/* ISC Base64 Routines */
...
...
This diff is collapsed.
Click to expand it.
libraries/liblutil/passwd.c
+
6
−
4
View file @
f4a06993
...
...
@@ -109,7 +109,7 @@ lutil_passwd(
if
((
p
=
passwd_scheme
(
passwd
,
"{MD5}"
,
schemes
))
!=
NULL
)
{
lutil_MD5_CTX
MD5context
;
unsigned
char
MD5digest
[
16
];
char
base64digest
[
25
];
/* ceiling(sizeof(input)/3) * 4 + 1 */
char
base64digest
[
LUTIL_BASE64_ENCODE_LEN
(
16
)];
lutil_MD5Init
(
&
MD5context
);
lutil_MD5Update
(
&
MD5context
,
...
...
@@ -127,7 +127,7 @@ lutil_passwd(
}
else
if
((
p
=
passwd_scheme
(
passwd
,
"{SHA}"
,
schemes
))
!=
NULL
)
{
lutil_SHA1_CTX
SHA1context
;
unsigned
char
SHA1digest
[
20
];
char
base64digest
[
29
];
/* ceiling(sizeof(input)/3) * 4 + 1 */
char
base64digest
[
LUTIL_BASE64_ENCODE_LEN
(
20
)];
lutil_SHA1Init
(
&
SHA1context
);
lutil_SHA1Update
(
&
SHA1context
,
...
...
@@ -150,7 +150,8 @@ lutil_passwd(
unsigned
char
*
orig_pass
=
NULL
;
/* base64 un-encode password */
orig_pass
=
(
unsigned
char
*
)
malloc
((
size_t
)(
pw_len
*
0
.
75
+
1
));
orig_pass
=
(
unsigned
char
*
)
malloc
(
(
size_t
)
(
LUTIL_BASE64_DECODE_LEN
(
pw_len
)
+
1
)
);
if
((
rc
=
lutil_b64_pton
(
p
,
orig_pass
,
pw_len
))
<
0
)
{
free
(
orig_pass
);
...
...
@@ -179,7 +180,8 @@ lutil_passwd(
unsigned
char
*
orig_pass
=
NULL
;
/* base64 un-encode password */
orig_pass
=
(
unsigned
char
*
)
malloc
((
size_t
)(
pw_len
*
0
.
75
+
1
));
orig_pass
=
(
unsigned
char
*
)
malloc
(
(
size_t
)
(
LUTIL_BASE64_DECODE_LEN
(
pw_len
)
+
1
)
);
if
((
rc
=
lutil_b64_pton
(
p
,
orig_pass
,
pw_len
))
<
0
)
{
free
(
orig_pass
);
...
...
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