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
248eeb82
Commit
248eeb82
authored
Jul 10, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This patch adds implementation of SHA2 to pgcrypto.
New hashes: SHA256, SHA384, SHA512. Marko Kreen
parent
73a7c322
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
209 additions
and
4 deletions
+209
-4
contrib/pgcrypto/Makefile
contrib/pgcrypto/Makefile
+4
-3
contrib/pgcrypto/internal.c
contrib/pgcrypto/internal.c
+205
-1
No files found.
contrib/pgcrypto/Makefile
View file @
248eeb82
#
# $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.1
7 2005/07/06 16:14:42 tgl
Exp $
# $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.1
8 2005/07/10 03:52:56 momjian
Exp $
#
# if you don't have OpenSSL, you can use libc random() or /dev/urandom
INT_CFLAGS
=
-DRAND_SILLY
#INT_CFLAGS = -DRAND_DEV=\"/dev/urandom\"
INT_SRCS
=
md5.c sha1.c internal.c blf.c rijndael.c
INT_SRCS
=
md5.c sha1.c sha2.c internal.c blf.c rijndael.c
INT_TESTS
=
sha2
OSSL_CFLAGS
=
-DRAND_OPENSSL
OSSL_SRCS
=
openssl.c
OSSL_TESTS
=
des 3des cast5
CF_SRCS
=
$(
if
$(
subst
no,,
$(with_openssl)
)
,
$(OSSL_SRCS)
,
$(INT_SRCS)
)
CF_TESTS
=
$(
if
$(
subst
no,,
$(with_openssl)
)
,
$(OSSL_TESTS)
)
CF_TESTS
=
$(
if
$(
subst
no,,
$(with_openssl)
)
,
$(OSSL_TESTS)
,
$(INT_TESTS)
)
CF_CFLAGS
=
$(
if
$(
subst
no,,
$(with_openssl)
)
,
$(OSSL_CFLAGS)
,
$(INT_CFLAGS)
)
PG_CPPFLAGS
=
$(CF_CFLAGS)
...
...
contrib/pgcrypto/internal.c
View file @
248eeb82
...
...
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.1
6 2005/03/21 05:19:55 neilc
Exp $
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.1
7 2005/07/10 03:52:56 momjian
Exp $
*/
...
...
@@ -36,6 +36,7 @@
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
#include "blf.h"
#include "rijndael.h"
...
...
@@ -56,6 +57,9 @@
static
void
init_md5
(
PX_MD
*
h
);
static
void
init_sha1
(
PX_MD
*
h
);
static
void
init_sha256
(
PX_MD
*
h
);
static
void
init_sha384
(
PX_MD
*
h
);
static
void
init_sha512
(
PX_MD
*
h
);
struct
int_digest
{
...
...
@@ -67,6 +71,9 @@ static const struct int_digest
int_digest_list
[]
=
{
{
"md5"
,
init_md5
},
{
"sha1"
,
init_sha1
},
{
"sha256"
,
init_sha256
},
{
"sha384"
,
init_sha384
},
{
"sha512"
,
init_sha512
},
{
NULL
,
NULL
}
};
...
...
@@ -164,6 +171,146 @@ int_sha1_free(PX_MD * h)
px_free
(
h
);
}
/* SHA256 */
static
unsigned
int_sha256_len
(
PX_MD
*
h
)
{
return
SHA256_DIGEST_LENGTH
;
}
static
unsigned
int_sha256_block_len
(
PX_MD
*
h
)
{
return
SHA256_BLOCK_LENGTH
;
}
static
void
int_sha256_update
(
PX_MD
*
h
,
const
uint8
*
data
,
unsigned
dlen
)
{
SHA256_CTX
*
ctx
=
(
SHA256_CTX
*
)
h
->
p
.
ptr
;
SHA256_Update
(
ctx
,
data
,
dlen
);
}
static
void
int_sha256_reset
(
PX_MD
*
h
)
{
SHA256_CTX
*
ctx
=
(
SHA256_CTX
*
)
h
->
p
.
ptr
;
SHA256_Init
(
ctx
);
}
static
void
int_sha256_finish
(
PX_MD
*
h
,
uint8
*
dst
)
{
SHA256_CTX
*
ctx
=
(
SHA256_CTX
*
)
h
->
p
.
ptr
;
SHA256_Final
(
dst
,
ctx
);
}
static
void
int_sha256_free
(
PX_MD
*
h
)
{
SHA256_CTX
*
ctx
=
(
SHA256_CTX
*
)
h
->
p
.
ptr
;
px_free
(
ctx
);
px_free
(
h
);
}
/* SHA384 */
static
unsigned
int_sha384_len
(
PX_MD
*
h
)
{
return
SHA384_DIGEST_LENGTH
;
}
static
unsigned
int_sha384_block_len
(
PX_MD
*
h
)
{
return
SHA384_BLOCK_LENGTH
;
}
static
void
int_sha384_update
(
PX_MD
*
h
,
const
uint8
*
data
,
unsigned
dlen
)
{
SHA384_CTX
*
ctx
=
(
SHA384_CTX
*
)
h
->
p
.
ptr
;
SHA384_Update
(
ctx
,
data
,
dlen
);
}
static
void
int_sha384_reset
(
PX_MD
*
h
)
{
SHA384_CTX
*
ctx
=
(
SHA384_CTX
*
)
h
->
p
.
ptr
;
SHA384_Init
(
ctx
);
}
static
void
int_sha384_finish
(
PX_MD
*
h
,
uint8
*
dst
)
{
SHA384_CTX
*
ctx
=
(
SHA384_CTX
*
)
h
->
p
.
ptr
;
SHA384_Final
(
dst
,
ctx
);
}
static
void
int_sha384_free
(
PX_MD
*
h
)
{
SHA384_CTX
*
ctx
=
(
SHA384_CTX
*
)
h
->
p
.
ptr
;
px_free
(
ctx
);
px_free
(
h
);
}
/* SHA512 */
static
unsigned
int_sha512_len
(
PX_MD
*
h
)
{
return
SHA512_DIGEST_LENGTH
;
}
static
unsigned
int_sha512_block_len
(
PX_MD
*
h
)
{
return
SHA512_BLOCK_LENGTH
;
}
static
void
int_sha512_update
(
PX_MD
*
h
,
const
uint8
*
data
,
unsigned
dlen
)
{
SHA512_CTX
*
ctx
=
(
SHA512_CTX
*
)
h
->
p
.
ptr
;
SHA512_Update
(
ctx
,
data
,
dlen
);
}
static
void
int_sha512_reset
(
PX_MD
*
h
)
{
SHA512_CTX
*
ctx
=
(
SHA512_CTX
*
)
h
->
p
.
ptr
;
SHA512_Init
(
ctx
);
}
static
void
int_sha512_finish
(
PX_MD
*
h
,
uint8
*
dst
)
{
SHA512_CTX
*
ctx
=
(
SHA512_CTX
*
)
h
->
p
.
ptr
;
SHA512_Final
(
dst
,
ctx
);
}
static
void
int_sha512_free
(
PX_MD
*
h
)
{
SHA512_CTX
*
ctx
=
(
SHA512_CTX
*
)
h
->
p
.
ptr
;
px_free
(
ctx
);
px_free
(
h
);
}
/* init functions */
static
void
...
...
@@ -204,6 +351,63 @@ init_sha1(PX_MD * md)
md
->
reset
(
md
);
}
static
void
init_sha256
(
PX_MD
*
md
)
{
SHA256_CTX
*
ctx
;
ctx
=
px_alloc
(
sizeof
(
*
ctx
));
md
->
p
.
ptr
=
ctx
;
md
->
result_size
=
int_sha256_len
;
md
->
block_size
=
int_sha256_block_len
;
md
->
reset
=
int_sha256_reset
;
md
->
update
=
int_sha256_update
;
md
->
finish
=
int_sha256_finish
;
md
->
free
=
int_sha256_free
;
md
->
reset
(
md
);
}
static
void
init_sha384
(
PX_MD
*
md
)
{
SHA384_CTX
*
ctx
;
ctx
=
px_alloc
(
sizeof
(
*
ctx
));
md
->
p
.
ptr
=
ctx
;
md
->
result_size
=
int_sha384_len
;
md
->
block_size
=
int_sha384_block_len
;
md
->
reset
=
int_sha384_reset
;
md
->
update
=
int_sha384_update
;
md
->
finish
=
int_sha384_finish
;
md
->
free
=
int_sha384_free
;
md
->
reset
(
md
);
}
static
void
init_sha512
(
PX_MD
*
md
)
{
SHA512_CTX
*
ctx
;
ctx
=
px_alloc
(
sizeof
(
*
ctx
));
md
->
p
.
ptr
=
ctx
;
md
->
result_size
=
int_sha512_len
;
md
->
block_size
=
int_sha512_block_len
;
md
->
reset
=
int_sha512_reset
;
md
->
update
=
int_sha512_update
;
md
->
finish
=
int_sha512_finish
;
md
->
free
=
int_sha512_free
;
md
->
reset
(
md
);
}
/*
* ciphers generally
*/
...
...
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