summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/base64.c16
-rw-r--r--src/common/md5_common.c4
-rw-r--r--src/common/scram-common.c10
3 files changed, 15 insertions, 15 deletions
diff --git a/src/common/base64.c b/src/common/base64.c
index 6028f413472..240461fe1e6 100644
--- a/src/common/base64.c
+++ b/src/common/base64.c
@@ -41,15 +41,15 @@ static const int8 b64lookup[128] = {
/*
* pg_b64_encode
*
- * Encode into base64 the given string. Returns the length of the encoded
- * string, and -1 in the event of an error with the result buffer zeroed
- * for safety.
+ * Encode the 'src' byte array into base64. Returns the length of the encoded
+ * string, and -1 in the event of an error with the result buffer zeroed for
+ * safety.
*/
int
-pg_b64_encode(const char *src, int len, char *dst, int dstlen)
+pg_b64_encode(const uint8 *src, int len, char *dst, int dstlen)
{
char *p;
- const char *s,
+ const uint8 *s,
*end = src + len;
int pos = 2;
uint32 buf = 0;
@@ -59,7 +59,7 @@ pg_b64_encode(const char *src, int len, char *dst, int dstlen)
while (s < end)
{
- buf |= (unsigned char) *s << (pos << 3);
+ buf |= *s << (pos << 3);
pos--;
s++;
@@ -113,11 +113,11 @@ error:
* buffer zeroed for safety.
*/
int
-pg_b64_decode(const char *src, int len, char *dst, int dstlen)
+pg_b64_decode(const char *src, int len, uint8 *dst, int dstlen)
{
const char *srcend = src + len,
*s = src;
- char *p = dst;
+ uint8 *p = dst;
char c;
int b = 0;
uint32 buf = 0;
diff --git a/src/common/md5_common.c b/src/common/md5_common.c
index 61e396b0bbf..057ae7a449f 100644
--- a/src/common/md5_common.c
+++ b/src/common/md5_common.c
@@ -105,7 +105,7 @@ pg_md5_hash(const void *buff, size_t len, char *hexsum, const char **errstr)
* (of size MD5_DIGEST_LENGTH) rather than being converted to ASCII hex.
*/
bool
-pg_md5_binary(const void *buff, size_t len, void *outbuf, const char **errstr)
+pg_md5_binary(const void *buff, size_t len, uint8 *outbuf, const char **errstr)
{
pg_cryptohash_ctx *ctx;
@@ -142,7 +142,7 @@ pg_md5_binary(const void *buff, size_t len, void *outbuf, const char **errstr)
* error context.
*/
bool
-pg_md5_encrypt(const char *passwd, const char *salt, size_t salt_len,
+pg_md5_encrypt(const char *passwd, const uint8 *salt, size_t salt_len,
char *buf, const char **errstr)
{
size_t passwd_len = strlen(passwd);
diff --git a/src/common/scram-common.c b/src/common/scram-common.c
index bfd2a340016..e47a6ebbaab 100644
--- a/src/common/scram-common.c
+++ b/src/common/scram-common.c
@@ -37,7 +37,7 @@
int
scram_SaltedPassword(const char *password,
pg_cryptohash_type hash_type, int key_length,
- const char *salt, int saltlen, int iterations,
+ const uint8 *salt, int saltlen, int iterations,
uint8 *result, const char **errstr)
{
int password_len = strlen(password);
@@ -62,7 +62,7 @@ scram_SaltedPassword(const char *password,
/* First iteration */
if (pg_hmac_init(hmac_ctx, (uint8 *) password, password_len) < 0 ||
- pg_hmac_update(hmac_ctx, (uint8 *) salt, saltlen) < 0 ||
+ pg_hmac_update(hmac_ctx, salt, saltlen) < 0 ||
pg_hmac_update(hmac_ctx, (uint8 *) &one, sizeof(uint32)) < 0 ||
pg_hmac_final(hmac_ctx, Ui_prev, key_length) < 0)
{
@@ -207,7 +207,7 @@ scram_ServerKey(const uint8 *salted_password,
*/
char *
scram_build_secret(pg_cryptohash_type hash_type, int key_length,
- const char *salt, int saltlen, int iterations,
+ const uint8 *salt, int saltlen, int iterations,
const char *password, const char **errstr)
{
uint8 salted_password[SCRAM_MAX_KEY_LEN];
@@ -290,7 +290,7 @@ scram_build_secret(pg_cryptohash_type hash_type, int key_length,
*(p++) = '$';
/* stored key */
- encoded_result = pg_b64_encode((char *) stored_key, key_length, p,
+ encoded_result = pg_b64_encode(stored_key, key_length, p,
encoded_stored_len);
if (encoded_result < 0)
{
@@ -307,7 +307,7 @@ scram_build_secret(pg_cryptohash_type hash_type, int key_length,
*(p++) = ':';
/* server key */
- encoded_result = pg_b64_encode((char *) server_key, key_length, p,
+ encoded_result = pg_b64_encode(server_key, key_length, p,
encoded_server_len);
if (encoded_result < 0)
{