Example #1
0
EFI_STATUS password_crypt (const char *password, UINT32 pw_length,
			   const PASSWORD_CRYPT *pw_crypt, UINT8 *hash)
{
	EFI_STATUS efi_status;

	if (!pw_crypt)
		return EFI_INVALID_PARAMETER;

	switch (pw_crypt->method) {
	case TRADITIONAL_DES:
	case EXTEND_BSDI_DES:
		efi_status = EFI_UNSUPPORTED;
		break;
	case MD5_BASED:
		efi_status = md5_crypt (password, pw_length,
					(char *)pw_crypt->salt,
					pw_crypt->salt_size, hash);
		break;
	case SHA256_BASED:
		efi_status = sha256_crypt(password, pw_length,
					  (char *)pw_crypt->salt,
					  pw_crypt->salt_size,
					  pw_crypt->iter_count, hash);
		break;
	case SHA512_BASED:
		efi_status = sha512_crypt(password, pw_length,
					  (char *)pw_crypt->salt,
					  pw_crypt->salt_size,
					  pw_crypt->iter_count, hash);
		break;
	case BLOWFISH_BASED:
		if (pw_crypt->salt_size != (7 + 22 + 1)) {
			efi_status = EFI_INVALID_PARAMETER;
			break;
		}
		efi_status = blowfish_crypt(password, (char *)pw_crypt->salt,
					    hash);
		break;
	default:
		return EFI_INVALID_PARAMETER;
	}

	return efi_status;
}
Example #2
0
void do_crypt(char *s, char *d, int size)
{
   strlcpy(d, sha256_crypt(s, "$5$") + 4, size);
}