Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:15

0001 /* pgp.h
0002 
0003    PGP related functions.
0004 
0005    Copyright (C) 2001, 2002 Niels Möller
0006 
0007    This file is part of GNU Nettle.
0008 
0009    GNU Nettle is free software: you can redistribute it and/or
0010    modify it under the terms of either:
0011 
0012      * the GNU Lesser General Public License as published by the Free
0013        Software Foundation; either version 3 of the License, or (at your
0014        option) any later version.
0015 
0016    or
0017 
0018      * the GNU General Public License as published by the Free
0019        Software Foundation; either version 2 of the License, or (at your
0020        option) any later version.
0021 
0022    or both in parallel, as here.
0023 
0024    GNU Nettle is distributed in the hope that it will be useful,
0025    but WITHOUT ANY WARRANTY; without even the implied warranty of
0026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027    General Public License for more details.
0028 
0029    You should have received copies of the GNU General Public License and
0030    the GNU Lesser General Public License along with this program.  If
0031    not, see http://www.gnu.org/licenses/.
0032 */
0033 
0034 #ifndef NETTLE_PGP_H_INCLUDED
0035 #define NETTLE_PGP_H_INCLUDED
0036 
0037 #include <time.h>
0038 
0039 #include "nettle-types.h"
0040 #include "bignum.h"
0041 
0042 #ifdef __cplusplus
0043 extern "C" {
0044 #endif
0045 
0046 /* Name mangling */
0047 #define pgp_put_uint32 nettle_pgp_put_uint32
0048 #define pgp_put_uint16 nettle_pgp_put_uint16
0049 #define pgp_put_mpi nettle_pgp_put_mpi
0050 #define pgp_put_string nettle_pgp_put_string
0051 #define pgp_put_length nettle_pgp_put_length
0052 #define pgp_put_header nettle_pgp_put_header
0053 #define pgp_put_header_length nettle_pgp_put_header_length
0054 #define pgp_sub_packet_start nettle_pgp_sub_packet_start
0055 #define pgp_put_sub_packet nettle_pgp_put_sub_packet
0056 #define pgp_sub_packet_end nettle_pgp_sub_packet_end
0057 #define pgp_put_public_rsa_key nettle_pgp_put_public_rsa_key
0058 #define pgp_put_rsa_sha1_signature nettle_pgp_put_rsa_sha1_signature
0059 #define pgp_put_userid nettle_pgp_put_userid
0060 #define pgp_crc24 nettle_pgp_crc24
0061 #define pgp_armor nettle_pgp_armor
0062 
0063 struct nettle_buffer;
0064 struct rsa_public_key;
0065 struct rsa_private_key;
0066 struct sha1_ctx;
0067 
0068 int
0069 pgp_put_uint32(struct nettle_buffer *buffer, uint32_t i);
0070 
0071 int
0072 pgp_put_uint16(struct nettle_buffer *buffer, unsigned i);
0073 
0074 int
0075 pgp_put_mpi(struct nettle_buffer *buffer, const mpz_t x);
0076 
0077 int
0078 pgp_put_string(struct nettle_buffer *buffer,
0079            unsigned length,
0080            const uint8_t *s);
0081 
0082 int
0083 pgp_put_length(struct nettle_buffer *buffer,
0084            unsigned length);
0085 
0086 int
0087 pgp_put_header(struct nettle_buffer *buffer,
0088            unsigned tag, unsigned length);
0089 
0090 void
0091 pgp_put_header_length(struct nettle_buffer *buffer,
0092               /* start of the header */
0093               unsigned start,
0094               unsigned field_size);
0095 
0096 unsigned
0097 pgp_sub_packet_start(struct nettle_buffer *buffer);
0098 
0099 int
0100 pgp_put_sub_packet(struct nettle_buffer *buffer,
0101            unsigned type,
0102            unsigned length,
0103            const uint8_t *data);
0104 
0105 void
0106 pgp_sub_packet_end(struct nettle_buffer *buffer, unsigned start);
0107 
0108 int
0109 pgp_put_public_rsa_key(struct nettle_buffer *,
0110                const struct rsa_public_key *key,
0111                time_t timestamp);
0112 
0113 int
0114 pgp_put_rsa_sha1_signature(struct nettle_buffer *buffer,
0115                const struct rsa_private_key *key,
0116                const uint8_t *keyid,
0117                unsigned type,
0118                struct sha1_ctx *hash);
0119 
0120 int
0121 pgp_put_userid(struct nettle_buffer *buffer,
0122            unsigned length,
0123            const uint8_t *name);
0124 
0125 uint32_t
0126 pgp_crc24(unsigned length, const uint8_t *data);
0127 
0128 int
0129 pgp_armor(struct nettle_buffer *buffer,
0130       const char *tag,
0131       unsigned length,
0132       const uint8_t *data);
0133 
0134 /* Values that can be passed to pgp_put_header when the size of the
0135  * length field, but not the length itself, is known. Also the minimum length
0136  * for the given field size. */
0137 enum pgp_lengths
0138   {
0139     PGP_LENGTH_ONE_OCTET = 0,
0140     PGP_LENGTH_TWO_OCTETS = 192,
0141     PGP_LENGTH_FOUR_OCTETS = 8384,
0142   };
0143 
0144 enum pgp_public_key_algorithm
0145   {
0146     PGP_RSA = 1,
0147     PGP_RSA_ENCRYPT = 2,
0148     PGP_RSA_SIGN = 3,
0149     PGP_EL_GAMAL_ENCRYPT = 16,
0150     PGP_DSA = 17,
0151     PGP_EL_GAMAL = 20,
0152   };
0153 
0154 enum pgp_symmetric_algorithm
0155   {
0156     PGP_PLAINTEXT = 0,
0157     PGP_IDEA = 1,
0158     PGP_3DES = 2,
0159     PGP_CAST5 = 3,
0160     PGP_BLOWFISH = 4,
0161     PGP_SAFER_SK = 5,
0162     PGP_AES128 = 7,
0163     PGP_AES192 = 8,
0164     PGP_AES256 = 9,
0165   };
0166 
0167 enum pgp_compression_algorithm
0168   {
0169     PGP_UNCOMPRESSED = 0,
0170     PGP_ZIP = 1,
0171     PGP_ZLIB = 2,
0172   };
0173 
0174 enum pgp_hash_algorithm
0175   {
0176     PGP_MD5 = 1,
0177     PGP_SHA1 = 2,
0178     PGP_RIPEMD = 3,
0179     PGP_MD2 = 5,
0180     PGP_TIGER192 = 6,
0181     PGP_HAVAL = 7,
0182   };
0183 
0184 enum pgp_tag
0185   {
0186     PGP_TAG_PUBLIC_SESSION_KEY = 1,
0187     PGP_TAG_SIGNATURE = 2,
0188     PGP_TAG_SYMMETRIC_SESSION_KEY = 3,
0189     PGP_TAG_ONE_PASS_SIGNATURE = 4,
0190     PGP_TAG_SECRET_KEY = 5,
0191     PGP_TAG_PUBLIC_KEY = 6,
0192     PGP_TAG_SECRET_SUBKEY = 7,
0193     PGP_TAG_COMPRESSED = 8,
0194     PGP_TAG_ENCRYPTED = 9,
0195     PGP_TAG_MARKER = 10,
0196     PGP_TAG_LITERAL = 11,
0197     PGP_TAG_TRUST = 12,
0198     PGP_TAG_USERID = 13,
0199     PGP_TAG_PUBLIC_SUBKEY = 14,
0200   };
0201 
0202 enum pgp_signature_type
0203   {
0204     PGP_SIGN_BINARY = 0,
0205     PGP_SIGN_TEXT = 1,
0206     PGP_SIGN_STANDALONE = 2,
0207     PGP_SIGN_CERTIFICATION = 0x10,
0208     PGP_SIGN_CERTIFICATION_PERSONA = 0x11,
0209     PGP_SIGN_CERTIFICATION_CASUAL = 0x12,
0210     PGP_SIGN_CERTIFICATION_POSITIVE = 0x13,
0211     PGP_SIGN_SUBKEY = 0x18,
0212     PGP_SIGN_KEY = 0x1f,
0213     PGP_SIGN_REVOCATION = 0x20,
0214     PGP_SIGN_REVOCATION_SUBKEY = 0x28,
0215     PGP_SIGN_REVOCATION_CERTIFICATE = 0x30,
0216     PGP_SIGN_TIMESTAMP = 0x40,
0217   };
0218 
0219 enum pgp_subpacket_tag
0220   {
0221     PGP_SUBPACKET_CREATION_TIME = 2,
0222     PGP_SUBPACKET_SIGNATURE_EXPIRATION_TIME = 3,
0223     PGP_SUBPACKET_EXPORTABLE_CERTIFICATION = 4,
0224     PGP_SUBPACKET_TRUST_SIGNATURE = 5,
0225     PGP_SUBPACKET_REGULAR_EXPRESSION = 6,
0226     PGP_SUBPACKET_REVOCABLE = 7,
0227     PGP_SUBPACKET_KEY_EXPIRATION_TIME = 9,
0228     PGP_SUBPACKET_PLACEHOLDER = 10 ,
0229     PGP_SUBPACKET_PREFERRED_SYMMETRIC_ALGORITHMS = 11,
0230     PGP_SUBPACKET_REVOCATION_KEY = 12,
0231     PGP_SUBPACKET_ISSUER_KEY_ID = 16,
0232     PGP_SUBPACKET_NOTATION_DATA = 20,
0233     PGP_SUBPACKET_PREFERRED_HASH_ALGORITHMS = 21,
0234     PGP_SUBPACKET_PREFERRED_COMPRESSION_ALGORITHMS = 22,
0235     PGP_SUBPACKET_KEY_SERVER_PREFERENCES = 23,
0236     PGP_SUBPACKET_PREFERRED_KEY_SERVER = 24,
0237     PGP_SUBPACKET_PRIMARY_USER_ID = 25,
0238     PGP_SUBPACKET_POLICY_URL = 26,
0239     PGP_SUBPACKET_KEY_FLAGS = 27,
0240     PGP_SUBPACKET_SIGNERS_USER_ID = 28,
0241     PGP_SUBPACKET_REASON_FOR_REVOCATION = 29,
0242   };
0243 
0244 #ifdef __cplusplus
0245 }
0246 #endif
0247 
0248 #endif /* NETTLE_PGP_H_INCLUDED */