Convert::ASN1 - Decode error

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi all,

I want to decode a .der file. I upgrade my version to 0.19 but I still
have the same trouble, when I use Data Dumper it gives :
'error' => 'decode error at
/usr/lib/perl5/site_perl/5.8.1/Convert/ASN1/ line 123
but asn_dump works find, my asn.1 seems ok.

In fact when I do a decode like that $data =
Dumper of $data gives $VAR1 = undef;
So after when I want to do a $data->->; of course
it prints nothing.

I set the option $asn->configure( decode => { encoding => DER } );
before, don't know if the problem occurs because of that.

I would like to know if somebody had the same problem before and from
what it could come from. I can send my little program if somebody wants
more details.


Re: Convert::ASN1 - Decode error

Quoted text here. Click to load it

Post the program here. It's quite acceptable to do that - in fact, it's
expected of you. It's also expected that the script you post be as small as
you can make it, but still demonstrate the problem that you're facing.


Re: Convert::ASN1 - Decode error

Ok thanks Rob. I'm quite new on forums.
Well I don't see a way to post files by google so I copy that directly
here. I can't copy the .der file too so you'll not be able to test it.
I will try to post that to your email, to attach the 2 files. Or do you
know another way ?

Here is a resume of my perl program. It still have 168 lines but
because of the asn.1 structure. Tested with Convert::ASN1 v0.19 (the
last). If you copy and test it with the good .der it prints debug
infos, I mean it is totally operationnal for tests.

# we want to read a asn.1 file
use Convert::ASN1 qw(:all);
use Getopt::Long;
use Data::Dumper;

my ($file, $data, $dataToCheck);

# -file answer.der
GetOptions ('file=s' => $file);

# read asn.1 file
my $fileSize = (stat($file))[7];
print "\nsize $fileSize";
print "\nfile $file";

open(INPUT, $file) || die "can't open $file: $!\n";
binmode INPUT;
read INPUT, $dataToCheck, $fileSize;

my $asn = Convert::ASN1->new;
# we use Der not Ber
$asn->configure( decode => { encoding => DER } );

# the asn.1
    SerValResponse ::= SEQUENCE {
        responseStatus             SerValResponseStatus,
        responseBytes       [0] EXPLICIT ResponseBytes OPTIONAL

    SerValResponseStatus ::= ENUMERATED {
        successful            (0),
        malformedRequest      (1),
        internalError         (2),
        tryLater              (3),
        sigRequired           (5),
        unauthorized          (6)

    ResponseBytes ::= SEQUENCE {
        responseType   OBJECT IDENTIFIER,
        response       BasicSerValResponse

    responseValue ::= CHOICE {
        basicResponse   BasicSerValResponse

    BasicSerValResponse ::= SEQUENCE {
        tbsResponseData         ResponseData,
        signatureAlgorithm      AlgorithmIdentifier,
        signature               BIT STRING,
        certs                   EXPLICIT SEQUENCE OF Certificate

    ResponseData ::= SEQUENCE {
        version              [0] INTEGER,
        nonce                    INTEGER,
        responderID              ResponderID,
        producedAt               GeneralizedTime,
        responses                SingleResponse,
        responseExtensions   [1] EXPLICIT Extensions OPTIONAL

    ResponderID ::= CHOICE {
          byName               [1] IA5String

    SingleResponse ::= SEQUENCE {
          certificate                  Certificate,
          certStatus                   CertStatus,
          thisUpdate                   GeneralizedTime,
        nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
        singleExtensions   [1]       EXPLICIT Extensions OPTIONAL

    CertStatus ::= CHOICE {
        good        [0]     IMPLICIT IA5String,
           revoked     [1]     IMPLICIT RevokedInfo,
           invalid     [2]     IMPLICIT InvalidInfo

    RevokedInfo ::= SEQUENCE {
        revocationTime              GeneralizedTime,
        revocationReason    [0]     EXPLICIT CRLReason OPTIONAL

    InvalidInfo ::= ENUMERATED {
        unknown             (0),
        invalidValPolicy    (1),
        invalidCertPolicy   (2),
        invalidKeyUsage     (3),
        invalidTrustedPath  (4),
        outdatedCertificate (5),
        invalidExtKeyUsage  (6)

    Extensions  ::=  SEQUENCE OF Extension

    Extension  ::=  SEQUENCE  {
        extnID      OBJECT IDENTIFIER,
        critical    BOOLEAN,
        extnValue   OCTET STRING

    CRLReason ::= ENUMERATED {
        unspecified             (0),
        keyCompromise           (1),
        cACompromise            (2),
        affiliationChanged      (3),
        superseded              (4),
        cessationOfOperation    (5),
        certificateHold         (6),
        removeFromCRL           (8)

    AlgorithmIdentifier ::= SEQUENCE {
        algorithm        OBJECT IDENTIFIER,
        parameters        ANY

    CertificateValue ::= SEQUENCE {
        oneCertificate    Certificate

    Certificate ::= OCTET STRING
Quoted text here. Click to load it

# choose what we want to read
my $structure = $asn->find('SerValResponse');

if ($asn->error ne '') { print "\nError: " . $asn->error; }
if ($structure->error ne '') { print "\nError: " . $structure->error; }

# link data to asn.1 structure
$data_1 = $structure->decode($dataToCheck);

print "\n";
print "Dumper structure";
print" ==================================================\n";
print Dumper ($structure);
print "\nDumper data";
print" ==================================================\n";
print Dumper ($data_1);

# what we want to have : this doesn't work
print "\nresponseStatus ".
$data_1->-> ."\n";

# For tests
print "structure\n";
print "data\n";
print "asn\n";
print "dataToCheck\n";

Re: Convert::ASN1 - Decode error

oups on google I can't see your email entirely so...


Re: Convert::ASN1 - Decode error

well, thanks google !
they cut email ?? funny...
ok I try this :


Site Timeline