3 * PGP related functions.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2001, 2002 Niels Möller
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 #ifndef NETTLE_PGP_H_INCLUDED
27 #define NETTLE_PGP_H_INCLUDED
31 #include "nettle-types.h"
39 #define pgp_put_uint32 nettle_pgp_put_uint32
40 #define pgp_put_uint16 nettle_pgp_put_uint16
41 #define pgp_put_mpi nettle_pgp_put_mpi
42 #define pgp_put_string nettle_pgp_put_string
43 #define pgp_put_length nettle_pgp_put_length
44 #define pgp_put_header nettle_pgp_put_header
45 #define pgp_put_header_length nettle_pgp_put_header_length
46 #define pgp_sub_packet_start nettle_pgp_sub_packet_start
47 #define pgp_put_sub_packet nettle_pgp_put_sub_packet
48 #define pgp_sub_packet_end nettle_pgp_sub_packet_end
49 #define pgp_put_public_rsa_key nettle_pgp_put_public_rsa_key
50 #define pgp_put_rsa_sha1_signature nettle_pgp_put_rsa_sha1_signature
51 #define pgp_put_userid nettle_pgp_put_userid
52 #define pgp_crc24 nettle_pgp_crc24
53 #define pgp_armor nettle_pgp_armor
56 struct rsa_public_key
;
57 struct rsa_private_key
;
61 pgp_put_uint32(struct nettle_buffer
*buffer
, uint32_t i
);
64 pgp_put_uint16(struct nettle_buffer
*buffer
, unsigned i
);
67 pgp_put_mpi(struct nettle_buffer
*buffer
, const mpz_t x
);
70 pgp_put_string(struct nettle_buffer
*buffer
,
75 pgp_put_length(struct nettle_buffer
*buffer
,
79 pgp_put_header(struct nettle_buffer
*buffer
,
80 unsigned tag
, unsigned length
);
83 pgp_put_header_length(struct nettle_buffer
*buffer
,
84 /* start of the header */
89 pgp_sub_packet_start(struct nettle_buffer
*buffer
);
92 pgp_put_sub_packet(struct nettle_buffer
*buffer
,
98 pgp_sub_packet_end(struct nettle_buffer
*buffer
, unsigned start
);
101 pgp_put_public_rsa_key(struct nettle_buffer
*,
102 const struct rsa_public_key
*key
,
106 pgp_put_rsa_sha1_signature(struct nettle_buffer
*buffer
,
107 const struct rsa_private_key
*key
,
108 const uint8_t *keyid
,
110 struct sha1_ctx
*hash
);
113 pgp_put_userid(struct nettle_buffer
*buffer
,
115 const uint8_t *name
);
118 pgp_crc24(unsigned length
, const uint8_t *data
);
121 pgp_armor(struct nettle_buffer
*buffer
,
124 const uint8_t *data
);
126 /* Values that can be passed to pgp_put_header when the size of the
127 * length field, but not the length itself, is known. Also the minimum length
128 * for the given field size. */
131 PGP_LENGTH_ONE_OCTET
= 0,
132 PGP_LENGTH_TWO_OCTETS
= 192,
133 PGP_LENGTH_FOUR_OCTETS
= 8384,
136 enum pgp_public_key_algorithm
141 PGP_EL_GAMAL_ENCRYPT
= 16,
146 enum pgp_symmetric_algorithm
159 enum pgp_compression_algorithm
161 PGP_UNCOMPRESSED
= 0,
166 enum pgp_hash_algorithm
178 PGP_TAG_PUBLIC_SESSION_KEY
= 1,
179 PGP_TAG_SIGNATURE
= 2,
180 PGP_TAG_SYMMETRIC_SESSION_KEY
= 3,
181 PGP_TAG_ONE_PASS_SIGNATURE
= 4,
182 PGP_TAG_SECRET_KEY
= 5,
183 PGP_TAG_PUBLIC_KEY
= 6,
184 PGP_TAG_SECRET_SUBKEY
= 7,
185 PGP_TAG_COMPRESSED
= 8,
186 PGP_TAG_ENCRYPTED
= 9,
188 PGP_TAG_LITERAL
= 11,
191 PGP_TAG_PUBLIC_SUBKEY
= 14,
194 enum pgp_signature_type
198 PGP_SIGN_STANDALONE
= 2,
199 PGP_SIGN_CERTIFICATION
= 0x10,
200 PGP_SIGN_CERTIFICATION_PERSONA
= 0x11,
201 PGP_SIGN_CERTIFICATION_CASUAL
= 0x12,
202 PGP_SIGN_CERTIFICATION_POSITIVE
= 0x13,
203 PGP_SIGN_SUBKEY
= 0x18,
205 PGP_SIGN_REVOCATION
= 0x20,
206 PGP_SIGN_REVOCATION_SUBKEY
= 0x28,
207 PGP_SIGN_REVOCATION_CERTIFICATE
= 0x30,
208 PGP_SIGN_TIMESTAMP
= 0x40,
211 enum pgp_subpacket_tag
213 PGP_SUBPACKET_CREATION_TIME
= 2,
214 PGP_SUBPACKET_SIGNATURE_EXPIRATION_TIME
= 3,
215 PGP_SUBPACKET_EXPORTABLE_CERTIFICATION
= 4,
216 PGP_SUBPACKET_TRUST_SIGNATURE
= 5,
217 PGP_SUBPACKET_REGULAR_EXPRESSION
= 6,
218 PGP_SUBPACKET_REVOCABLE
= 7,
219 PGP_SUBPACKET_KEY_EXPIRATION_TIME
= 9,
220 PGP_SUBPACKET_PLACEHOLDER
= 10 ,
221 PGP_SUBPACKET_PREFERRED_SYMMETRIC_ALGORITHMS
= 11,
222 PGP_SUBPACKET_REVOCATION_KEY
= 12,
223 PGP_SUBPACKET_ISSUER_KEY_ID
= 16,
224 PGP_SUBPACKET_NOTATION_DATA
= 20,
225 PGP_SUBPACKET_PREFERRED_HASH_ALGORITHMS
= 21,
226 PGP_SUBPACKET_PREFERRED_COMPRESSION_ALGORITHMS
= 22,
227 PGP_SUBPACKET_KEY_SERVER_PREFERENCES
= 23,
228 PGP_SUBPACKET_PREFERRED_KEY_SERVER
= 24,
229 PGP_SUBPACKET_PRIMARY_USER_ID
= 25,
230 PGP_SUBPACKET_POLICY_URL
= 26,
231 PGP_SUBPACKET_KEY_FLAGS
= 27,
232 PGP_SUBPACKET_SIGNERS_USER_ID
= 28,
233 PGP_SUBPACKET_REASON_FOR_REVOCATION
= 29,
240 #endif /* NETTLE_PGP_H_INCLUDED */