NAME

Convert::BER - Basic Encoding Rules for ASN.1

SYNOPSIS

    use Convert::BER;

    $ber = new Convert::BER;

    $ber->encode(
	INTEGER => 10,
	STRING  => "a string",
	SEQUENCE => [
	    BOOLEAN => 1,
	    STRING => [ qw(a list of strings) ]
	]
    );

    $ber->decode(
	INTEGER => \$int,
	STRING  => \$str,
	SEQUENCE => [
	    BOOLEAN => \$bool,
	    STRING => \@str_list
	]
    );

DESCRIPTION

INTEGER => VALUE
STRING => VALUE
BOOLEAN => VALUE
NULL => VALUE
OBJECT_ID => VALUE

Encode VALUE, if VALUE is a reference to an ARRAY then encode each element in the array.

SEQUENCE => ARRAY
SET => ARRAY

Encode the contents of ARRAY and add a SEQUENCE or SET header

BER => OBJ

OBJ should be a Convert::BER object, the buffer of this object will just be inserted. If OBJ is a reference to an ARRAY then each element in the array should be a Convert::BER object and all of then will be inserted.

OPTIONAL => ARRAY

decode content of ARRAY if they exists, or none of them. =item CONSTRUCTED => ARRAY

CONSTRUCTED => OBJ

ARRAY should be a reference to a 2 element array

OBJ should be a Convert::BER object

DEFINEING NEW TYPES

pack SELF, BER, ARG

pack ARG into BER, called as a static method on SELF

unpack SELF, BER, POSREF, ARG

unpack an element. POSREF is a reference to a scalar holding the starting point, and should be updated with the position of the end.

ARG is a reference where the result should be placed.

pack_array SELF, BER, ARG

As pack but ARG will be a reference to an ARRAY. Used only if type want to do something different to the usual (eg SEQUENCE)

unpack_array SELF, BER, POSREF, ARG

As unpack but ARG will be a reference to an ARRAY. Used only if type want to do something different to the usual (eg SEQUENCE)

AUTHOR

Graham Barr <gbarr@ti.com>

CREDITS

The following people have given some useful input into the design of this package.

Russell Fulton <r.fulton@auckland.ac.nz> Benjamin Holzman <bah@mail.med.cornell.edu> Emmanuel Tlemcani <Emmanuel.Tlemcani@der.edfgdf.fr> Ian Redfern <RedfernI@logica.com>

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.