Add macro %isu_package to generate ISU Package
[platform/upstream/rpm.git] / rpmio / digest.h
1 #ifndef _RPMDIGEST_H
2 #define _RPMDIGEST_H
3
4 #include <rpm/rpmpgp.h>
5
6 typedef struct pgpDigAlg_s * pgpDigAlg;
7
8 typedef int (*setmpifunc)(pgpDigAlg digp, int num, const uint8_t *p);
9 typedef int (*verifyfunc)(pgpDigAlg pgpkey, pgpDigAlg pgpsig,
10                           uint8_t *hash, size_t hashlen, int hash_algo);
11 typedef void (*freefunc)(pgpDigAlg digp);
12
13 struct pgpDigAlg_s {
14     setmpifunc setmpi;
15     verifyfunc verify;
16     freefunc free;
17     int mpis;
18     void *data;                 /*!< algorithm specific private data */
19 };
20
21 /** \ingroup rpmio
22  * Values parsed from OpenPGP signature/pubkey packet(s).
23  */
24 struct pgpDigParams_s {
25     char * userid;
26     uint8_t * hash;
27     uint8_t tag;
28
29     uint8_t version;            /*!< version number. */
30     uint32_t time;              /*!< key/signature creation time. */
31     uint8_t pubkey_algo;                /*!< public key algorithm. */
32
33     uint8_t hash_algo;
34     uint8_t sigtype;
35     uint8_t hashlen;
36     uint8_t signhash16[2];
37     pgpKeyID_t signid;
38     uint8_t saved;
39 #define PGPDIG_SAVED_TIME       (1 << 0)
40 #define PGPDIG_SAVED_ID         (1 << 1)
41
42     pgpDigAlg alg;
43 };
44
45 pgpDigAlg pgpPubkeyNew(int algo);
46
47 pgpDigAlg pgpSignatureNew(int algo);
48
49 pgpDigAlg pgpDigAlgFree(pgpDigAlg da);
50
51 /** \ingroup rpmpgp
52  * Return no. of bits in a multiprecision integer.
53  * @param p             pointer to multiprecision integer
54  * @return              no. of bits
55  */
56 static inline
57 unsigned int pgpMpiBits(const uint8_t *p)
58 {
59     return ((p[0] << 8) | p[1]);
60 }
61
62 /** \ingroup rpmpgp
63  * Return no. of bytes in a multiprecision integer.
64  * @param p             pointer to multiprecision integer
65  * @return              no. of bytes
66  */
67 static inline
68 size_t pgpMpiLen(const uint8_t *p)
69 {
70     return (2 + ((pgpMpiBits(p)+7)>>3));
71 }
72         
73 #endif /* _RPMDIGEST_H */