/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2007,2010,2011 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/cryptodisk.h>
#include <grub/partition.h>
GRUB_MOD_LICENSE ("GPLv3+");
/* On disk LUKS header */
struct grub_luks_phdr
{
struct
{
} __attribute__ ((packed));
static grub_cryptodisk_t
int check_boot)
{
const char *iptr;
char *optr;
int benbi_log = 0;
if (check_boot)
return NULL;
/* Read the LUKS header. */
if (err)
{
if (err == GRUB_ERR_OUT_OF_RANGE)
return NULL;
}
/* Look for LUKS magic sequence. */
return NULL;
iptr++)
{
if (*iptr != '-')
}
*optr = 0;
{
return NULL;
}
/* Make sure that strings are null terminated. */
if (!ciph)
{
return NULL;
}
/* Configure the cipher used for the bulk data. */
if (!cipher)
return NULL;
{
return NULL;
}
/* Configure the cipher mode. */
{
}
{
}
{
}
{
}
{
if (!secondary_cipher)
{
return NULL;
}
{
return NULL;
}
{
return NULL;
}
}
{
{
return NULL;
}
}
else
{
return NULL;
}
{
for (benbi_log = 0;
benbi_log++);
}
{
/* Configure the hash and cipher used for ESSIV. */
if (!essiv_hash)
{
"Couldn't load %s hash", hash_str);
return NULL;
}
if (!essiv_cipher)
{
return NULL;
}
}
else
{
cipheriv);
return NULL;
}
/* Configure the hash used for the AF splitter and HMAC. */
if (!hash)
{
hashspec);
return NULL;
}
if (!newdev)
return NULL;
#ifdef GRUB_UTIL
#endif
return newdev;
}
static grub_err_t
{
unsigned i;
char *tmp;
if (err)
return err;
if (!split_key)
return grub_errno;
/* Get the passphrase from the user. */
{
}
/* Try to recover master key from each active keyslot. */
{
/* Check if keyslot is enabled. */
continue;
/* Calculate the PBKDF2 of the user supplied passphrase. */
if (gcry_err)
{
return grub_crypto_gcry_error (gcry_err);
}
if (gcry_err)
{
return grub_crypto_gcry_error (gcry_err);
}
/* Read and decrypt the key material from the disk. */
[i].keyMaterialOffset), 0,
if (err)
{
return err;
}
if (gcry_err)
{
return grub_crypto_gcry_error (gcry_err);
}
/* Merge the decrypted key material to get the candidate master key. */
if (gcry_err)
{
return grub_crypto_gcry_error (gcry_err);
}
/* Calculate the PBKDF2 of the candidate master key. */
sizeof (header.mkDigestSalt),
sizeof (candidate_digest));
if (gcry_err)
{
return grub_crypto_gcry_error (gcry_err);
}
/* Compare the calculated PBKDF2 to the digest stored
in the header to see if it's correct. */
{
continue;
}
/* Set the master key. */
if (gcry_err)
{
return grub_crypto_gcry_error (gcry_err);
}
return GRUB_ERR_NONE;
}
return GRUB_ACCESS_DENIED;
}
};
{
}
{
}