- my $handled = 0;
- for my $line (split /\n/, $status) {
- if ($line =~ /^\[GNUPG:\] IMPORT_OK \d+ ([0-9A-F]{40})/) {
- my $imported_key = $1;
- if ($keyid ne $imported_key &&
- $keyid ne substr($imported_key, -16) &&
- $keyid ne substr($imported_key, -8)) {
- warn("Imported unexpected key. expected: $keyid; got: $imported_key.\n");
- next;
- };
- push @keyids_ok, $keyid;
- shift @KEYIDS;
- $handled = 1;
- last;
- } elsif ($line =~ /^\[GNUPG:\] NODATA/) {
- push @keyids_failed, $keyid;
- shift @KEYIDS;
- $handled = 1;
- last;
+ my %local_keyids = map { $_ => 1 } @KEYIDS;
+ for my $line (split /\n/, $status) {
+ if ($line =~ /^\[GNUPG:\] IMPORT_OK \d+ ([0-9A-F]{8})([0-9A-F]{16})([0-9A-F]{8})([0-9A-F]{0,8})/) {
+ my $imported_key;
+ $imported_key = $1.$2.$3 if $local_keyids{$1.$2.$3}; # v3 key
+ $imported_key = $1.$2.$3.$4 if $local_keyids{$1.$2.$3.$4};
+ $imported_key = $3.$4 if $local_keyids{ $3.$4};
+ $imported_key = $4 if $local_keyids{ $4};
+ unless ($imported_key) {
+ notice ("Imported unexpected key; got: $1$2$3$4. (This is normal for v3 keys.)\n");
+ next;