63"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
92 const char *fp =
NULL;
105 elog(
ERROR,
"null value for password rejected");
108 elog(
ERROR,
"null value for salt rejected");
114 elog(
ERROR,
"insufficient result buffer size to encrypt password");
149 errmsg(
"invalid format of salt"),
150 errhint(
"magic byte format for shacrypt is either \"$5$\" or \"$6$\""));
194 errmsg(
"could not parse salt options"));
213 errmsg(
"rounds=%d exceeds maximum supported value (%d), using %d instead",
222 errmsg(
"rounds=%d is below supported value (%d), using %d instead",
274 elog(
ERROR,
"unknown crypt identifier \"%c\"", salt[1]);
309 elog(
ERROR,
"bogus magic byte found in salt string");
313 elog(
ERROR,
"bogus magic byte found in salt string");
321 elog(
ERROR,
"invalid rounds option specified in salt string");
330 errmsg(
"invalid character in salt string: \"%.*s\"",
351 elog(
DEBUG1,
"using salt \"%s\", salt len = %d, rounds = %u",
359 elog(
ERROR,
"unexpected length of salt string");
405 (block & 1) ?
sha_buf : (
const unsigned char *)
pw,
422 for (block =
len; block > 0; block--)
455 for (block = 16 +
sha_buf[0]; block > 0; block--)
492 for (block = 0; block <
rounds; block++)
512 if ((block % 3) != 0)
516 if ((block % 7) != 0)
546#define b64_from_24bit(B2, B1, B0, N) \
548 unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0); \
552 appendStringInfoCharMacro(out_buf, _crypt_itoa64[w & 0x3f]); \
606 elog(
ERROR,
"unsupported digest length");
640 errmsg(
"cannot create encrypted password"));
char * px_crypt_shacrypt(const char *pw, const char *salt, char *passwd, unsigned dstlen)
#define b64_from_24bit(B2, B1, B0, N)
static const char _crypt_itoa64[64+1]
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
int pg_mblen(const char *mbstr)
void pfree(void *pointer)
void * palloc0(Size size)
#define CHECK_FOR_INTERRUPTS()
int px_find_digest(const char *name, PX_MD **res)
#define PX_SHACRYPT_ROUNDS_MAX
#define PX_SHACRYPT_BUF_LEN
#define PX_SHACRYPT_ROUNDS_MIN
#define PX_SHACRYPT_DIGEST_MAX_LEN
#define PX_SHACRYPT_SALT_MAX_LEN
#define PX_SHACRYPT_ROUNDS_DEFAULT
void px_memset(void *ptr, int c, size_t len)
#define px_md_finish(md, buf)
#define px_md_update(md, data, dlen)
int strtoint(const char *pg_restrict str, char **pg_restrict endptr, int base)
void destroyStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
StringInfo makeStringInfoExt(int initsize)
void appendStringInfoString(StringInfo str, const char *s)
#define appendStringInfoCharMacro(str, ch)