/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 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/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
{0, 0, 0, 0, 0, 0}
};
{
{"sha256sum", "sha256"},
{"sha512sum", "sha512"},
{"sha1sum", "sha1"},
{"md5sum", "md5"},
{"crc", "crc32"},
};
static inline int
hextoval (char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return -1;
}
static grub_err_t
{
while (1)
{
grub_ssize_t r;
if (r < 0)
return grub_errno;
if (r == 0)
break;
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
unsigned i;
if (!hashlist)
return grub_errno;
{
const char *p = buf;
{
}
if (*p++ != ' ' || *p++ != ' ')
if (prefix)
{
char *filename;
if (!filename)
return grub_errno;
if (!uncompress)
}
else
{
if (!uncompress)
file = grub_file_open (p);
}
if (!file)
{
return grub_errno;
}
if (err)
{
if (!keep)
{
return err;
}
grub_print_error ();
unread++;
continue;
}
{
if (!keep)
{
return grub_error (GRUB_ERR_TEST_FAILURE,
"hash of '%s' mismatches", p);
}
mismatch++;
continue;
}
}
return grub_error (GRUB_ERR_TEST_FAILURE,
"%d files couldn't be read and hash "
return GRUB_ERR_NONE;
}
static grub_err_t
{
unsigned i;
unsigned unread = 0;
for (i = 0; i < ARRAY_SIZE (aliases); i++)
if (!hashname)
if (!hash)
{
if (argc != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"--check is incompatible with file list");
}
for (i = 0; i < (unsigned) argc; i++)
{
unsigned j;
if (!uncompress)
if (!file)
{
if (!keep)
return grub_errno;
grub_print_error ();
unread++;
continue;
}
if (err)
{
if (!keep)
return err;
grub_print_error ();
unread++;
continue;
}
}
if (unread)
unread);
return GRUB_ERR_NONE;
}
{
N_("-h HASH [-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
}
{
}