summaryrefslogtreecommitdiff
path: root/rpmio/rpmpgp_sequoia.c
blob: e01acd0e9702b726eac4bd918c5a6219853434ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// When rpm is configured to use Sequoia for the OpenPGP implementation
// ('configure --crypto=sequoia'), librpmio is linked against
// librpm_sequoia.
//
// librpm_sequoia can't directly implement the OpenPGP API, because
// librpmio won't reexport librpm_sequoia's symbols, and we don't want
// a program linking against librpmio to explicitly link against
// (i.e., need a DT_NEEDED entry for) librpm_sequoia.
//
// We can circumvent this problem by having librpm_sequoia provide
// identical functions under different names, and then having librpmio
// provide forwarders.  That's what this file does: it forwards pgpFoo
// to _pgpFoo.  It's a bit ugly, but it is better than a brittle,
// non-portable hack.

#include "rpmpgpval.h"

// Wrap a function.
//
// Define f to call _f, which has an identical function signature.
#define W(rt, f, params, args) \
  extern rt _##f params;       \
  rt f params {                \
    return _##f args;          \
  }

W(int, pgpSignatureType, (pgpDigParams _digp), (_digp))
W(pgpDigParams, pgpDigParamsFree, (pgpDigParams digp), (digp))
W(int, pgpDigParamsCmp, (pgpDigParams p1, pgpDigParams p2), (p1, p2))
W(unsigned int, pgpDigParamsAlgo,
  (pgpDigParams digp, unsigned int algotype), (digp, algotype))
W(const uint8_t *, pgpDigParamsSignID, (pgpDigParams digp), (digp))
W(const char *, pgpDigParamsUserID, (pgpDigParams digp), (digp))
W(int, pgpDigParamsVersion, (pgpDigParams digp), (digp))
W(uint32_t, pgpDigParamsCreationTime, (pgpDigParams digp), (digp))
W(rpmRC, pgpVerifySignature,
  (pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx),
  (key, sig, hashctx))
W(int, pgpPubkeyKeyID,
  (const uint8_t * pkt, size_t pktlen, pgpKeyID_t keyid),
  (pkt, pktlen, keyid))
W(int, pgpPubkeyFingerprint,
  (const uint8_t * pkt, size_t pktlen, uint8_t **fp, size_t *fplen),
  (pkt, pktlen, fp, fplen))
W(char *, pgpArmorWrap,
  (int atype, const unsigned char * s, size_t ns),
  (atype, s, ns))
W(int, pgpPubKeyCertLen,
  (const uint8_t *pkts, size_t pktslen, size_t *certlen),
  (pkts, pktslen, certlen))
W(int, pgpPrtParams,
  (const uint8_t *pkts, size_t pktlen, unsigned int pkttype, pgpDigParams *ret),
  (pkts, pktlen, pkttype, ret))
W(int, pgpPrtParamsSubkeys,
  (const uint8_t *pkts, size_t pktlen,
   pgpDigParams mainkey, pgpDigParams **subkeys,
   int *subkeysCount),
  (pkts, pktlen, mainkey, subkeys, subkeysCount))
W(pgpArmor, pgpParsePkts,
  (const char *armor, uint8_t ** pkt, size_t * pktlen),
  (armor, pkt, pktlen))
W(rpmRC, pgpPubKeyLint,
  (const uint8_t *pkts, size_t pktslen, char **explanation),
  (pkts, pktslen, explanation))
W(int, rpmInitCrypto, (void), ())
W(int, rpmFreeCrypto, (void), ())
W(DIGEST_CTX, rpmDigestInit, (int hashalgo, rpmDigestFlags flags),
  (hashalgo, flags))
W(DIGEST_CTX, rpmDigestDup, (DIGEST_CTX octx), (octx))
W(size_t, rpmDigestLength, (int hashalgo), (hashalgo))
W(int, rpmDigestUpdate, (DIGEST_CTX ctx, const void * data, size_t len),
  (ctx, data, len))
W(int, rpmDigestFinal,
  (DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii),
  (ctx, datap, lenp, asAscii))

// These functions are deprecated and scheduled for removal in 4.19.
W(int, pgpPrtPkts,
  (const uint8_t *pkts, size_t pktlen, pgpDig dig, int printing),
  (pkts, pktlen, dig, printing))
W(pgpDig, pgpNewDig, (), ())
W(void, pgpCleanDig, (pgpDig dig), (dig))
W(pgpDig, pgpFreeDig, (pgpDig dig), (dig))
W(pgpDigParams, pgpDigGetParams,
  (pgpDig dig, unsigned int pkttype),
  (dig, pkttype))
W(rpmRC, pgpVerifySig,
  (pgpDig dig, DIGEST_CTX hashctx),
  (dig, hashctx))