nettle  3.7.3
About: Nettle is a low-level cryptographic library.
  Fossies Dox: nettle-3.7.3.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pgp.h
Go to the documentation of this file.
1 /* pgp.h
2 
3  PGP related functions.
4 
5  Copyright (C) 2001, 2002 Niels Möller
6 
7  This file is part of GNU Nettle.
8 
9  GNU Nettle is free software: you can redistribute it and/or
10  modify it under the terms of either:
11 
12  * the GNU Lesser General Public License as published by the Free
13  Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  or
17 
18  * the GNU General Public License as published by the Free
19  Software Foundation; either version 2 of the License, or (at your
20  option) any later version.
21 
22  or both in parallel, as here.
23 
24  GNU Nettle is distributed in the hope that it will be useful,
25  but WITHOUT ANY WARRANTY; without even the implied warranty of
26  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27  General Public License for more details.
28 
29  You should have received copies of the GNU General Public License and
30  the GNU Lesser General Public License along with this program. If
31  not, see http://www.gnu.org/licenses/.
32 */
33 
34 #ifndef NETTLE_PGP_H_INCLUDED
35 #define NETTLE_PGP_H_INCLUDED
36 
37 #include <time.h>
38 
39 #include "nettle-types.h"
40 #include "bignum.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /* Name mangling */
47 #define pgp_put_uint32 nettle_pgp_put_uint32
48 #define pgp_put_uint16 nettle_pgp_put_uint16
49 #define pgp_put_mpi nettle_pgp_put_mpi
50 #define pgp_put_string nettle_pgp_put_string
51 #define pgp_put_length nettle_pgp_put_length
52 #define pgp_put_header nettle_pgp_put_header
53 #define pgp_put_header_length nettle_pgp_put_header_length
54 #define pgp_sub_packet_start nettle_pgp_sub_packet_start
55 #define pgp_put_sub_packet nettle_pgp_put_sub_packet
56 #define pgp_sub_packet_end nettle_pgp_sub_packet_end
57 #define pgp_put_public_rsa_key nettle_pgp_put_public_rsa_key
58 #define pgp_put_rsa_sha1_signature nettle_pgp_put_rsa_sha1_signature
59 #define pgp_put_userid nettle_pgp_put_userid
60 #define pgp_crc24 nettle_pgp_crc24
61 #define pgp_armor nettle_pgp_armor
62 
63 struct nettle_buffer;
64 struct rsa_public_key;
65 struct rsa_private_key;
66 struct sha1_ctx;
67 
68 int
69 pgp_put_uint32(struct nettle_buffer *buffer, uint32_t i);
70 
71 int
72 pgp_put_uint16(struct nettle_buffer *buffer, unsigned i);
73 
74 int
75 pgp_put_mpi(struct nettle_buffer *buffer, const mpz_t x);
76 
77 int
78 pgp_put_string(struct nettle_buffer *buffer,
79  unsigned length,
80  const uint8_t *s);
81 
82 int
83 pgp_put_length(struct nettle_buffer *buffer,
84  unsigned length);
85 
86 int
87 pgp_put_header(struct nettle_buffer *buffer,
88  unsigned tag, unsigned length);
89 
90 void
92  /* start of the header */
93  unsigned start,
94  unsigned field_size);
95 
96 unsigned
97 pgp_sub_packet_start(struct nettle_buffer *buffer);
98 
99 int
100 pgp_put_sub_packet(struct nettle_buffer *buffer,
101  unsigned type,
102  unsigned length,
103  const uint8_t *data);
104 
105 void
106 pgp_sub_packet_end(struct nettle_buffer *buffer, unsigned start);
107 
108 int
110  const struct rsa_public_key *key,
111  time_t timestamp);
112 
113 int
115  const struct rsa_private_key *key,
116  const uint8_t *keyid,
117  unsigned type,
118  struct sha1_ctx *hash);
119 
120 int
121 pgp_put_userid(struct nettle_buffer *buffer,
122  unsigned length,
123  const uint8_t *name);
124 
125 uint32_t
126 pgp_crc24(unsigned length, const uint8_t *data);
127 
128 int
129 pgp_armor(struct nettle_buffer *buffer,
130  const char *tag,
131  unsigned length,
132  const uint8_t *data);
133 
134 /* Values that can be passed to pgp_put_header when the size of the
135  * length field, but not the length itself, is known. Also the minimum length
136  * for the given field size. */
138  {
142  };
143 
145  {
146  PGP_RSA = 1,
150  PGP_DSA = 17,
152  };
153 
155  {
157  PGP_IDEA = 1,
158  PGP_3DES = 2,
165  };
166 
168  {
170  PGP_ZIP = 1,
171  PGP_ZLIB = 2,
172  };
173 
175  {
176  PGP_MD5 = 1,
177  PGP_SHA1 = 2,
179  PGP_MD2 = 5,
182  };
183 
185  {
200  };
201 
203  {
212  PGP_SIGN_KEY = 0x1f,
217  };
218 
220  {
242  };
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif /* NETTLE_PGP_H_INCLUDED */
#define x
#define i
#define hash
__mpz_struct mpz_t[1]
Definition: mini-gmp.h:77
pgp_subpacket_tag
Definition: pgp.h:220
@ PGP_SUBPACKET_POLICY_URL
Definition: pgp.h:238
@ PGP_SUBPACKET_KEY_FLAGS
Definition: pgp.h:239
@ PGP_SUBPACKET_CREATION_TIME
Definition: pgp.h:221
@ PGP_SUBPACKET_PREFERRED_KEY_SERVER
Definition: pgp.h:236
@ PGP_SUBPACKET_PREFERRED_SYMMETRIC_ALGORITHMS
Definition: pgp.h:229
@ PGP_SUBPACKET_SIGNERS_USER_ID
Definition: pgp.h:240
@ PGP_SUBPACKET_REVOCATION_KEY
Definition: pgp.h:230
@ PGP_SUBPACKET_PREFERRED_HASH_ALGORITHMS
Definition: pgp.h:233
@ PGP_SUBPACKET_TRUST_SIGNATURE
Definition: pgp.h:224
@ PGP_SUBPACKET_EXPORTABLE_CERTIFICATION
Definition: pgp.h:223
@ PGP_SUBPACKET_KEY_SERVER_PREFERENCES
Definition: pgp.h:235
@ PGP_SUBPACKET_ISSUER_KEY_ID
Definition: pgp.h:231
@ PGP_SUBPACKET_NOTATION_DATA
Definition: pgp.h:232
@ PGP_SUBPACKET_PLACEHOLDER
Definition: pgp.h:228
@ PGP_SUBPACKET_REVOCABLE
Definition: pgp.h:226
@ PGP_SUBPACKET_KEY_EXPIRATION_TIME
Definition: pgp.h:227
@ PGP_SUBPACKET_REGULAR_EXPRESSION
Definition: pgp.h:225
@ PGP_SUBPACKET_PREFERRED_COMPRESSION_ALGORITHMS
Definition: pgp.h:234
@ PGP_SUBPACKET_PRIMARY_USER_ID
Definition: pgp.h:237
@ PGP_SUBPACKET_SIGNATURE_EXPIRATION_TIME
Definition: pgp.h:222
@ PGP_SUBPACKET_REASON_FOR_REVOCATION
Definition: pgp.h:241
#define pgp_put_header
Definition: pgp.h:52
#define pgp_put_userid
Definition: pgp.h:59
#define pgp_put_public_rsa_key
Definition: pgp.h:57
#define pgp_put_rsa_sha1_signature
Definition: pgp.h:58
#define pgp_put_sub_packet
Definition: pgp.h:55
pgp_compression_algorithm
Definition: pgp.h:168
@ PGP_ZLIB
Definition: pgp.h:171
@ PGP_UNCOMPRESSED
Definition: pgp.h:169
@ PGP_ZIP
Definition: pgp.h:170
#define pgp_crc24
Definition: pgp.h:60
pgp_hash_algorithm
Definition: pgp.h:175
@ PGP_HAVAL
Definition: pgp.h:181
@ PGP_TIGER192
Definition: pgp.h:180
@ PGP_RIPEMD
Definition: pgp.h:178
@ PGP_MD5
Definition: pgp.h:176
@ PGP_MD2
Definition: pgp.h:179
@ PGP_SHA1
Definition: pgp.h:177
#define pgp_put_string
Definition: pgp.h:50
pgp_symmetric_algorithm
Definition: pgp.h:155
@ PGP_IDEA
Definition: pgp.h:157
@ PGP_PLAINTEXT
Definition: pgp.h:156
@ PGP_CAST5
Definition: pgp.h:159
@ PGP_AES192
Definition: pgp.h:163
@ PGP_BLOWFISH
Definition: pgp.h:160
@ PGP_AES256
Definition: pgp.h:164
@ PGP_SAFER_SK
Definition: pgp.h:161
@ PGP_AES128
Definition: pgp.h:162
@ PGP_3DES
Definition: pgp.h:158
#define pgp_put_uint32
Definition: pgp.h:47
pgp_public_key_algorithm
Definition: pgp.h:145
@ PGP_DSA
Definition: pgp.h:150
@ PGP_RSA_SIGN
Definition: pgp.h:148
@ PGP_RSA
Definition: pgp.h:146
@ PGP_EL_GAMAL_ENCRYPT
Definition: pgp.h:149
@ PGP_RSA_ENCRYPT
Definition: pgp.h:147
@ PGP_EL_GAMAL
Definition: pgp.h:151
#define pgp_sub_packet_start
Definition: pgp.h:54
#define pgp_put_uint16
Definition: pgp.h:48
#define pgp_put_mpi
Definition: pgp.h:49
#define pgp_put_header_length
Definition: pgp.h:53
#define pgp_sub_packet_end
Definition: pgp.h:56
#define pgp_armor
Definition: pgp.h:61
pgp_lengths
Definition: pgp.h:138
@ PGP_LENGTH_TWO_OCTETS
Definition: pgp.h:140
@ PGP_LENGTH_ONE_OCTET
Definition: pgp.h:139
@ PGP_LENGTH_FOUR_OCTETS
Definition: pgp.h:141
#define pgp_put_length
Definition: pgp.h:51
pgp_signature_type
Definition: pgp.h:203
@ PGP_SIGN_REVOCATION_SUBKEY
Definition: pgp.h:214
@ PGP_SIGN_TEXT
Definition: pgp.h:205
@ PGP_SIGN_STANDALONE
Definition: pgp.h:206
@ PGP_SIGN_BINARY
Definition: pgp.h:204
@ PGP_SIGN_CERTIFICATION
Definition: pgp.h:207
@ PGP_SIGN_TIMESTAMP
Definition: pgp.h:216
@ PGP_SIGN_REVOCATION_CERTIFICATE
Definition: pgp.h:215
@ PGP_SIGN_CERTIFICATION_PERSONA
Definition: pgp.h:208
@ PGP_SIGN_CERTIFICATION_POSITIVE
Definition: pgp.h:210
@ PGP_SIGN_SUBKEY
Definition: pgp.h:211
@ PGP_SIGN_REVOCATION
Definition: pgp.h:213
@ PGP_SIGN_KEY
Definition: pgp.h:212
@ PGP_SIGN_CERTIFICATION_CASUAL
Definition: pgp.h:209
pgp_tag
Definition: pgp.h:185
@ PGP_TAG_SYMMETRIC_SESSION_KEY
Definition: pgp.h:188
@ PGP_TAG_SECRET_KEY
Definition: pgp.h:190
@ PGP_TAG_PUBLIC_KEY
Definition: pgp.h:191
@ PGP_TAG_PUBLIC_SUBKEY
Definition: pgp.h:199
@ PGP_TAG_ONE_PASS_SIGNATURE
Definition: pgp.h:189
@ PGP_TAG_TRUST
Definition: pgp.h:197
@ PGP_TAG_SIGNATURE
Definition: pgp.h:187
@ PGP_TAG_USERID
Definition: pgp.h:198
@ PGP_TAG_COMPRESSED
Definition: pgp.h:193
@ PGP_TAG_SECRET_SUBKEY
Definition: pgp.h:192
@ PGP_TAG_LITERAL
Definition: pgp.h:196
@ PGP_TAG_ENCRYPTED
Definition: pgp.h:194
@ PGP_TAG_PUBLIC_SESSION_KEY
Definition: pgp.h:186
@ PGP_TAG_MARKER
Definition: pgp.h:195
Definition: sha1.h:59