Subject: | [PATCH] 3 minor improvements |
3 minor improvements included in the attached unidiff patch.
1. gen_key(), add the possibility to specify what key algorithm to use.
2. gen_key(), add Subkey-Type and Subkey-Length, currently being set to Key-Type/Size.
3. fingerprint(), removed unused parameter "key_name" and simplified the RE used to match
the fingerprint.
Patch is against GPG 0.06
Perl version is v5.10.1
Tested on
$ uname -a
Linux peppardev 2.6.32-33-generic-pae #72-Ubuntu SMP Fri Jul 29 22:06:29 UTC 2011 i686
GNU/Linux
$ lsb_release -d
Description: Ubuntu 10.04.3 LTS
Subject: | GPG.pm.diff |
--- GPG.pm~ 2012-01-16 12:13:56.208168563 +0100
+++ GPG.pm 2012-01-16 12:15:48.316168821 +0100
@@ -2,7 +2,7 @@
use strict;
use vars qw/$VERSION/;
- $VERSION = "0.05";
+ $VERSION = "0.06.1";
use IO::Handle;
use IPC::Open3;
@@ -120,6 +120,8 @@
my $comment = $params{'comment'} || '';
my $passphrase = $params{'passphrase'};
$this->error("no passphrase defined !") and return if !$passphrase;
+ my $algorithm = $params{'algorithm'};
+ $this->error("no algorithm defined !") and return if !$algorithm;
srand();
my $tmp_filename = $this->{homedir}."/tmp_".sprintf("%08d",int(rand()*100000000));
@@ -128,8 +130,10 @@
my $secring = "$tmp_filename.sec";
my $script = '';
- $script .= "Key-Type: 20\n";
+ $script .= "Key-Type: $algorithm\n";
$script .= "Key-Length: $key_size\n";
+ $script .= "Subkey-Type: $algorithm\n";
+ $script .= "Subkey-Length: $key_size\n";
$script .= "Name-Real: $real_name\n";
$script .= "Name-Comment: $comment\n" if $comment;
$script .= "Name-Email: $email\n";
@@ -273,10 +277,9 @@
my @text = split(/\s*\n/,$output);
for(my $i = 0; $i < $#text; $i++) {
- if ($text[$i] =~ /^pub\s+.*\/(\w+)\s+\S+\s+(.*)\s*$/) {
+ if ($text[$i] =~ /^pub\s+.*\/(\w+)\s+\S+$/) {
my $hash = {};
$hash->{'key_id'} = $1 if $1;
- $hash->{'key_name'} = $2 if $2;
$text[$i+1] =~ /^\s+Key fingerprint = (.*)\s*$/m;
$hash->{'fingerprint'} = $1 if $1;