[pacman-dev] [PATCH 1/2] Make functions to decode a signature and extract keyid public

Allan McRae allan at archlinux.org
Tue Oct 15 02:24:51 EDT 2013


These are useful for frontends.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/alpm.h       | 6 ++++++
 lib/libalpm/be_package.c | 2 +-
 lib/libalpm/signing.c    | 6 +++---
 lib/libalpm/signing.h    | 5 -----
 lib/libalpm/sync.c       | 4 ++--
 5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index b049007..29b9f37 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -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
  */
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 526d927..3f577ba 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -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;
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index a856f13..7e4d41b 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -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;
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index 2d49240..42b60b1 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -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: */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 9081c73..a4b1bb8 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -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) {
-- 
1.8.4



More information about the pacman-dev mailing list