1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Make functions to decode a signature and extract keyid public

These are useful for frontends.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2013-10-15 15:53:51 +10:00
parent 968486ecc0
commit c7f159c1c9
5 changed files with 12 additions and 11 deletions

View File

@ -1075,6 +1075,12 @@ int alpm_db_check_pgp_signature(alpm_db_t *db, alpm_siglist_t *siglist);
int alpm_siglist_cleanup(alpm_siglist_t *siglist);
int alpm_decode_signature(const char *base64_data,
unsigned char **data, size_t *data_len);
int alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
const unsigned char *sig, const size_t len, alpm_list_t **keys);
/*
* Groups
*/

View File

@ -570,7 +570,7 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
return -1;
}
if(_alpm_extract_keyid(handle, filename, sig, len, &keys) == 0) {
if(alpm_extract_keyid(handle, filename, sig, len, &keys) == 0) {
alpm_list_t *k;
for(k = keys; k; k = k->next) {
char *key = k->data;

View File

@ -425,7 +425,7 @@ int _alpm_key_import(alpm_handle_t *handle, const char *fpr)
* @return 0 on success, -1 on failure to properly decode
*/
int _alpm_decode_signature(const char *base64_data,
int SYMEXPORT alpm_decode_signature(const char *base64_data,
unsigned char **data, size_t *data_len)
{
size_t len = strlen(base64_data);
@ -525,7 +525,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
if(base64_sig) {
/* memory-based, we loaded it from a sync DB */
size_t data_len;
int decode_ret = _alpm_decode_signature(base64_sig,
int decode_ret = alpm_decode_signature(base64_sig,
&decoded_sigdata, &data_len);
if(decode_ret) {
handle->pm_errno = ALPM_ERR_SIG_INVALID;
@ -964,7 +964,7 @@ int SYMEXPORT alpm_siglist_cleanup(alpm_siglist_t *siglist)
* @param keys a pointer to storage for key IDs
* @return 0 on success, -1 on error
*/
int _alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
int SYMEXPORT alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
const unsigned char *sig, const size_t len, alpm_list_t **keys)
{
size_t pos, spos, blen, hlen, ulen, slen;

View File

@ -34,11 +34,6 @@ int _alpm_process_siglist(alpm_handle_t *handle, const char *identifier,
int _alpm_key_in_keychain(alpm_handle_t *handle, const char *fpr);
int _alpm_key_import(alpm_handle_t *handle, const char *fpr);
int _alpm_decode_signature(const char *base64_data,
unsigned char **data, size_t *data_len);
int _alpm_extract_keyid(alpm_handle_t *handle, const char *identifier,
const unsigned char *sig, const size_t len, alpm_list_t **keys);
#endif /* _ALPM_SIGNING_H */
/* vim: set ts=2 sw=2 noet: */

View File

@ -1007,11 +1007,11 @@ static int check_keyring(alpm_handle_t *handle)
if((level & ALPM_SIG_PACKAGE) && pkg->base64_sig) {
unsigned char *decoded_sigdata = NULL;
size_t data_len;
int decode_ret = _alpm_decode_signature(pkg->base64_sig,
int decode_ret = alpm_decode_signature(pkg->base64_sig,
&decoded_sigdata, &data_len);
if(decode_ret == 0) {
alpm_list_t *keys = NULL;
if(_alpm_extract_keyid(handle, pkg->name, decoded_sigdata,
if(alpm_extract_keyid(handle, pkg->name, decoded_sigdata,
data_len, &keys) == 0) {
alpm_list_t *k;
for(k = keys; k; k = k->next) {