#ifndef H_RPMPGP
#define H_RPMPGP
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* \file rpmio/rpmpgp.h
*
* OpenPGP constants and structures from RFC-2440.
extern "C" {
#endif
-/**
+/** \ingroup rpmpgp
*/
typedef struct DIGEST_CTX_s * DIGEST_CTX;
-/**
+/** \ingroup rpmpgp
*/
typedef struct pgpDig_s * pgpDig;
-/**
+/** \ingroup rpmpgp
*/
typedef struct pgpDigParams_s * pgpDigParams;
typedef uint8_t pgpKeyID_t[8];
typedef uint8_t pgpTime_t[4];
-/**
+/** \ingroup rpmpgp
*/
typedef const struct pgpValTbl_s {
int val;
const char * str;
} * pgpValTbl;
-/**
+/** \ingroup rpmpgp
* 4.3. Packet Tags
*
* The packet tag denotes what type of packet the body holds. Note that
PGPTAG_CONTROL = 63 /*!< Control (GPG) */
} pgpTag;
-/**
+/** \ingroup rpmpgp
*/
extern struct pgpValTbl_s pgpTagTbl[];
-/**
+/** \ingroup rpmpgp
* 5.1. Public-Key Encrypted Session Key Packets (Tag 1)
*
* A Public-Key Encrypted Session Key packet holds the session key used
} pgpPktPubkey;
-/**
+/** \ingroup rpmpgp
* 5.2.1. Signature Types
*
* There are a number of possible meanings for a signature, which are
PGPSIGTYPE_TIMESTAMP = 0x40 /*!< Timestamp */
} pgpSigType;
-/**
+/** \ingroup rpmpgp
*/
extern struct pgpValTbl_s pgpSigTypeTbl[];
-/**
+/** \ingroup rpmpgp
* 9.1. Public Key Algorithms
*
\verbatim
PGPPUBKEYALGO_DH = 21 /*!< Diffie-Hellman (X9.42) */
} pgpPubkeyAlgo;
-/**
+/** \ingroup rpmpgp
*/
extern struct pgpValTbl_s pgpPubkeyTbl[];
-/**
+/** \ingroup rpmpgp
* 9.2. Symmetric Key Algorithms
*
\verbatim
PGPSYMKEYALGO_NOENCRYPT = 110 /*!< no encryption */
} pgpSymkeyAlgo;
-/**
+/** \ingroup rpmpgp
* Symmetric key (string, value) pairs.
*/
extern struct pgpValTbl_s pgpSymkeyTbl[];
-/**
+/** \ingroup rpmpgp
* 9.3. Compression Algorithms
*
\verbatim
PGPCOMPRESSALGO_BZIP2 = 3 /*!< BZIP2 */
} pgpCompressAlgo;
-/**
+/** \ingroup rpmpgp
* Compression (string, value) pairs.
*/
extern struct pgpValTbl_s pgpCompressionTbl[];
-/**
+/** \ingroup rpmpgp
* 9.4. Hash Algorithms
*
\verbatim
PGPHASHALGO_SHA512 = 10, /*!< SHA512 */
} pgpHashAlgo;
-/**
+/** \ingroup rpmpgp
* Hash (string, value) pairs.
*/
extern struct pgpValTbl_s pgpHashTbl[];
-/**
+/** \ingroup rpmpgp
* 5.2.2. Version 3 Signature Packet Format
*
* The body of a version 3 Signature Packet contains:
uint8_t signhash16[2]; /*!< left 16 bits of signed hash value. */
} * pgpPktSigV3;
-/**
+/** \ingroup rpmpgp
* 5.2.3. Version 4 Signature Packet Format
*
* The body of a version 4 Signature Packet contains:
uint8_t hashlen[2]; /*!< length of following hashed material. */
} * pgpPktSigV4;
-/**
+/** \ingroup rpmpgp
* 5.2.3.1. Signature Subpacket Specification
*
* The subpacket fields consist of zero or more signature subpackets.
PGPSUBTYPE_CRITICAL = 128 /*!< critical subpacket marker */
} pgpSubType;
-/**
+/** \ingroup rpmpgp
* Subtype (string, value) pairs.
*/
extern struct pgpValTbl_s pgpSubTypeTbl[];
-/**
+/** \ingroup rpmpgp
* 5.2. Signature Packet (Tag 2)
*
* A signature packet describes a binding between some public key and
uint8_t s2k[1];
} pgpPktSymkey;
-/**
+/** \ingroup rpmpgp
* 5.4. One-Pass Signature Packets (Tag 4)
*
* The One-Pass Signature packet precedes the signed data and contains
uint8_t nested;
} * pgpPktOnepass;
-/**
+/** \ingroup rpmpgp
* 5.5.1. Key Packet Variants
*
* 5.5.1.1. Public Key Packet (Tag 6)
uint8_t pubkey_algo; /*!< public key algorithm. */
} * pgpPktKeyV3;
-/**
+/** \ingroup rpmpgp
* The version 4 format is similar to the version 3 format except for
* the absence of a validity period. This has been moved to the
* signature packet. In addition, fingerprints of version 4 keys are
uint8_t pubkey_algo; /*!< public key algorithm. */
} * pgpPktKeyV4;
-/**
+/** \ingroup rpmpgp
* 5.5.3. Secret Key Packet Formats
*
* The Secret Key and Secret Subkey packets contain all the data of the
struct pgpPktKeyV4_s v4;
} pgpPktKey;
-/*
+/* \ingroup rpmpgp
* 5.6. Compressed Data Packet (Tag 8)
*
* The Compressed Data packet contains compressed data. Typically, this
uint8_t data[1];
} pgpPktCdata;
-/*
+/* \ingroup rpmpgp
* 5.7. Symmetrically Encrypted Data Packet (Tag 9)
*
* The Symmetrically Encrypted Data packet contains data encrypted with
uint8_t data[1];
} pgpPktEdata;
-/*
+/* \ingroup rpmpgp
* 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)
*
* An experimental version of PGP used this packet as the Literal
* in order to cause that version to report that newer software is
* necessary to process the message.
*/
-/*
+/* \ingroup rpmpgp
* 5.9. Literal Data Packet (Tag 11)
*
* A Literal Data packet contains the body of a message; data that is
uint8_t filename[1];
} pgpPktLdata;
-/*
+/* \ingroup rpmpgp
* 5.10. Trust Packet (Tag 12)
*
* The Trust packet is used only within keyrings and is not normally
uint8_t flag;
} pgpPktTrust;
-/*
+/* \ingroup rpmpgp
* 5.11. User ID Packet (Tag 13)
*
* A User ID packet consists of data that is intended to represent the
uint8_t userid[1];
} pgpPktUid;
-/**
+/** \ingroup rpmpgp
*/
union pgpPktPre_u {
pgpPktPubkey pubkey; /*!< 5.1. Public-Key Encrypted Session Key */
pgpPktUid uid; /*!< 5.11. User ID */
};
-/**
+/** \ingroup rpmpgp
*/
typedef enum pgpArmor_e {
PGPARMOR_ERR_CRC_CHECK = -7,
PGPARMOR_SECKEY = 7 /*!< SECRET KEY BLOCK */
} pgpArmor;
-/**
+/** \ingroup rpmpgp
* Armor (string, value) pairs.
*/
extern struct pgpValTbl_s pgpArmorTbl[];
-/**
+/** \ingroup rpmpgp
*/
typedef enum pgpArmorKey_e {
PGPARMORKEY_VERSION = 1, /*!< Version: */
PGPARMORKEY_CHARSET = 5 /*!< Charset: */
} pgpArmorKey;
-/**
+/** \ingroup rpmpgp
* Armor key (string, value) pairs.
*/
extern struct pgpValTbl_s pgpArmorKeyTbl[];
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Bit(s) to control digest operation.
*/
typedef enum rpmDigestFlags_e {
} rpmDigestFlags;
-/**
+/** \ingroup rpmpgp
* Return (native-endian) integer from big-endian representation.
* @param s pointer to big-endian integer
* @param nbytes no. of bytes
return i;
}
-/**
+/** \ingroup rpmpgp
* Return length of an OpenPGP packet.
* @param s pointer to packet
* @retval *lenp no. of bytes in packet
}
}
-/**
+/** \ingroup rpmpgp
* Return no. of bits in a multiprecision integer.
* @param p pointer to multiprecision integer
* @return no. of bits
return ((p[0] << 8) | p[1]);
}
-/**
+/** \ingroup rpmpgp
* Return no. of bytes in a multiprecision integer.
* @param p pointer to multiprecision integer
* @return no. of bytes
return (2 + ((pgpMpiBits(p)+7)>>3));
}
-/**
+/** \ingroup rpmpgp
* Convert to hex.
* @param t target buffer (returned)
* @param s source bytes
return t;
}
-/**
+/** \ingroup rpmpgp
* Return hex formatted representation of bytes.
* @todo Remove static buffer.
* @param p bytes
return prbuf;
}
-/**
+/** \ingroup rpmpgp
* Return hex formatted representation of a multiprecision integer.
* @todo Remove static buffer.
* @param p bytes
return prbuf;
}
-/**
+/** \ingroup rpmpgp
* Return string representation of am OpenPGP value.
* @param vs table of (string,value) pairs
* @param val byte value to lookup
return vs->str;
}
-/**
+/** \ingroup rpmpgp
* Return value of an OpenPGP string.
* @param vs table of (string,value) pairs
* @param s string token to lookup
return vs->val;
}
-/**
+/** \ingroup rpmpgp
* Print an OpenPGP value.
* @param pre output prefix
* @param vs table of (string,value) pairs
*/
void pgpPrtVal(const char * pre, pgpValTbl vs, uint8_t val);
-/**
+/** \ingroup rpmpgp
* Print/parse an OpenPGP subtype packet.
* @param h packet
* @param hlen packet length (no. of bytes)
*/
int pgpPrtSubType(const uint8_t *h, unsigned int hlen, pgpSigType sigtype);
-/**
+/** \ingroup rpmpgp
* Print/parse an OpenPGP signature packet.
* @param tag packet tag
* @param h packet contents
*/
int pgpPrtSig(pgpTag tag, const uint8_t *h, unsigned int hlen);
-/**
+/** \ingroup rpmpgp
* Print/parse an OpenPGP key packet.
* @param tag packet tag
* @param h packet contents
*/
int pgpPrtKey(pgpTag tag, const uint8_t *h, unsigned int hlen);
-/**
+/** \ingroup rpmpgp
* Print/parse an OpenPGP userid packet.
* @param tag packet tag
* @param h packet contents
*/
int pgpPrtUserID(pgpTag tag, const uint8_t *h, unsigned int hlen);
-/**
+/** \ingroup rpmpgp
* Print/parse an OpenPGP comment packet.
* @param tag packet tag
* @param h packet contents
*/
int pgpPrtComment(pgpTag tag, const uint8_t *h, unsigned int hlen);
-/**
+/** \ingroup rpmpgp
* Calculate OpenPGP public key fingerprint.
* @todo V3 non-RSA public keys not implemented.
* @param pkt OpenPGP packet (i.e. PGPTAG_PUBLIC_KEY)
int pgpPubkeyFingerprint(const uint8_t * pkt, unsigned int pktlen,
pgpKeyID_t keyid);
-/**
+/** \ingroup rpmpgp
* Extract OpenPGP public key fingerprint from base64 encoded packet.
* @todo V3 non-RSA public keys not implemented.
* @param b64pkt base64 encoded openpgp packet
int pgpExtractPubkeyFingerprint(const char * b64pkt, pgpKeyID_t keyid);
-/**
+/** \ingroup rpmpgp
* Print/parse next OpenPGP packet.
* @param pkt OpenPGP packet
* @param pleft no. bytes remaining
*/
int pgpPrtPkt(const uint8_t *pkt, unsigned int pleft);
-/**
+/** \ingroup rpmpgp
* Print/parse a OpenPGP packet(s).
* @param pkts OpenPGP packet(s)
* @param pktlen OpenPGP packet(s) length (no. of bytes)
*/
int pgpPrtPkts(const uint8_t *pkts, unsigned int pktlen, pgpDig dig, int printing);
-/**
+/** \ingroup rpmpgp
* Parse armored OpenPGP packets from a file.
* @param fn file name
* @retval pkt dearmored OpenPGP packet(s)
pgpArmor pgpReadPkts(const char * fn,
const uint8_t ** pkt, size_t * pktlen);
-/**
+/** \ingroup rpmpgp
* Wrap a OpenPGP packets in ascii armor for transport.
* @param atype type of armor
* @param s binary pkt data
*/
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns);
-/**
+/** \ingroup rpmpgp
* Create a container for parsed OpenPGP packates.
* @return container
*/
pgpDig pgpNewDig(void);
-/**
+/** \ingroup rpmpgp
* Release (malloc'd) data from container.
* @param dig container
*/
void pgpCleanDig(pgpDig dig);
-/**
+/** \ingroup rpmpgp
* Destroy a container for parsed OpenPGP packates.
* @param dig container
* @return NULL always
*/
pgpDig pgpFreeDig(pgpDig dig);
-/**
+/** \ingroup rpmpgp
* Is buffer at beginning of an OpenPGP packet?
* @param p buffer
* @return 1 if an OpenPGP packet, 0 otherwise
#define CRC24_INIT 0xb704ce
#define CRC24_POLY 0x1864cfb
-/**
+/** \ingroup rpmpgp
* Return CRC of a buffer.
* @param octets bytes
* @param len no. of bytes
return crc & 0xffffff;
}
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Perform cryptography initialization.
* It must be called before any cryptography can be used within rpm.
* It's not normally necessary to call it directly as it's called in
*/
int rpmInitCrypto(void);
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Duplicate a digest context.
* @param octx existing digest context
* @return duplicated digest context
*/
DIGEST_CTX rpmDigestDup(DIGEST_CTX octx);
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Obtain digest length in bytes.
* @param hashalgo type of digest
* @return digest length
*/
size_t rpmDigestLength(pgpHashAlgo hashalgo);
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Initialize digest.
* Set bit count to 0 and buffer to mysterious initialization constants.
* @param hashalgo type of digest
*/
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags);
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Update context with next plain text buffer.
* @param ctx digest context
* @param data next data buffer
*/
int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len);
-/** \ingroup rpmio
+/** \ingroup rpmpgp
* Return digest and destroy context.
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)