sks-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sks-devel] 16-digit keyid with machine-readable output


From: Phil Pennock
Subject: Re: [Sks-devel] 16-digit keyid with machine-readable output
Date: Thu, 25 Oct 2012 15:48:25 -0400

On 2012-10-25 at 12:42 -0700, k clair wrote:
> I can't find anywhere that this is documented: Is there a way to 
> get the machine-readable output of a search to return the 16-digit 
> keyid rather than the 8-digit keyid?

Not at present.  It would require code changes, nothing too severe.

Here's the code that generates the lines; a little option sprinkling
into the line generation, tied into setting that option from the query
form, and that should be all that's needed.

----------------------------8< cut here >8------------------------------
let key_to_lines key =
  let full_keyid = Fingerprint.keyid_from_key ~short:false key in
  let keyid = Fingerprint.keyid_to_string ~short:true full_keyid in
  let pkey = KeyMerge.key_to_pkey key in
  let key_packet = pkey.KeyMerge.key in
  let pki = ParsePGP.parse_pubkey_info key_packet in
  let uids = pkey.KeyMerge.uids in
  let exp_string = match pki.pk_expiration with
    | None -> ""
    | Some 0 -> "-"
    | Some days -> sprintf "%Ld"
        (Int64.add pki.pk_ctime (Int64.mul daysecs (Int64.of_int days)))
  in
  let key_line = sprintf "pub:%s:%d:%d:%Ld:%s:%s"
                   keyid
                   pki.pk_alg
                   pki.pk_keylen
                   pki.pk_ctime
                   exp_string
                   (if (Index.is_revoked key) then "r" else "")
  in
  let uid_lines =
    List.map ~f:(fun (uid,sigs) ->
      match uid.packet_type with
          User_ID_Packet -> uid_to_line full_keyid uid sigs
        | User_Attribute_Packet -> "uat::::"
        | _ -> "???::::"
      ) uids
  in
  key_line::uid_lines
----------------------------8< cut here >8------------------------------

And then in fingerprint.ml:
----------------------------8< cut here >8------------------------------
let keyid_to_string ?(short=true) keyid =
  let hex = Utils.hexstring keyid in
  if short
  then String.sub ~pos:(String.length hex - 8) ~len:8 hex
  else hex
----------------------------8< cut here >8------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]