summaryrefslogtreecommitdiff
path: root/src/include/common/scram-common.h
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-04-03 17:30:49 +0900
committerMichael Paquier <michael@paquier.xyz>2021-04-03 17:30:49 +0900
commite6bdfd9700ebfc7df811c97c2fc46d7e94e329a2 (patch)
tree2fb0dad9a0ba47b6ba0a6da9780b77a65dc7dffa /src/include/common/scram-common.h
parent1d9c5d0ce2dcac05850401cf266a9df10a68de49 (diff)
Refactor HMAC implementations
Similarly to the cryptohash implementations, this refactors the existing HMAC code into a single set of APIs that can be plugged with any crypto libraries PostgreSQL is built with (only OpenSSL currently). If there is no such libraries, a fallback implementation is available. Those new APIs are designed similarly to the existing cryptohash layer, so there is no real new design here, with the same logic around buffer bound checks and memory handling. HMAC has a dependency on cryptohashes, so all the cryptohash types supported by cryptohash{_openssl}.c can be used with HMAC. This refactoring is an advantage mainly for SCRAM, that included its own implementation of HMAC with SHA256 without relying on the existing crypto libraries even if PostgreSQL was built with their support. This code has been tested on Windows and Linux, with and without OpenSSL, across all the versions supported on HEAD from 1.1.1 down to 1.0.1. I have also checked that the implementations are working fine using some sample results, a custom extension of my own, and doing cross-checks across different major versions with SCRAM with the client and the backend. Author: Michael Paquier Reviewed-by: Bruce Momjian Discussion: https://postgr.es/m/X9m0nkEJEzIPXjeZ@paquier.xyz
Diffstat (limited to 'src/include/common/scram-common.h')
-rw-r--r--src/include/common/scram-common.h13
1 files changed, 0 insertions, 13 deletions
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);