VOMS::Lite::ASN1Helper
VOMS::Lite::ASN1Helper - Perl extension for basic ASN.1 encoding and decoding. There is no OO in this module, it's a very basic straightforward implementation of ASN.1.
SYNOPSIS
use
VOMS::Lite::ASN1Helper
qw( Hex DecToHex ASN1BitStr ASN1Wrap ASN1UnwrapHex ASNLenStr ASN1Index ASN1Unwrap ASN1OIDtoOID)
;
# To convert a binary string, $data, to padded hex i.e. ([0-9a-f]{2})*
my
$hexstr
=Hex(
$data
);
# To convert an integer to a padded string of hex values
my
$hexint
=DecToHex(
$int
);
# To convert ASN1 represeantation of an OID to a dot representation e.g. 1.2.840.113549.1.9.1
my
$OIDstr
=ASN1OIDtoOID(
$data
);
# To convert a dot representation of an OID (e.g. 1.2.840.113549.1.9.1) to an ASN1 represeantation
my
$ASN1str
=OIDtoASN1OID(
$oid
);
# To convert a hex representation of a N*8 bit bytestring into an ASN1 bitstring
my
$hexbitstr
=ASN1BitStr(
$hexstr
);
my
$hexbitstr
=ASN1BitStr(
$hexstr
,
$lengthinbits
);
# To wrap a hex string into an ASN.1 Primative
my
$objectstr
=30;
#30 denotes a SEQUENCE
my
$asn1prim
=ASN1Wrap(
$hexstr
);
# To unwrap a chunk of BER encoded ASN.1
my
$contents
=ASN1Unwrap(
$data
);
my
$contentshex
=ASN1UnwrapHex(
$data
);
# or
my
(
$headerLength
,
$dataLength
,
$class
,
$constructed
,
$tag
,
$contents
)=ASN1Unwrap(
$data
);
# To return the ASN.1 length header for a hex representation of some data
my
$LenghtHeaderHex
=ASNLenStr(
$hexstr
);
# To index an ASN.1 string
foreach
ASN1Index(
$data
) {
my
(
$class
,
$constructed
,
$tag
,
$position
,
$headLength
,
$dataLength
)=
@$_
;
...
}
DESCRIPTION
VOMS::Lite::ASN1Helper is designed to provide simple ASN.1 encoding decoding methods for VOMS::Lite.
EXPORT
None by default.
By EXPORT_OK the following functions: Hex DecToHex ASN1BitStr ASN1Wrap ASN1UnwrapHex ASNLenStr ASN1Index ASN1Unwrap ASN1OIDtoOID OIDtoASN1OID
SEE ALSO
The X.680 and X.690 specifications: http://www.itu.int/ITU-T/studygroups/com17/languages/
This module was originally designed for the SHEBANGS project at The University of Manchester. http://www.mc.manchester.ac.uk/projects/shebangs/ now http://www.rcs.manchester.ac.uk/research/shebangs/
Mailing list, shebangs@listserv.manchester.ac.uk Mailing list, voms-lite@listserv.manchester.ac.uk
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
AUTHOR
Mike Jones <mike.jones@manchester.ac.uk>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by Mike Jones
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.