Blame rpmio/digest.h

2ff057
#ifndef _RPMDIGEST_H
2ff057
#define _RPMDIGEST_H
2ff057
2ff057
#include <rpm/rpmpgp.h>
2ff057
2ff057
typedef struct pgpDigAlg_s * pgpDigAlg;
2ff057
2ff057
typedef int (*setmpifunc)(pgpDigAlg digp, int num, const uint8_t *p);
2ff057
typedef int (*verifyfunc)(pgpDigAlg pgpkey, pgpDigAlg pgpsig,
2ff057
                          uint8_t *hash, size_t hashlen, int hash_algo);
2ff057
typedef void (*freefunc)(pgpDigAlg digp);
2ff057
2ff057
struct pgpDigAlg_s {
2ff057
    setmpifunc setmpi;
2ff057
    verifyfunc verify;
2ff057
    freefunc free;
2ff057
    int mpis;
2ff057
    void *data;			/*!< algorithm specific private data */
2ff057
};
2ff057
2ff057
/** \ingroup rpmio
2ff057
 * Values parsed from OpenPGP signature/pubkey packet(s).
2ff057
 */
2ff057
struct pgpDigParams_s {
2ff057
    char * userid;
2ff057
    uint8_t * hash;
2ff057
    uint8_t tag;
2ff057
2ff057
    uint8_t version;		/*!< version number. */
2ff057
    uint32_t time;		/*!< key/signature creation time. */
2ff057
    uint8_t pubkey_algo;		/*!< public key algorithm. */
2ff057
2ff057
    uint8_t hash_algo;
2ff057
    uint8_t sigtype;
2ff057
    uint8_t hashlen;
2ff057
    uint8_t signhash16[2];
2ff057
    pgpKeyID_t signid;
2ff057
    uint8_t saved;
2ff057
#define	PGPDIG_SAVED_TIME	(1 << 0)
2ff057
#define	PGPDIG_SAVED_ID		(1 << 1)
2ff057
2ff057
    pgpDigAlg alg;
2ff057
};
2ff057
2ff057
pgpDigAlg pgpPubkeyNew(int algo);
2ff057
2ff057
pgpDigAlg pgpSignatureNew(int algo);
2ff057
2ff057
pgpDigAlg pgpDigAlgFree(pgpDigAlg da);
2ff057
2ff057
/** \ingroup rpmpgp
2ff057
 * Return no. of bits in a multiprecision integer.
2ff057
 * @param p		pointer to multiprecision integer
2ff057
 * @return		no. of bits
2ff057
 */
2ff057
static inline
2ff057
unsigned int pgpMpiBits(const uint8_t *p)
2ff057
{
2ff057
    return ((p[0] << 8) | p[1]);
2ff057
}
2ff057
2ff057
/** \ingroup rpmpgp
2ff057
 * Return no. of bytes in a multiprecision integer.
2ff057
 * @param p		pointer to multiprecision integer
2ff057
 * @return		no. of bytes
2ff057
 */
2ff057
static inline
2ff057
size_t pgpMpiLen(const uint8_t *p)
2ff057
{
2ff057
    return (2 + ((pgpMpiBits(p)+7)>>3));
2ff057
}
2ff057
	
2ff057
#endif /* _RPMDIGEST_H */