On 11/12/2011 04:17 AM, Csabi wrote:
> It is possible to convert an already created .sig file to .asc file?
> (ASCII armored output)?

ascii armor is just a standard header and footer, wrapped around
base64-encoded data plus a checksum:

 https://tools.ietf.org/html/rfc4880#section-6

If you have perl installed, you can use the attached script to convert
from a binary version to an ascii-armored version.  Invoke it like:

  openpgp-armor-convert < foo.sig > foo.asc

hth,

        --dkg
#!/usr/bin/perl -wT

# Author: Daniel Kahn Gillmor <d...@fifthhorseman.net>
# Date: 2011-11-12
# License: GPLv3+

# Convert a raw OpenPGP bytestring to an ascii-armored block
# as specified in:
#
# https://tools.ietf.org/html/rfc4880#section-6

# pass the bytestring on stdin; armored output goes to stdout

# accepts one argument for the type of OpenPGP block, defaults to
# SIGNATURE

# FIXME: inspect the bytestream and deduce the type of block directly

# FIXME: work as a filter to be able to encode arbitrarily long
# strings instead of bringing it all into RAM at once.

# FIXME: send this Digest::CRC spec upstream to make it easier for
# future users.

# BUG: $ctx->b64digest goes into an infinite loop with width=24
# needs reporting

use strict;
use warnings;
use Digest::CRC;
use MIME::Base64;

my $ctx = Digest::CRC->new(width => 24, init=> 0xB704CE,
                           xorout => 0x000000, refout => 0,
                           poly => 0x864CFB, refin => 0,
                           cont => 1);
my $data;
my $type = $ARGV[0];
$type = 'SIGNATURE' if (! defined($type));
$type = uc($type);

local $/;           # enable "slurp" mode
$data = <STDIN>;
$ctx->add($data);

printf("-----BEGIN PGP %s-----\n\n%s=%s-----END PGP %s-----\n",
       $type, encode_base64($data),
       encode_base64(pack("H*", sprintf("%06x", $ctx->digest))),
       $type);

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users

Reply via email to