+ int ret, len;
+
+ if (a->tag > b->tag) {
+ ret = 1;
+ } else if (b->tag > a->tag) {
+ ret = -1;
+ } else {
+ len = (a->length < b->length) ? a->length : b->length;
+ ret = memcmp(a->data, b->data, len);
+ if (ret == 0 && a->length != b->length) {
+ ret = (a->length < b->length) ? -1 : 1;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * compare_signatures - Check to see if 2 OpenPGP signatures are the same.
+ * @a: The first signature to compare.
+ * @b: The second signature to compare.
+ *
+ * Takes 2 signature packets and returns true if they are the same and
+ * false otherwise.
+ */
+bool compare_signatures(struct openpgp_packet *a, struct openpgp_packet *b)
+{
+ uint64_t a_keyid, b_keyid;
+ time_t a_creation, b_creation;
+
+ if (a->data[0] != b->data[0]) {
+ /* Different signature versions, so not the same */
+ return false;
+ } else if (a->data[0] == 4 && a->data[1] != b->data[1]) {
+ /* Type 4 signature, but different types */
+ return false;
+ } else {
+ sig_info(a, &a_keyid, &a_creation);
+ sig_info(b, &b_keyid, &b_creation);
+ return (a_creation == b_creation) && (a_keyid == b_keyid);
+ }