Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Need Convert::ASN1 library encoded text in uper format

by santosh_vjit (Novice)
on Feb 22, 2018 at 12:03 UTC ( [id://1209739]=perlquestion: print w/replies, xml ) Need Help??

santosh_vjit has asked for the wisdom of the Perl Monks concerning the following question:

Hi Friends,

I have requirement to encode the below sequence structure with values to uper encoded rule and pass the string to other class. But using Convert::ASN1 library im able to encode only in ber/der format. Can any one of you please guide how to encode below input in uper encoding format and capture that encoded string in a variable. P.S: If require i can provide ASN1 structure of input.

#!/usr/bin/perl -w use Data::Dumper; use Getopt::Std; use Convert::ASN1 qw(:io :debug); getopts('s:D', \%opts); if (!defined($opts{'s'})) { print STDERR "Missing ASN.1 Specification file!\n"; HELP_MESSAGE(); exit 1; } $specfile = $opts{'s'}; $DEBUG = $opts{'D'}; $asn = Convert::ASN1->new(encoding=>'DER'); $r = $asn->prepare_file($specfile); #print Dumper($r); if (!defined($r)) { print "ERROR: " . $asn->error . "\n"; } $securityModeError = $asn->find("ATCmessageheader"); $pdu = $securityModeError->encode( msgidentificationnumber => 1, msgreferencenumber =>1, timestamp =>{timehours=>12, timeminutes=>07, timeseconds=>50} ); print "Encode : pdu ". Dumper($pdu), "\n"; print "Decode: pdu ". Dumper($securityModeError->decode($pdu)). "\n";

Replies are listed 'Best First'.
Re: Need Convert::ASN1 library encoded text in uper format
by thanos1983 (Parson) on Feb 22, 2018 at 12:31 UTC

    Hello santosh_vjit,

    I am afraid what you ask is not possible. From the module documentation Convert::ASN1/DESCRIPTION:

    Convert::ASN1 encodes and decodes ASN.1 data structures using BER/DER +rules.

    In conclusion only allowed encoding(s) from the module are: Basic Encoding Rules (BER) and Distinguished Encoding Rules (DER). The remaining encoding(s) e.g. Packed Encoding Rules, aligned (PER) and unaligned (UPER), and XML Encoding Rules (XER), basic and canonical are not supported from the module.

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
      Thanks BR for your reply.

      Yes from documentation i could figure out that only BER/DER encoding is possible. But I wanted to know if there is any other way where i can encode the structure in UPER encoding rule.

        Hello again santosh_vjit,

        I guess the only alternative way is to implemented yourself and extend the module. :)

        BR / Thanos

        Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1209739]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found