diff options
Diffstat (limited to 'src/include/common')
-rw-r--r-- | src/include/common/hmac.h | 29 | ||||
-rw-r--r-- | src/include/common/md5.h | 2 | ||||
-rw-r--r-- | src/include/common/scram-common.h | 13 | ||||
-rw-r--r-- | src/include/common/sha1.h | 2 |
4 files changed, 33 insertions, 13 deletions
diff --git a/src/include/common/hmac.h b/src/include/common/hmac.h new file mode 100644 index 00000000000..ea0343a9da7 --- /dev/null +++ b/src/include/common/hmac.h @@ -0,0 +1,29 @@ +/*------------------------------------------------------------------------- + * + * hmac.h + * Generic headers for HMAC + * + * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * src/include/common/hmac.h + * + *------------------------------------------------------------------------- + */ + +#ifndef PG_HMAC_H +#define PG_HMAC_H + +#include "common/cryptohash.h" + +/* opaque context, private to each HMAC implementation */ +typedef struct pg_hmac_ctx pg_hmac_ctx; + +extern pg_hmac_ctx *pg_hmac_create(pg_cryptohash_type type); +extern int pg_hmac_init(pg_hmac_ctx *ctx, const uint8 *key, size_t len); +extern int pg_hmac_update(pg_hmac_ctx *ctx, const uint8 *data, size_t len); +extern int pg_hmac_final(pg_hmac_ctx *ctx, uint8 *dest, size_t len); +extern void pg_hmac_free(pg_hmac_ctx *ctx); + +#endif /* PG_HMAC_H */ diff --git a/src/include/common/md5.h b/src/include/common/md5.h index 6d100f5cfc2..62a31e6ed4e 100644 --- a/src/include/common/md5.h +++ b/src/include/common/md5.h @@ -18,6 +18,8 @@ /* Size of result generated by MD5 computation */ #define MD5_DIGEST_LENGTH 16 +/* Block size for MD5 */ +#define MD5_BLOCK_SIZE 64 /* password-related data */ #define MD5_PASSWD_CHARSET "0123456789abcdef" diff --git a/src/include/common/scram-common.h b/src/include/common/scram-common.h index 9d684b41e8e..5777ce9fe33 100644 --- a/src/include/common/scram-common.h +++ b/src/include/common/scram-common.h @@ -46,19 +46,6 @@ */ #define SCRAM_DEFAULT_ITERATIONS 4096 -/* - * Context data for HMAC used in SCRAM authentication. - */ -typedef struct -{ - pg_cryptohash_ctx *sha256ctx; - uint8 k_opad[SHA256_HMAC_B]; -} scram_HMAC_ctx; - -extern int scram_HMAC_init(scram_HMAC_ctx *ctx, const uint8 *key, int keylen); -extern int scram_HMAC_update(scram_HMAC_ctx *ctx, const char *str, int slen); -extern int scram_HMAC_final(uint8 *result, scram_HMAC_ctx *ctx); - extern int scram_SaltedPassword(const char *password, const char *salt, int saltlen, int iterations, uint8 *result); extern int scram_H(const uint8 *str, int len, uint8 *result); diff --git a/src/include/common/sha1.h b/src/include/common/sha1.h index a61bc47deda..b1ee36f8eaf 100644 --- a/src/include/common/sha1.h +++ b/src/include/common/sha1.h @@ -15,5 +15,7 @@ /* Size of result generated by SHA1 computation */ #define SHA1_DIGEST_LENGTH 20 +/* Block size for SHA1 */ +#define SHA1_BLOCK_SIZE 64 #endif /* PG_SHA1_H */ |