2
* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4
* This file is part of GNUPG.
6
* GNUPG is free software; you can redistribute it and/or modify
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
7
8
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* the Free Software Foundation; either version 3 of the License, or
9
10
* (at your option) any later version.
11
* GNUPG is distributed in the hope that it will be useful,
12
* GnuPG is distributed in the hope that it will be useful,
12
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15
* GNU General Public License for more details.
16
17
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18
* along with this program; if not, see <http://www.gnu.org/licenses/>.
20
20
#ifndef G10_CIPHER_H
21
21
#define G10_CIPHER_H
23
23
#include <gcrypt.h>
25
#define CIPHER_ALGO_NONE GCRY_CIPHER_NONE
26
#define CIPHER_ALGO_IDEA GCRY_CIPHER_IDEA
27
#define CIPHER_ALGO_3DES GCRY_CIPHER_3DES
28
#define CIPHER_ALGO_CAST5 GCRY_CIPHER_CAST5
29
#define CIPHER_ALGO_BLOWFISH GCRY_CIPHER_BLOWFISH /* 128 bit */
30
#define CIPHER_ALGO_SAFER_SK128 GCRY_CIPHER_SK128
31
#define CIPHER_ALGO_DES_SK GCRY_CIPHER_DES_SK
32
#define CIPHER_ALGO_AES GCRY_CIPHER_AES
33
#define CIPHER_ALGO_AES192 GCRY_CIPHER_AES192
34
#define CIPHER_ALGO_AES256 GCRY_CIPHER_AES256
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
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
35
44
#define CIPHER_ALGO_RIJNDAEL CIPHER_ALGO_AES
36
45
#define CIPHER_ALGO_RIJNDAEL192 CIPHER_ALGO_AES192
37
46
#define CIPHER_ALGO_RIJNDAEL256 CIPHER_ALGO_AES256
38
#define CIPHER_ALGO_TWOFISH GCRY_CIPHER_TWOFISH /* 256 bit */
39
#define CIPHER_ALGO_DUMMY 110 /* no encryption at all */
41
#define PUBKEY_ALGO_RSA GCRY_PK_RSA
42
#define PUBKEY_ALGO_RSA_E GCRY_PK_RSA_E
43
#define PUBKEY_ALGO_RSA_S GCRY_PK_RSA_S
44
#define PUBKEY_ALGO_ELGAMAL_E GCRY_PK_ELG_E
45
#define PUBKEY_ALGO_DSA GCRY_PK_DSA
46
#define PUBKEY_ALGO_ELGAMAL GCRY_PK_ELG
48
#define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN
49
#define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR
50
#define PUBKEY_USAGE_CERT 4 /* key is also good to certify other keys*/
51
#define PUBKEY_USAGE_AUTH 8
53
#define DIGEST_ALGO_MD5 GCRY_MD_MD5
54
#define DIGEST_ALGO_SHA1 GCRY_MD_SHA1
55
#define DIGEST_ALGO_RMD160 GCRY_MD_RMD160
56
#define DIGEST_ALGO_SHA256 GCRY_MD_SHA256
57
#define DIGEST_ALGO_SHA384 GCRY_MD_SHA384
58
#define DIGEST_ALGO_SHA512 GCRY_MD_SHA512
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_CAMELLIA256 12
51
#define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */
53
#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA
54
#define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */
55
#define PUBKEY_ALGO_RSA_S /* 3 */ GCRY_PK_RSA_S /* RSA sign only. */
56
#define PUBKEY_ALGO_ELGAMAL_E /* 16 */ GCRY_PK_ELG_E /* Elgamal encr only */
57
#define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA
58
#define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */
60
#define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */
61
#define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */
62
#define PUBKEY_USAGE_CERT GCRY_PK_USAGE_CERT /* Also good to certify keys. */
63
#define PUBKEY_USAGE_AUTH GCRY_PK_USAGE_AUTH /* Good for authentication. */
64
#define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN /* Unknown usage flag. */
66
#define DIGEST_ALGO_MD5 /* 1 */ GCRY_MD_MD5
67
#define DIGEST_ALGO_SHA1 /* 2 */ GCRY_MD_SHA1
68
#define DIGEST_ALGO_RMD160 /* 3 */ GCRY_MD_RMD160
69
/* 4, 5, 6, and 7 are reserved */
70
#define DIGEST_ALGO_SHA256 /* 8 */ GCRY_MD_SHA256
71
#define DIGEST_ALGO_SHA384 /* 9 */ GCRY_MD_SHA384
72
#define DIGEST_ALGO_SHA512 /* 10 */ GCRY_MD_SHA512
73
/* SHA224 is only available in libgcrypt 1.4.0; thus we
74
can't use the GCRY macro here. */
75
#define DIGEST_ALGO_SHA224 /* 11 */ 11 /* GCRY_MD_SHA224 */
60
77
#define COMPRESS_ALGO_NONE 0
61
78
#define COMPRESS_ALGO_ZIP 1
62
79
#define COMPRESS_ALGO_ZLIB 2
80
#define COMPRESS_ALGO_BZIP2 3
64
82
#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
65
83
|| (a)==PUBKEY_ALGO_RSA_S )
66
#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL || (a)==PUBKEY_ALGO_ELGAMAL_E)
84
#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E)
85
#define is_DSA(a) ((a)==PUBKEY_ALGO_DSA)
71
int algo_info_printed;
73
byte key[32]; /* this is the largest used keylen (256 bit) */
87
/* The data encryption key object. */
92
int algo_info_printed;
95
byte key[32]; /* This is the largest used keylen (256 bit). */
77
#ifndef EXTERN_UNLESS_MAIN_MODULE
78
#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
79
#define EXTERN_UNLESS_MAIN_MODULE extern
81
#define EXTERN_UNLESS_MAIN_MODULE
84
EXTERN_UNLESS_MAIN_MODULE int g10_opt_verbose;
85
EXTERN_UNLESS_MAIN_MODULE const char *g10_opt_homedir;
100
/* Constants to allocate static MPI arrays. */
89
101
#define PUBKEY_MAX_NPKEY 4
90
102
#define PUBKEY_MAX_NSKEY 6
91
103
#define PUBKEY_MAX_NSIG 2
92
104
#define PUBKEY_MAX_NENC 2
94
#define MD_HANDLE gcry_md_hd_t
95
#define CIPHER_HANDLE gcry_cipher_hd_t
97
106
#endif /*G10_CIPHER_H*/