~ubuntu-branches/ubuntu/precise/rpm/precise-proposed

« back to all changes in this revision

Viewing changes to rpmio/rpmpgp.h

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-06-28 11:12:30 UTC
  • mfrom: (17.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100628111230-8ggjjhgpvrnr3ybx
Tags: 4.8.1-5
Fix compilation on hurd and kfreebsd (Closes: #587366).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
/** \ingroup rpmpgp
24
24
 */
25
25
typedef struct DIGEST_CTX_s * DIGEST_CTX;
 
26
typedef struct rpmDigestBundle_s * rpmDigestBundle;
26
27
 
27
28
/** \ingroup rpmpgp
28
29
 */
919
920
    PGPARMORKEY_CHARSET         = 5  /*!< Charset: */
920
921
} pgpArmorKey;
921
922
 
 
923
typedef enum pgpValType_e {
 
924
    PGPVAL_TAG                  = 1,
 
925
    PGPVAL_ARMORBLOCK           = 2,
 
926
    PGPVAL_ARMORKEY             = 3,
 
927
    PGPVAL_SIGTYPE              = 4,
 
928
    PGPVAL_SUBTYPE              = 5,
 
929
    PGPVAL_PUBKEYALGO           = 6,
 
930
    PGPVAL_SYMKEYALGO           = 7,
 
931
    PGPVAL_COMPRESSALGO         = 8,
 
932
    PGPVAL_HASHALGO             = 9,
 
933
    PGPVAL_SERVERPREFS          = 10,
 
934
} pgpValType;
 
935
 
922
936
/** \ingroup rpmpgp
923
937
 * Bit(s) to control digest operation.
924
938
 */
926
940
    RPMDIGEST_NONE      = 0
927
941
} rpmDigestFlags;
928
942
 
 
943
/** \ingroup rpmpgp
 
944
 * Return string representation of am OpenPGP value.
 
945
 * @param type          type of value
 
946
 * @param val           byte value to lookup
 
947
 * @return              string value of byte
 
948
 */
 
949
const char * pgpValString(pgpValType type, uint8_t val);
929
950
 
930
951
/** \ingroup rpmpgp
931
952
 * Return (native-endian) integer from big-endian representation.
1012
1033
pgpArmor pgpReadPkts(const char * fn, uint8_t ** pkt, size_t * pktlen);
1013
1034
 
1014
1035
/** \ingroup rpmpgp
 
1036
 * Parse armored OpenPGP packets from memory.
 
1037
 * @param armor         armored OpenPGP packet string
 
1038
 * @retval pkt          dearmored OpenPGP packet(s) (malloced)
 
1039
 * @retval pktlen       dearmored OpenPGP packet(s) length in bytes
 
1040
 * @return              type of armor found
 
1041
 */
 
1042
pgpArmor pgpParsePkts(const char *armor, uint8_t ** pkt, size_t * pktlen);
 
1043
 
 
1044
/** \ingroup rpmpgp
1015
1045
 * Wrap a OpenPGP packets in ascii armor for transport.
1016
1046
 * @param atype         type of armor
1017
1047
 * @param s             binary pkt data
1021
1051
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns);
1022
1052
 
1023
1053
/** \ingroup rpmpgp
1024
 
 * Create a container for parsed OpenPGP packates.
 
1054
 * Create a container for parsed OpenPGP packet(s).
1025
1055
 * @return              container
1026
1056
 */
1027
1057
pgpDig pgpNewDig(void);
1033
1063
void pgpCleanDig(pgpDig dig);
1034
1064
 
1035
1065
/** \ingroup rpmpgp
1036
 
 * Destroy a container for parsed OpenPGP packates.
 
1066
 * Destroy a container for parsed OpenPGP packet(s).
1037
1067
 * @param dig           container
1038
1068
 * @return              NULL always
1039
1069
 */
1040
1070
pgpDig pgpFreeDig(pgpDig dig);
1041
1071
 
1042
1072
/** \ingroup rpmpgp
 
1073
 * Verify a PGP signature.
 
1074
 * @param dig           container
 
1075
 * @param hashctx       digest context
 
1076
 * @return              RPMRC_OK on success 
 
1077
 */
 
1078
rpmRC pgpVerifySig(pgpDig dig, DIGEST_CTX hashctx);
 
1079
 
 
1080
/** \ingroup rpmpgp
 
1081
 * Return a string identification of a PGP signature/pubkey.
 
1082
 * @param digp          signature/pubkey container
 
1083
 * @return              string describing the item and parameters
 
1084
 */
 
1085
char *pgpIdentItem(pgpDigParams digp);
 
1086
 
 
1087
/** \ingroup rpmpgp
1043
1088
 * Perform cryptography initialization.
1044
1089
 * It must be called before any cryptography can be used within rpm.
1045
1090
 * It's not normally necessary to call it directly as it's called in
1100
1145
        void ** datap,
1101
1146
        size_t * lenp, int asAscii);
1102
1147
 
 
1148
/** \ingroup rpmpgp
 
1149
 * Create a new digest bundle.
 
1150
 * @return              New digest bundle
 
1151
 */
 
1152
rpmDigestBundle rpmDigestBundleNew(void);
 
1153
 
 
1154
/** \ingroup rpmpgp
 
1155
 * Free a digest bundle and all contained digest contexts.
 
1156
 * @param bundle        digest bundle
 
1157
 * @return              NULL always
 
1158
 */
 
1159
rpmDigestBundle rpmDigestBundleFree(rpmDigestBundle bundle);
 
1160
 
 
1161
/** \ingroup rpmpgp
 
1162
 * Add a new type of digest to a bundle.
 
1163
 * @param bundle        digest bundle
 
1164
 * @param algo          type of digest
 
1165
 * @param flags         bit(s) to control digest operation
 
1166
 * @return              0 on success
 
1167
 */
 
1168
int rpmDigestBundleAdd(rpmDigestBundle bundle, pgpHashAlgo algo,
 
1169
                        rpmDigestFlags flags);
 
1170
 
 
1171
/** \ingroup rpmpgp
 
1172
 * Update contexts within bundle with next plain text buffer.
 
1173
 * @param bundle        digest bundle
 
1174
 * @param data          next data buffer
 
1175
 * @param len           no. bytes of data
 
1176
 * @return              0 on success
 
1177
 */
 
1178
int rpmDigestBundleUpdate(rpmDigestBundle bundle, const void *data, size_t len);
 
1179
 
 
1180
/** \ingroup rpmpgp
 
1181
 * Return digest from a bundle and destroy context, see rpmDigestFinal().
 
1182
 *
 
1183
 * @param bundle        digest bundle
 
1184
 * @param algo          type of digest to return
 
1185
 * @retval datap        address of returned digest
 
1186
 * @retval lenp         address of digest length
 
1187
 * @param asAscii       return digest as ascii string?
 
1188
 * @return              0 on success
 
1189
 */
 
1190
int rpmDigestBundleFinal(rpmDigestBundle bundle,
 
1191
         pgpHashAlgo algo, void ** datap, size_t * lenp, int asAscii);
 
1192
 
 
1193
/** \ingroup rpmpgp
 
1194
 * Duplicate a digest context from a bundle.
 
1195
 * @param bundle        digest bundle
 
1196
 * @param algo          type of digest to dup
 
1197
 * @return              duplicated digest context
 
1198
 */
 
1199
DIGEST_CTX rpmDigestBundleDupCtx(rpmDigestBundle bundle, pgpHashAlgo algo);
 
1200
 
1103
1201
#ifdef __cplusplus
1104
1202
}
1105
1203
#endif