pgp.h 4.57 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* pgp.h
 *
 * PGP related functions.
 */

/* nettle, low-level cryptographics library
 *
 * Copyright (C) 2001, 2002 Niels Mller
 *  
 * The nettle library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * The nettle library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with the nettle library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA.
 */

#ifndef NETTLE_PGP_H_INCLUDED
#define NETTLE_PGP_H_INCLUDED

#include "bignum.h"

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Name mangling */
#define pgp_put_uint32 nettle_pgp_put_uint32
#define pgp_put_uint16 nettle_pgp_put_uint16
#define pgp_put_mpi nettle_pgp_put_mpi
#define pgp_put_string nettle_pgp_put_string
#define pgp_put_length nettle_pgp_put_length
#define pgp_put_header nettle_pgp_put_header
#define pgp_put_header_length nettle_pgp_put_header_length
#define pgp_sub_packet_start nettle_pgp_sub_packet_start
#define pgp_put_sub_packet nettle_pgp_put_sub_packet
#define pgp_sub_packet_end nettle_pgp_sub_packet_end
#define pgp_put_userid nettle_pgp_put_userid
#define pgp_crc24 nettle_pgp_crc24
#define pgp_armor nettle_pgp_armor

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
struct nettle_buffer;

int
pgp_put_uint32(struct nettle_buffer *buffer, uint32_t i);

int
pgp_put_uint16(struct nettle_buffer *buffer, unsigned i);

int
pgp_put_mpi(struct nettle_buffer *buffer, mpz_t x);

int
pgp_put_string(struct nettle_buffer *buffer,
	       unsigned length,
	       const uint8_t *s);

int
pgp_put_length(struct nettle_buffer *buffer,
	       unsigned length);

int
pgp_put_header(struct nettle_buffer *buffer,
	       unsigned tag, unsigned length);

void
pgp_put_header_length(struct nettle_buffer *buffer,
		      /* start of the header */
		      unsigned start,
		      unsigned field_size);

unsigned
pgp_sub_packet_start(struct nettle_buffer *buffer);

int
pgp_put_sub_packet(struct nettle_buffer *buffer,
		   unsigned type,
		   unsigned length,
		   const uint8_t *data);

void
pgp_sub_packet_end(struct nettle_buffer *buffer, unsigned start);


int
pgp_put_userid(struct nettle_buffer *buffer,
	       unsigned length,
	       const uint8_t *name);

uint32_t
pgp_crc24(unsigned length, const uint8_t *data);

int
pgp_armor(struct nettle_buffer *buffer,
	  const char *tag,
	  unsigned length,
	  const uint8_t *data);

/* Values that can be passed to pgp_put_header when the size of the
 * length field, but not the length itself, is known. Also the minimum length
 * for the given field size. */
enum pgp_lengths
  {
    PGP_LENGTH_ONE_OCTET = 0,
    PGP_LENGTH_TWO_OCTETS = 192,
    PGP_LENGTH_FOUR_OCTETS = 8384,
  };

enum pgp_public_key_algorithm
  {
    PGP_RSA = 1,
    PGP_RSA_ENCRYPT = 2,
    PGP_RSA_SIGN = 3,
    PGP_EL_GAMAL_ENCRYPT = 16,
    PGP_DSA = 17,
    PGP_EL_GAMAL = 20,
  };

enum pgp_symmetric_algorithm
  {
    PGP_PLAINTEXT = 0,
    PGP_IDEA = 1,
    PGP_3DES = 2,
    PGP_CAST5 = 3,
    PGP_BLOWFISH = 4,
    PGP_SAFER_SK = 5,
    PGP_AES128 = 7,
    PGP_AES192 = 8,
    PGP_AES256 = 9,
  };

enum pgp_compression_algorithm
  {
    PGP_UNCOMPRESSED = 0,
    PGP_ZIP = 1,
    PGP_ZLIB = 2,
  };

enum pgp_hash_algorithm
  {
    PGP_MD5 = 1,
    PGP_SHA1 = 2,
    PGP_RIPEMD = 3,
    PGP_MD2 = 5,
    PGP_TIGER192 = 6,
    PGP_HAVAL = 7,
  };

enum pgp_tag
  {
    PGP_TAG_PUBLIC_SESSION_KEY = 1,
    PGP_TAG_SIGNATURE = 2,
    PGP_TAG_SYMMETRIC_SESSION_KEY = 3,
    PGP_TAG_ONE_PASS_SIGNATURE = 4,
    PGP_TAG_SECRET_KEY = 5,
    PGP_TAG_PUBLIC_KEY = 6,
    PGP_TAG_SECRET_SUBKEY = 7,
    PGP_TAG_COMPRESSED = 8,
    PGP_TAG_ENCRYPTED = 9,
    PGP_TAG_MARKER = 10,
    PGP_TAG_LITERAL = 11,
    PGP_TAG_TRUST = 12,
    PGP_TAG_USERID = 13,
    PGP_TAG_PUBLIC_SUBKEY = 14,
  };

enum pgp_signature_type
  {
    PGP_SIGN_BINARY = 0,
    PGP_SIGN_TEXT = 1,
    PGP_SIGN_STANDALONE = 2,
    PGP_SIGN_CERTIFICATION = 0x10,
    PGP_SIGN_CERTIFICATION_PERSONA = 0x11,
    PGP_SIGN_CERTIFICATION_CASUAL = 0x12,
    PGP_SIGN_CERTIFICATION_POSITIVE = 0x13,
    PGP_SIGN_SUBKEY = 0x18,
    PGP_SIGN_KEY = 0x1f,
    PGP_SIGN_REVOCATION = 0x20,
    PGP_SIGN_REVOCATION_SUBKEY = 0x28,
    PGP_SIGN_REVOCATION_CERTIFICATE = 0x30,
    PGP_SIGN_TIMESTAMP = 0x40,
  };

#endif /* NETTLE_PGP_H_INCLUDED */