Fix for extended length Le in decipher
[gnupg.git] / include / cipher.h
blob8e198283d5559535de1b54f43d680f335edfa589
1 /* cipher.h - Definitions for OpenPGP
2 * Copyright (C) 1998, 1999, 2000, 2001, 2006,
3 * 2007 Free Software Foundation, Inc.
5 * This file is part of GnuPG.
7 * GnuPG is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * GnuPG is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef G10_CIPHER_H
21 #define G10_CIPHER_H
23 #include <gcrypt.h>
25 /* Macros for compatibility with older libgcrypt versions. */
26 #ifndef GCRY_PK_USAGE_CERT
27 # define GCRY_PK_USAGE_CERT 4
28 # define GCRY_PK_USAGE_AUTH 8
29 # define GCRY_PK_USAGE_UNKN 128
30 #endif
33 /* Constants for OpenPGP. */
35 #define CIPHER_ALGO_NONE /* 0 */ GCRY_CIPHER_NONE
36 #define CIPHER_ALGO_IDEA /* 1 */ GCRY_CIPHER_IDEA
37 #define CIPHER_ALGO_3DES /* 2 */ GCRY_CIPHER_3DES
38 #define CIPHER_ALGO_CAST5 /* 3 */ GCRY_CIPHER_CAST5
39 #define CIPHER_ALGO_BLOWFISH /* 4 */ GCRY_CIPHER_BLOWFISH /* 128 bit */
40 /* 5 & 6 are reserved */
41 #define CIPHER_ALGO_AES /* 7 */ GCRY_CIPHER_AES
42 #define CIPHER_ALGO_AES192 /* 8 */ GCRY_CIPHER_AES192
43 #define CIPHER_ALGO_AES256 /* 9 */ GCRY_CIPHER_AES256
44 #define CIPHER_ALGO_RIJNDAEL CIPHER_ALGO_AES
45 #define CIPHER_ALGO_RIJNDAEL192 CIPHER_ALGO_AES192
46 #define CIPHER_ALGO_RIJNDAEL256 CIPHER_ALGO_AES256
47 #define CIPHER_ALGO_TWOFISH /* 10 */ GCRY_CIPHER_TWOFISH /* 256 bit */
48 /* Note: Camellia ids don't match those used by libgcrypt. */
49 #define CIPHER_ALGO_CAMELLIA128 11
50 #define CIPHER_ALGO_CAMELLIA192 12
51 #define CIPHER_ALGO_CAMELLIA256 13
52 #define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */
54 #define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA
55 #define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */
56 #define PUBKEY_ALGO_RSA_S /* 3 */ GCRY_PK_RSA_S /* RSA sign only. */
57 #define PUBKEY_ALGO_ELGAMAL_E /* 16 */ GCRY_PK_ELG_E /* Elgamal encr only */
58 #define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA
59 #define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */
61 #define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */
62 #define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */
63 #define PUBKEY_USAGE_CERT GCRY_PK_USAGE_CERT /* Also good to certify keys. */
64 #define PUBKEY_USAGE_AUTH GCRY_PK_USAGE_AUTH /* Good for authentication. */
65 #define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN /* Unknown usage flag. */
67 #define DIGEST_ALGO_MD5 /* 1 */ GCRY_MD_MD5
68 #define DIGEST_ALGO_SHA1 /* 2 */ GCRY_MD_SHA1
69 #define DIGEST_ALGO_RMD160 /* 3 */ GCRY_MD_RMD160
70 /* 4, 5, 6, and 7 are reserved */
71 #define DIGEST_ALGO_SHA256 /* 8 */ GCRY_MD_SHA256
72 #define DIGEST_ALGO_SHA384 /* 9 */ GCRY_MD_SHA384
73 #define DIGEST_ALGO_SHA512 /* 10 */ GCRY_MD_SHA512
74 /* SHA224 is only available in libgcrypt 1.4.0; thus we
75 can't use the GCRY macro here. */
76 #define DIGEST_ALGO_SHA224 /* 11 */ 11 /* GCRY_MD_SHA224 */
78 #define COMPRESS_ALGO_NONE 0
79 #define COMPRESS_ALGO_ZIP 1
80 #define COMPRESS_ALGO_ZLIB 2
81 #define COMPRESS_ALGO_BZIP2 3
83 #define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
84 || (a)==PUBKEY_ALGO_RSA_S )
85 #define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E)
86 #define is_DSA(a) ((a)==PUBKEY_ALGO_DSA)
88 /* The data encryption key object. */
89 typedef struct
91 int algo;
92 int keylen;
93 int algo_info_printed;
94 int use_mdc;
95 int symmetric;
96 byte key[32]; /* This is the largest used keylen (256 bit). */
97 char s2k_cacheid[1+16+1];
98 } DEK;
102 /* Constants to allocate static MPI arrays. */
103 #define PUBKEY_MAX_NPKEY 4
104 #define PUBKEY_MAX_NSKEY 6
105 #define PUBKEY_MAX_NSIG 2
106 #define PUBKEY_MAX_NENC 2
108 #endif /*G10_CIPHER_H*/