Convert-ASN1

 view release on metacpan or  search on metacpan

examples/tsa3161  view on Meta::CPAN

my $tsa_key;
  { # get key
	my $filename = $ENV{'TSAKeyFile'} or &dieif(1, "Missing environment variable 'TSAKeyFile'");;
        my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks) = stat $filename;
	open TSAKEY, "<$filename" or &dieif(1,"cannot open TSAKeyFile '$filename'");
	binmode TSAKEY;
        my $tsa_key_pem;
	read TSAKEY, $tsa_key_pem, $size;  
	close TSAKEY;
        $tsa_key = Crypt::OpenSSL::RSA->new_private_key($tsa_key_pem) or &dieif(1,"TSAKeyFile '$filename' cannot be decoded");
  }

# some magic
my $time = Time::HiRes::gettimeofday() ;
my $now = int($time);
my $serial = ($time-1288070000)*1000000*100000 +$$;
my $TSTInfo_asn = &asnfind('TSTInfo');
$TSTInfo_asn->configure('encoding','DER');
$TSTInfo_asn->configure('encode',{time=>'withzone'});
$TSTInfo_asn->configure('encode',{timezone=>0});

lib/Convert/ASN1.pod  view on Meta::CPAN

is to use Math::BigInt

=back

Decode options

=over 4

=item time

This controls how a UTCTime or a GeneralizedTime element will be decoded. The default
is C<utctime>.

=over 4

=item utctime

The value returned will be a time value as returned by the C<time> function.

=item withzone

lib/Convert/ASN1.pod  view on Meta::CPAN


=item raw

The value returned will be the raw encoding as extracted from the PDU.

=back

=item bigint

If during decoding any big integers are discovered (integers greater
than 32 bits), they will be decoded into big integer objects. This option
controls the big integer class into which the objects will be blessed.
The default is to use Math::BigInt.

=item null

The value to decode ASN.1 NULL types into.
If not set, it defaults to C<1>.

=back

lib/Convert/ASN1.pod  view on Meta::CPAN


Decode the given ASN.1 encoded C<TAG>.

=item asn_encode_tag ( TAG )

Encode B<TAG> value for encoding.
We assume that the tag has been correctly generated with L</"asn_tag ( CLASS, VALUE )">.

=item asn_decode_length ( LEN )

Decode the given ASN.1 decoded C<LEN>.

=item asn_encode_length ( LEN )

Encode the given C<LEN> to its ASN.1 encoding.

=back

=head2 Constants

=over 4

t/11indef.t  view on Meta::CPAN

#!/usr/local/bin/perl

#
# Test that indefinite length encodings can be decoded
#

BEGIN { require './t/funcs.pl' }

use Convert::ASN1;
my @zz = ( 0, 0 );

print "1..7\n";

btest 1, $asn = Convert::ASN1->new or warn $asn->error;



( run in 2.204 seconds using v1.01-cache-2.11-cpan-26ccb49234f )