moved PGP types to pgp/pgp.h
[strongswan.git] / src / libstrongswan / pgp / pgp.h
1 /*
2 * Copyright (C) 2002-2009 Andreas Steffen
3 *
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup pgpi pgp
19 * @{ @ingroup pgp
20 */
21
22 #ifndef PGP_H_
23 #define PGP_H_
24
25 typedef enum pgp_packet_tag_t pgp_packet_tag_t;
26 typedef enum pgp_sym_alg_t pgp_sym_alg_t;
27
28 #include <chunk.h>
29 #include <enum.h>
30
31 /**
32 * OpenPGP packet tags as defined in section 4.3 of RFC 4880
33 */
34 enum pgp_packet_tag_t {
35 PGP_PKT_RESERVED = 0,
36 PGP_PKT_PUBKEY_ENC_SESSION_KEY = 1,
37 PGP_PKT_SIGNATURE = 2,
38 PGP_PKT_SYMKEY_ENC_SESSION_KEY = 3,
39 PGP_PKT_ONE_PASS_SIGNATURE_PKT = 4,
40 PGP_PKT_SECRET_KEY = 5,
41 PGP_PKT_PUBLIC_KEY = 6,
42 PGP_PKT_SECRET_SUBKEY = 7,
43 PGP_PKT_COMPRESSED_DATA = 8,
44 PGP_PKT_SYMKEY_ENC_DATA = 9,
45 PGP_PKT_MARKER = 10,
46 PGP_PKT_LITERAL_DATA = 11,
47 PGP_PKT_TRUST = 12,
48 PGP_PKT_USER_ID = 13,
49 PGP_PKT_PUBLIC_SUBKEY = 14,
50 PGP_PKT_USER_ATTRIBUTE = 17,
51 PGP_PKT_SYM_ENC_INT_PROT_DATA = 18,
52 PGP_PKT_MOD_DETECT_CODE = 19
53 };
54
55 /**
56 * Enum names for pgp_packet_tag_t
57 */
58 extern enum_name_t *pgp_packet_tag_names;
59
60 /**
61 * OpenPGP public key algorithms as defined in section 9.1 of RFC 4880
62 */
63 enum pgp_pubkey_alg_t {
64 PGP_PUBKEY_ALG_RSA = 1,
65 PGP_PUBKEY_ALG_RSA_ENC_ONLY = 2,
66 PGP_PUBKEY_ALG_RSA_SIGN_ONLY = 3,
67 PGP_PUBKEY_ALG_ELGAMAL_ENC_ONLY = 16,
68 PGP_PUBKEY_ALG_DSA = 17,
69 PGP_PUBKEY_ALG_ECC = 18,
70 PGP_PUBKEY_ALG_ECDSA = 19,
71 PGP_PUBKEY_ALG_ELGAMAL = 20,
72 PGP_PUBKEY_ALG_DIFFIE_HELLMAN = 21,
73 };
74
75 /**
76 * Enum names for pgp_pubkey_alg_t
77 */
78 extern enum_name_t *pgp_pubkey_alg_names;
79
80 /**
81 * OpenPGP symmetric key algorithms as defined in section 9.2 of RFC 4880
82 */
83 enum pgp_sym_alg_t {
84 PGP_SYM_ALG_PLAIN = 0,
85 PGP_SYM_ALG_IDEA = 1,
86 PGP_SYM_ALG_3DES = 2,
87 PGP_SYM_ALG_CAST5 = 3,
88 PGP_SYM_ALG_BLOWFISH = 4,
89 PGP_SYM_ALG_SAFER = 5,
90 PGP_SYM_ALG_DES = 6,
91 PGP_SYM_ALG_AES_128 = 7,
92 PGP_SYM_ALG_AES_192 = 8,
93 PGP_SYM_ALG_AES_256 = 9,
94 PGP_SYM_ALG_TWOFISH = 10
95 };
96
97 /**
98 * Enum names for pgp_sym_alg_t
99 */
100 extern enum_name_t *pgp_sym_alg_names;
101
102 #define PGP_INVALID_LENGTH 0xffffffff
103
104 /**
105 * Returns the length of an OpenPGP (RFC 4880) packet
106 * The blob pointer is advanced past the length field
107 *
108 * @param blob pointer to an OpenPGP blob
109 * @param len size of the length field
110 * @return length of the next OpenPGP packet
111 */
112 size_t pgp_length(chunk_t *blob, size_t len);
113
114 #endif /** PGP_H_ @}*/