-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 2012-05-22 20:31, Giovanni Mascellani wrote:
> Hi.
> 

> Moreover, I would like to skip the HTTP part, since I think it's
> quite expensive. The original pksclient script queries directly the
> PKS database.
> 

Hi Giovanni,

You might want to try something like the attached patch

needs "make sksclient", and use it like ./sksclient 6b0b9508

(note, I've only added support for that key format)


- -- 
- ----------------------------
Kristian Fiskerstrand
http://www.sumptuouscapital.com
Twitter: @krifisk
- ----------------------------
Corruptissima re publica plurimæ leges
The greater the degeneration of the republic, the more of its laws
- ----------------------------
This email was digitally signed using the OpenPGP
standard. If you want to read more about this
The book: Sending Emails - The Safe Way: An
introduction to OpenPGP security is now
available in both Amazon Kindle and Paperback
format at
http://www.amazon.com/dp/B006RSG1S4/
- ----------------------------
Public PGP key 0xE3EDFAE3 at http://www.sumptuouscapital.com/pgp/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJPvr34AAoJEBbgz41rC5UINQIQAIuijyUEBZHTrPxx0HbiMjwb
y2caupHiimu7OMhWHyN+ssRum91W7cMfBBgc1+bhY8rWf2E1W6wMsg67Bmc/u7nF
PhX1CIQqFUYAFlCBGfkCfu9dAPkhL75dd1FEl5gTm8kVyyWo5Xuk28KaMNf2kEJf
4HC6JNJylhiol+iTIY9fLh+i1Jf+RJHQR1ILsypltf5zho8RG488a657f/8DsJxU
Aardp1M8f3i+mn/YWT+oQylAxJPgESdkgkpfA7t1qBWammIpQbn5juiWPuZf3WkA
TH3wjPlglPNYxZsXpi36kpAT1NtsHUx7UdVRHQanOqobV22v+82r83kbqhR8Dobz
+dCSbZoH5FNmoq2vi4MX1O9Rr5US2m3wQnUFnn0bibieqkow+4EupEopFuKjYH2c
P2164sN5DBNLxEYW714maCuxt2YnmL2p7XtJHceSU6D8jRh1yW2Z/41aeZY9xrv9
WYghNFrySeEftLbxFLSjtBNVg3exeYyoP8TThMrVmYDJetPfAc8Y477KBkUi88bP
9/bldD5sK/xYblRdfNyfYDt3DpQafmDVv1YgZpXMImriohcmCbTauu4vfUljiPET
cR50pswLSE1FkNWBYGg50hzYjWHplwwhYq9vqEVYm7IxwEsByqJfqcZAeDjOjP4T
ulWD8KA6Oz4NkjyRszSU
=KeDl
-----END PGP SIGNATURE-----
# HG changeset patch
# User kristi...@kristian-precis.sumptuous.sumptuouscapital.com
# Date 1337900336 -7200
# Node ID b0b3bd7426f5380028aeca749882da604629207f
# Parent  db829ad86f241856d6158717c92fb9123b804e83
Add sksclient

diff -r db829ad86f24 -r b0b3bd7426f5 Makefile
--- a/Makefile  Sun May 20 21:42:30 2012 +0100
+++ b/Makefile  Fri May 25 00:58:56 2012 +0200
@@ -159,6 +159,12 @@
 spider.bc: $(LIBS.bc) $(ALLOBJS.bc) spider.cmo
        $(OCAMLC) -o spider.bc $(OCAMLFLAGS) $(ALLOBJS.bc) spider.cmo
 
+sksclient: $(LIBS) $(ALLOBJS) sksclient.cmx
+       $(OCAMLOPT) -o sksclient $(OCAMLOPTFLAGS) $(ALLOBJS) sksclient.cmx
+
+sksclient.bc: $(LIBS.bc) $(ALLOBJS.bc) sksclient.cmo
+       $(OCAMLC) -o sksclient.bc $(OCAMLFLAGS) $(ALLOBJS.bc) sksclient.cmo
+
 sks: $(LIBS) $(ALLOBJS) sks.cmx
        $(OCAMLOPT) -o sks $(OCAMLOPTFLAGS) $(ALLOBJS) sks.cmx
 
diff -r db829ad86f24 -r b0b3bd7426f5 sksclient.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sksclient.ml      Fri May 25 00:58:56 2012 +0200
@@ -0,0 +1,76 @@
+(************************************************************************)
+(* This file is part of SKS.  SKS is free software; you can
+   redistribute it and/or modify it under the terms of the GNU General
+   Public License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+   USA *)
+(***********************************************************************)
+
+open StdLabels
+open MoreLabels
+open Printf
+open Common
+open DbMessages
+  
+
+
+let key_id =
+  if Array.length Sys.argv = 2 then
+    Sys.argv.(1)
+  else
+    ""
+
+let settings = {
+    Keydb.withtxn = !Settings.transactions;
+    Keydb.cache_bytes = !Settings.cache_bytes;
+    Keydb.pagesize = !Settings.pagesize;
+    Keydb.dbdir = Lazy.force Settings.dbdir;
+    Keydb.dumpdir = Lazy.force Settings.dumpdir;
+ } 
+ module Keydb = Keydb.Safe
+        
+let get_keys_by_keyid keyid =
+    let keyid_length = String.length keyid in
+    let short_keyid = String.sub ~pos:(keyid_length - 4) ~len:4 keyid in
+    let keys = Keydb.get_by_short_subkeyid short_keyid in
+    match keyid_length with
+      | 4 -> (* 32-bit keyid.  No further filtering required. *)
+         keys
+
+      | 8 -> (* 64-bit keyid *) 
+          List.filter keys
+          ~f:(fun key -> keyid = (Fingerprint.from_key key).Fingerprint.keyid 
||
+          (** Return keys i& subkeys with matching long keyID *)
+            let (mainkeyid,subkeyids) = Fingerprint.keyids_from_key 
~short:false key in
+            List.exists (fun x -> x = keyid) subkeyids)
+         
+      | 20 -> (* 160-bit v. 4 fingerprint *)
+         failwith "not implemented"
+
+      | 16 -> (* 128-bit v3 fingerprint.  Not supported *)
+         failwith "not implemented"
+
+      | _ -> failwith "unknown keyid type"
+         
+let () =
+       set_logfile "sksclient";
+       Keydb.open_dbs settings;        
+       let keys = get_keys_by_keyid (KeyHash.dehexify key_id) in 
+       let aakeys = 
+           match keys with
+             | [] -> ""
+             | _ -> let keystr = Key.to_string_multiple keys in
+                     Armor.encode_pubkey_string keystr
+         in
+       printf "%s\n" aakeys; 
+       Keydb.close_dbs ();
+       
\ No newline at end of file
_______________________________________________
Sks-devel mailing list
Sks-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/sks-devel

Reply via email to