2006-04-19 13:26:11 +02:00
|
|
|
/* cipher.h - Definitions for OpenPGP
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
|
2003-06-05 09:14:21 +02:00
|
|
|
*
|
2006-04-19 13:26:11 +02:00
|
|
|
* This file is part of GnuPG.
|
2003-06-05 09:14:21 +02:00
|
|
|
*
|
2006-04-19 13:26:11 +02:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
2003-06-05 09:14:21 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2006-04-19 13:26:11 +02:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
2003-06-05 09:14:21 +02:00
|
|
|
* 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 this program; if not, write to the Free Software
|
2006-04-19 13:26:11 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
2003-06-05 09:14:21 +02:00
|
|
|
*/
|
|
|
|
#ifndef G10_CIPHER_H
|
|
|
|
#define G10_CIPHER_H
|
|
|
|
|
2003-06-18 21:56:13 +02:00
|
|
|
#include <gcrypt.h>
|
|
|
|
|
2006-04-19 13:26:11 +02:00
|
|
|
/* Macros for compatibility with older libgcrypt versions. */
|
|
|
|
#ifndef GCRY_PK_USAGE_CERT
|
|
|
|
# define GCRY_PK_USAGE_CERT 4
|
|
|
|
# define GCRY_PK_USAGE_AUTH 8
|
|
|
|
# define GCRY_PK_USAGE_UNKN 128
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Constants for OpenPGP. */
|
|
|
|
|
|
|
|
#define CIPHER_ALGO_NONE /* 0 */ GCRY_CIPHER_NONE
|
|
|
|
#define CIPHER_ALGO_IDEA /* 1 */ GCRY_CIPHER_IDEA
|
|
|
|
#define CIPHER_ALGO_3DES /* 2 */ GCRY_CIPHER_3DES
|
|
|
|
#define CIPHER_ALGO_CAST5 /* 3 */ GCRY_CIPHER_CAST5
|
|
|
|
#define CIPHER_ALGO_BLOWFISH /* 4 */ GCRY_CIPHER_BLOWFISH /* 128 bit */
|
|
|
|
/* 5 & 6 are reserved */
|
|
|
|
#define CIPHER_ALGO_AES /* 7 */ GCRY_CIPHER_AES
|
|
|
|
#define CIPHER_ALGO_AES192 /* 8 */ GCRY_CIPHER_AES192
|
|
|
|
#define CIPHER_ALGO_AES256 /* 9 */ GCRY_CIPHER_AES256
|
2003-06-05 09:14:21 +02:00
|
|
|
#define CIPHER_ALGO_RIJNDAEL CIPHER_ALGO_AES
|
|
|
|
#define CIPHER_ALGO_RIJNDAEL192 CIPHER_ALGO_AES192
|
|
|
|
#define CIPHER_ALGO_RIJNDAEL256 CIPHER_ALGO_AES256
|
2006-04-19 13:26:11 +02:00
|
|
|
#define CIPHER_ALGO_TWOFISH /* 10 */ GCRY_CIPHER_TWOFISH /* 256 bit */
|
|
|
|
#define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2006-04-19 13:26:11 +02:00
|
|
|
#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA
|
|
|
|
#define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */
|
|
|
|
#define PUBKEY_ALGO_RSA_S /* 3 */ GCRY_PK_RSA_S /* RSA sign only. */
|
|
|
|
#define PUBKEY_ALGO_ELGAMAL_E /* 16 */ GCRY_PK_ELG_E /* Elgamal encr only */
|
|
|
|
#define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA
|
|
|
|
#define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2006-04-19 13:26:11 +02:00
|
|
|
#define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */
|
|
|
|
#define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */
|
|
|
|
#define PUBKEY_USAGE_CERT GCRY_PK_USAGE_CERT /* Also good to certify keys. */
|
|
|
|
#define PUBKEY_USAGE_AUTH GCRY_PK_USAGE_AUTH /* Good for authentication. */
|
|
|
|
#define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN /* Unknown usage flag. */
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2006-04-19 13:26:11 +02:00
|
|
|
#define DIGEST_ALGO_MD5 /* 1 */ GCRY_MD_MD5
|
|
|
|
#define DIGEST_ALGO_SHA1 /* 2 */ GCRY_MD_SHA1
|
|
|
|
#define DIGEST_ALGO_RMD160 /* 3 */ GCRY_MD_RMD160
|
|
|
|
/* 4, 5, 6, and 7 are reserved */
|
|
|
|
#define DIGEST_ALGO_SHA256 /* 8 */ GCRY_MD_SHA256
|
|
|
|
#define DIGEST_ALGO_SHA384 /* 9 */ GCRY_MD_SHA384
|
|
|
|
#define DIGEST_ALGO_SHA512 /* 10 */ GCRY_MD_SHA512
|
2006-04-28 16:32:13 +02:00
|
|
|
/* SHA224 is as of now only defined in the libgcrypt SVN; thus we
|
|
|
|
can't use that macro. */
|
|
|
|
#define DIGEST_ALGO_SHA224 /* 11 */ 11 /* GCRY_MD_SHA224 */
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
#define COMPRESS_ALGO_NONE 0
|
|
|
|
#define COMPRESS_ALGO_ZIP 1
|
|
|
|
#define COMPRESS_ALGO_ZLIB 2
|
2006-04-19 13:26:11 +02:00
|
|
|
#define COMPRESS_ALGO_BZIP2 3
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
|
|
|
|
|| (a)==PUBKEY_ALGO_RSA_S )
|
2006-04-19 13:26:11 +02:00
|
|
|
#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E)
|
|
|
|
#define is_DSA(a) ((a)==PUBKEY_ALGO_DSA)
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2006-04-19 13:26:11 +02:00
|
|
|
/* The data encryption key object. */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int algo;
|
|
|
|
int keylen;
|
|
|
|
int algo_info_printed;
|
|
|
|
int use_mdc;
|
|
|
|
int symmetric;
|
|
|
|
byte key[32]; /* This is the largest used keylen (256 bit). */
|
2003-06-05 09:14:21 +02:00
|
|
|
} DEK;
|
|
|
|
|
|
|
|
|
2003-06-18 21:56:13 +02:00
|
|
|
|
2006-04-19 13:26:11 +02:00
|
|
|
/* Constants to allocate static MPI arrays. */
|
2003-06-05 09:14:21 +02:00
|
|
|
#define PUBKEY_MAX_NPKEY 4
|
|
|
|
#define PUBKEY_MAX_NSKEY 6
|
|
|
|
#define PUBKEY_MAX_NSIG 2
|
|
|
|
#define PUBKEY_MAX_NENC 2
|
|
|
|
|
|
|
|
#endif /*G10_CIPHER_H*/
|