Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
742d0f25
Commit
742d0f25
authored
Sep 29, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up comments.
parent
2a314add
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
src/backend/libpq/md5.c
src/backend/libpq/md5.c
+14
-9
No files found.
src/backend/libpq/md5.c
View file @
742d0f25
...
@@ -10,13 +10,11 @@
...
@@ -10,13 +10,11 @@
*
*
* Sverre H. Huseby <sverrehu@online.no>
* Sverre H. Huseby <sverrehu@online.no>
*
*
* $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.
7 2001/09/27 23:16:23 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.
8 2001/09/29 19:49:50 tgl
Exp $
*/
*/
#include "postgres.h"
#include "postgres.h"
#include <errno.h>
#include "libpq/crypt.h"
#include "libpq/crypt.h"
#ifdef FRONTEND
#ifdef FRONTEND
...
@@ -291,24 +289,31 @@ md5_hash(const void *buff, size_t len, char *hexsum)
...
@@ -291,24 +289,31 @@ md5_hash(const void *buff, size_t len, char *hexsum)
/*
/*
* puts md5(username+passwd) in buf provided buflen is at least 36 bytes
* Computes MD5 checksum of "passwd" (a null-terminated string) followed
* returns 1 on success, 0 on any kind of failure and sets errno accordingly
* by "salt" (which need not be null-terminated).
*
* Output format is "md5" followed by a 32-hex-digit MD5 checksum.
* Hence, the output buffer "buf" must be at least 36 bytes long.
*
* Returns TRUE if okay, FALSE on error (out of memory).
*/
*/
bool
EncryptMD5
(
const
char
*
passwd
,
const
char
*
salt
,
size_t
salt_len
,
bool
EncryptMD5
(
const
char
*
passwd
,
const
char
*
salt
,
size_t
salt_len
,
char
*
buf
)
char
*
buf
)
{
{
char
*
crypt_buf
=
palloc
(
strlen
(
passwd
)
+
salt_len
);
size_t
passwd_len
=
strlen
(
passwd
);
char
*
crypt_buf
=
palloc
(
passwd_len
+
salt_len
);
bool
ret
;
bool
ret
;
strcpy
(
buf
,
"md5"
);
/*
/*
* Place salt at the end because it may be known by users
* Place salt at the end because it may be known by users
* trying to crack the MD5 output.
* trying to crack the MD5 output.
*/
*/
strcpy
(
crypt_buf
,
passwd
);
strcpy
(
crypt_buf
,
passwd
);
memcpy
(
crypt_buf
+
strlen
(
passwd
),
salt
,
salt_len
);
memcpy
(
crypt_buf
+
passwd_len
,
salt
,
salt_len
);
strcpy
(
buf
,
"md5"
);
ret
=
md5_hash
(
crypt_buf
,
passwd_len
+
salt_len
,
buf
+
3
);
ret
=
md5_hash
(
crypt_buf
,
strlen
(
passwd
)
+
salt_len
,
buf
+
3
);
pfree
(
crypt_buf
);
pfree
(
crypt_buf
);
return
ret
;
return
ret
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment