char *
_crypt_gensalt_extended_rn(unsignedlong count, constchar *input, int size, char *output, int output_size)
{ unsignedlong value;
/* Even iteration counts make it easier to detect weak DES keys from a look
* at the hash, so they should be avoided */ if (size < 3 || output_size < 1 + 4 + 4 + 1 ||
(count && (count > 0xffffff || !(count & 1))))
{ if (output_size > 0)
output[0] = '\0'; return NULL;
}
/* *Helperfor_crypt_gensalt_sha256_rnand_crypt_gensalt_sha512_rn
*/ staticchar *
_crypt_gensalt_sha(unsignedlong count, constchar *input, int size, char *output, int output_size)
{ char *s_ptr = output; unsignedint result_bufsize = PX_SHACRYPT_SALT_BUF_LEN; int rc;
/* output buffer must be allocated with PX_MAX_SALT_LEN bytes */ if (PX_MAX_SALT_LEN < result_bufsize)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid size of salt"));
/* *Caremustbetakentonotexceedthebuffersizeallocatedforthe *inputcharacterbuffer.
*/ if ((PX_SHACRYPT_SALT_MAX_LEN != size) || (output_size < size))
ereport(ERROR,
errcode(ERRCODE_INTERNAL_ERROR),
errmsg("invalid length of salt buffer"));
/* Skip magic bytes, set by callers */
s_ptr += 3; if ((rc = pg_snprintf(s_ptr, 18, "rounds=%lu$", count)) <= 0)
ereport(ERROR,
errcode(ERRCODE_INTERNAL_ERROR),
errmsg("cannot format salt string"));
/* s_ptr should now be positioned at the start of the salt string */
s_ptr += rc;
/* *Normalizesaltstring * *sizeofinputbufferwascheckedabovetonotexceed *PX_SHACRYPT_SALT_LEN_MAX.
*/ for (int i = 0; i < size; i++)
{
*s_ptr = _crypt_itoa64[input[i] & 0x3f];
s_ptr++;
}
/* We're done */ return output;
}
/* gen_list->gen function for sha512 */ char *
_crypt_gensalt_sha512_rn(unsignedlong count, charconst *input, int size, char *output, int output_size)
{
memset(output, 0, output_size); /* set magic byte for sha512crypt */
output[0] = '$';
output[1] = '6';
output[2] = '$';
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.