rpm  5.4.10
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;
32  rpmuint8_t tag;
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 {
269 } pgpPubkeyAlgo;
270 /*@=typeuse@*/
271 
274 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
275 extern struct pgpValTbl_s pgpPubkeyTbl[];
276 
302 /*@-typeuse@*/
303 typedef enum pgpSymkeyAlgo_e {
319 } pgpSymkeyAlgo;
320 /*@=typeuse@*/
321 
325 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
326 extern struct pgpValTbl_s pgpSymkeyTbl[];
327 
343 /*@-typeuse@*/
344 typedef enum pgpCompressAlgo_e {
350 /*@=typeuse@*/
351 
355 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
356 extern struct pgpValTbl_s pgpCompressionTbl[];
357 
361 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
362 extern struct pgpValTbl_s pgpHashTbl[];
363 
385 typedef struct pgpPktSigV3_s {
394 } * pgpPktSigV3;
395 
417 typedef struct pgpPktSigV4_s {
423 } * pgpPktSigV4;
424 
503 /*@-typeuse@*/
504 typedef enum pgpSubType_e {
544 } pgpSubType;
545 /*@=typeuse@*/
546 
550 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
551 extern struct pgpValTbl_s pgpSubTypeTbl[];
552 
573 typedef union pgpPktSig_u {
576 } * pgpPktSig;
577 
606 typedef struct pgpPktSymkey_s {
610 } pgpPktSymkey;
611 
641 typedef struct pgpPktOnepass_s {
648 } * pgpPktOnepass;
649 
722 typedef struct pgpPktKeyV3_s {
727 } * pgpPktKeyV3;
728 
760 typedef struct pgpPktKeyV4_s {
764 } * pgpPktKeyV4;
765 
830 typedef union pgpPktKey_u {
833 } pgpPktKey;
834 
859 typedef struct pgpPktCdata_s {
862 } pgpPktCdata;
863 
898 typedef struct pgpPktEdata_s {
900 } pgpPktEdata;
901 
918 /*
919  * 5.9. Literal Data Packet (Tag 11)
920  *
921  * A Literal Data packet contains the body of a message; data that is
922  * not to be further interpreted.
923  *
924  * The body of this packet consists of:
925  * - A one-octet field that describes how the data is formatted.
926  *
927  * If it is a 'b' (0x62), then the literal packet contains binary data.
928  * If it is a 't' (0x74), then it contains text data, and thus may need
929  * line ends converted to local form, or other text-mode changes. RFC
930  * 1991 also defined a value of 'l' as a 'local' mode for machine-local
931  * conversions. This use is now deprecated.
932  * - File name as a string (one-octet length, followed by file name),
933  * if the encrypted data should be saved as a file.
934  *
935  * If the special name "_CONSOLE" is used, the message is considered to
936  * be "for your eyes only". This advises that the message data is
937  * unusually sensitive, and the receiving program should process it more
938  * carefully, perhaps avoiding storing the received data to disk, for
939  * example.
940  * - A four-octet number that indicates the modification date of the
941  * file, or the creation time of the packet, or a zero that
942  * indicates the present time.
943  * - The remainder of the packet is literal data.
944  *
945  * Text data is stored with <CR><LF> text endings (i.e. network-normal
946  * line endings). These should be converted to native line endings by
947  * the receiving software.
948  */
949 typedef struct pgpPktLdata_s {
953 } pgpPktLdata;
954 
968 typedef struct pgpPktTrust_s {
970 } pgpPktTrust;
971 
982 typedef struct pgpPktUid_s {
984 } pgpPktUid;
985 
988 /*@-typeuse@*/
989 typedef enum pgpArmor_e {
997 #define PGPARMOR_ERROR PGPARMOR_ERR_NO_BEGIN_PGP
1006 } pgpArmor;
1007 /*@=typeuse@*/
1008 
1012 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
1013 extern struct pgpValTbl_s pgpArmorTbl[];
1014 
1017 /*@-typeuse@*/
1018 typedef enum pgpArmorKey_e {
1024 } pgpArmorKey;
1025 /*@=typeuse@*/
1026 
1030 /*@observer@*/ /*@unchecked@*/ /*@unused@*/
1031 extern struct pgpValTbl_s pgpArmorKeyTbl[];
1032 
1033 #if defined(_RPMPGP_INTERNAL)
1034 
1036 union pgpPktPre_u {
1037  pgpPktPubkey pubkey;
1038  pgpPktSig sig;
1039  pgpPktSymkey symkey;
1040  pgpPktOnepass onepass;
1041  pgpPktKey key;
1042  pgpPktCdata cdata;
1043  pgpPktEdata edata;
1045  pgpPktLdata ldata;
1046  pgpPktTrust tdata;
1047  pgpPktUid uid;
1048 };
1049 
1050 struct pgpPkt_s {
1051  pgpTag tag;
1052  unsigned int pktlen;
1053  union {
1054  const rpmuint8_t * h;
1055  const pgpPktKeyV3 j;
1056  const pgpPktKeyV4 k;
1057  const pgpPktSigV3 r;
1058  const pgpPktSigV4 s;
1059  const pgpPktUid * u;
1060  } u;
1061  unsigned int hlen;
1062 };
1063 #endif /* _RPMPGP_INTERNAL */
1064 
1065 /*@-fcnuse@*/
1066 #ifdef __cplusplus
1067 extern "C" {
1068 #endif
1069 
1076 /*@unused@*/ static inline
1077 unsigned int pgpGrab(const rpmuint8_t * s, size_t nbytes)
1078  /*@*/
1079 {
1080  unsigned int i = 0;
1081  size_t nb = (nbytes <= sizeof(i) ? nbytes : sizeof(i));
1082  while (nb--)
1083  i = (i << 8) | *s++;
1084  return i;
1085 }
1086 
1093 /*@unused@*/ static inline
1094 unsigned int pgpLen(const rpmuint8_t * s, /*@out@*/ unsigned int * lenp)
1095  /*@modifies *lenp @*/
1096 {
1097  if (*s < (rpmuint8_t)192) {
1098  *lenp = (unsigned int) *s++;
1099  return 1;
1100  } else if (*s < (rpmuint8_t)255) {
1101  *lenp = (unsigned int) ((((unsigned)s[0]) - 192) << 8) + (unsigned)s[1] + 192;
1102  return 2;
1103  } else {
1104  *lenp = pgpGrab(s+1, 4);
1105  return 5;
1106  }
1107 }
1108 
1114 /*@unused@*/ static inline
1115 unsigned int pgpMpiBits(const rpmuint8_t * p)
1116  /*@requires maxRead(p) >= 1 @*/
1117  /*@*/
1118 {
1119  return (unsigned int) ((p[0] << 8) | p[1]);
1120 }
1121 
1127 /*@unused@*/ static inline
1128 unsigned int pgpMpiLen(const rpmuint8_t * p)
1129  /*@requires maxRead(p) >= 1 @*/
1130  /*@*/
1131 {
1132  return (2 + ((pgpMpiBits(p)+7)>>3));
1133 }
1134 
1142 /*@unused@*/ static inline
1143 char * pgpHexCvt(/*@returned@*/ char * t, const rpmuint8_t * s, size_t nbytes)
1144  /*@modifies *t @*/
1145 {
1146  static char hex[] = "0123456789abcdef";
1147  while (nbytes-- > 0) {
1148  unsigned int i;
1149  i = (unsigned int) *s++;
1150  *t++ = hex[ (i >> 4) & 0xf ];
1151  *t++ = hex[ (i ) & 0xf ];
1152  }
1153  *t = '\0';
1154  return t;
1155 }
1156 
1164 /*@unused@*/ static inline /*@observer@*/
1165 char * pgpHexStr(const rpmuint8_t * p, size_t plen)
1166  /*@*/
1167 {
1168  static char prbuf[8*BUFSIZ]; /* XXX ick */
1169  char *t = prbuf;
1170  t = pgpHexCvt(t, p, plen);
1171  return prbuf;
1172 }
1173 
1180 /*@unused@*/ static inline /*@observer@*/
1181 const char * pgpMpiStr(const rpmuint8_t * p)
1182  /*@requires maxRead(p) >= 3 @*/
1183  /*@*/
1184 {
1185  static char prbuf[8*BUFSIZ]; /* XXX ick */
1186  char *t = prbuf;
1187  sprintf(t, "[%4u]: ", pgpGrab(p, 2));
1188  t += strlen(t);
1189  t = pgpHexCvt(t, p+2, pgpMpiLen(p)-2);
1190  return prbuf;
1191 }
1192 
1199 /*@unused@*/ static inline /*@observer@*/
1200 const char * pgpValStr(pgpValTbl vs, rpmuint8_t val)
1201  /*@*/
1202 {
1203  do {
1204  if (vs->val == (int)val)
1205  break;
1206  } while ((++vs)->val != -1);
1207  return vs->str;
1208 }
1209 
1217 /*@unused@*/ static inline
1218 int pgpValTok(pgpValTbl vs, const char * s, const char * se)
1219  /*@*/
1220 {
1221  do {
1222  size_t vlen = strlen(vs->str);
1223  if (vlen <= (size_t)(se-s) && !strncmp(s, vs->str, vlen))
1224  break;
1225  } while ((++vs)->val != -1);
1226  return vs->val;
1227 }
1228 
1235 /*@-exportlocal@*/
1236 void pgpPrtVal(const char * pre, pgpValTbl vs, rpmuint8_t val)
1237  /*@globals fileSystem @*/
1238  /*@modifies fileSystem @*/;
1239 /*@=exportlocal@*/
1240 
1248 #if defined(_RPMPGP_INTERNAL)
1249 /*@-exportlocal@*/
1250 int pgpPrtSubType(const rpmuint8_t * h, size_t hlen, pgpSigType sigtype)
1251  /*@globals fileSystem @*/
1252  /*@modifies fileSystem @*/;
1253 /*@=exportlocal@*/
1254 #endif
1255 
1261 #if defined(_RPMPGP_INTERNAL)
1262 /*@-exportlocal@*/
1263 int pgpPrtSig(const pgpPkt pp)
1264  /*@globals fileSystem, internalState @*/
1265  /*@modifies fileSystem, internalState @*/;
1266 
1267 int pgpPrtSigParams(pgpDig dig, const pgpPkt pp, pgpPubkeyAlgo pubkey_algo,
1268  pgpSigType sigtype, const rpmuint8_t * p)
1269  /*@globals fileSystem @*/
1270  /*@modifies fileSystem @*/;
1271 
1272 const rpmuint8_t * pgpPrtPubkeyParams(pgpDig dig, const pgpPkt pp,
1273  pgpPubkeyAlgo pubkey_algo, /*@returned@*/ const rpmuint8_t * p)
1274  /*@globals fileSystem, internalState @*/
1275  /*@modifies fileSystem, internalState @*/;
1276 
1277 /*@=exportlocal@*/
1278 #endif
1279 
1285 #if defined(_RPMPGP_INTERNAL)
1286 int pgpPrtKey(const pgpPkt pp)
1287  /*@globals fileSystem, internalState @*/
1288  /*@modifies fileSystem, internalState @*/;
1289 #endif
1290 
1296 #if defined(_RPMPGP_INTERNAL)
1297 /*@-exportlocal@*/
1298 int pgpPrtUserID(const pgpPkt pp)
1299  /*@globals fileSystem, internalState @*/
1300  /*@modifies fileSystem, internalState @*/;
1301 /*@=exportlocal@*/
1302 #endif
1303 
1309 #if defined(_RPMPGP_INTERNAL)
1310 /*@-exportlocal@*/
1311 int pgpPrtComment(const pgpPkt pp)
1312  /*@globals fileSystem @*/
1313  /*@modifies fileSystem @*/;
1314 /*@=exportlocal@*/
1315 #endif
1316 
1325 /*@-exportlocal@*/
1326 int pgpPubkeyFingerprint(const rpmuint8_t * pkt, size_t pktlen,
1327  /*@out@*/ rpmuint8_t * keyid)
1328  /*@modifies *keyid @*/;
1329 /*@=exportlocal@*/
1330 
1338 int pgpExtractPubkeyFingerprint(const char * b64pkt,
1339  /*@out@*/ rpmuint8_t * keyid)
1340  /*@modifies *keyid @*/;
1341 
1349 #if defined(_RPMPGP_INTERNAL)
1350 int pgpPktLen(const rpmuint8_t * pkt, size_t pleft, /*@out@*/ pgpPkt pp)
1351  /*@modifies pp @*/;
1352 #endif
1353 
1360 /*@-exportlocal@*/
1361 int pgpPrtPkt(const rpmuint8_t * pkt, size_t pleft)
1362  /*@globals fileSystem, internalState @*/
1363  /*@modifies fileSystem, internalState @*/;
1364 /*@=exportlocal@*/
1365 
1374 int pgpGrabPkts(const rpmuint8_t * pkts, size_t pktlen,
1375  /*@out@*/ rpmuint8_t *** pppkts, /*@out@*/ int * pnpkts)
1376  /*@modifies *pppkts, *pnpkts @*/;
1377 
1386 int pgpPrtPkts(const rpmuint8_t * pkts, size_t pktlen, pgpDig dig, int printing)
1387  /*@globals fileSystem, internalState @*/
1388  /*@modifies dig, fileSystem, internalState @*/;
1389 
1398  /*@out@*/ rpmuint8_t ** pkt, /*@out@*/ size_t * pktlen)
1399  /*@globals h_errno, fileSystem, internalState @*/
1400  /*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
1401 
1409 pgpArmor pgpReadPkts(const char * fn,
1410  /*@out@*/ rpmuint8_t ** pkt, /*@out@*/ size_t * pktlen)
1411  /*@globals h_errno, fileSystem, internalState @*/
1412  /*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
1413 
1421 char * pgpArmorWrap(rpmuint8_t atype, const unsigned char * s, size_t ns)
1422  /*@*/;
1423 
1430 pgpHashAlgo pgpHashAlgoStringToNumber(const char *name, size_t name_len)
1431  /*@*/;
1432 
1436 /*@unchecked@*/
1437 extern pgpVSFlags pgpDigVSFlags;
1438 
1444 /*@unused@*/ /*@null@*/
1445 pgpDig pgpDigUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ pgpDig dig)
1446  /*@modifies dig @*/;
1447 #define pgpDigUnlink(_dig) \
1448  ((pgpDig)rpmioUnlinkPoolItem((rpmioItem)(_dig), __FUNCTION__, __FILE__, __LINE__))
1449 
1455 /*@unused@*/ /*@newref@*/ /*@null@*/
1456 pgpDig pgpDigLink (/*@null@*/ pgpDig dig)
1457  /*@modifies dig @*/;
1458 #define pgpDigLink(_dig) \
1459  ((pgpDig)rpmioLinkPoolItem((rpmioItem)(_dig), __FUNCTION__, __FILE__, __LINE__))
1460 
1466 /*@unused@*/ /*@null@*/
1467 pgpDig pgpDigFree(/*@killref@*/ /*@only@*/ /*@null@*/ pgpDig dig)
1468  /*@modifies dig @*/;
1469 #define pgpDigFree(_dig) \
1470  ((pgpDig)rpmioFreePoolItem((rpmioItem)(_dig), __FUNCTION__, __FILE__, __LINE__))
1471 
1479 /*@relnull@*/
1481  /*@globals fileSystem @*/
1482  /*@modifies fileSystem @*/;
1483 int rpmbcExportPubkey(pgpDig dig)
1484  /*@*/;
1485 int rpmbcExportSignature(pgpDig dig, /*@only@*/ DIGEST_CTX ctx)
1486  /*@*/;
1487 
1492 void pgpDigClean(/*@null@*/ pgpDig dig)
1493  /*@modifies dig @*/;
1494 
1500 /*@exposed@*/
1501 pgpDigParams pgpGetPubkey(const pgpDig dig)
1502  /*@*/;
1503 
1509 /*@exposed@*/
1511  /*@*/;
1512 
1518 rpmuint32_t pgpGetSigtag(const pgpDig dig)
1519  /*@*/;
1520 
1526 rpmuint32_t pgpGetSigtype(const pgpDig dig)
1527  /*@*/;
1528 
1534 /*@observer@*/ /*@null@*/
1535 extern const void * pgpGetSig(const pgpDig dig)
1536  /*@*/;
1537 
1543 rpmuint32_t pgpGetSiglen(const pgpDig dig)
1544  /*@*/;
1545 
1555 int pgpSetSig(pgpDig dig,
1556  rpmuint32_t sigtag, rpmuint32_t sigtype,
1557  /*@kept@*/ /*@null@*/ const void * sig, rpmuint32_t siglen)
1558  /*@modifies dig @*/;
1559 
1566 /*@null@*/
1567 void * pgpStatsAccumulator(pgpDig dig, int opx)
1568  /*@*/;
1569 
1577 int pgpSetFindPubkey(pgpDig dig,
1578  /*@null@*/ int (*findPubkey) (void *ts, /*@null@*/ void *dig),
1579  /*@exposed@*/ /*@null@*/ void * _ts)
1580  /*@modifies dig @*/;
1581 
1587 int pgpFindPubkey(pgpDig dig)
1588  /*@modifies dig @*/;
1589 
1596 /*@unused@*/ static inline
1597 int pgpIsPkt(const rpmuint8_t * p, /*@null@*/ pgpTag * tagp)
1598  /*@modifies *tagp @*/
1599 {
1600  unsigned int val = (unsigned int) *p++;
1601  pgpTag tag;
1602  int rc;
1603 
1604  /* XXX can't deal with these. */
1605  if (!(val & 0x80))
1606  return 0;
1607 
1608  if (val & 0x40)
1609  tag = (pgpTag)(val & 0x3f);
1610  else
1611  tag = (pgpTag)((val >> 2) & 0xf);
1612 
1613  switch (tag) {
1614  case PGPTAG_MARKER:
1617  case PGPTAG_PUBLIC_KEY:
1618  case PGPTAG_SECRET_KEY:
1620  case PGPTAG_SIGNATURE:
1621  case PGPTAG_COMMENT:
1622  case PGPTAG_COMMENT_OLD:
1623  case PGPTAG_LITERAL_DATA:
1625  case PGPTAG_SYMMETRIC_DATA:
1626  rc = 1;
1627  break;
1628  case PGPTAG_PUBLIC_SUBKEY:
1629  case PGPTAG_SECRET_SUBKEY:
1630  case PGPTAG_USER_ID:
1631  case PGPTAG_RESERVED:
1632  case PGPTAG_TRUST:
1633  case PGPTAG_PHOTOID:
1634  case PGPTAG_ENCRYPTED_MDC:
1635  case PGPTAG_MDC:
1636  case PGPTAG_PRIVATE_60:
1637  case PGPTAG_PRIVATE_62:
1638  case PGPTAG_CONTROL:
1639  default:
1640  rc = 0;
1641  break;
1642  }
1643  if (tagp != NULL)
1644  *tagp = tag;
1645  return rc;
1646 }
1647 
1648 #define CRC24_INIT 0xb704ce
1649 #define CRC24_POLY 0x1864cfb
1650 
1657 /*@unused@*/ static inline
1658 unsigned int pgpCRC(const rpmuint8_t * octets, size_t len)
1659  /*@*/
1660 {
1661  unsigned int crc = CRC24_INIT;
1662  int i;
1663 
1664  while (len--) {
1665  crc ^= (*octets++) << 16;
1666  for (i = 0; i < 8; i++) {
1667  crc <<= 1;
1668  if (crc & 0x1000000)
1669  crc ^= CRC24_POLY;
1670  }
1671  }
1672  return crc & 0xffffff;
1673 }
1674 
1677 typedef int (*pgpImplSet_t) (/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
1678  /*@modifies ctx, dig @*/;
1679 
1682 typedef int (*pgpImplErrChk_t) (pgpDig dig, const char * msg, int rc, unsigned expected)
1683  /*@*/;
1684 
1687 typedef int (*pgpImplAvailable_t) (pgpDig dig, int algo)
1688  /*@*/;
1689 
1692 typedef int (*pgpImplGenerate_t) (pgpDig dig)
1693  /*@*/;
1694 
1697 typedef int (*pgpImplSign_t) (pgpDig dig)
1698  /*@*/;
1699 
1702 typedef int (*pgpImplVerify_t) (pgpDig dig)
1703  /*@*/;
1704 
1707 typedef int (*pgpImplMpiItem_t) (const char * pre, pgpDig dig, int itemno,
1708  const rpmuint8_t * p, /*@null@*/ const rpmuint8_t * pend)
1709  /*@globals fileSystem @*/
1710  /*@modifies dig, fileSystem @*/;
1711 
1714 typedef void (*pgpImplClean_t) (void * impl)
1715  /*@modifies impl @*/;
1716 
1719 typedef void * (*pgpImplFree_t) (/*@only@*/ void * impl)
1720  /*@modifies impl @*/;
1721 
1724 typedef void * (*pgpImplInit_t) (void)
1725  /*@*/;
1726 
1727 
1730 typedef struct pgpImplVecs_s {
1735 
1740 
1744 
1749 } pgpImplVecs_t;
1750 
1753 /*@unchecked@*/
1754 extern pgpImplVecs_t * pgpImplVecs;
1755 
1756 /*@-mustmod@*/
1759 /*@unused@*/ static inline
1760 int pgpImplSetRSA(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
1761  /*@modifies ctx, dig @*/
1762 {
1763  return (*pgpImplVecs->_pgpSetRSA) (ctx, dig, sigp);
1764 }
1765 
1768 /*@unused@*/ static inline
1769 int pgpImplSetDSA(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
1770  /*@modifies ctx, dig @*/
1771 {
1772  return (*pgpImplVecs->_pgpSetDSA) (ctx, dig, sigp);
1773 }
1774 
1777 /*@unused@*/ static inline
1778 int pgpImplSetELG(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
1779  /*@modifies ctx, dig @*/
1780 {
1781  return (*pgpImplVecs->_pgpSetELG) (ctx, dig, sigp);
1782 }
1783 
1786 /*@unused@*/ static inline
1787 int pgpImplSetECDSA(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
1788  /*@modifies ctx, dig @*/
1789 {
1790  return (*pgpImplVecs->_pgpSetECDSA) (ctx, dig, sigp);
1791 }
1792 
1795 /*@unused@*/ static inline
1796 int pgpImplErrChk(pgpDig dig, const char * msg, int rc, unsigned expected)
1797  /*@*/
1798 {
1799  return (pgpImplVecs->_pgpErrChk
1800  ? (*pgpImplVecs->_pgpErrChk) (dig, msg, rc, expected)
1801  : rc);
1802 }
1803 
1806 /*@unused@*/ static inline
1807 int pgpImplAvailableCipher(pgpDig dig, int algo)
1808  /*@*/
1809 {
1810  return (pgpImplVecs->_pgpAvailableCipher
1811  ? (*pgpImplVecs->_pgpAvailableCipher) (dig, algo)
1812  : 0);
1813 }
1814 
1817 /*@unused@*/ static inline
1818 int pgpImplAvailableDigest(pgpDig dig, int algo)
1819  /*@*/
1820 {
1821  return (pgpImplVecs->_pgpAvailableDigest
1822  ? (*pgpImplVecs->_pgpAvailableDigest) (dig, algo)
1823  : 0);
1824 }
1825 
1828 /*@unused@*/ static inline
1829 int pgpImplAvailablePubkey(pgpDig dig, int algo)
1830  /*@*/
1831 {
1832  return (pgpImplVecs->_pgpAvailablePubkey
1833  ? (*pgpImplVecs->_pgpAvailablePubkey) (dig, algo)
1834  : 0);
1835 }
1836 
1839 /*@unused@*/ static inline
1841  /*@*/
1842 {
1843  return (pgpImplVecs->_pgpVerify
1844  ? (*pgpImplVecs->_pgpVerify) (dig)
1845  : 0);
1846 }
1847 
1850 /*@unused@*/ static inline
1852  /*@*/
1853 {
1854  return (pgpImplVecs->_pgpSign
1855  ? (*pgpImplVecs->_pgpSign) (dig)
1856  : 0);
1857 }
1858 
1861 /*@unused@*/ static inline
1863  /*@*/
1864 {
1865  return (pgpImplVecs->_pgpGenerate
1866  ? (*pgpImplVecs->_pgpGenerate) (dig)
1867  : 0);
1868 }
1869 
1872 /*@unused@*/ static inline
1873 int pgpImplMpiItem(const char * pre, pgpDig dig, int itemno,
1874  const rpmuint8_t * p, /*@null@*/ const rpmuint8_t * pend)
1875  /*@modifies dig @*/
1876 {
1877  return (*pgpImplVecs->_pgpMpiItem) (pre, dig, itemno, p, pend);
1878 }
1879 
1882 /*@unused@*/ static inline
1883 void pgpImplClean(void * impl)
1884  /*@modifies impl @*/
1885 {
1886 /*@-noeffectuncon@*/
1887  (*pgpImplVecs->_pgpClean) (impl);
1888 /*@=noeffectuncon@*/
1889 }
1890 
1893 /*@unused@*/ static inline
1894 /*@null@*/
1895 void * pgpImplFree(/*@only@*/ void * impl)
1896  /*@modifies impl @*/
1897 {
1898  return (*pgpImplVecs->_pgpFree) (impl);
1899 }
1900 
1903 /*@unused@*/ static inline
1904 void * pgpImplInit(void)
1905  /*@*/
1906 {
1907  return (*pgpImplVecs->_pgpInit) ();
1908 }
1909 /*@=mustmod@*/
1910 
1911 
1912 #ifdef __cplusplus
1913 }
1914 #endif
1915 /*@=fcnuse@*/
1916 
1917 #endif /* H_RPMPGP */