/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
* 2007, 2008, 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/>.
*/
#ifdef GRUB_UTIL
#include <termios.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#endif
GRUB_MOD_LICENSE ("GPLv3+");
struct grub_crypto_hmac_handle
{
void *ctx;
void *opad;
};
/* Based on libgcrypt-1.4.4/src/misc.c. */
void
{
}
void
{
}
void
{
{
break;
}
}
void
{
}
void
{
{
break;
}
}
void
{
}
const gcry_md_spec_t *
{
while (1)
{
return md;
if (grub_crypto_autoload_hook && first)
else
return NULL;
first = 0;
}
}
const gcry_cipher_spec_t *
{
while (1)
{
{
const char **alias;
return ciph;
continue;
return ciph;
}
if (grub_crypto_autoload_hook && first)
else
return NULL;
first = 0;
}
}
{
if (!ret)
return NULL;
return ret;
}
const unsigned char *key,
unsigned keylen)
{
}
{
return GPG_ERR_NOT_SUPPORTED;
return GPG_ERR_INV_ARG;
return GPG_ERR_NO_ERROR;
}
{
return GPG_ERR_NOT_SUPPORTED;
return GPG_ERR_INV_ARG;
return GPG_ERR_NO_ERROR;
}
void *iv_in)
{
void *iv;
return GPG_ERR_NOT_SUPPORTED;
return GPG_ERR_INV_ARG;
{
}
return GPG_ERR_NO_ERROR;
}
void *iv)
{
return GPG_ERR_NOT_SUPPORTED;
return GPG_ERR_INV_ARG;
{
}
return GPG_ERR_NO_ERROR;
}
struct grub_crypto_hmac_handle *
{
unsigned i;
return NULL;
if (!ctx)
goto err;
{
if (!helpkey)
goto err;
}
if (!ipad)
goto err;
if (!opad)
goto err;
{
ipad[i] ^= 0x36;
opad[i] ^= 0x5c;
}
if (!ret)
goto err;
return ret;
err:
return NULL;
}
void
const void *data,
{
}
{
grub_uint8_t *p;
if (!ctx2)
return GPG_ERR_OUT_OF_MEMORY;
return GPG_ERR_NO_ERROR;
}
{
if (!hnd)
return GPG_ERR_OUT_OF_MEMORY;
}
{
if (in == GPG_ERR_NO_ERROR)
return GRUB_ERR_NONE;
return GRUB_ACCESS_DENIED;
}
int
{
{
counter++;
}
return !!counter;
}
int
{
#ifdef GRUB_UTIL
struct termios s, t;
int tty_changed = 0;
char *ptr;
/* Disable echoing. Based on glibc. */
{
/* Save the old one. */
s = t;
/* Tricky, tricky. */
}
else
tty_changed = 0;
*ptr-- = 0;
/* Restore the original setting. */
if (tty_changed)
grub_xputs ("\n");
grub_refresh ();
return 1;
#else
unsigned cur_len = 0;
int key;
while (1)
{
key = grub_getkey ();
break;
if (key == '\e')
{
cur_len = 0;
break;
}
if (key == '\b')
{
cur_len--;
continue;
}
if (!grub_isprint (key))
continue;
}
grub_xputs ("\n");
grub_refresh ();
return (key != '\e');
#endif
}