/*
* 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/>.
*/
/* Contains elements based on gcrypt-module.h and gcrypt.h.in.
If it's changed please update this file. */
#ifndef GRUB_CRYPTO_HEADER
typedef enum
{
enum gcry_cipher_modes
{
};
/* Type for the cipher_setkey function. */
const unsigned char *key,
unsigned keylen);
/* Type for the cipher_encrypt function. */
typedef void (*gcry_cipher_encrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf);
/* Type for the cipher_decrypt function. */
typedef void (*gcry_cipher_decrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf);
/* Type for the cipher_stencrypt function. */
typedef void (*gcry_cipher_stencrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf,
unsigned int n);
/* Type for the cipher_stdecrypt function. */
typedef void (*gcry_cipher_stdecrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf,
unsigned int n);
typedef struct gcry_cipher_oid_spec
{
const char *oid;
int mode;
/* Module specification structure for ciphers. */
typedef struct gcry_cipher_spec
{
const char *name;
const char **aliases;
#ifdef GRUB_UTIL
const char *modname;
#endif
/* Type for the md_init function. */
typedef void (*gcry_md_init_t) (void *c);
/* Type for the md_write function. */
/* Type for the md_final function. */
typedef void (*gcry_md_final_t) (void *c);
/* Type for the md_read function. */
typedef unsigned char *(*gcry_md_read_t) (void *c);
typedef struct gcry_md_oid_spec
{
const char *oidstring;
/* Module specification structure for message digests. */
typedef struct gcry_md_spec
{
const char *name;
unsigned char *asnoid;
int asnlen;
/* Block size, needed for HMAC. */
#ifdef GRUB_UTIL
const char *modname;
#endif
struct grub_crypto_cipher_handle
{
char ctx[0];
};
struct grub_crypto_hmac_handle;
const gcry_cipher_spec_t *
grub_crypto_lookup_cipher_by_name (const char *name);
const unsigned char *key,
unsigned keylen);
static inline void
{
}
static inline void
{
{
in1ptr++;
in2ptr++;
outptr++;
size--;
}
while (size >= sizeof (grub_uint64_t))
{
*(grub_uint64_t *) (void *) outptr
= (*(grub_uint64_t *) (void *) in1ptr
^ *(grub_uint64_t *) (void *) in2ptr);
in1ptr += sizeof (grub_uint64_t);
in2ptr += sizeof (grub_uint64_t);
outptr += sizeof (grub_uint64_t);
size -= sizeof (grub_uint64_t);
}
while (size)
{
in1ptr++;
in2ptr++;
outptr++;
size--;
}
}
void *iv_in);
void *iv);
void
void
void
void
void
const gcry_md_spec_t *
grub_crypto_lookup_md_by_name (const char *name);
struct grub_crypto_hmac_handle *
void
const void *data,
extern gcry_md_spec_t _gcry_digest_spec_md5;
extern gcry_md_spec_t _gcry_digest_spec_sha1;
/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant
of digest supplied by MD. Inputs are the password P of length PLEN,
the salt S of length SLEN, the iteration counter C (> 0), and the
desired derived output length DKLEN. Output buffer is DK which
must have room for at least DKLEN octets. The output buffer will
be filled with the derived data. */
unsigned int c,
int
grub_crypto_memcmp (const void *a, const void *b, grub_size_t n);
int
/* For indistinguishibility. */
extern void (*grub_crypto_autoload_hook) (const char *name);
#ifdef GRUB_UTIL
void grub_gcry_init_all (void);
void grub_gcry_fini_all (void);
#endif
#endif