First try to gcry glue
This commit is contained in:
parent
34f4a5b005
commit
c9b1ebc10b
7 changed files with 401 additions and 1 deletions
138
include/grub/crypto.h
Normal file
138
include/grub/crypto.h
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
|
||||
* 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* 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_CIPHER_HEADER
|
||||
#define GRUB_CIPHER_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPG_ERR_NO_ERROR,
|
||||
GPG_ERR_BAD_MPI,
|
||||
GPG_ERR_BAD_SECKEY,
|
||||
GPG_ERR_BAD_SIGNATURE,
|
||||
GPG_ERR_CIPHER_ALGO,
|
||||
GPG_ERR_CONFLICT,
|
||||
GPG_ERR_DECRYPT_FAILED,
|
||||
GPG_ERR_DIGEST_ALGO,
|
||||
GPG_ERR_GENERAL,
|
||||
GPG_ERR_INTERNAL,
|
||||
GPG_ERR_INV_ARG,
|
||||
GPG_ERR_INV_CIPHER_MODE,
|
||||
GPG_ERR_INV_FLAG,
|
||||
GPG_ERR_INV_KEYLEN,
|
||||
GPG_ERR_INV_OBJ,
|
||||
GPG_ERR_INV_OP,
|
||||
GPG_ERR_INV_SEXP,
|
||||
GPG_ERR_INV_VALUE,
|
||||
GPG_ERR_MISSING_VALUE,
|
||||
GPG_ERR_NO_ENCRYPTION_SCHEME,
|
||||
GPG_ERR_NO_OBJ,
|
||||
GPG_ERR_NO_PRIME,
|
||||
GPG_ERR_NO_SIGNATURE_SCHEME,
|
||||
GPG_ERR_NOT_FOUND,
|
||||
GPG_ERR_NOT_IMPLEMENTED,
|
||||
GPG_ERR_NOT_SUPPORTED,
|
||||
GPG_ERROR_CFLAGS,
|
||||
GPG_ERR_PUBKEY_ALGO,
|
||||
GPG_ERR_SELFTEST_FAILED,
|
||||
GPG_ERR_TOO_SHORT,
|
||||
GPG_ERR_UNSUPPORTED,
|
||||
GPG_ERR_WEAK_KEY,
|
||||
GPG_ERR_WRONG_KEY_USAGE,
|
||||
GPG_ERR_WRONG_PUBKEY_ALGO,
|
||||
} gcry_err_code_t;
|
||||
|
||||
enum gcry_cipher_modes
|
||||
{
|
||||
GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */
|
||||
GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */
|
||||
GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */
|
||||
GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */
|
||||
GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */
|
||||
GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */
|
||||
GCRY_CIPHER_MODE_CTR = 6 /* Counter. */
|
||||
};
|
||||
|
||||
/* Type for the cipher_setkey function. */
|
||||
typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c,
|
||||
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;
|
||||
} gcry_cipher_oid_spec_t;
|
||||
|
||||
/* Module specification structure for ciphers. */
|
||||
typedef struct gcry_cipher_spec
|
||||
{
|
||||
const char *name;
|
||||
const char **aliases;
|
||||
gcry_cipher_oid_spec_t *oids;
|
||||
grub_size_t blocksize;
|
||||
grub_size_t keylen;
|
||||
grub_size_t contextsize;
|
||||
gcry_cipher_setkey_t setkey;
|
||||
gcry_cipher_encrypt_t encrypt;
|
||||
gcry_cipher_decrypt_t decrypt;
|
||||
gcry_cipher_stencrypt_t stencrypt;
|
||||
gcry_cipher_stdecrypt_t stdecrypt;
|
||||
} gcry_cipher_spec_t;
|
||||
|
||||
struct grub_cipher
|
||||
{
|
||||
struct grub_cipher *next;
|
||||
const char *name;
|
||||
};
|
||||
typedef struct grub_cipher *grub_cipher_t;
|
||||
|
||||
extern grub_cipher_t EXPORT_VAR (grub_ciphers);
|
||||
void EXPORT_FUNC(grub_burn_stack) (grub_size_t size);
|
||||
|
||||
|
||||
#endif
|
36
include/grub/gcry_wrap.h
Normal file
36
include/grub/gcry_wrap.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GCRY_WRAP_HEADER
|
||||
#define GRUB_GCRY_WRAP_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/crypto.h>
|
||||
|
||||
typedef grub_uint32_t u32;
|
||||
typedef grub_uint16_t u16;
|
||||
typedef grub_uint8_t byte;
|
||||
typedef grub_size_t size_t;
|
||||
|
||||
#define _gcry_burn_stack grub_burn_stack
|
||||
#define log_error(fmt, args...) grub_dprintf ("crypto", fmt, ## args)
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue