rpm  5.4.14
rpmpgp.h
Go to the documentation of this file.
1 #ifndef H_RPMPGP
2 #define H_RPMPGP
3 
13 #include <string.h>
14 #include <popt.h>
15 #include <rpmiotypes.h>
16 #include <yarn.h>
17 
18 #if defined(_RPMPGP_INTERNAL)
19 #include <rpmsw.h>
20 
21 /*@unchecked@*/
22 extern int _pgp_error_count;
23 
27 struct pgpDigParams_s {
28 /*@only@*/ /*@null@*/
29  const char * userid;
30 /*@dependent@*/ /*@null@*/
31  const rpmuint8_t * hash;
33 
34  rpmuint8_t version;
35  rpmuint8_t time[4];
36  rpmuint8_t pubkey_algo;
38  rpmuint8_t hash_algo;
39  rpmuint8_t sigtype;
40  size_t hashlen;
41  rpmuint8_t signhash16[2];
42  rpmuint8_t signid[8];
43  rpmuint8_t expire[4];
44  rpmuint8_t keyexpire[4];
46  rpmuint8_t saved;
47 #define PGPDIG_SAVED_TIME (1 << 0)
48 #define PGPDIG_SAVED_ID (1 << 1)
49 
50 };
51 
55 struct pgpDig_s {
56  struct rpmioItem_s _item;
57  struct pgpDigParams_s signature;
58  struct pgpDigParams_s pubkey;
59 
60 /*@observer@*/ /*@null@*/
61  const char * pubkey_algoN;
62 /*@observer@*/ /*@null@*/
63  const char * hash_algoN;
64 
65  rpmuint32_t sigtag;
66  rpmuint32_t sigtype;
67 /*@relnull@*/
68  const void * sig;
69  size_t siglen;
70  const void * pub;
71  size_t publen;
74  struct rpmop_s dops;
75  struct rpmop_s sops;
77  int (*findPubkey) (void * _ts, /*@null@*/ void * _dig)
78  /*@modifies *_ts, *_dig @*/;
79 /*@null@*/
80  void * _ts;
82  rpmuint8_t ** ppkts;
83  int npkts;
84  size_t nbytes;
86 /*@only@*/ /*@null@*/
87  DIGEST_CTX sha1ctx;
88 /*@only@*/ /*@null@*/
89  DIGEST_CTX hdrsha1ctx;
90 /*@only@*/ /*@null@*/
91  void * sha1;
92  size_t sha1len;
94 /*@only@*/ /*@null@*/
95  DIGEST_CTX md5ctx;
96 /*@only@*/ /*@null@*/
97  DIGEST_CTX hdrctx;
98 /*@only@*/ /*@null@*/
99  void * md5;
100  size_t md5len;
102 /*@owned@*/ /*@relnull@*/
103  void * impl;
105 #if defined(__LCLINT__)
106 /*@refs@*/
107  int nrefs;
108 #endif
109 };
110 #endif /* _RPMPGP_INTERNAL */
111 
114 typedef const struct pgpValTbl_s {
115  int val;
116 /*@observer@*/
117  const char * str;
118 } * pgpValTbl;
119 
127 typedef enum pgpTag_e {
146  PGPTAG_MDC = 19,
151 } pgpTag;
152 
155 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
156 extern struct pgpValTbl_s pgpTagTbl[];
157 
192 typedef struct pgpPktPubkey_s {
196 } pgpPktPubkey;
197 
204 /*@-typeuse@*/
205 typedef enum pgpSigType_e {
225 } pgpSigType;
226 /*@=typeuse@*/
227 
230 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
231 extern struct pgpValTbl_s pgpSigTypeTbl[];
232 
256 /*@-typeuse@*/
257 typedef enum pgpPubkeyAlgo_e {
268 } pgpPubkeyAlgo;
269 /*@=typeuse@*/
270 
273 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
274 extern struct pgpValTbl_s pgpPubkeyTbl[];
275 
301 /*@-typeuse@*/
302 typedef enum pgpSymkeyAlgo_e {
318 } pgpSymkeyAlgo;
319 /*@=typeuse@*/
320 
324 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
325 extern struct pgpValTbl_s pgpSymkeyTbl[];
326 
342 /*@-typeuse@*/
343 typedef enum pgpCompressAlgo_e {
349 /*@=typeuse@*/
350 
354 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
355 extern struct pgpValTbl_s pgpCompressionTbl[];
356 
360 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
361 extern struct pgpValTbl_s pgpHashTbl[];
362 
384 typedef struct pgpPktSigV3_s {
393 } * pgpPktSigV3;
394 
416 typedef struct pgpPktSigV4_s {
422 } * pgpPktSigV4;
423 
502 /*@-typeuse@*/
503 typedef enum pgpSubType_e {
543 } pgpSubType;
544 /*@=typeuse@*/
545 
549 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
550 extern struct pgpValTbl_s pgpSubTypeTbl[];
551 
572 typedef union pgpPktSig_u {
575 } * pgpPktSig;
576 
605 typedef struct pgpPktSymkey_s {
609 } pgpPktSymkey;
610 
640 typedef struct pgpPktOnepass_s {
647 } * pgpPktOnepass;
648 
721 typedef struct pgpPktKeyV3_s {
726 } * pgpPktKeyV3;
727 
759 typedef struct pgpPktKeyV4_s {
763 } * pgpPktKeyV4;
764 
829 typedef union pgpPktKey_u {
832 } pgpPktKey;
833 
858 typedef struct pgpPktCdata_s {
861 } pgpPktCdata;
862 
897 typedef struct pgpPktEdata_s {
899 } pgpPktEdata;
900 
917 /*
918  * 5.9. Literal Data Packet (Tag 11)
919  *
920  * A Literal Data packet contains the body of a message; data that is
921  * not to be further interpreted.
922  *
923  * The body of this packet consists of:
924  * - A one-octet field that describes how the data is formatted.
925  *
926  * If it is a 'b' (0x62), then the literal packet contains binary data.
927  * If it is a 't' (0x74), then it contains text data, and thus may need
928  * line ends converted to local form, or other text-mode changes. RFC
929  * 1991 also defined a value of 'l' as a 'local' mode for machine-local
930  * conversions. This use is now deprecated.
931  * - File name as a string (one-octet length, followed by file name),
932  * if the encrypted data should be saved as a file.
933  *
934  * If the special name "_CONSOLE" is used, the message is considered to
935  * be "for your eyes only". This advises that the message data is
936  * unusually sensitive, and the receiving program should process it more
937  * carefully, perhaps avoiding storing the received data to disk, for
938  * example.
939  * - A four-octet number that indicates the modification date of the
940  * file, or the creation time of the packet, or a zero that
941  * indicates the present time.
942  * - The remainder of the packet is literal data.
943  *
944  * Text data is stored with <CR><LF> text endings (i.e. network-normal
945  * line endings). These should be converted to native line endings by
946  * the receiving software.
947  */
948 typedef struct pgpPktLdata_s {
952 } pgpPktLdata;
953 
967 typedef struct pgpPktTrust_s {
969 } pgpPktTrust;
970 
981 typedef struct pgpPktUid_s {
983 } pgpPktUid;
984 
987 /*@-typeuse@*/
988 typedef enum pgpArmor_e {
996 #define PGPARMOR_ERROR PGPARMOR_ERR_NO_BEGIN_PGP
1005 } pgpArmor;
1006 /*@=typeuse@*/
1007 
1011 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
1012 extern struct pgpValTbl_s pgpArmorTbl[];
1013 
1016 /*@-typeuse@*/
1017 typedef enum pgpArmorKey_e {
1023 } pgpArmorKey;
1024 /*@=typeuse@*/
1025 
1029 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
1030 extern struct pgpValTbl_s pgpArmorKeyTbl[];
1031 
1032 #if defined(_RPMPGP_INTERNAL)
1033 
1035 union pgpPktPre_u {
1036  pgpPktPubkey pubkey;
1037  pgpPktSig sig;
1038  pgpPktSymkey symkey;
1039  pgpPktOnepass onepass;
1040  pgpPktKey key;
1041  pgpPktCdata cdata;
1042  pgpPktEdata edata;
1044  pgpPktLdata ldata;
1045  pgpPktTrust tdata;
1046  pgpPktUid uid;
1047 };
1048 
1049 struct pgpPkt_s {
1050  pgpTag tag;
1051  unsigned int pktlen;
1052  union {
1053  const rpmuint8_t * h;
1054  const pgpPktKeyV3 j;
1055  const pgpPktKeyV4 k;
1056  const pgpPktSigV3 r;
1057  const pgpPktSigV4 s;
1058  const pgpPktUid * u;
1059  } u;
1060  unsigned int hlen;
1061 };
1062 #endif /* _RPMPGP_INTERNAL */
1063 
1064 /*@-fcnuse@*/
1065 #ifdef __cplusplus
1066 extern "C" {
1067 #endif
1068 
1075 /*@unused@*/ static inline
1076 unsigned int pgpGrab(const rpmuint8_t * s, size_t nbytes)
1077  /*@*/
1078 {
1079  unsigned int i = 0;
1080  size_t nb = (nbytes <= sizeof(i) ? nbytes : sizeof(i));
1081  while (nb--)
1082  i = (i << 8) | *s++;
1083  return i;
1084 }
1085 
1092 /*@unused@*/ static inline
1093 unsigned int pgpLen(const rpmuint8_t * s, /*@out@*/ unsigned int * lenp)
1094  /*@modifies *lenp @*/
1095 {
1096  if (*s < (rpmuint8_t)192) {
1097  *lenp = (unsigned int) *s++;
1098  return 1;
1099  } else if (*s < (rpmuint8_t)255) {
1100  *lenp = (unsigned int) ((((unsigned)s[0]) - 192) << 8) + (unsigned)s[1] + 192;
1101  return 2;
1102  } else {
1103  *lenp = pgpGrab(s+1, 4);
1104  return 5;
1105  }
1106 }
1107 
1113 /*@unused@*/ static inline
1114 unsigned int pgpMpiBits(const rpmuint8_t * p)
1115  /*@requires maxRead(p) >= 1 @*/
1116  /*@*/
1117 {
1118  return (unsigned int) ((p[0] << 8) | p[1]);
1119 }
1120 
1126 /*@unused@*/ static inline
1127 unsigned int pgpMpiLen(const rpmuint8_t * p)
1128  /*@requires maxRead(p) >= 1 @*/
1129  /*@*/
1130 {
1131  return (2 + ((pgpMpiBits(p)+7)>>3));
1132 }
1133 
1141 /*@unused@*/ static inline
1142 char * pgpHexCvt(/*@returned@*/ char * t, const rpmuint8_t * s, size_t nbytes)
1143  /*@modifies *t @*/
1144 {
1145  static char hex[] = "0123456789abcdef";
1146  while (nbytes-- > 0) {
1147  unsigned int i;
1148  i = (unsigned int) *s++;
1149  *t++ = hex[ (i >> 4) & 0xf ];
1150  *t++ = hex[ (i ) & 0xf ];
1151  }
1152  *t = '\0';
1153  return t;
1154 }
1155 
1163 /*@unused@*/ static inline /*@observer@*/
1164 char * pgpHexStr(const rpmuint8_t * p, size_t plen)
1165  /*@*/
1166 {
1167  static char prbuf[8*BUFSIZ]; /* XXX ick */
1168  char *t = prbuf;
1169  t = pgpHexCvt(t, p, plen);
1170  return prbuf;
1171 }
1172 
1179 /*@unused@*/ static inline /*@observer@*/
1180 const char * pgpMpiStr(const rpmuint8_t * p)
1181  /*@requires maxRead(p) >= 3 @*/
1182  /*@*/
1183 {
1184  static char prbuf[8*BUFSIZ]; /* XXX ick */
1185  char *t = prbuf;
1186  sprintf(t, "[%4u]: ", pgpGrab(p, 2));
1187  t += strlen(t);
1188  t = pgpHexCvt(t, p+2, pgpMpiLen(p)-2);
1189  return prbuf;
1190 }
1191 
1198 /*@unused@*/ static inline /*@observer@*/
1200  /*@*/
1201 {
1202  do {
1203  if (vs->val == (int)val)
1204  break;
1205  } while ((++vs)->val != -1);
1206  return vs->str;
1207 }
1208 
1216 /*@unused@*/ static inline
1217 int pgpValTok(pgpValTbl vs, const char * s, const char * se)
1218  /*@*/
1219 {
1220  do {
1221  size_t vlen = strlen(vs->str);
1222  if (vlen <= (size_t)(se-s) && !strncmp(s, vs->str, vlen))
1223  break;
1224  } while ((++vs)->val != -1);
1225  return vs->val;
1226 }
1227 
1234 /*@-exportlocal@*/
1235 void pgpPrtVal(const char * pre, pgpValTbl vs, rpmuint8_t val)
1236  /*@globals fileSystem @*/
1237  /*@modifies fileSystem @*/;
1238 /*@=exportlocal@*/
1239 
1247 #if defined(_RPMPGP_INTERNAL)
1248 /*@-exportlocal@*/
1249 int pgpPrtSubType(const rpmuint8_t * h, size_t hlen, pgpSigType sigtype)
1250  /*@globals fileSystem @*/
1251  /*@modifies fileSystem @*/;
1252 /*@=exportlocal@*/
1253 #endif
1254 
1260 #if defined(_RPMPGP_INTERNAL)
1261 /*@-exportlocal@*/
1262 int pgpPrtSig(const pgpPkt pp)
1263  /*@globals fileSystem, internalState @*/
1264  /*@modifies fileSystem, internalState @*/;
1265 
1266 int pgpPrtSigParams(pgpDig dig, const pgpPkt pp, pgpPubkeyAlgo pubkey_algo,
1267  pgpSigType sigtype, const rpmuint8_t * p)
1268  /*@globals fileSystem @*/
1269  /*@modifies fileSystem @*/;
1270 
1271 const rpmuint8_t * pgpPrtPubkeyParams(pgpDig dig, const pgpPkt pp,
1272  pgpPubkeyAlgo pubkey_algo, /*@returned@*/ const rpmuint8_t * p)
1273  /*@globals fileSystem, internalState @*/
1274  /*@modifies fileSystem, internalState @*/;
1275 
1276 /*@=exportlocal@*/
1277 #endif
1278 
1284 #if defined(_RPMPGP_INTERNAL)
1285 int pgpPrtKey(const pgpPkt pp)
1286  /*@globals fileSystem, internalState @*/
1287  /*@modifies fileSystem, internalState @*/;
1288 #endif
1289 
1295 #if defined(_RPMPGP_INTERNAL)
1296 /*@-exportlocal@*/
1297 int pgpPrtUserID(const pgpPkt pp)
1298  /*@globals fileSystem, internalState @*/
1299  /*@modifies fileSystem, internalState @*/;
1300 /*@=exportlocal@*/
1301 #endif
1302 
1308 #if defined(_RPMPGP_INTERNAL)
1309 /*@-exportlocal@*/
1310 int pgpPrtComment(const pgpPkt pp)
1311  /*@globals fileSystem @*/
1312  /*@modifies fileSystem @*/;
1313 /*@=exportlocal@*/
1314 #endif
1315 
1324 /*@-exportlocal@*/
1325 int pgpPubkeyFingerprint(const rpmuint8_t * pkt, size_t pktlen,
1326  /*@out@*/ rpmuint8_t * keyid)
1327  /*@modifies *keyid @*/;
1328 /*@=exportlocal@*/
1329 
1337 int pgpExtractPubkeyFingerprint(const char * b64pkt,
1338  /*@out@*/ rpmuint8_t * keyid)
1339  /*@modifies *keyid @*/;
1340 
1348 #if defined(_RPMPGP_INTERNAL)
1349 int pgpPktLen(const rpmuint8_t * pkt, size_t pleft, /*@out@*/ pgpPkt pp)
1350  /*@modifies pp @*/;
1351 #endif
1352 
1359 /*@-exportlocal@*/
1360 int pgpPrtPkt(const rpmuint8_t * pkt, size_t pleft)
1361  /*@globals fileSystem, internalState @*/
1362  /*@modifies fileSystem, internalState @*/;
1363 /*@=exportlocal@*/
1364 
1373 int pgpGrabPkts(const rpmuint8_t * pkts, size_t pktlen,
1374  /*@out@*/ rpmuint8_t *** pppkts, /*@out@*/ int * pnpkts)
1375  /*@modifies *pppkts, *pnpkts @*/;
1376 
1385 int pgpPrtPkts(const rpmuint8_t * pkts, size_t pktlen, pgpDig dig, int printing)
1386  /*@globals fileSystem, internalState @*/
1387  /*@modifies dig, fileSystem, internalState @*/;
1388 
1397  /*@out@*/ rpmuint8_t ** pkt, /*@out@*/ size_t * pktlen)
1398  /*@globals h_errno, fileSystem, internalState @*/
1399  /*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
1400 
1408 pgpArmor pgpReadPkts(const char * fn,
1409  /*@out@*/ rpmuint8_t ** pkt, /*@out@*/ size_t * pktlen)
1410  /*@globals h_errno, fileSystem, internalState @*/
1411  /*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
1412 
1420 char * pgpArmorWrap(rpmuint8_t atype, const unsigned char * s, size_t ns)
1421  /*@*/;
1422 
1429 pgpHashAlgo pgpHashAlgoStringToNumber(const char *name, size_t name_len)
1430  /*@*/;
1431 
1435 /*@unchecked@*/
1436 extern pgpVSFlags pgpDigVSFlags;
1437 
1443 /*@unused@*/ /*@null@*/
1444 pgpDig pgpDigUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ pgpDig dig)
1445  /*@modifies dig @*/;
1446 #define pgpDigUnlink(_dig) \
1447  ((pgpDig)rpmioUnlinkPoolItem((rpmioItem)(_dig), __FUNCTION__, __FILE__, __LINE__))
1448 
1454 /*@unused@*/ /*@newref@*/ /*@null@*/
1455 pgpDig pgpDigLink (/*@null@*/ pgpDig dig)
1456  /*@modifies dig @*/;
1457 #define pgpDigLink(_dig) \
1458  ((pgpDig)rpmioLinkPoolItem((rpmioItem)(_dig), __FUNCTION__, __FILE__, __LINE__))
1459 
1465 /*@unused@*/ /*@null@*/
1466 pgpDig pgpDigFree(/*@killref@*/ /*@only@*/ /*@null@*/ pgpDig dig)
1467  /*@modifies dig @*/;
1468 #define pgpDigFree(_dig) \
1469  ((pgpDig)rpmioFreePoolItem((rpmioItem)(_dig), __FUNCTION__, __FILE__, __LINE__))
1470 
1478 /*@relnull@*/
1480  /*@globals fileSystem @*/
1481  /*@modifies fileSystem @*/;
1483  /*@*/;
1484 int rpmbcExportSignature(pgpDig dig, /*@only@*/ DIGEST_CTX ctx)
1485  /*@*/;
1486 
1491 void pgpDigClean(/*@null@*/ pgpDig dig)
1492  /*@modifies dig @*/;
1493 
1499 /*@exposed@*/
1501  /*@*/;
1502 
1508 /*@exposed@*/
1510  /*@*/;
1511 
1518  /*@*/;
1519 
1526  /*@*/;
1527 
1533 /*@observer@*/ /*@null@*/
1534 extern const void * pgpGetSig(const pgpDig dig)
1535  /*@*/;
1536 
1543  /*@*/;
1544 
1554 int pgpSetSig(pgpDig dig,
1555  rpmuint32_t sigtag, rpmuint32_t sigtype,
1556  /*@kept@*/ /*@null@*/ const void * sig, rpmuint32_t siglen)
1557  /*@modifies dig @*/;
1558 
1565 /*@null@*/
1566 void * pgpStatsAccumulator(pgpDig dig, int opx)
1567  /*@*/;
1568 
1577  /*@null@*/ int (*findPubkey) (void *ts, /*@null@*/ void *dig),
1578  /*@exposed@*/ /*@null@*/ void * _ts)
1579  /*@modifies dig @*/;
1580 
1586 int pgpFindPubkey(pgpDig dig)
1587  /*@modifies dig @*/;
1588 
1595 /*@unused@*/ static inline
1596 int pgpIsPkt(const rpmuint8_t * p, /*@null@*/ pgpTag * tagp)
1597  /*@modifies *tagp @*/
1598 {
1599  unsigned int val = (unsigned int) *p++;
1600  pgpTag tag;
1601  int rc;
1602 
1603  /* XXX can't deal with these. */
1604  if (!(val & 0x80))
1605  return 0;
1606 
1607  if (val & 0x40)
1608  tag = (pgpTag)(val & 0x3f);
1609  else
1610  tag = (pgpTag)((val >> 2) & 0xf);
1611 
1612  switch (tag) {
1613  case PGPTAG_MARKER:
1616  case PGPTAG_PUBLIC_KEY:
1617  case PGPTAG_SECRET_KEY:
1619  case PGPTAG_SIGNATURE:
1620  case PGPTAG_COMMENT:
1621  case PGPTAG_COMMENT_OLD:
1622  case PGPTAG_LITERAL_DATA:
1624  case PGPTAG_SYMMETRIC_DATA:
1625  rc = 1;
1626  break;
1627  case PGPTAG_PUBLIC_SUBKEY:
1628  case PGPTAG_SECRET_SUBKEY:
1629  case PGPTAG_USER_ID:
1630  case PGPTAG_RESERVED:
1631  case PGPTAG_TRUST:
1632  case PGPTAG_PHOTOID:
1633  case PGPTAG_ENCRYPTED_MDC:
1634  case PGPTAG_MDC:
1635  case PGPTAG_PRIVATE_60:
1636  case PGPTAG_PRIVATE_62:
1637  case PGPTAG_CONTROL:
1638  default:
1639  rc = 0;
1640  break;
1641  }
1642  if (tagp != NULL)
1643  *tagp = tag;
1644  return rc;
1645 }
1646 
1647 #define CRC24_INIT 0xb704ce
1648 #define CRC24_POLY 0x1864cfb
1649 
1656 /*@unused@*/ static inline
1657 unsigned int pgpCRC(const rpmuint8_t * octets, size_t len)
1658  /*@*/
1659 {
1660  unsigned int crc = CRC24_INIT;
1661  int i;
1662 
1663  while (len--) {
1664  crc ^= (*octets++) << 16;
1665  for (i = 0; i < 8; i++) {
1666  crc <<= 1;
1667  if (crc & 0x1000000)
1668  crc ^= CRC24_POLY;
1669  }
1670  }
1671  return crc & 0xffffff;
1672 }
1673 
1677  /*@modifies ctx, dig @*/;
1678 
1681 typedef int (*pgpImplErrChk_t) (pgpDig dig, const char * msg, int rc, unsigned expected)
1682  /*@*/;
1683 
1686 typedef int (*pgpImplAvailable_t) (pgpDig dig, int algo)
1687  /*@*/;
1688 
1692  /*@*/;
1693 
1697  /*@*/;
1698 
1702  /*@*/;
1703 
1706 typedef int (*pgpImplMpiItem_t) (const char * pre, pgpDig dig, int itemno,
1707  const rpmuint8_t * p, /*@null@*/ const rpmuint8_t * pend)
1708  /*@globals fileSystem @*/
1709  /*@modifies dig, fileSystem @*/;
1710 
1713 typedef void (*pgpImplClean_t) (void * impl)
1714  /*@modifies impl @*/;
1715 
1718 typedef void * (*pgpImplFree_t) (/*@only@*/ void * impl)
1719  /*@modifies impl @*/;
1720 
1723 typedef void * (*pgpImplInit_t) (void)
1724  /*@*/;
1725 
1726 
1729 typedef struct pgpImplVecs_s {
1734 
1739 
1743 
1748 } pgpImplVecs_t;
1749 
1752 /*@unchecked@*/
1753 extern pgpImplVecs_t * pgpImplVecs;
1754 
1755 /*@-mustmod@*/
1758 /*@unused@*/ static inline
1760  /*@modifies ctx, dig @*/
1761 {
1762  return (*pgpImplVecs->_pgpSetRSA) (ctx, dig, sigp);
1763 }
1764 
1767 /*@unused@*/ static inline
1769  /*@modifies ctx, dig @*/
1770 {
1771  return (*pgpImplVecs->_pgpSetDSA) (ctx, dig, sigp);
1772 }
1773 
1776 /*@unused@*/ static inline
1778  /*@modifies ctx, dig @*/
1779 {
1780  return (*pgpImplVecs->_pgpSetELG) (ctx, dig, sigp);
1781 }
1782 
1785 /*@unused@*/ static inline
1787  /*@modifies ctx, dig @*/
1788 {
1789  return (*pgpImplVecs->_pgpSetECDSA) (ctx, dig, sigp);
1790 }
1791 
1794 /*@unused@*/ static inline
1795 int pgpImplErrChk(pgpDig dig, const char * msg, int rc, unsigned expected)
1796  /*@*/
1797 {
1798  return (pgpImplVecs->_pgpErrChk
1799  ? (*pgpImplVecs->_pgpErrChk) (dig, msg, rc, expected)
1800  : rc);
1801 }
1802 
1805 /*@unused@*/ static inline
1806 int pgpImplAvailableCipher(pgpDig dig, int algo)
1807  /*@*/
1808 {
1809  return (pgpImplVecs->_pgpAvailableCipher
1810  ? (*pgpImplVecs->_pgpAvailableCipher) (dig, algo)
1811  : 0);
1812 }
1813 
1816 /*@unused@*/ static inline
1817 int pgpImplAvailableDigest(pgpDig dig, int algo)
1818  /*@*/
1819 {
1820  return (pgpImplVecs->_pgpAvailableDigest
1821  ? (*pgpImplVecs->_pgpAvailableDigest) (dig, algo)
1822  : 0);
1823 }
1824 
1827 /*@unused@*/ static inline
1828 int pgpImplAvailablePubkey(pgpDig dig, int algo)
1829  /*@*/
1830 {
1831  return (pgpImplVecs->_pgpAvailablePubkey
1832  ? (*pgpImplVecs->_pgpAvailablePubkey) (dig, algo)
1833  : 0);
1834 }
1835 
1838 /*@unused@*/ static inline
1840  /*@*/
1841 {
1842  return (pgpImplVecs->_pgpVerify
1843  ? (*pgpImplVecs->_pgpVerify) (dig)
1844  : 0);
1845 }
1846 
1849 /*@unused@*/ static inline
1851  /*@*/
1852 {
1853  return (pgpImplVecs->_pgpSign
1854  ? (*pgpImplVecs->_pgpSign) (dig)
1855  : 0);
1856 }
1857 
1860 /*@unused@*/ static inline
1862  /*@*/
1863 {
1864  return (pgpImplVecs->_pgpGenerate
1865  ? (*pgpImplVecs->_pgpGenerate) (dig)
1866  : 0);
1867 }
1868 
1871 /*@unused@*/ static inline
1872 int pgpImplMpiItem(const char * pre, pgpDig dig, int itemno,
1873  const rpmuint8_t * p, /*@null@*/ const rpmuint8_t * pend)
1874  /*@modifies dig @*/
1875 {
1876  return (*pgpImplVecs->_pgpMpiItem) (pre, dig, itemno, p, pend);
1877 }
1878 
1881 /*@unused@*/ static inline
1882 void pgpImplClean(void * impl)
1883  /*@modifies impl @*/
1884 {
1885 /*@-noeffectuncon@*/
1886  (*pgpImplVecs->_pgpClean) (impl);
1887 /*@=noeffectuncon@*/
1888 }
1889 
1892 /*@unused@*/ static inline
1893 /*@null@*/
1894 void * pgpImplFree(/*@only@*/ void * impl)
1895  /*@modifies impl @*/
1896 {
1897  return (*pgpImplVecs->_pgpFree) (impl);
1898 }
1899 
1902 /*@unused@*/ static inline
1903 void * pgpImplInit(void)
1904  /*@*/
1905 {
1906  return (*pgpImplVecs->_pgpInit) ();
1907 }
1908 /*@=mustmod@*/
1909 
1910 
1911 #ifdef __cplusplus
1912 }
1913 #endif
1914 /*@=fcnuse@*/
1915 
1916 #endif /* H_RPMPGP */
rpmuint8_t pubkey_algo
Definition: rpmpgp.h:762
rpmuint32_t siglen
Definition: signature.c:618
rpmuint8_t userid[1]
Definition: rpmpgp.h:982
static unsigned int pgpMpiBits(const rpmuint8_t *p)
Return no.
Definition: rpmpgp.h:1114
void pgpHexCvt(t, md5sum, md5len)
struct pgpPktSigV3_s v3
Definition: rpmpgp.h:573
rpmuint8_t sigtype
Definition: rpmpgp.h:418
5.5.1.
Definition: rpmpgp.h:721
const rpmuint8_t * pgpPrtPubkeyParams(pgpDig dig, const pgpPkt pp, pgpPubkeyAlgo pubkey_algo, const rpmuint8_t *p)
Definition: rpmpgp.c:681
pgpImplVecs_t * pgpImplVecs
Definition: rpmpgp.c:38
struct pgpPktLdata_s pgpPktLdata
5.8.
5.7.
Definition: rpmpgp.h:897
rpmuint8_t data[1]
Definition: rpmpgp.h:898
void pgpPrtVal(const char *pre, pgpValTbl vs, rpmuint8_t val)
Print an OpenPGP value.
Definition: rpmpgp.c:289
enum pgpPubkeyAlgo_e pgpPubkeyAlgo
9.1.
int pgpGrabPkts(const rpmuint8_t *pkts, size_t pktlen, rpmuint8_t ***pppkts, int *pnpkts)
Return array of packet pointers.
Definition: rpmpgp.c:1306
rpmuint8_t hash_algo
Definition: rpmpgp.h:420
DIGEST_CTX ctx
Definition: signature.c:785
struct pgpPktSigV4_s * pgpPktSigV4
5.2.3.
struct pgpPktTrust_s pgpPktTrust
5.10.
int(* pgpImplSign_t)(pgpDig dig)
Definition: rpmpgp.h:1696
void *(* pgpImplFree_t)(void *impl)
Definition: rpmpgp.h:1718
rpmuint8_t compressalgo
Definition: rpmpgp.h:859
return se
Definition: macro.c:897
rpmuint8_t format
Definition: rpmpgp.h:949
struct pgpPktPubkey_s pgpPktPubkey
5.1.
int pgpPktLen(const rpmuint8_t *pkt, size_t pleft, pgpPkt pp)
Definition: rpmpgp.c:939
static int pgpImplAvailableDigest(pgpDig dig, int algo)
Definition: rpmpgp.h:1817
int pgpExtractPubkeyFingerprint(const char *b64pkt, rpmuint8_t *keyid)
Extract OpenPGP public key fingerprint from base64 encoded packet.
Definition: rpmpgp.c:1028
int(* pgpImplErrChk_t)(pgpDig dig, const char *msg, int rc, unsigned expected)
Definition: rpmpgp.h:1681
pgpImplAvailable_t _pgpAvailableCipher
Definition: rpmpgp.h:1736
5.6.
Definition: rpmpgp.h:858
struct pgpPktKeyV3_s * pgpPktKeyV3
5.5.1.
int pgpPrtPkt(const rpmuint8_t *pkt, size_t pleft)
Return lenth of a OpenPGP packet.
Definition: rpmpgp.c:1040
* lenp
Definition: header.c:1796
enum pgpSymkeyAlgo_e pgpSymkeyAlgo
9.2.
5.11.
Definition: rpmpgp.h:981
static char *size_t nb
fgets(3) analogue that reads \ continuations.
Definition: macro.c:409
int pgpPubkeyFingerprint(const rpmuint8_t *pkt, size_t pktlen, rpmuint8_t *keyid)
Print/parse an OpenPGP subtype packet.
Definition: rpmpgp.c:969
int rc
Definition: poptALL.c:670
struct pgpPktCdata_s pgpPktCdata
5.6.
pgpImplSet_t _pgpSetECDSA
Definition: rpmpgp.h:1733
pgpTag_e
4.3.
Definition: rpmpgp.h:127
int pgpFindPubkey(pgpDig dig)
Call find pubkey vector.
Definition: rpmpgp.c:1298
#define CRC24_POLY
Definition: rpmpgp.h:1648
pgpPubkeyAlgo_e
9.1.
Definition: rpmpgp.h:257
struct pgpPktKeyV4_s * pgpPktKeyV4
The version 4 format is similar to the version 3 format except for the absence of a validity period...
rpmuint8_t data[1]
Definition: rpmpgp.h:860
5.2.3.
Definition: rpmpgp.h:416
enum pgpCompressAlgo_e pgpCompressAlgo
9.3.
#define pgpDigLink(_dig)
Definition: rpmpgp.h:1457
rpmuint8_t pubkey_algo
Definition: rpmpgp.h:419
static int pgpImplGenerate(pgpDig dig)
Definition: rpmpgp.h:1861
void pgpDigClean(pgpDig dig)
Release (malloc&#39;d) data from container.
Definition: rpmpgp.c:1106
pgpImplMpiItem_t _pgpMpiItem
Definition: rpmpgp.h:1744
rpmuint8_t keyid[8]
Definition: rpmpgp.h:194
#define pgpDigUnlink(_dig)
Definition: rpmpgp.h:1446
Header h
Definition: spec.c:739
enum pgpArmorKey_e pgpArmorKey
pgpImplClean_t _pgpClean
Definition: rpmpgp.h:1745
static int pgpImplSign(pgpDig dig)
Definition: rpmpgp.h:1850
pgpArmorKey_e
Definition: rpmpgp.h:1017
static int pgpImplAvailableCipher(pgpDig dig, int algo)
Definition: rpmpgp.h:1806
repo _ts
Definition: rpmrepo.c:164
struct pgpDig_s * pgpDig
Definition: rpmiotypes.h:86
static int pgpImplSetELG(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
Definition: rpmpgp.h:1777
static int pgpImplSetDSA(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
Definition: rpmpgp.h:1768
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
Definition: rpmiotypes.h:26
struct rpmiob_s * rpmiob
Definition: rpmiotypes.h:60
5.2.2.
Definition: rpmpgp.h:384
sprintf(t," (%u)",(unsigned) dig->nbytes)
pgpArmor pgpReadPkts(const char *fn, rpmuint8_t **pkt, size_t *pktlen)
Parse armored OpenPGP packets from a file.
Definition: rpmpgp.c:1569
5.5.3.
Definition: rpmpgp.h:829
rpmuint8_t hashlen
Definition: rpmpgp.h:386
pgpDig pgpDigNew(pgpVSFlags vsflags, pgpPubkeyAlgo pubkey_algo)
Create a container for parsed OpenPGP packates.
Definition: rpmpgp.c:1205
static unsigned int pgpCRC(const rpmuint8_t *octets, size_t len)
Return CRC of a buffer.
Definition: rpmpgp.h:1657
pgpImplAvailable_t _pgpAvailableDigest
Definition: rpmpgp.h:1737
size_t ns
Definition: db3.c:1892
struct pgpValTbl_s pgpTagTbl[]
Definition: rpmpgp.c:205
static void * pgpImplFree(void *impl)
Definition: rpmpgp.h:1894
struct pgpPktSymkey_s pgpPktSymkey
5.3.
static void * pgpImplInit(void)
Definition: rpmpgp.h:1903
unsigned int rpmuint32_t
Definition: rpmiotypes.h:28
pgpVSFlags pgpDigVSFlags
Disabler bits(s) for signature/digest checking.
Definition: rpmpgp.c:1104
rpmuint8_t algo
Definition: rpmpgp.h:195
rpmuint8_t symkey_algo
Definition: rpmpgp.h:607
rpmuint8_t filename[1]
Definition: rpmpgp.h:951
struct pgpValTbl_s pgpHashTbl[]
Hash (string, value) pairs.
Definition: rpmpgp.c:143
char * p
Definition: macro.c:413
void *(* pgpImplInit_t)(void)
Definition: rpmpgp.h:1723
pgpArmor_e
Definition: rpmpgp.h:988
static char * pgpHexStr(const rpmuint8_t *p, size_t plen)
Return hex formatted representation of bytes.
Definition: rpmpgp.h:1164
int pgpPrtSigParams(pgpDig dig, const pgpPkt pp, pgpPubkeyAlgo pubkey_algo, pgpSigType sigtype, const rpmuint8_t *p)
Definition: rpmpgp.c:429
rpmuint8_t version
Definition: rpmpgp.h:760
enum pgpHashAlgo_e pgpHashAlgo
9.4.
int(* pgpImplAvailable_t)(pgpDig dig, int algo)
Definition: rpmpgp.h:1686
rpmuint8_t filenamelen
Definition: rpmpgp.h:950
rpmuint8_t flag
Definition: rpmpgp.h:968
struct pgpPktEdata_s pgpPktEdata
5.7.
void * pgpStatsAccumulator(pgpDig dig, int opx)
Return pgpDig container accumulator structure.
Definition: rpmpgp.c:1270
he tag
Definition: db3.c:1927
rpmuint8_t pubkey_algo
Definition: rpmpgp.h:644
int _pgp_error_count
Definition: rpmpgp.c:35
rpmuint8_t valid[2]
Definition: rpmpgp.h:724
pgpDigParams pgpGetSignature(pgpDig dig)
Return OpenPGP signature parameters.
Definition: rpmpgp.c:1226
enum pgpVSFlags_e pgpVSFlags
Bit(s) to control digest and signature verification.
Digest private data.
Definition: digest.c:127
key
Definition: macro.c:383
unsigned int pktlen
Definition: rpmts-py.c:1092
rpmuint8_t signid[8]
Definition: rpmpgp.h:645
int pgpPrtPkts(const rpmuint8_t *pkts, size_t pktlen, pgpDig dig, int printing)
Print/parse a OpenPGP packet(s).
Definition: rpmpgp.c:1352
pgpImplSet_t _pgpSetRSA
Definition: rpmpgp.h:1730
union pgpPktKey_u pgpPktKey
5.5.3.
rpmuint8_t version
Definition: rpmpgp.h:193
struct pgpValTbl_s * pgpValTbl
return k val
Definition: rpmmtree.c:401
struct pgpValTbl_s pgpArmorTbl[]
Armor (string, value) pairs.
Definition: rpmpgp.c:231
struct pgpPkt_s * pgpPkt
Definition: rpmiotypes.h:82
static int pgpImplSetECDSA(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
Definition: rpmpgp.h:1786
rpmuint8_t sigtype
Definition: rpmpgp.h:387
enum pgpSubType_e pgpSubType
5.2.3.1.
rpmuint8_t version
Definition: rpmpgp.h:385
rpmuint8_t time[4]
Definition: rpmpgp.h:723
static int pgpImplErrChk(pgpDig dig, const char *msg, int rc, unsigned expected)
Definition: rpmpgp.h:1795
rpmuint8_t nested
Definition: rpmpgp.h:646
pgpImplAvailable_t _pgpAvailablePubkey
Definition: rpmpgp.h:1738
static const char * pgpMpiStr(const rpmuint8_t *p)
Return hex formatted representation of a multiprecision integer.
Definition: rpmpgp.h:1180
pgpImplSet_t _pgpSetDSA
Definition: rpmpgp.h:1731
rpmuint8_t sigtype
Definition: rpmpgp.h:642
pgpSubType_e
5.2.3.1.
Definition: rpmpgp.h:503
static unsigned
Definition: rpmmtree.c:386
rpmuint32_t pgpGetSigtype(pgpDig dig)
Get signature tag type.
Definition: rpmpgp.c:1241
pgpImplErrChk_t _pgpErrChk
Definition: rpmpgp.h:1735
pgpImplInit_t _pgpInit
Definition: rpmpgp.h:1747
pgpImplVerify_t _pgpVerify
Definition: rpmpgp.h:1740
char * pgpArmorWrap(rpmuint8_t atype, const unsigned char *s, size_t ns)
Wrap a OpenPGP packets in ascii armor for transport.
Definition: rpmpgp.c:1579
int j
Definition: spec.c:743
Cumulative statistics for an operation.
Definition: rpmsw.h:39
pgpImplSet_t _pgpSetELG
Definition: rpmpgp.h:1732
struct pgpPktUid_s pgpPktUid
5.11.
static unsigned int pgpLen(const rpmuint8_t *s, unsigned int *lenp)
Return length of an OpenPGP packet.
Definition: rpmpgp.h:1093
rpmuint32_t pgpGetSigtag(pgpDig dig)
Get signature tag.
Definition: rpmpgp.c:1236
int rpmbcExportSignature(pgpDig dig, DIGEST_CTX ctx)
Definition: rpmbc.c:923
static int pgpImplSetRSA(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
Definition: rpmpgp.h:1759
struct pgpPktSigV3_s * pgpPktSigV3
5.2.2.
void(* pgpImplClean_t)(void *impl)
Definition: rpmpgp.h:1713
int(* pgpImplMpiItem_t)(const char *pre, pgpDig dig, int itemno, const rpmuint8_t *p, const rpmuint8_t *pend)
Definition: rpmpgp.h:1706
fts u
Definition: rpmmtree.c:3828
rpmuint8_t time[4]
Definition: rpmpgp.h:761
rpmuint8_t hash_algo
Definition: rpmpgp.h:643
enum pgpTag_e pgpTag
4.3.
pgpImplFree_t _pgpFree
Definition: rpmpgp.h:1746
int pgpPrtSubType(const rpmuint8_t *h, size_t hlen, pgpSigType sigtype)
Definition: rpmpgp.c:299
size_t md5len
Definition: signature.c:621
int pgpPrtComment(const pgpPkt pp)
Definition: rpmpgp.c:910
const char * s
Definition: poptALL.c:734
char * t
Definition: rpmds.c:2716
struct pgpValTbl_s pgpArmorKeyTbl[]
Armor key (string, value) pairs.
Definition: rpmpgp.c:242
static void pgpImplClean(void *impl)
Definition: rpmpgp.h:1882
static int pgpIsPkt(const rpmuint8_t *p, pgpTag *tagp)
Is buffer at beginning of an OpenPGP packet?
Definition: rpmpgp.h:1596
static unsigned int pgpMpiLen(const rpmuint8_t *p)
Return no.
Definition: rpmpgp.h:1127
int(* pgpImplGenerate_t)(pgpDig dig)
Definition: rpmpgp.h:1691
const char * str
Definition: rpmpgp.h:117
int pgpSetFindPubkey(pgpDig dig, int(*findPubkey)(void *ts, void *dig), void *_ts)
Set find pubkey vector.
Definition: rpmpgp.c:1284
pgpSigType_e
5.2.1.
Definition: rpmpgp.h:205
struct pgpPktKeyV4_s v4
Definition: rpmpgp.h:831
struct pgpValTbl_s pgpSubTypeTbl[]
Subtype (string, value) pairs.
Definition: rpmpgp.c:165
const void * pgpGetSig(pgpDig dig)
Get signature tag data, i.e.
Definition: rpmpgp.c:1246
5.2.
Definition: rpmpgp.h:572
struct pgpPktSigV4_s v4
Definition: rpmpgp.h:574
int pgpPrtUserID(const pgpPkt pp)
Definition: rpmpgp.c:893
static int pgpImplVerify(pgpDig dig)
Definition: rpmpgp.h:1839
rpmuint8_t version
Definition: rpmpgp.h:606
rpmuint8_t signhash16[2]
Definition: rpmpgp.h:392
const char * msg
Definition: rpmts-py.c:976
struct pgpDigParams_s * pgpDigParams
Definition: rpmiotypes.h:90
rpmuint8_t time[4]
Definition: rpmpgp.h:388
struct pgpValTbl_s pgpSymkeyTbl[]
Symmetric key (string, value) pairs.
Definition: rpmpgp.c:116
return NULL
Definition: poptALL.c:613
pgpSymkeyAlgo_e
9.2.
Definition: rpmpgp.h:302
int val
Definition: rpmpgp.h:115
rpmuint8_t version
Definition: rpmpgp.h:417
rpmuint8_t version
Definition: rpmpgp.h:641
static const char * pgpValStr(pgpValTbl vs, rpmuint8_t val)
Return string representation of am OpenPGP value.
Definition: rpmpgp.h:1199
pgpHashAlgo pgpHashAlgoStringToNumber(const char *name, size_t name_len)
Convert a hash algorithm &quot;foo&quot; to the internal PGPHASHALGO_FOO number.
Definition: rpmpgp.c:1628
pgpImplSign_t _pgpSign
Definition: rpmpgp.h:1741
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
Definition: spec.c:737
struct pgpPktKeyV3_s v3
Definition: rpmpgp.h:830
k
Definition: rpmmtree.c:394
static const char * name
int pgpSetSig(pgpDig dig, rpmuint32_t sigtag, rpmuint32_t sigtype, const void *sig, rpmuint32_t siglen)
Set signature tag info, i.e.
Definition: rpmpgp.c:1256
rpmuint32_t pgpGetSiglen(pgpDig dig)
Get signature tag data length, i.e.
Definition: rpmpgp.c:1251
enum pgpSigType_e pgpSigType
5.2.1.
static PyObject *unsigned char * pkt
Definition: rpmts-py.c:1089
5.8.
Definition: rpmpgp.h:948
rpmuint8_t version
Definition: rpmpgp.h:722
#define pgpDigFree(_dig)
Definition: rpmpgp.h:1468
int
Save source and expand field into target.
Definition: rpmds.c:2709
static unsigned int pgpGrab(const rpmuint8_t *s, size_t nbytes)
Return (native-endian) integer from big-endian representation.
Definition: rpmpgp.h:1076
rpmuint8_t pubkey_algo
Definition: rpmpgp.h:390
#define CRC24_INIT
Definition: rpmpgp.h:1647
rpmuint8_t hash_algo
Definition: rpmpgp.h:391
static int pgpImplMpiItem(const char *pre, pgpDig dig, int itemno, const rpmuint8_t *p, const rpmuint8_t *pend)
Definition: rpmpgp.h:1872
static int pgpImplAvailablePubkey(pgpDig dig, int algo)
Definition: rpmpgp.h:1828
struct pgpImplVecs_s pgpImplVecs_t
int rpmbcExportPubkey(pgpDig dig)
Definition: rpmbc.c:864
union pgpPktSig_u * pgpPktSig
5.2.
rpmVSFlags vsflags
Definition: rpmrepo.c:161
rpmuint8_t hashlen[2]
Definition: rpmpgp.h:421
pgpDigParams sigp
Definition: signature.c:748
int(* pgpImplVerify_t)(pgpDig dig)
Definition: rpmpgp.h:1701
rpmuint8_t pubkey_algo
Definition: rpmpgp.h:725
pgpCompressAlgo_e
9.3.
Definition: rpmpgp.h:343
int i
Definition: spec.c:743
static int pgpValTok(pgpValTbl vs, const char *s, const char *se)
Return value of an OpenPGP string.
Definition: rpmpgp.h:1217
pgpDig dig
Definition: rpmts-py.c:979
pgpArmor pgpArmorUnwrap(rpmiob iob, rpmuint8_t **pkt, size_t *pktlen)
Parse armored OpenPGP packets from an iob.
Definition: rpmpgp.c:1398
pgpImplGenerate_t _pgpGenerate
Definition: rpmpgp.h:1742
int(* pgpImplSet_t)(DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
Definition: rpmpgp.h:1676
The version 4 format is similar to the version 3 format except for the absence of a validity period...
Definition: rpmpgp.h:759
5.10.
Definition: rpmpgp.h:967
int pgpPrtSig(const pgpPkt pp)
Definition: rpmpgp.c:505
pgpDigParams pgpGetPubkey(pgpDig dig)
Return OpenPGP pubkey parameters.
Definition: rpmpgp.c:1231
struct pgpValTbl_s pgpCompressionTbl[]
Compression (string, value) pairs.
Definition: rpmpgp.c:135
size_t fn
Definition: macro.c:1698
struct pgpValTbl_s pgpPubkeyTbl[]
Definition: rpmpgp.c:103
enum pgpArmor_e pgpArmor
rpmuint8_t signid[8]
Definition: rpmpgp.h:389
int pgpPrtKey(const pgpPkt pp)
Definition: rpmpgp.c:832
int len
Definition: rpmdb-py.c:119
rpmuint8_t s2k[1]
Definition: rpmpgp.h:608
struct pgpPktOnepass_s * pgpPktOnepass
5.4.
struct pgpValTbl_s pgpSigTypeTbl[]
Definition: rpmpgp.c:84