From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8056 invoked by alias); 13 Jun 2018 15:18:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42999 Received: (qmail 8970 invoked by uid 1010); 13 Jun 2018 15:18:48 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f175.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.175):SA:0(-1.9/5.0):. Processed in 1.567712 secs); 13 Jun 2018 15:18:48 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: doron.behar@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dLeMVA27qHJQ6hyEtCnd52RLvp05zODi0+EM3iLb8rs=; b=pTVgdZCJMz3t2OLZKZScxMsj2NZjftoBs8o+SkSEANbnkyZZAL2tAzRhzwlv7oN542 n4zw84HPmpscwZiTUR5h5HcxJ9aijcWPNHKnqT89kncY2SQoxzMy3+iqtNWxmBOewBd8 rxgUINmvS3/2FozHI1gzxdGQ9TAGIPWyPNZhIcAJMV6a5yn77CQRXj1PoKp7AJTts1J+ QjYsHPto9oJx4gjTaFodv6AEYCY2jXW2aVbL6TYNM5+mMwyv29c37aWXw5HQ2Egkkxio 0lQzGZGMsWgI4OO4h/gG6VmkQ7S3daYJw2fs5yCRBokb63acSkRR6rzwdCg4fm8YWw1z CwUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=dLeMVA27qHJQ6hyEtCnd52RLvp05zODi0+EM3iLb8rs=; b=flmnhmiKavqTaElosrE64gclfvnMX7sbVRATh6Uq9dnnAN/vIYLlbm6QeYmbXL+FIq dOYIUrXe+oOUyN2ARNAZp8w1NHbfMp5D65QuU29I9zd/USFqRBN8/9NqYKQbus0cPryr 67vtFCP2ugkVZ8OuhFFwXo7X30zmyOS6bWo7b2WJZ5hA+mxLaXf+gVpNG2+YIwXa3mZg ZRNDR0SFhP/YiVNDmQqaOWvEqMnDGANiiTCtZnIESn7levoyrkTmreTnCAmMNVMPv9QX E4pU9MkEpwAalnvzZQIsmXDc+4hVcYFZc7QxB5oUyz6aYx3BlPWCm71/nLxgK7gVPV3Z WeNA== X-Gm-Message-State: APt69E3h7ldvB9mLeRU+QXL1ywngrJjNgdGJoxbs3o7ZASKar1aOIha5 iMVoHsRcmzclHtj6YoEjGlGBm7nk X-Google-Smtp-Source: ADUXVKKFEJoPKdJ6bnHdIecxlvVNkEncR4f2+RM6SNFJr7HcCnpJz3GObAUYs837dxa0ihsF/Xw3mA== X-Received: by 2002:adf:a148:: with SMTP id r8-v6mr4432228wrr.104.1528903122114; Wed, 13 Jun 2018 08:18:42 -0700 (PDT) Date: Wed, 13 Jun 2018 18:17:48 +0300 From: Doron Behar To: zsh-workers@zsh.org Subject: Re: [PATCH] _gpg: Use explicit UIDs for public / secret keys. Message-ID: <20180613151748.dktvf3xm6m6zdrb5@NUC.doronbehar.com> Mail-Followup-To: zsh-workers@zsh.org References: <20180609200940.17041-1-doron.behar@gmail.com> <20180609203932.x3s4hbmbl6rtba76@tarpaulin.shahaf.local2> <20180612105457.wnuoenlfzapgosmf@NUC.doronbehar.com> <20180612221411.GA20129@osmium.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180612221411.GA20129@osmium.lan> User-Agent: NeoMutt/20180512 On Tue, Jun 12, 2018 at 06:14:11PM -0400, Phil Pennock wrote: > Unless you need trust information or some of the specific parts of the > userid, using `--fast-list-mode` can have significant wins too. I have ran `diff` on the output of `gpg --list-public-keys --with-colons` and `gpg --list-public-keys --fast-list-mode --with-colons` and there was no significant reduce in the amount of output with my version of gpg, as noted in the commit message you quoted. > > Matthew's link to > > is accurate and good guidance. As is his pointer to check the correct > column numbers. > Since columns may be added or removed in the format, as explained in this documentation, I think it'll be better not to hard-code the columns' numbers while parsing. Therefor, I'm inclined to go through all of the fields after `fpr` and after `uid` in every line. With the field in the line with `fpr`, it's easy to be sure of the `uid` we get from this line since we can check if it's matched against `[A-F0-9]{40}`. As for the line with description (or usually an email address), I'm not sure what regex match to test on it before putting it in the right array.. As already pointed out by Daniel, testing it with `=~ "@"` is not good enough. Perhaps here we'll use a hard-coded number as documented in gpg's repository? I need some opinions here.. > Beware that recent versions of GnuPG always show fingerprints, for keys > and subkeys, because (per commit message) "The fingerprint should always > be used thus we should always print it."; so you'll get multiple `fpr:` > records per top-level key, although between the `sec` or `pub` top-level > introducer and the `uid:` lines for _that_ key there should just be the > top-level fingerprint. > > > Welcome to the world of GnuPG integration. You have my sympathy. But > also my encouragement. :) > > -Phil Anyway, I've created a draft that should be a much better and much more understood but it's not ready yet as I'm not sure about what I explained above, this is it: local public_keys_lines=(${(f)"$(_call_program public-keys ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"}) local -a uids emails local i j parts for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do parts=(${(@s.:.)public_keys_lines[$i]}) if [[ ${parts[1]} == "fpr" ]]; then # This loop ensures that no matter if fields are added, the last field # that is built from 40 upper case A-Z letters is used as the uid. # We named the variable current_uid becuase it may have many email # addresses. for (( j = 2; j <${#parts[@]}; ++j )); do if [[ "${parts[$j]}" =~ "[A-F0-9]{40}" ]]; then current_uid="${parts[$j]}" fi done i=$((i + 1)) parts=(${(@s.:.)public_keys_lines[$i]}) while [[ ${parts[1]} == "uid" ]]; do for (( j = 2; j <${#parts[@]}; ++j )); do # FIXME? if [[ "${parts[$j]}" =~ "@" ]]; then uids+=("${current_uid}") emails+=("${parts[$j]}") fi done i=$((i + 1)) parts=(${(@s.:.)public_keys_lines[$i]}) done fi done _describe -t public-keys 'public key' emails uids For me it works great and it is much faster then before, yet I'm not sure about the if statement right below the `FIXME` comment.