mixmaster

mixmaster 3.0 patched for libressl
git clone git://parazyd.org/mixmaster.git
Log | Files | Refs | README

pgp.h (6048B)


      1 /* Mixmaster version 3.0  --  (C) 1999 - 2006 Anonymizer Inc. and others.
      2 
      3    Mixmaster may be redistributed and modified under certain conditions.
      4    This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
      5    ANY KIND, either express or implied. See the file COPYRIGHT for
      6    details.
      7 
      8    OpenPGP messages
      9    $Id: pgp.h 934 2006-06-24 13:40:39Z rabbi $ */
     10 
     11 
     12 #ifdef USE_PGP
     13 #ifndef _PGP_H
     14 #include "mix3.h"
     15 #ifdef USE_OPENSSL
     16 #include <openssl/opensslv.h>
     17 #endif /* USE_OPENSSL */
     18 
     19 /* in the PGP Version header, list the same information as all other
     20    versions of Mixmaster to prevent anonymity set division. */
     21 #define CLOAK
     22 
     23 /* try to make the messages look similar to PGP 2.6.3i output
     24    (compression is not always the same though). */
     25 #define MIMIC
     26 
     27 /* packet types */
     28 #define PGP_SESKEY 1
     29 #define PGP_SIG 2
     30 #define PGP_SYMSESKEY 3
     31 #define PGP_OSIG 4
     32 #define PGP_SECKEY 5
     33 #define PGP_PUBKEY 6
     34 #define PGP_SECSUBKEY 7
     35 #define PGP_COMPRESSED 8
     36 #define PGP_ENCRYPTED 9
     37 #define PGP_MARKER 10
     38 #define PGP_LITERAL 11
     39 #define PGP_TRUST 12
     40 #define PGP_USERID 13
     41 #define PGP_PUBSUBKEY 14
     42 #define PGP_ENCRYPTEDMDC 18
     43 #define PGP_MDC 19
     44 
     45 /* symmetric algorithms */
     46 #define PGP_K_ANY 0
     47 #define PGP_K_IDEA 1
     48 #define PGP_K_3DES 2
     49 #define PGP_K_CAST5 3
     50 #define PGP_K_BF 4
     51 #define PGP_K_AES128 7
     52 #define PGP_K_AES192 8
     53 #define PGP_K_AES256 9
     54 
     55 /* hash algorithms */
     56 #define PGP_H_MD5 1
     57 #define PGP_H_SHA1 2
     58 #define PGP_H_RIPEMD 3
     59 
     60 /* signature types */
     61 #define PGP_SIG_BINARY 0
     62 #define PGP_SIG_CANONIC 1
     63 #define PGP_SIG_CERT 0x10
     64 #define PGP_SIG_CERT1 0x11
     65 #define PGP_SIG_CERT2 0x12
     66 #define PGP_SIG_CERT3 0x13
     67 #define isPGP_SIG_CERT(x) (x >= PGP_SIG_CERT && x <= PGP_SIG_CERT3)
     68 #define PGP_SIG_BINDSUBKEY 0x18
     69 #define PGP_SIG_KEYREVOKE 0x20
     70 #define PGP_SIG_SUBKEYREVOKE 0x28
     71 #define PGP_SIG_CERTREVOKE 0x30
     72 
     73 /* signature subpacket types */
     74 #define PGP_SUB_CREATIME 2
     75 #define PGP_SUB_CERTEXPIRETIME 3
     76 #define PGP_SUB_KEYEXPIRETIME 9
     77 #define PGP_SUB_PSYMMETRIC 11
     78 #define PGP_SUB_ISSUER 16
     79 #define PGP_SUB_PRIMARY 25
     80 #define PGP_SUB_FEATURES 30
     81 
     82 #define ARMORED 1
     83 
     84 /* publick key algorithm operation modes */
     85 
     86 #define PK_ENCRYPT 1
     87 #define PK_DECRYPT 2
     88 #define PK_SIGN 3
     89 #define PK_VERIFY 4
     90 
     91 #define MD5PREFIX "\x30\x20\x30\x0C\x06\x08\x2A\x86\x48\x86\xF7\x0D\x02\x05\x05\x00\x04\x10"
     92 #define SHA1PREFIX "\x30\x21\x30\x09\x06\x05\x2b\x0E\x03\x02\x1A\x05\x00\x04\x14"
     93 
     94 typedef struct {
     95   int ok;
     96   BUFFER *userid;
     97   byte sigtype;
     98   long sigtime;
     99   byte hash[16];
    100 } pgpsig;
    101 
    102 /* internal error codes */
    103 #define PGP_SIGVRFY 99		/* valid signature packet to be verified */
    104 
    105 /* pgpdata.c */
    106 int pgp_getsk(BUFFER *p, BUFFER *pass, BUFFER *key);
    107 int pgp_makesk(BUFFER *out, BUFFER *key, int sym, int type, int hash,
    108 	       BUFFER *pass);
    109 void pgp_iteratedsk(BUFFER *salted, BUFFER *salt, BUFFER *pass, byte c);
    110 int pgp_expandsk(BUFFER *key, int skalgo, int hashalgo, BUFFER *data);
    111 int skcrypt(BUFFER *data, int skalgo, BUFFER *key, BUFFER *iv, int enc);
    112 int mpi_get(BUFFER *buf, BUFFER *mpi);
    113 int mpi_put(BUFFER *buf, BUFFER *mpi);
    114 int pgp_rsa(BUFFER *buf, BUFFER *key, int mode);
    115 void pgp_sigcanonic(BUFFER *msg);
    116 int pgp_makepubkey(BUFFER *seckey, BUFFER *outtxt, BUFFER *pubkey,
    117 		   BUFFER *pass, int keyalgo);
    118 int pgp_makekeyheader(int type, BUFFER *keypacket, BUFFER *outtxt,
    119                    BUFFER *pass, int keyalgo);
    120 int pgp_getkey(int mode, int algo, int *sym, int *mdc, long *expires, BUFFER *keypacket, BUFFER *key,
    121 	       BUFFER *keyid, BUFFER *userid, BUFFER *pass);
    122 int pgp_rsakeygen(int bits, BUFFER *userid, BUFFER *pass, char *pubring,
    123 		  char *secring, int remail);
    124 int pgp_dhkeygen(int bits, BUFFER *userid, BUFFER *pass, char *pubring,
    125 		 char *secring, int remail);
    126 int pgp_dosign(int algo, BUFFER *data, BUFFER *key);
    127 int pgp_elgencrypt(BUFFER *b, BUFFER *key);
    128 int pgp_elgdecrypt(BUFFER *b, BUFFER *key);
    129 int pgp_keyid(BUFFER *key, BUFFER *id);
    130 int pgp_keylen(int symalgo);
    131 int pgp_blocklen(int symalgo);
    132 
    133 /* pgpget.c */
    134 int pgp_getmsg(BUFFER *in, BUFFER *key, BUFFER *sig, char *pubring,
    135 	       char *secring);
    136 int pgp_ispacket(BUFFER *buf);
    137 int pgp_isconventional(BUFFER *buf);
    138 int pgp_packettype(BUFFER *buf, long *len, int *partial);
    139 int pgp_packetpartial(BUFFER *buf, long *len, int *partial);
    140 int pgp_getpacket(BUFFER *buf, BUFFER *p);
    141 int pgp_getsig(BUFFER *p, pgpsig *sig, char *pubring);
    142 void pgp_verify(BUFFER *msg, BUFFER *detached, pgpsig *sig);
    143 int pgp_getsymmetric(BUFFER *buf, BUFFER *key, int algo, int type);
    144 int pgp_getliteral(BUFFER *buf);
    145 int pgp_uncompress(BUFFER *buf);
    146 int pgp_getsessionkey(BUFFER *buf, BUFFER *pass, char *secring);
    147 int pgp_getsymsessionkey(BUFFER *buf, BUFFER *pass);
    148 
    149 /* pgpcreat.c */
    150 int pgp_packet(BUFFER *buf, int type);
    151 int pgp_packet3(BUFFER *buf, int type);
    152 int pgp_symmetric(BUFFER *buf, BUFFER *key, int mdc);
    153 int pgp_literal(BUFFER *buf, char *filename, int text);
    154 int pgp_compress(BUFFER *buf);
    155 int pgp_sessionkey(BUFFER *buf, BUFFER *user, BUFFER *keyid, BUFFER *seskey,
    156 		   char *pubring);
    157 void pgp_marker(BUFFER *buf);
    158 int pgp_symsessionkey(BUFFER *buf, BUFFER *seskey, BUFFER *pass);
    159 int pgp_sign(BUFFER *msg, BUFFER *msg2, BUFFER *sig, BUFFER *userid,
    160 	     BUFFER *pass, int type, int self, long now, int remail,
    161 	     BUFFER *seckey, char *secring);
    162 int pgp_digest(int hashalgo, BUFFER *in, BUFFER *d);
    163 
    164 /* pgpdb.c */
    165 
    166 int pgpdb_getkey(int mode, int algo, int *sym, int *mdc, long *expires, BUFFER *key, BUFFER *user,
    167 		 BUFFER *founduid, BUFFER *keyid, char *keyring, BUFFER *pass);
    168 
    169 typedef struct {
    170   int filetype;
    171   BUFFER *db;
    172   LOCK *lock;
    173   int modified;
    174   int type; /* undefined, public, private */
    175   char filename[LINELEN];
    176   BUFFER *encryptkey;
    177 #ifndef NDEBUG
    178   int writer;
    179 #endif
    180 } KEYRING;
    181 
    182 KEYRING *pgpdb_new(char *keyring, int filetype, BUFFER *encryptkey, int type);
    183 KEYRING *pgpdb_open(char *keyring, BUFFER *encryptkey, int writer, int type);
    184 int pgpdb_append(KEYRING *keydb, BUFFER *p);
    185 int pgpdb_getnext(KEYRING *keydb, BUFFER *p, BUFFER *keyid, BUFFER *userid);
    186 int pgpdb_close(KEYRING *keydb);
    187 
    188 #endif /* not _PGP_H */
    189 #endif /* USE_PGP */