Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

rpmio/rpmpgp.h

Go to the documentation of this file.
00001 #ifndef H_RPMPGP
00002 #define H_RPMPGP
00003 
00013 #if !defined(_BEECRYPT_API_H)
00014 /*@-redef@*/
00015 typedef unsigned char byte;
00016 /*@=redef@*/
00017 #endif  /* _BEECRYPT_API_H */
00018 
00021 typedef /*@abstract@*/ struct DIGEST_CTX_s * DIGEST_CTX;
00022 
00025 typedef const struct pgpValTbl_s {
00026     int val;
00027 /*@observer@*/ const char * str;
00028 } * pgpValTbl;
00029  
00037 typedef enum pgpTag_e {
00038     PGPTAG_RESERVED             =  0, 
00039     PGPTAG_PUBLIC_SESSION_KEY   =  1, 
00040     PGPTAG_SIGNATURE            =  2, 
00041     PGPTAG_SYMMETRIC_SESSION_KEY=  3, 
00042     PGPTAG_ONEPASS_SIGNATURE    =  4, 
00043     PGPTAG_SECRET_KEY           =  5, 
00044     PGPTAG_PUBLIC_KEY           =  6, 
00045     PGPTAG_SECRET_SUBKEY        =  7, 
00046     PGPTAG_COMPRESSED_DATA      =  8, 
00047     PGPTAG_SYMMETRIC_DATA       =  9, 
00048     PGPTAG_MARKER               = 10, 
00049     PGPTAG_LITERAL_DATA         = 11, 
00050     PGPTAG_TRUST                = 12, 
00051     PGPTAG_USER_ID              = 13, 
00052     PGPTAG_PUBLIC_SUBKEY        = 14, 
00053     PGPTAG_COMMENT_OLD          = 16, 
00054     PGPTAG_PHOTOID              = 17, 
00055     PGPTAG_ENCRYPTED_MDC        = 18, 
00056     PGPTAG_MDC                  = 19, 
00057     PGPTAG_PRIVATE_60           = 60, 
00058     PGPTAG_COMMENT              = 61, 
00059     PGPTAG_PRIVATE_62           = 62, 
00060     PGPTAG_CONTROL              = 63  
00061 } pgpTag;
00062 
00065 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00066 extern struct pgpValTbl_s pgpTagTbl[];
00067 
00102 typedef struct pgpPktPubkey_s {
00103     byte version;       
00104     byte keyid[8];      
00105     byte algo;          
00106 } pgpPktPubkey;
00107 
00108 
00115 /*@-typeuse@*/
00116 typedef enum pgpSigType_e {
00117     PGPSIGTYPE_BINARY            = 0x00, 
00118     PGPSIGTYPE_TEXT              = 0x01, 
00119     PGPSIGTYPE_STANDALONE        = 0x02, 
00120     PGPSIGTYPE_GENERIC_CERT      = 0x10,
00122     PGPSIGTYPE_PERSONA_CERT      = 0x11,
00124     PGPSIGTYPE_CASUAL_CERT       = 0x12,
00126     PGPSIGTYPE_POSITIVE_CERT     = 0x13,
00128     PGPSIGTYPE_SUBKEY_BINDING    = 0x18, 
00129     PGPSIGTYPE_SIGNED_KEY        = 0x1F, 
00130     PGPSIGTYPE_KEY_REVOKE        = 0x20, 
00131     PGPSIGTYPE_SUBKEY_REVOKE     = 0x28, 
00132     PGPSIGTYPE_CERT_REVOKE       = 0x30, 
00133     PGPSIGTYPE_TIMESTAMP         = 0x40  
00134 } pgpSigType;
00135 /*@=typeuse@*/
00136 
00139 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00140 extern struct pgpValTbl_s pgpSigTypeTbl[];
00141 
00165 /*@-typeuse@*/
00166 typedef enum pgpPubkeyAlgo_e {
00167     PGPPUBKEYALGO_RSA           =  1,   
00168     PGPPUBKEYALGO_RSA_ENCRYPT   =  2,   
00169     PGPPUBKEYALGO_RSA_SIGN      =  3,   
00170     PGPPUBKEYALGO_ELGAMAL_ENCRYPT = 16, 
00171     PGPPUBKEYALGO_DSA           = 17,   
00172     PGPPUBKEYALGO_EC            = 18,   
00173     PGPPUBKEYALGO_ECDSA         = 19,   
00174     PGPPUBKEYALGO_ELGAMAL       = 20,   
00175     PGPPUBKEYALGO_DH            = 21    
00176 } pgpPubkeyAlgo;
00177 /*@=typeuse@*/
00178 
00181 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00182 extern struct pgpValTbl_s pgpPubkeyTbl[];
00183 
00208 /*@-typeuse@*/
00209 typedef enum pgpSymkeyAlgo_e {
00210     PGPSYMKEYALGO_PLAINTEXT     =  0,   
00211     PGPSYMKEYALGO_IDEA          =  1,   
00212     PGPSYMKEYALGO_TRIPLE_DES    =  2,   
00213     PGPSYMKEYALGO_CAST5         =  3,   
00214     PGPSYMKEYALGO_BLOWFISH      =  4,   
00215     PGPSYMKEYALGO_SAFER         =  5,   
00216     PGPSYMKEYALGO_DES_SK        =  6,   
00217     PGPSYMKEYALGO_AES_128       =  7,   
00218     PGPSYMKEYALGO_AES_192       =  8,   
00219     PGPSYMKEYALGO_AES_256       =  9,   
00220     PGPSYMKEYALGO_TWOFISH       = 10    
00221 } pgpSymkeyAlgo;
00222 /*@=typeuse@*/
00223 
00227 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00228 extern struct pgpValTbl_s pgpSymkeyTbl[];
00229 
00245 /*@-typeuse@*/
00246 typedef enum pgpCompressAlgo_e {
00247     PGPCOMPRESSALGO_NONE        =  0,   
00248     PGPCOMPRESSALGO_ZIP         =  1,   
00249     PGPCOMPRESSALGO_ZLIB        =  2    
00250 } pgpCompressAlgo;
00251 /*@=typeuse@*/
00252 
00256 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00257 extern struct pgpValTbl_s pgpCompressionTbl[];
00258 
00280 typedef enum pgpHashAlgo_e {
00281     PGPHASHALGO_MD5             = 1,    
00282     PGPHASHALGO_SHA1            = 2,    
00283     PGPHASHALGO_RIPEMD160       = 3,    
00284     PGPHASHALGO_MD2             = 5,    
00285     PGPHASHALGO_TIGER192        = 6,    
00286     PGPHASHALGO_HAVAL_5_160     = 7     
00287 } pgpHashAlgo;
00288 
00292 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00293 extern struct pgpValTbl_s pgpHashTbl[];
00294 
00316 typedef struct pgpPktSigV3_s {
00317     byte version;       
00318     byte hashlen;       
00319     byte sigtype;       
00320     byte time[4];       
00321     byte signid[8];     
00322     byte pubkey_algo;   
00323     byte hash_algo;     
00324     byte signhash16[2]; 
00325 } * pgpPktSigV3;
00326 
00348 typedef struct pgpPktSigV4_s {
00349     byte version;       
00350     byte sigtype;       
00351     byte pubkey_algo;   
00352     byte hash_algo;     
00353     byte hashlen[2];    
00354 } * pgpPktSigV4;
00355 
00422 /*@-typeuse@*/
00423 typedef enum pgpSubType_e {
00424     PGPSUBTYPE_SIG_CREATE_TIME  =   2, 
00425     PGPSUBTYPE_SIG_EXPIRE_TIME  =   3, 
00426     PGPSUBTYPE_EXPORTABLE_CERT  =   4, 
00427     PGPSUBTYPE_TRUST_SIG        =   5, 
00428     PGPSUBTYPE_REGEX            =   6, 
00429     PGPSUBTYPE_REVOCABLE        =   7, 
00430     PGPSUBTYPE_KEY_EXPIRE_TIME  =   9, 
00431     PGPSUBTYPE_BACKWARD_COMPAT  =  10, 
00432     PGPSUBTYPE_PREFER_SYMKEY    =  11, 
00433     PGPSUBTYPE_REVOKE_KEY       =  12, 
00434     PGPSUBTYPE_ISSUER_KEYID     =  16, 
00435     PGPSUBTYPE_NOTATION         =  20, 
00436     PGPSUBTYPE_PREFER_HASH      =  21, 
00437     PGPSUBTYPE_PREFER_COMPRESS  =  22, 
00438     PGPSUBTYPE_KEYSERVER_PREFERS=  23, 
00439     PGPSUBTYPE_PREFER_KEYSERVER =  24, 
00440     PGPSUBTYPE_PRIMARY_USERID   =  25, 
00441     PGPSUBTYPE_POLICY_URL       =  26, 
00442     PGPSUBTYPE_KEY_FLAGS        =  27, 
00443     PGPSUBTYPE_SIGNER_USERID    =  28, 
00444     PGPSUBTYPE_REVOKE_REASON    =  29, 
00445     PGPSUBTYPE_INTERNAL_100     = 100, 
00446     PGPSUBTYPE_INTERNAL_101     = 101, 
00447     PGPSUBTYPE_INTERNAL_102     = 102, 
00448     PGPSUBTYPE_INTERNAL_103     = 103, 
00449     PGPSUBTYPE_INTERNAL_104     = 104, 
00450     PGPSUBTYPE_INTERNAL_105     = 105, 
00451     PGPSUBTYPE_INTERNAL_106     = 106, 
00452     PGPSUBTYPE_INTERNAL_107     = 107, 
00453     PGPSUBTYPE_INTERNAL_108     = 108, 
00454     PGPSUBTYPE_INTERNAL_109     = 109, 
00455     PGPSUBTYPE_INTERNAL_110     = 110 
00456 } pgpSubType;
00457 /*@=typeuse@*/
00458 
00462 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00463 extern struct pgpValTbl_s pgpSubTypeTbl[];
00464 
00485 typedef union pgpPktSig_u {
00486     struct pgpPktSigV3_s v3;
00487     struct pgpPktSigV4_s v4;
00488 } * pgpPktSig;
00489 
00518 typedef struct pgpPktSymkey_s {
00519     byte version;       
00520     byte symkey_algo;
00521     byte s2k[1];
00522 } pgpPktSymkey;
00523 
00553 typedef struct pgpPktOnepass_s {
00554     byte version;       
00555     byte sigtype;       
00556     byte hash_algo;     
00557     byte pubkey_algo;   
00558     byte signid[8];     
00559     byte nested;
00560 } * pgpPktOnepass;
00561 
00634 typedef struct pgpPktKeyV3_s {
00635     byte version;       
00636     byte time[4];       
00637     byte valid[2];      
00638     byte pubkey_algo;   
00639 } * pgpPktKeyV3;
00640 
00672 typedef struct pgpPktKeyV4_s {
00673     byte version;       
00674     byte time[4];       
00675     byte pubkey_algo;   
00676 } * pgpPktKeyV4;
00677 
00742 typedef union pgpPktKey_u {
00743     struct pgpPktKeyV3_s v3;
00744     struct pgpPktKeyV4_s v4;
00745 } pgpPktKey;
00746 
00747 /*
00748  * 5.6. Compressed Data Packet (Tag 8)
00749  *
00750  * The Compressed Data packet contains compressed data. Typically, this
00751  * packet is found as the contents of an encrypted packet, or following
00752  * a Signature or One-Pass Signature packet, and contains literal data
00753  * packets.
00754  *
00755  * The body of this packet consists of:
00756  *   - One octet that gives the algorithm used to compress the packet.
00757  *   - The remainder of the packet is compressed data.
00758  *
00759  * A Compressed Data Packet's body contains an block that compresses
00760  * some set of packets. See section "Packet Composition" for details on
00761  * how messages are formed.
00762  *
00763  * ZIP-compressed packets are compressed with raw RFC 1951 DEFLATE
00764  * blocks. Note that PGP V2.6 uses 13 bits of compression. If an
00765  * implementation uses more bits of compression, PGP V2.6 cannot
00766  * decompress it.
00767  *
00768  * ZLIB-compressed packets are compressed with RFC 1950 ZLIB-style
00769  * blocks.
00770  */
00771 typedef struct pgpPktCdata_s {
00772     byte compressalgo;
00773     byte data[1];
00774 } pgpPktCdata;
00775 
00776 /*
00777  * 5.7. Symmetrically Encrypted Data Packet (Tag 9)
00778  *
00779  * The Symmetrically Encrypted Data packet contains data encrypted with
00780  * a symmetric-key algorithm. When it has been decrypted, it will
00781  * typically contain other packets (often literal data packets or
00782  * compressed data packets).
00783  *
00784  * The body of this packet consists of:
00785  *   - Encrypted data, the output of the selected symmetric-key cipher
00786  *     operating in PGP's variant of Cipher Feedback (CFB) mode.
00787  *
00788  * The symmetric cipher used may be specified in an Public-Key or
00789  * Symmetric-Key Encrypted Session Key packet that precedes the
00790  * Symmetrically Encrypted Data Packet.  In that case, the cipher
00791  * algorithm octet is prefixed to the session key before it is
00792  * encrypted.  If no packets of these types precede the encrypted data,
00793  * the IDEA algorithm is used with the session key calculated as the MD5
00794  * hash of the passphrase.
00795  *
00796  * The data is encrypted in CFB mode, with a CFB shift size equal to the
00797  * cipher's block size.  The Initial Vector (IV) is specified as all
00798  * zeros.  Instead of using an IV, OpenPGP prefixes a 10-octet string to
00799  * the data before it is encrypted.  The first eight octets are random,
00800  * and the 9th and 10th octets are copies of the 7th and 8th octets,
00801  * respectively. After encrypting the first 10 octets, the CFB state is
00802  * resynchronized if the cipher block size is 8 octets or less.  The
00803  * last 8 octets of ciphertext are passed through the cipher and the
00804  * block boundary is reset.
00805  *
00806  * The repetition of 16 bits in the 80 bits of random data prefixed to
00807  * the message allows the receiver to immediately check whether the
00808  * session key is incorrect.
00809  */
00810 typedef struct pgpPktEdata_s {
00811     byte data[1];
00812 } pgpPktEdata;
00813 
00814 /*
00815  * 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)
00816  *
00817  * An experimental version of PGP used this packet as the Literal
00818  * packet, but no released version of PGP generated Literal packets with
00819  * this tag. With PGP 5.x, this packet has been re-assigned and is
00820  * reserved for use as the Marker packet.
00821  *
00822  * The body of this packet consists of:
00823  *   - The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8).
00824  *
00825  * Such a packet MUST be ignored when received.  It may be placed at the
00826  * beginning of a message that uses features not available in PGP 2.6.x
00827  * in order to cause that version to report that newer software is
00828  * necessary to process the message.
00829  */
00830 /*
00831  * 5.9. Literal Data Packet (Tag 11)
00832  *
00833  * A Literal Data packet contains the body of a message; data that is
00834  * not to be further interpreted.
00835  *
00836  * The body of this packet consists of:
00837  *   - A one-octet field that describes how the data is formatted.
00838  *
00839  * If it is a 'b' (0x62), then the literal packet contains binary data.
00840  * If it is a 't' (0x74), then it contains text data, and thus may need
00841  * line ends converted to local form, or other text-mode changes.  RFC
00842  * 1991 also defined a value of 'l' as a 'local' mode for machine-local
00843  * conversions.  This use is now deprecated.
00844  *   - File name as a string (one-octet length, followed by file name),
00845  *     if the encrypted data should be saved as a file.
00846  *
00847  * If the special name "_CONSOLE" is used, the message is considered to
00848  * be "for your eyes only".  This advises that the message data is
00849  * unusually sensitive, and the receiving program should process it more
00850  * carefully, perhaps avoiding storing the received data to disk, for
00851  * example.
00852  *   - A four-octet number that indicates the modification date of the
00853  *     file, or the creation time of the packet, or a zero that
00854  *     indicates the present time.
00855  *   - The remainder of the packet is literal data.
00856  *
00857  * Text data is stored with <CR><LF> text endings (i.e. network-normal
00858  * line endings).  These should be converted to native line endings by
00859  * the receiving software.
00860  */
00861 typedef struct pgpPktLdata_s {
00862     byte format;
00863     byte filenamelen;
00864     byte filename[1];
00865 } pgpPktLdata;
00866 
00867 /*
00868  * 5.10. Trust Packet (Tag 12)
00869  *
00870  * The Trust packet is used only within keyrings and is not normally
00871  * exported.  Trust packets contain data that record the user's
00872  * specifications of which key holders are trustworthy introducers,
00873  * along with other information that implementing software uses for
00874  * trust information.
00875  *
00876  * Trust packets SHOULD NOT be emitted to output streams that are
00877  * transferred to other users, and they SHOULD be ignored on any input
00878  * other than local keyring files.
00879  */
00880 typedef struct pgpPktTrust_s {
00881     byte flag;
00882 } pgpPktTrust;
00883 
00884 /*
00885  * 5.11. User ID Packet (Tag 13)
00886  *
00887  * A User ID packet consists of data that is intended to represent the
00888  * name and email address of the key holder.  By convention, it includes
00889  * an RFC 822 mail name, but there are no restrictions on its content.
00890  * The packet length in the header specifies the length of the user id.
00891  * If it is text, it is encoded in UTF-8.
00892  *
00893  */
00894 typedef struct pgpPktUid_s {
00895     byte userid[1];
00896 } pgpPktUid;
00897 
00900 union pgpPktPre_u {
00901     pgpPktPubkey pubkey;        
00902     pgpPktSig sig;              
00903     pgpPktSymkey symkey;        
00904     pgpPktOnepass onepass;      
00905     pgpPktKey key;              
00906     pgpPktCdata cdata;          
00907     pgpPktEdata edata;          
00909     pgpPktLdata ldata;          
00910     pgpPktTrust tdata;          
00911     pgpPktUid uid;              
00912 };
00913 
00916 /*@-typeuse@*/
00917 typedef enum pgpArmor_e {
00918     PGPARMOR_ERROR              = -1,
00919     PGPARMOR_NONE               =  0,
00920     PGPARMOR_MESSAGE            =  1, 
00921     PGPARMOR_PUBKEY             =  2, 
00922     PGPARMOR_SIGNATURE          =  3, 
00923     PGPARMOR_SIGNED_MESSAGE     =  4, 
00924     PGPARMOR_FILE               =  5, 
00925     PGPARMOR_PRIVKEY            =  6, 
00926     PGPARMOR_SECKEY             =  7  
00927 } pgpArmor;
00928 /*@=typeuse@*/
00929 
00933 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00934 extern struct pgpValTbl_s pgpArmorTbl[];
00935 
00938 /*@-typeuse@*/
00939 typedef enum pgpArmorKey_e {
00940     PGPARMORKEY_VERSION         = 1, 
00941     PGPARMORKEY_COMMENT         = 2, 
00942     PGPARMORKEY_MESSAGEID       = 3, 
00943     PGPARMORKEY_HASH            = 4, 
00944     PGPARMORKEY_CHARSET         = 5  
00945 } pgpArmorKey;
00946 /*@=typeuse@*/
00947 
00951 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
00952 extern struct pgpValTbl_s pgpArmorKeyTbl[];
00953 
00957 typedef enum rpmDigestFlags_e {
00958     RPMDIGEST_NONE      = 0
00959 } rpmDigestFlags;
00960 
00961 
00962 /*@-fcnuse@*/
00963 #ifdef __cplusplus
00964 extern "C" {
00965 #endif
00966 
00973 /*@unused@*/ static inline
00974 unsigned int pgpGrab(const byte *s, int nbytes)
00975         /*@*/
00976 {
00977     unsigned int i = 0;
00978     int nb = (nbytes <= sizeof(i) ? nbytes : sizeof(i));
00979 /*@-boundsread@*/
00980     while (nb--)
00981         i = (i << 8) | *s++;
00982 /*@=boundsread@*/
00983     return i;
00984 }
00985 
00992 /*@unused@*/ static inline
00993 int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp)
00994         /*@modifies *lenp @*/
00995 {
00996 /*@-boundswrite@*/
00997     if (*s < 192) {
00998         (*lenp) = *s++;
00999         return 1;
01000     } else if (*s < 255) {
01001         (*lenp) = ((((unsigned)s[0]) - 192) << 8) + s[1] + 192;
01002         return 2;
01003     } else {
01004         (*lenp) = pgpGrab(s+1, 4);
01005         return 5;
01006     }
01007 /*@=boundswrite@*/
01008 }
01009 
01015 /*@unused@*/ static inline
01016 unsigned int pgpMpiBits(const byte *p)
01017         /*@requires maxRead(p) >= 1 @*/
01018         /*@*/
01019 {
01020     return ((p[0] << 8) | p[1]);
01021 }
01022 
01028 /*@unused@*/ static inline
01029 unsigned int pgpMpiLen(const byte *p)
01030         /*@requires maxRead(p) >= 1 @*/
01031         /*@*/
01032 {
01033     return (2 + ((pgpMpiBits(p)+7)>>3));
01034 }
01035         
01043 /*@unused@*/ static inline
01044 char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
01045         /*@modifies *t @*/
01046 {
01047     static char hex[] = "0123456789abcdef";
01048 /*@-boundswrite@*/
01049     while (nbytes-- > 0) {
01050         unsigned int i;
01051         i = *s++;
01052         *t++ = hex[ (i >> 4) & 0xf ];
01053         *t++ = hex[ (i     ) & 0xf ];
01054     }
01055     *t = '\0';
01056 /*@=boundswrite@*/
01057     return t;
01058 }
01059 
01067 /*@unused@*/ static inline /*@observer@*/
01068 char * pgpHexStr(const byte *p, unsigned int plen)
01069         /*@*/
01070 {
01071     static char prbuf[2048];
01072     char *t = prbuf;
01073     t = pgpHexCvt(t, p, plen);
01074     return prbuf;
01075 }
01076 
01083 /*@unused@*/ static inline /*@observer@*/
01084 const char * pgpMpiStr(const byte *p)
01085         /*@requires maxRead(p) >= 3 @*/
01086         /*@*/
01087 {
01088     static char prbuf[2048];
01089     char *t = prbuf;
01090     sprintf(t, "[%4u]: ", pgpGrab(p, 2));
01091     t += strlen(t);
01092     t = pgpHexCvt(t, p+2, pgpMpiLen(p)-2);
01093     return prbuf;
01094 }
01095 
01102 /*@unused@*/ static inline /*@observer@*/
01103 const char * pgpValStr(pgpValTbl vs, byte val)
01104         /*@*/
01105 {
01106     do {
01107         if (vs->val == val)
01108             break;
01109     } while ((++vs)->val != -1);
01110     return vs->str;
01111 }
01112 
01120 /*@unused@*/ static inline
01121 int pgpValTok(pgpValTbl vs, const char * s, const char * se)
01122         /*@*/
01123 {
01124     do {
01125         int vlen = strlen(vs->str);
01126         if (vlen <= (se-s) && !strncmp(s, vs->str, vlen))
01127             break;
01128     } while ((++vs)->val != -1);
01129     return vs->val;
01130 }
01131 
01132 /*@-exportlocal@*/
01139 void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
01140         /*@globals fileSystem @*/
01141         /*@modifies fileSystem @*/;
01142 
01150 int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
01151         /*@globals fileSystem @*/
01152         /*@modifies fileSystem @*/;
01153 
01161 int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
01162         /*@globals fileSystem @*/
01163         /*@modifies fileSystem @*/;
01164 
01172 int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
01173         /*@globals fileSystem @*/
01174         /*@modifies fileSystem @*/;
01175 
01183 int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
01184         /*@globals fileSystem @*/
01185         /*@modifies fileSystem @*/;
01186 
01194 int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
01195         /*@globals fileSystem @*/
01196         /*@modifies fileSystem @*/;
01197 
01204 int pgpPrtPkt(const byte *pkt, unsigned int pleft)
01205         /*@globals fileSystem @*/
01206         /*@modifies fileSystem @*/;
01207 /*@=exportlocal@*/
01208 
01217 int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing)
01218         /*@globals fileSystem @*/
01219         /*@modifies fileSystem @*/;
01220 
01228 pgpArmor pgpReadPkts(const char * fn,
01229                 /*@out@*/ const byte ** pkt, /*@out@*/ size_t * pktlen)
01230         /*@globals fileSystem, internalState @*/
01231         /*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
01232 
01240 char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
01241         /*@*/;
01242 
01247 /*@only@*/
01248 pgpDig pgpNewDig(void)
01249         /*@*/;
01250 
01255 void pgpCleanDig(/*@null@*/ pgpDig dig)
01256         /*@modifies dig @*/;
01257 
01263 /*@only@*/ /*@null@*/
01264 pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
01265         /*@modifies dig @*/;
01266 
01272 /*@unused@*/ static inline
01273 int pgpIsPkt(const byte * p)
01274         /*@*/
01275 {
01276 /*@-boundsread@*/
01277     unsigned int val = *p++;
01278 /*@=boundsread@*/
01279     pgpTag tag;
01280     int rc;
01281 
01282     /* XXX can't deal with these. */
01283     if (!(val & 0x80))
01284         return 0;
01285 
01286     if (val & 0x40)
01287         tag = (val & 0x3f);
01288     else
01289         tag = (val >> 2) & 0xf;
01290 
01291     switch (tag) {
01292     case PGPTAG_MARKER:
01293     case PGPTAG_SYMMETRIC_SESSION_KEY:
01294     case PGPTAG_ONEPASS_SIGNATURE:
01295     case PGPTAG_PUBLIC_KEY:
01296     case PGPTAG_SECRET_KEY:
01297     case PGPTAG_PUBLIC_SESSION_KEY:
01298     case PGPTAG_SIGNATURE:
01299     case PGPTAG_COMMENT:
01300     case PGPTAG_COMMENT_OLD:
01301     case PGPTAG_LITERAL_DATA:
01302     case PGPTAG_COMPRESSED_DATA:
01303     case PGPTAG_SYMMETRIC_DATA:
01304         rc = 1;
01305         break;
01306     case PGPTAG_PUBLIC_SUBKEY:
01307     case PGPTAG_SECRET_SUBKEY:
01308     case PGPTAG_USER_ID:
01309     case PGPTAG_RESERVED:
01310     case PGPTAG_TRUST:
01311     case PGPTAG_PHOTOID:
01312     case PGPTAG_ENCRYPTED_MDC:
01313     case PGPTAG_MDC:
01314     case PGPTAG_PRIVATE_60:
01315     case PGPTAG_PRIVATE_62:
01316     case PGPTAG_CONTROL:
01317     default:
01318         rc = 0;
01319         break;
01320     }
01321 
01322     return rc;
01323 }
01324 
01325 #define CRC24_INIT      0xb704ce
01326 #define CRC24_POLY      0x1864cfb
01327 
01334 /*@unused@*/ static inline
01335 unsigned int pgpCRC(const byte *octets, size_t len)
01336         /*@*/
01337 {
01338     unsigned int crc = CRC24_INIT;
01339     int i;
01340 
01341     while (len--) {
01342 /*@-boundsread@*/
01343         crc ^= (*octets++) << 16;
01344 /*@=boundsread@*/
01345         for (i = 0; i < 8; i++) {
01346             crc <<= 1;
01347             if (crc & 0x1000000)
01348                 crc ^= CRC24_POLY;
01349         }
01350     }
01351     return crc & 0xffffff;
01352 }
01353 
01359 /*@only@*/
01360 DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
01361         /*@*/;
01362 
01370 /*@only@*/ /*@null@*/
01371 DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
01372         /*@*/;
01373 
01381 int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len)
01382         /*@modifies ctx @*/;
01383 
01395 int rpmDigestFinal(/*@only@*/ /*@null@*/ DIGEST_CTX ctx,
01396         /*@null@*/ /*@out@*/ void ** datap,
01397         /*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
01398                 /*@modifies *datap, *lenp @*/;
01399 
01400 #ifdef __cplusplus
01401 }
01402 #endif
01403 /*@=fcnuse@*/
01404 
01405 #endif  /* H_RPMPGP */

Generated on Sun Oct 26 13:02:03 2003 for rpm by doxygen1.2.18