]> the.earth.li Git - onak.git/blobdiff - lookup.c
Add support for v5 keys
[onak.git] / lookup.c
index fda1686234f06160dfd7af7be1819c441fcf2bc2..35c039bf906c8c9d59e8706e052261f9dd481cc9 100644 (file)
--- a/lookup.c
+++ b/lookup.c
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "build-config.h"
+
 #include "armor.h"
 #include "charfuncs.h"
 #include "cleankey.h"
@@ -36,7 +38,6 @@
 #include "onak-conf.h"
 #include "parsekey.h"
 #include "photoid.h"
-#include "version.h"
 
 #define OP_UNKNOWN 0
 #define OP_GET     1
@@ -146,8 +147,20 @@ int main(int argc, char *argv[])
                        params[i+1] = NULL;
                        if (search != NULL && strlen(search) == 42 &&
                                        search[0] == '0' && search[1] == 'x') {
-                               fingerprint.length = MAX_FINGERPRINT_LEN;
-                               for (j = 0; j < MAX_FINGERPRINT_LEN; j++) {
+                               /* v4 fingerprint */
+                               fingerprint.length = 20;
+                               for (j = 0; j < 20; j++) {
+                                       fingerprint.fp[j] = (hex2bin(
+                                                       search[2 + j * 2])
+                                                               << 4) +
+                                               hex2bin(search[3 + j * 2]);
+                               }
+                               isfp = true;
+                       } else if (search != NULL && strlen(search) == 66 &&
+                                       search[0] == '0' && search[1] == 'x') {
+                               /* v5 fingerprint */
+                               fingerprint.length = 32;
+                               for (j = 0; j < 32; j++) {
                                        fingerprint.fp[j] = (hex2bin(
                                                        search[2 + j * 2])
                                                                << 4) +
@@ -239,7 +252,7 @@ int main(int argc, char *argv[])
                                        result,
                                        search);
                                puts("<pre>");
-                               cleankeys(publickey);
+                               cleankeys(&publickey, config.clean_policies);
                                flatten_publickey(publickey,
                                                        &packets,
                                                        &list_end);