Convert-ASN1-0.26000755000765000765 011764713076 13164 5ustar00gbarrgbarr000000000000LICENSE100644000765000765 4367511764713076 14311 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26This software is copyright (c) 2012 by Graham Barr. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012 by Graham Barr. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012 by Graham Barr. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End mkparse100644000765000765 307311764713076 14635 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26#!/usr/local/bin/perl # $Id: mkparse,v 1.2 2002/03/25 07:39:46 gbarr Exp $ my($source,$dest) = @ARGV; system qw(byacc -P),$source; open(OUT, ">$dest") or die "Cannot open $dest: $!\n"; open(IN, "cpp y.tab.pl|"); %var = (); %seen = (); %state = (); while() { # In perl the stack size is not a problem next if /YYSTACKSIZE/; next if /^# \d+ "(.*?)"/ and $1 ne "parser.y"; # Replace variables with constant subs if(s/^\$([A-Z][A-Z_0-9]*)\s*=\s*(\d+)\s*;/sub const$1 () { $2 }/) { $var{$1} = "const" . $1 . "()"; } s/ (\$([A-Z][A-Z_0-9]*)) / exists $var{$2} ? $var{$2} : $1 /xeg; # Comment out the id line s/^(?=\$yysccsid)/#/; # Use my variables s/^(\@yy\w+\s+=)/my $1/; # Make yyparse return $$ for the top terminal if (/^sub yyparse/ .. /^\}\s*#\s*yyparse/) { s/\breturn\(1\)/return undef/; s/\breturn\(0\)/return \$yyvs[\$yyvsp]/; } # Are we inside the switch statement ? my $ln = /^\s+switch:/ .. /^\s+\$yyssp -= \$yym;/; # Change all the if statements in the switch to labels if ( $ln ) { s/^if \(\$yyn == (\d+)\s*\)/State$1:/ and $state{"State$1"} = ''; } # fix an uninit bug s/^(\s*)(?=\$yycheck\[\$yyn\]\s+==)/$1\$yyn <= \$#yycheck && /; print OUT; # Print the goto for the switch print OUT <<'ESQ' if $ln == 2; my $label = "State$yyn"; goto $label if exists $yystate{$label}; last switch; ESQ } # output table with names of labels that exist my $states = '%yystate = (\'' . join("','",%state) . "');\n"; $states =~ s/(.{60,75},)/$1\n/g; print OUT $states,"\n1;\n"; close OUT; close IN; META.yml100644000765000765 123511764713076 14517 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26--- abstract: 'Convert between perl data structures and ASN.1 encoded packets' author: - 'Graham Barr ' build_requires: Math::BigInt: 1.997 Test::More: 0.90 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300015, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Convert-ASN1 no_index: directory: - lib/Convert/ASN1 - t - examples resources: bugtracker: https://github.com/gbarr/perl-Convert-ASN1/issues repository: git://github.com/gbarr/perl-Convert-ASN1.git version: 0.26 MANIFEST100644000765000765 136511764713076 14403 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26ChangeLog LICENSE MANIFEST META.json META.yml Makefile.PL OldChanges README.md SIGNATURE dist.ini examples/ldap examples/ldap-search examples/x509decode lib/Convert/ASN1.pm lib/Convert/ASN1.pod lib/Convert/ASN1/Debug.pm lib/Convert/ASN1/IO.pm lib/Convert/ASN1/_decode.pm lib/Convert/ASN1/_encode.pm lib/Convert/ASN1/parser.pm mkparse parser.y t/00prim.t t/01tag.t t/02seq.t t/03seqof.t t/04opt.t t/05time.t t/06bigint.t t/07input.dat t/07io.t t/08set.t t/09contr.t t/10choice.t t/11explicit.t t/11indef.t t/12der.t t/13utf8.t t/14any.t t/15extseq.t t/16extset.t t/17extchoice.t t/18tagdefault.t t/aj.cer t/aj2.cer t/allianz_root.cer t/dsacert.der t/funcs.pl t/new_root_ca.cer t/pgpextension.der t/subca_2.cer t/telesec_799972029.crt t/verisign.der t/x509.t dist.ini100644000765000765 155711764713076 14721 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26name = Convert-ASN1 author = Graham Barr license = Perl_5 copyright_holder = Graham Barr abstract = Convert between perl data structures and ASN.1 encoded packets [@Filter] :version = 4.1 ; Dist::Zilla version needed bundle = @Basic remove = GatherDir remove = Readme [MetaNoIndex] directory = lib/Convert/ASN1 directory = t directory = examples [Git::GatherDir] [Git::NextVersion] [PkgVersion] [PodVersion] [Prereqs / TestRequires] Test::More = 0.90 Math::BigInt = 1.997 [NextRelease] format = %v -- %{EEE MMM dd HH:mm:ss VVV yyyy}d filename = ChangeLog [MetaJSON] [MetaResources] bugtracker.web = https://github.com/gbarr/perl-Convert-ASN1/issues repository.web = https://github.com/gbarr/perl-Convert-ASN1 repository.url = git://github.com/gbarr/perl-Convert-ASN1.git repository.type = git [Signature] [@Git] changelog = ChangeLog parser.y100644000765000765 3336711764713076 14767 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26%token WORD 1 %token CLASS 2 %token SEQUENCE 3 %token SET 4 %token CHOICE 5 %token OF 6 %token IMPLICIT 7 %token EXPLICIT 8 %token OPTIONAL 9 %token LBRACE 10 %token RBRACE 11 %token COMMA 12 %token ANY 13 %token ASSIGN 14 %token NUMBER 15 %token ENUM 16 %token COMPONENTS 17 %token POSTRBRACE 18 %token DEFINED 19 %token BY 20 %token EXTENSION_MARKER 21 %{ # Copyright (c) 2000-2005 Graham Barr . All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package Convert::ASN1::parser; use strict; use Convert::ASN1 qw(:all); use vars qw( $asn $yychar $yyerrflag $yynerrs $yyn @yyss $yyssp $yystate @yyvs $yyvsp $yylval $yys $yym $yyval ); BEGIN { Convert::ASN1->_internal_syms } my $yydebug=0; my %yystate; my %base_type = ( BOOLEAN => [ asn_encode_tag(ASN_BOOLEAN), opBOOLEAN ], INTEGER => [ asn_encode_tag(ASN_INTEGER), opINTEGER ], BIT_STRING => [ asn_encode_tag(ASN_BIT_STR), opBITSTR ], OCTET_STRING => [ asn_encode_tag(ASN_OCTET_STR), opSTRING ], STRING => [ asn_encode_tag(ASN_OCTET_STR), opSTRING ], NULL => [ asn_encode_tag(ASN_NULL), opNULL ], OBJECT_IDENTIFIER => [ asn_encode_tag(ASN_OBJECT_ID), opOBJID ], REAL => [ asn_encode_tag(ASN_REAL), opREAL ], ENUMERATED => [ asn_encode_tag(ASN_ENUMERATED), opINTEGER ], ENUM => [ asn_encode_tag(ASN_ENUMERATED), opINTEGER ], 'RELATIVE-OID' => [ asn_encode_tag(ASN_RELATIVE_OID), opROID ], SEQUENCE => [ asn_encode_tag(ASN_SEQUENCE | ASN_CONSTRUCTOR), opSEQUENCE ], EXPLICIT => [ asn_encode_tag(ASN_SEQUENCE | ASN_CONSTRUCTOR), opEXPLICIT ], SET => [ asn_encode_tag(ASN_SET | ASN_CONSTRUCTOR), opSET ], ObjectDescriptor => [ asn_encode_tag(ASN_UNIVERSAL | 7), opSTRING ], UTF8String => [ asn_encode_tag(ASN_UNIVERSAL | 12), opUTF8 ], NumericString => [ asn_encode_tag(ASN_UNIVERSAL | 18), opSTRING ], PrintableString => [ asn_encode_tag(ASN_UNIVERSAL | 19), opSTRING ], TeletexString => [ asn_encode_tag(ASN_UNIVERSAL | 20), opSTRING ], T61String => [ asn_encode_tag(ASN_UNIVERSAL | 20), opSTRING ], VideotexString => [ asn_encode_tag(ASN_UNIVERSAL | 21), opSTRING ], IA5String => [ asn_encode_tag(ASN_UNIVERSAL | 22), opSTRING ], UTCTime => [ asn_encode_tag(ASN_UNIVERSAL | 23), opUTIME ], GeneralizedTime => [ asn_encode_tag(ASN_UNIVERSAL | 24), opGTIME ], GraphicString => [ asn_encode_tag(ASN_UNIVERSAL | 25), opSTRING ], VisibleString => [ asn_encode_tag(ASN_UNIVERSAL | 26), opSTRING ], ISO646String => [ asn_encode_tag(ASN_UNIVERSAL | 26), opSTRING ], GeneralString => [ asn_encode_tag(ASN_UNIVERSAL | 27), opSTRING ], CharacterString => [ asn_encode_tag(ASN_UNIVERSAL | 28), opSTRING ], UniversalString => [ asn_encode_tag(ASN_UNIVERSAL | 28), opSTRING ], BMPString => [ asn_encode_tag(ASN_UNIVERSAL | 30), opSTRING ], BCDString => [ asn_encode_tag(ASN_OCTET_STR), opBCD ], CHOICE => [ '', opCHOICE ], ANY => [ '', opANY ], EXTENSION_MARKER => [ '', opEXTENSIONS ], ); my $tagdefault = 1; # 0:IMPLICIT , 1:EXPLICIT default # args: class,plicit sub need_explicit { (defined($_[0]) && (defined($_[1])?$_[1]:$tagdefault)); } # Given an OP, wrap it in a SEQUENCE sub explicit { my $op = shift; my @seq = @$op; @seq[cTYPE,cCHILD,cVAR,cLOOP] = ('EXPLICIT',[$op],undef,undef); @{$op}[cTAG,cOPT] = (); \@seq; } %} %% top : slist { $$ = { '' => $1 }; } | module ; module : WORD ASSIGN aitem { $$ = { $1, [$3] }; } | module WORD ASSIGN aitem { $$=$1; $$->{$2} = [$4]; } ; aitem : class plicit anyelem postrb { $3->[cTAG] = $1; $$ = need_explicit($1,$2) ? explicit($3) : $3; } | celem ; anyelem : onelem | eelem | oelem | selem ; celem : COMPONENTS OF WORD { @{$$ = []}[cTYPE,cCHILD] = ('COMPONENTS', $3); } ; seqset : SEQUENCE | SET ; selem : seqset OF class plicit sselem optional { $5->[cTAG] = $3; @{$$ = []}[cTYPE,cCHILD,cLOOP,cOPT] = ($1, [$5], 1, $6); $$ = explicit($$) if need_explicit($3,$4); } ; sselem : eelem | oelem | onelem ; onelem : SEQUENCE LBRACE slist RBRACE { @{$$ = []}[cTYPE,cCHILD] = ('SEQUENCE', $3); } | SET LBRACE slist RBRACE { @{$$ = []}[cTYPE,cCHILD] = ('SET', $3); } | CHOICE LBRACE nlist RBRACE { @{$$ = []}[cTYPE,cCHILD] = ('CHOICE', $3); } ; eelem : ENUM LBRACE elist RBRACE { @{$$ = []}[cTYPE] = ('ENUM'); } ; oielem : WORD { @{$$ = []}[cTYPE] = $1; } | SEQUENCE { @{$$ = []}[cTYPE] = $1; } | SET { @{$$ = []}[cTYPE] = $1; } | ANY defined { @{$$ = []}[cTYPE,cCHILD,cDEFINE] = ('ANY',undef,$2); } | ENUM { @{$$ = []}[cTYPE] = $1; } ; defined : { $$=undef; } | DEFINED BY WORD { $$=$3; } ; oelem : oielem ; nlist : nlist1 { $$ = $1; } | nlist1 POSTRBRACE { $$ = $1; } ; nlist1 : nitem { $$ = [ $1 ]; } | nlist1 POSTRBRACE nitem { push @{$$=$1}, $3; } | nlist1 COMMA nitem { push @{$$=$1}, $3; } ; nitem : WORD class plicit anyelem { @{$$=$4}[cVAR,cTAG] = ($1,$2); $$ = explicit($$) if need_explicit($2,$3); } | EXTENSION_MARKER { @{$$=[]}[cTYPE] = 'EXTENSION_MARKER'; } ; slist : { $$ = []; } | slist1 { my $extension = 0; $$ = []; for my $i (@{$1}) { $extension = 1 if $i->[cTYPE] eq 'EXTENSION_MARKER'; $i->[cEXT] = $i->[cOPT]; $i->[cEXT] = 1 if $extension; push @{$$}, $i unless $i->[cTYPE] eq 'EXTENSION_MARKER'; } my $e = []; $e->[cTYPE] = 'EXTENSION_MARKER'; push @{$$}, $e if $extension; } | slist1 POSTRBRACE { my $extension = 0; $$ = []; for my $i (@{$1}) { $extension = 1 if $i->[cTYPE] eq 'EXTENSION_MARKER'; $i->[cEXT] = $i->[cOPT]; $i->[cEXT] = 1 if $extension; push @{$$}, $i unless $i->[cTYPE] eq 'EXTENSION_MARKER'; } my $e = []; $e->[cTYPE] = 'EXTENSION_MARKER'; push @{$$}, $e if $extension; } ; slist1 : sitem { $$ = [ $1 ]; } | slist1 COMMA sitem { push @{$$=$1}, $3; } | slist1 POSTRBRACE sitem { push @{$$=$1}, $3; } ; snitem : oelem optional { @{$$=$1}[cOPT] = ($2); } | eelem | selem | onelem ; sitem : WORD class plicit snitem { @{$$=$4}[cVAR,cTAG] = ($1,$2); $$->[cOPT] = $1 if $$->[cOPT]; $$ = explicit($$) if need_explicit($2,$3); } | celem | class plicit onelem { @{$$=$3}[cTAG] = ($1); $$ = explicit($$) if need_explicit($1,$2); } | EXTENSION_MARKER { @{$$=[]}[cTYPE] = 'EXTENSION_MARKER'; } ; optional : { $$ = undef; } | OPTIONAL { $$ = 1; } ; class : { $$ = undef; } | CLASS ; plicit : { $$ = undef; } | EXPLICIT { $$ = 1; } | IMPLICIT { $$ = 0; } ; elist : eitem {} | elist COMMA eitem {} ; eitem : WORD NUMBER {} ; postrb : {} | POSTRBRACE {} ; %% my %reserved = ( 'OPTIONAL' => $OPTIONAL, 'CHOICE' => $CHOICE, 'OF' => $OF, 'IMPLICIT' => $IMPLICIT, 'EXPLICIT' => $EXPLICIT, 'SEQUENCE' => $SEQUENCE, 'SET' => $SET, 'ANY' => $ANY, 'ENUM' => $ENUM, 'ENUMERATED' => $ENUM, 'COMPONENTS' => $COMPONENTS, '{' => $LBRACE, '}' => $RBRACE, ',' => $COMMA, '::=' => $ASSIGN, 'DEFINED' => $DEFINED, 'BY' => $BY ); my $reserved = join("|", reverse sort grep { /\w/ } keys %reserved); my %tag_class = ( APPLICATION => ASN_APPLICATION, UNIVERSAL => ASN_UNIVERSAL, PRIVATE => ASN_PRIVATE, CONTEXT => ASN_CONTEXT, '' => ASN_CONTEXT # if not specified, its CONTEXT ); ;## ;## This is NOT thread safe !!!!!! ;## my $pos; my $last_pos; my @stacked; sub parse { local(*asn) = \($_[0]); $tagdefault = $_[1] eq 'EXPLICIT' ? 1 : 0; ($pos,$last_pos,@stacked) = (); eval { local $SIG{__DIE__}; compile(verify(yyparse())); } } sub compile_one { my $tree = shift; my $ops = shift; my $name = shift; foreach my $op (@$ops) { next unless ref($op) eq 'ARRAY'; bless $op; my $type = $op->[cTYPE]; if (exists $base_type{$type}) { $op->[cTYPE] = $base_type{$type}->[1]; $op->[cTAG] = defined($op->[cTAG]) ? asn_encode_tag($op->[cTAG]): $base_type{$type}->[0]; } else { die "Unknown type '$type'\n" unless exists $tree->{$type}; my $ref = compile_one( $tree, $tree->{$type}, defined($op->[cVAR]) ? $name . "." . $op->[cVAR] : $name ); if (defined($op->[cTAG]) && $ref->[0][cTYPE] == opCHOICE) { @{$op}[cTYPE,cCHILD] = (opSEQUENCE,$ref); } else { @{$op}[cTYPE,cCHILD,cLOOP] = @{$ref->[0]}[cTYPE,cCHILD,cLOOP]; } $op->[cTAG] = defined($op->[cTAG]) ? asn_encode_tag($op->[cTAG]): $ref->[0][cTAG]; } $op->[cTAG] |= chr(ASN_CONSTRUCTOR) if length $op->[cTAG] && ($op->[cTYPE] == opSET || $op->[cTYPE] == opEXPLICIT || $op->[cTYPE] == opSEQUENCE); if ($op->[cCHILD]) { ;# If we have children we are one of ;# opSET opSEQUENCE opCHOICE opEXPLICIT compile_one($tree, $op->[cCHILD], defined($op->[cVAR]) ? $name . "." . $op->[cVAR] : $name); ;# If a CHOICE is given a tag, then it must be EXPLICIT if ($op->[cTYPE] == opCHOICE && defined($op->[cTAG]) && length($op->[cTAG])) { $op = bless explicit($op); $op->[cTYPE] = opSEQUENCE; } if ( @{$op->[cCHILD]} > 1) { ;#if ($op->[cTYPE] != opSEQUENCE) { ;# Here we need to flatten CHOICEs and check that SET and CHOICE ;# do not contain duplicate tags ;#} if ($op->[cTYPE] == opSET) { ;# In case we do CER encoding we order the SET elements by thier tags my @tags = map { length($_->[cTAG]) ? $_->[cTAG] : $_->[cTYPE] == opCHOICE ? (sort map { $_->[cTAG] } $_->[cCHILD])[0] : '' } @{$op->[cCHILD]}; @{$op->[cCHILD]} = @{$op->[cCHILD]}[sort { $tags[$a] cmp $tags[$b] } 0..$#tags]; } } else { ;# A SET of one element can be treated the same as a SEQUENCE $op->[cTYPE] = opSEQUENCE if $op->[cTYPE] == opSET; } } } $ops; } sub compile { my $tree = shift; ;# The tree should be valid enough to be able to ;# - resolve references ;# - encode tags ;# - verify CHOICEs do not contain duplicate tags ;# once references have been resolved, and also due to ;# flattening of COMPONENTS, it is possible for an op ;# to appear in multiple places. So once an op is ;# compiled we bless it. This ensure we dont try to ;# compile it again. while(my($k,$v) = each %$tree) { compile_one($tree,$v,$k); } $tree; } sub verify { my $tree = shift or return; my $err = ""; ;# Well it parsed correctly, now we ;# - check references exist ;# - flatten COMPONENTS OF (checking for loops) ;# - check for duplicate var names while(my($name,$ops) = each %$tree) { my $stash = {}; my @scope = (); my $path = ""; my $idx = 0; while($ops) { if ($idx < @$ops) { my $op = $ops->[$idx++]; my $var; if (defined ($var = $op->[cVAR])) { $err .= "$name: $path.$var used multiple times\n" if $stash->{$var}++; } if (defined $op->[cCHILD]) { if (ref $op->[cCHILD]) { push @scope, [$stash, $path, $ops, $idx]; if (defined $var) { $stash = {}; $path .= "." . $var; } $idx = 0; $ops = $op->[cCHILD]; } elsif ($op->[cTYPE] eq 'COMPONENTS') { splice(@$ops,--$idx,1,expand_ops($tree, $op->[cCHILD])); } else { die "Internal error\n"; } } } else { my $s = pop @scope or last; ($stash,$path,$ops,$idx) = @$s; } } } die $err if length $err; $tree; } sub expand_ops { my $tree = shift; my $want = shift; my $seen = shift || { }; die "COMPONENTS OF loop $want\n" if $seen->{$want}++; die "Undefined macro $want\n" unless exists $tree->{$want}; my $ops = $tree->{$want}; die "Bad macro for COMPUNENTS OF '$want'\n" unless @$ops == 1 && ($ops->[0][cTYPE] eq 'SEQUENCE' || $ops->[0][cTYPE] eq 'SET') && ref $ops->[0][cCHILD]; $ops = $ops->[0][cCHILD]; for(my $idx = 0 ; $idx < @$ops ; ) { my $op = $ops->[$idx++]; if ($op->[cTYPE] eq 'COMPONENTS') { splice(@$ops,--$idx,1,expand_ops($tree, $op->[cCHILD], $seen)); } } @$ops; } sub _yylex { my $ret = &_yylex; warn $ret; $ret; } sub yylex { return shift @stacked if @stacked; while ($asn =~ /\G(?: (\s+|--[^\n]*) | ([,{}]|::=) | ($reserved)\b | ( (?:OCTET|BIT)\s+STRING | OBJECT\s+IDENTIFIER | RELATIVE-OID )\b | (\w+(?:-\w+)*) | \[\s* ( (?:(?:APPLICATION|PRIVATE|UNIVERSAL|CONTEXT)\s+)? \d+ ) \s*\] | \((\d+)\) | (\.\.\.) )/sxgo ) { ($last_pos,$pos) = ($pos,pos($asn)); next if defined $1; # comment or whitespace if (defined $2 or defined $3) { my $ret = $+; # A comma is not required after a '}' so to aid the # parser we insert a fake token after any '}' if ($ret eq '}') { my $p = pos($asn); my @tmp = @stacked; @stacked = (); pos($asn) = $p if yylex() != $COMMA; # swallow it @stacked = (@tmp, $POSTRBRACE); } return $reserved{$yylval = $ret}; } if (defined $4) { ($yylval = $+) =~ s/\s+/_/g; return $WORD; } if (defined $5) { $yylval = $+; return $WORD; } if (defined $6) { my($class,$num) = ($+ =~ /^([A-Z]*)\s*(\d+)$/); $yylval = asn_tag($tag_class{$class}, $num); return $CLASS; } if (defined $7) { $yylval = $+; return $NUMBER; } if (defined $8) { return $EXTENSION_MARKER; } die "Internal error\n"; } die "Parse error before ",substr($asn,$pos,40),"\n" unless $pos == length($asn); 0 } sub yyerror { die @_," ",substr($asn,$last_pos,40),"\n"; } 1; t000755000765000765 011764713076 13350 5ustar00gbarrgbarr000000000000Convert-ASN1-0.2607io.t100644000765000765 354011764713076 14455 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl use Convert::ASN1 qw(:io); use IO::Socket; print "1..11\n"; my $result = pack("C*", 0x30, 0x3D, 0x04, 0x04, 0x46, 0x72, 0x65, 0x64, 0x30, 0x13, 0x04, 0x11, 0x41, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x20, 0x66, 0x6F, 0x72, 0x20, 0x66, 0x72, 0x65, 0x64, 0x04, 0x03, 0x4A, 0x6F, 0x65, 0x30, 0x1B, 0x04, 0x03, 0x68, 0x61, 0x73, 0x04, 0x01, 0x61, 0x04, 0x04, 0x6C, 0x69, 0x73, 0x74, 0x04, 0x02, 0x6F, 0x66, 0x04, 0x07, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x73); ($file = $0) =~ s/t$/dat/; open(OUT,"> $file"); asn_write(*OUT, $result); asn_write(*OUT, $result); close(OUT); open(IN,"< $file"); sysread(IN,$buffer,1024); close(IN); print "not " unless $buffer eq $result x 2; print "ok 1\n"; open(IN,"< $file"); asn_read(*IN, $input); close(IN); print "not " unless $input eq $result; print "ok 2\n"; open(IN,"< $file"); undef $input; $input = asn_get(*IN); print "not " unless $input eq $result; print "ok 3\n"; print "not " unless asn_ready(*IN); print "ok 4\n"; undef $input; $input = asn_get(*IN); print "not " unless $input eq $result; print "ok 5\n"; print "not " if asn_ready(*IN); print "ok 6\n"; close(IN); unlink($file); my $src = IO::Socket::INET->new(Proto => 'udp'); my $dst = IO::Socket::INET->new(Proto => 'udp'); bind($dst, pack_sockaddr_in(0, INADDR_ANY)); my $host = $dst->sockhost eq '0.0.0.0' ? '127.0.0.1' : $dst->sockhost; my $addr = pack_sockaddr_in($dst->sockport, inet_aton($host)); asn_send($src,$result,0,$addr) or print "not "; print "ok 7\n"; asn_recv($dst, $in2, 0) or print "not "; print "ok 8\n"; print "not " unless $in2 && $in2 eq $result; print "ok 9\n"; open(IN,"t/07input.dat") or die "Cannot open 07input.dat: $!\n"; undef $input; my $n = asn_read(*IN,$input); print "not " unless $n and $n == length($input); print "ok 10\n"; print "not " unless $n == 1283; print "ok 11\n"; aj.cer100644000765000765 225211764713076 14576 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t00L>0  *H 0C1 0 UDE10U  Allianz Group10UAllianz Dresdner CA0 050725134151Z 070726134151Z0h1(0& *H  alexander.jung@allianz.de1 0 UDE10U  Allianz Group10UAlexander Jung00  *H 0-nB*k9Dn y-꿡_%uӯz3Bu!3JS]W7sH CerԵɟ&\Uq_,gѣN^L<WY4 6M00 `HB0U02U )0%0! +w00+00Allianz Group Germany0For internal use and for use as regualted by subscriber agreements only. Not to be used for communications between third parties without express written consent of Allianz AG01+%https://rootca.allianz.com/ad-ca/cps/0:U3010/-+)http://rootca.allianz.com/ad-ca/ad-ca.crl0$U0alexander.jung@allianz.de0U#0#^A<֋XA-0U%0++0  *H &lÍ/޼BM倅8ynWc2Y˂Uu\ zu/NK'`t"Ck}2'/XpQ`:ݣ}l⪲/N .@U3٠!f@/QV[?}?";HL|Π")}y;يB޿@}Ѽ0P\{eލ´ǣ`5ȸ0 4c?<x509.t100644000765000765 2767111764713076 14437 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl print "1..26\n"; BEGIN { require 't/funcs.pl' } use Convert::ASN1; my $t = 1; my $asn = Convert::ASN1->new; btest $t++, $asn->prepare(<find('Certificate'); btest $t++, my $crlp = $asn->find('cRLDistributionPoints'); my %certs = ( 't/aj.cer' => ["http://rootca.allianz.com/ad-ca/ad-ca.crl"], 't/aj2.cer' => ["http://rootca.allianz.com/sc-ad-ca/sc-ad-ca.crl"], 't/allianz_root.cer' => ["http://rootca.allianz.com/rootca.crl"], 't/pgpextension.der' => ["http://ca.mayfirst.org/mfpl.crl"], 't/subca_2.cer' => [ "ldap://ldap.treas.gov/cn=CRL1,ou=US%20Treasury%20Root%20CA,ou=Certification%20Authorities,ou=Department%20of%20the%20Treasury,o=U.S.%20Government,c=US?authorityRevocationList" ], 't/dsacert.der' => undef, 't/new_root_ca.cer' => undef, 't/telesec_799972029.crt' => undef, 't/verisign.der' => undef, ); for my $file (sort keys %certs) { print "# $file\n"; my $cert = loadcert($file); btest $t++, my $data = $parser->decode($cert); $data ||= {}; my $extns = $data->{tbsCertificate}{extensions} || []; my ($ext) = grep { $_->{'extnID'} eq '2.5.29.31' } @$extns; if ($ext) { my $points = $crlp->decode($ext->{'extnValue'}); # decode the value $points = $points && $points->[0]->{'distributionPoint'}->{'fullName'}; btest $t++, !$crlp->error or warn($crlp->error); my @points = grep $_, map { $_->{'uniformResourceIdentifier'} } @{$points || []}; rtest $t++, $certs{$file}, \@points; } else { btest $t++, !$certs{$file}; } } sub loadcert { my $file = shift; open FILE, $file || die "cannot load test certificate" . $file . "\n"; binmode FILE; # HELLO Windows, dont fuss with this my $holdTerminator = $/; undef $/; # using slurp mode to read the DER-encoded binary certificate my $cert = ; $/ = $holdTerminator; close FILE; return $cert; } ChangeLog100644000765000765 2347111764713076 15046 0ustar00gbarrgbarr000000000000Convert-ASN1-0.260.26 -- Sat Jun 09 13:30:16 CDT 2012 * Avoid Modification of a read-only value attempted errors * dump Data::Dumper strings when rtest fails * Add tests from Crypt::X509 that found the last Modification of a read-only value attempted error 0.25 -- Fri Jun 08 19:31:59 CDT 2012 * fix a spelling mistake [gregor herrmann] * Add use strict and fix errors * Fix decoding of indefinite sequences with ANY * POD additions for ANY * EXPLICIT ops must pass their cVAR to their child op * Swallow a , after a } 0.24 -- Mon Jun 04 17:11:08 CDT 2012 * spelling fix [gregor herrmann] * Added tests for extension markers (fails currently) [Niels Laukens] * Bugfix for extension markerss in SETs and CHOICEs [Niels Laukens] * Skip attempting to encode opEXTENSIONS inside of CHOICE * Support for default explicit tagging [Peter Mogensen] * Added tests and doc for explicit tagging [Peter Mogensen] * Add new opEXPLICIT for sequences that are inserted for EXPLICIT tags 0.23 -- Thu May 03 16:32:46 CDT 2012 * Added support for EXTENSION MARKERS (...) (Niels Laukens) * Switch to Dist::Zilla for building Convert::ASN1 0.21 -- Mon Sep 15 14:34:45 CDT 2008 Bug Fixes * Fix decoding of OIDs with large value for 2nd element Enhancements * Support for SEQUENCE with no elements in ASN.1 * Added ability to define what value is put in perl data structory when decoding NULL elements Convert::ASN1 0.21 -- Fri Feb 2 20:24:59 CST 2007 Bug Fixes * Fixed problem with indefinite encoding inside an indefinite encoding Enhancements * Added support for type-local ANY DEFINED BY (patch from Leif Johansson) Convert::ASN1 0.20 -- Tue Feb 21 18:47:43 CST 2006 Bug Fixes * Fixed issues with decoding when calling script contains use encoding 'utf8' * Allow zero-length timestamps to be extracted * Fix incorrect length encoding for bitstrings Enhancements * Support encoding bigint's as BCD Convert::ASN1 0.19 -- Mon Apr 18 19:40:32 CDT 2005 Bug Fixes * Fixed reading of packets with indefinite-length encodings Enhancements * Add support for BCDString 2003-10-08 15:29 Graham Barr * lib/Convert/ASN1.pm: Release 0.18 2003-10-08 15:28 Graham Barr * MANIFEST, Makefile.PL, t/0-signature.t: Use Module::Build to build Makefile and add SIGNATURE 2003-10-08 13:28 Graham Barr * lib/Convert/: ASN1.pm, ASN1/_encode.pm: Fix bug in encoding BIT STRINGS where chr() was causing an upgrade to UTF8 2003-05-12 18:45 Graham Barr * lib/Convert/ASN1.pm: Release 0.17 2003-05-12 18:45 Graham Barr * MANIFEST: Add new tests into MANIFEST 2003-05-12 18:06 Graham Barr * t/funcs.pl: Skip rtest if Data::Dumper is not available 2003-05-07 16:13 Graham Barr * parser.y, lib/Convert/ASN1/parser.pm, t/04opt.t, t/funcs.pl: Support OPTIONAL on SET OF and SEQUENCE OF 2003-05-07 10:26 Graham Barr * lib/Convert/ASN1/_decode.pm, t/00prim.t: Fix OID decoding 2003-05-06 22:47 Graham Barr * t/14any.t: Remove duplicate my 2003-05-06 22:29 Graham Barr * parser.y, lib/Convert/ASN1.pm, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm, lib/Convert/ASN1/parser.pm, t/14any.t: Add support for ANY DEFINED BY Patch from Simon Wilkinson 2003-05-06 15:17 Graham Barr * lib/Convert/ASN1/Debug.pm: Fix debug output for OIDs 2003-05-06 13:40 Graham Barr * parser.y, lib/Convert/ASN1.pm, lib/Convert/ASN1.pod, lib/Convert/ASN1/parser.pm, t/08set.t, t/12der.t, t/13utf8.t: CER and DER SET encoding 2003-05-06 12:07 Graham Barr * t/13utf8.t, lib/Convert/ASN1.pm, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm: utf8 support for perl >= 5.8 2002-08-20 01:00 Graham Barr * lib/Convert/ASN1.pm: Release 0.16 2002-08-20 00:59 Graham Barr * README, lib/Convert/ASN1.pod: Update search.cpan.org link and add CPAN RT email address 2002-08-20 00:53 Graham Barr * t/10choice.t: Fix test count 2002-08-20 00:51 Graham Barr * parser.y, lib/Convert/ASN1/_encode.pm, lib/Convert/ASN1/parser.pm, t/10choice.t: Fix for nested CHOICEs and tagged CHOICEs in SEQUENCES 2002-03-25 14:59 Graham Barr * t/: 00prim.t, 01tag.t, 02seq.t, 03seqof.t, 04opt.t, 05time.t, 06bigint.t, 08set.t, 09contr.t, 11indef.t: Add more detail when tests fail 2002-03-25 09:06 Graham Barr * lib/Convert/ASN1/_decode.pm, t/10choice.t, t/11indef.t, MANIFEST: Patch from Wolfgang Laun Fix bug in decode when there are nested CHOICEs Add tests t/10choice.t t/11indef.t 2002-03-25 07:46 Graham Barr * lib/Convert/: ASN1.pm, ASN1.pod, ASN1/_decode.pm: Patch from Wolfgang Laun Addition of prepare_file and the change prepare to accept a filehandle. POD updates. Fix decode of nested indefinate lengths 2002-03-25 07:39 Graham Barr * mkparse, parser.y, lib/Convert/ASN1/parser.pm: Allow '-'s in names and fix an uninit warning in the generated parser 2002-02-15 06:51 Graham Barr * lib/Convert/ASN1/_encode.pm: Use ::isa to determine if stash argument is a HASH 2002-02-10 16:41 Graham Barr * MANIFEST, examples/x509decode: Added x509decode from Norbert Klasen 2002-02-10 16:12 Graham Barr * lib/Convert/ASN1.pm, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm, t/00prim.t, t/03seqof.t: Add support for units with one sinlge, unamed entry eg test ::= INTEGER or list ::= SEQUENCE OF OCTET STRING 2002-01-22 11:24 Graham Barr * README, parser.y, lib/Convert/ASN1.pm, lib/Convert/ASN1.pod, lib/Convert/ASN1/Debug.pm, lib/Convert/ASN1/IO.pm, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm, lib/Convert/ASN1/parser.pm: Release 0.15 2002-01-21 20:00 Graham Barr * t/06bigint.t: Be safer in creating BigInt objects 2002-01-02 16:56 Graham Barr * lib/Convert/ASN1/_encode.pm: Change the encode errors to include the hierarchical name of the element in the ASN.1 which is causing the problem 2002-01-02 16:31 Graham Barr * lib/Convert/ASN1.pm: Remove unwanted warn statement 2001-09-25 00:05 Graham Barr * lib/Convert/ASN1.pm: Better error reporting for encoding 2001-09-22 01:16 Graham Barr * parser.y, lib/Convert/ASN1.pm, lib/Convert/ASN1/Debug.pm, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm, lib/Convert/ASN1/parser.pm, t/00prim.t: Add support for RELATIVE-OID 2001-09-22 01:14 Graham Barr * t/: 00prim.t, 06bigint.t: Move some integer tests that really use bigint from 00prim.t into 06bigint.t 2001-09-21 23:24 Graham Barr * lib/Convert/ASN1.pm, lib/Convert/ASN1/_decode.pm, t/03seqof.t: Support for nested SEQUENCE/SET OF's 2001-09-10 19:03 Graham Barr * README, lib/Convert/ASN1.pm: Release 0.14 2001-09-10 15:35 Graham Barr * MANIFEST, t/08set.t, t/09contr.t: Add tests for contructed elements and SETs 2001-09-10 15:34 Graham Barr * lib/Convert/ASN1/_decode.pm: Add support for decoding contructed elements 2001-09-07 20:04 Graham Barr * lib/Convert/: ASN1.pod, ASN1/_decode.pm: Implement the decode of SETs 2001-09-06 18:54 Graham Barr * lib/Convert/: ASN1.pm, ASN1/Debug.pm: Change asn_dump to putput the correct tag number for long tags and also warn when a length is incorrect 2001-09-06 18:41 Graham Barr * lib/Convert/ASN1/_decode.pm: Fix for indefinite decoding 2001-08-26 08:12 Graham Barr * lib/Convert/ASN1.pm: Release 0.13 2001-08-24 15:13 Graham Barr * parser.y, lib/Convert/ASN1/parser.pm: Remove an unwanted warn statement 2001-08-01 19:02 Graham Barr * lib/Convert/ASN1/_encode.pm, t/00prim.t: Fix boundary condition where we switch over to using Math::BigInt to encode integers 2001-07-31 18:05 Graham Barr * MANIFEST, lib/Convert/ASN1.pm: Release 0.12 2001-07-31 18:04 Graham Barr * lib/Convert/ASN1/_encode.pm: Make sure value passed to enc_integer is treated as a number and not a string 2001-07-31 18:03 Graham Barr * parser.y, lib/Convert/ASN1/parser.pm: Report which type cannot be found on error 2001-06-11 14:13 Graham Barr * lib/Convert/ASN1.pm: Release 0.11 2001-06-11 14:04 Graham Barr * lib/Convert/ASN1/_decode.pm, t/02seq.t: Fix decode of REAL when it is not the last element of a sequence 2001-04-26 07:52 Graham Barr * lib/Convert/ASN1.pm, t/05time.t, t/06bigint.t, t/funcs.pl: Fix syntax to be compatible with perl5.004_04 Skip bigint tests on 5.004 as they trigger lots of warnings in Math::BigInt 2001-04-20 07:26 Graham Barr * lib/Convert/ASN1.pm, lib/Convert/ASN1/_encode.pm, t/06bigint.t: Fix some bigint encoding problems and add some tests 2001-04-20 00:00 Graham Barr * Makefile.PL, lib/Convert/ASN1.pm: Release 0.09 2001-04-19 23:52 Graham Barr * MANIFEST, lib/Convert/ASN1.pm, lib/Convert/ASN1.pod, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm, t/funcs.pl: Added support to use Math::BigInt, Thanks to Benjamin Trott 2001-04-19 23:50 Graham Barr * t/05time.t: Tests for UTCTime and GeneralizedTime (The previous was really for bigint tests) 2001-04-19 23:32 Graham Barr * t/06bigint.t: Tests for UTCTime and GeneralizedTime 2001-04-19 20:51 Graham Barr * lib/Convert/ASN1/IO.pm: Fix error message 2001-04-19 20:51 Graham Barr * lib/Convert/ASN1/_decode.pm: Get timezone right when decoding 2001-04-19 20:51 Graham Barr * t/funcs.pl: Useful debug enhancements 2001-02-05 22:36 Graham Barr * MANIFEST: Removed Convert-ASN1.ppd 2001-02-05 22:31 Graham Barr * lib/Convert/ASN1/parser.pm: Added CharacterString UniversalString BMPString 2001-01-29 22:35 Graham Barr * MANIFEST, OldChanges: Move perforce changelog aside and now generate with cvs2cl 2000-05-03 13:24 Graham Barr * MANIFEST, Makefile.PL, README, mkparse, parser.y, examples/ldap, examples/ldap-search, lib/Convert/ASN1.pm, lib/Convert/ASN1.pod, lib/Convert/ASN1/Debug.pm, lib/Convert/ASN1/IO.pm, lib/Convert/ASN1/_decode.pm, lib/Convert/ASN1/_encode.pm, lib/Convert/ASN1/parser.pm, t/00prim.t, t/01tag.t, t/02seq.t, t/03seqof.t, t/04opt.t, t/07io.t, t/funcs.pl: Initial revision README.md100644000765000765 522011764713076 14523 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26# Convert::ASN1 Convert::ASN1 is a perl library for encoding/decoding data using ASN.1 definitions The ASN.1 parser is not a complete implementation of the [ASN.1](http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf) specification. It has been built over time and features have been added on an as-needed basis. ## Latest Release The latest release can be found on http://www.cpan.org/ at http://search.cpan.org/dist/Convert-ASN1/ The documentation is at http://search.cpan.org/perldoc?Convert::ASN1 ## Installing Install with your favorite CPAN install manager, eg cpanm Convert::ASN1 If you do not have cpanm installed you can run curl -s -L http://cpanmin.us | perl - Convert::ASN1 ## Contributing ### Git The preferred method of contribution is by forking a repository on github. If you are not familiar with working with forked repositories please read http://help.github.com/fork-a-repo/ for details on how to setup your fork. Try to avoid submitting to the master branch in your fork, it is useful to keep that following the main repository and if I decide to cherry-pick or fixup any commit you submit in a pull request you will have tracking issues later To start a branch for fixes do the following, assuming you have the origin and upstream remotes setup as in the guide linked to above. git fetch upstream git checkout -b mybranch upstream/master this will checkout a new branch called _mybranch_ from the latest code the the master branch of the upstream repository. Once you have finished push that branch to your origin repository with git push -u origin HEAD The -u will setup branch tracking so if you later add more commits a simple git push is enough to push those commits. Once you have pushed the branch to github, send a pull as described at http://help.github.com/send-pull-requests/ ### Dist::Zilla The release is developed using [Dist::Zilla](http://search.cpan.org/perldoc?Dist::Zilla) you will need to install cpanm Dist::Zilla once you have the base install of Dist::Zilla run dzil authordeps --missing | cpanm dzil listdeps --missing | cpanm ### perl-byacc If you need to make changes to the parser then you will need to build perl-byacc1.8.2. You can fetch the source from [perl-byacc1.8.2.tar.gz](http://www.cpan.org/src/misc/perl-byacc1.8.2.tar.gz) With that built and available in your $PATH as byacc the parser can be compiled with perl mkparse parser.y lib/Convert/ASN1/parser.pm ## License This software is copyright (c) 2000-2012 by Graham Barr. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 01tag.t100644000765000765 306711764713076 14617 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test that the primitive operators are working # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..21\n"; btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( integer [0] INTEGER )) or warn $asn->error; $result = pack("C*", 0x80, 0x01, 0x08); stest 3, $result, $asn->encode(integer => 8) or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; ntest 5, 8, $ret->{integer}; btest 6, $asn->prepare(q( integer [APPLICATION 1] INTEGER )) or warn $asn->error; $result = pack("C*", 0x41, 0x01, 0x08); stest 7, $result, $asn->encode(integer => 8) or warn $asn->error; btest 8, $ret = $asn->decode($result) or warn $asn->error; ntest 9, 8, $ret->{integer}; btest 10, $asn->prepare(q( integer [CONTEXT 2] INTEGER )) or warn $asn->error; $result = pack("C*", 0x82, 0x01, 0x08); stest 11, $result, $asn->encode(integer => 8) or warn $asn->error; btest 12, $ret = $asn->decode($result) or warn $asn->error; ntest 13, 8, $ret->{integer}; btest 14, $asn->prepare(q( integer [UNIVERSAL 3] INTEGER )) or warn $asn->error; $result = pack("C*", 0x03, 0x01, 0x08); stest 15, $result, $asn->encode(integer => 8) or warn $asn->error; btest 16, $ret = $asn->decode($result) or warn $asn->error; ntest 17, 8, $ret->{integer}; btest 18, $asn->prepare(q( integer [PRIVATE 4] INTEGER )) or warn $asn->error; $result = pack("C*", 0xc4, 0x01, 0x08); stest 19, $result, $asn->encode(integer => 8) or warn $asn->error; btest 20, $ret = $asn->decode($result) or warn $asn->error; ntest 21, 8, $ret->{integer}; 02seq.t100644000765000765 302311764713076 14625 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of sequences # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..18\n"; btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( SEQUENCE { integer INTEGER, bool BOOLEAN, str STRING } )) or warn $asn->error; my $result = pack("C*", 0x30, 0x10, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x04, 0x08, 0x41, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67 ); stest 3, $result, $asn->encode(integer => 1, bool => 0, str => "A string") or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; ntest 5, 1, $ret->{integer}; ntest 6, 0, $ret->{bool}; stest 7, "A string", $ret->{str}; btest 8, $asn->prepare(q( seq SEQUENCE { integer INTEGER, bool BOOLEAN, str STRING } )) or warn $asn->error; stest 9, $result, $asn->encode(seq => { integer => 1, bool => 0, str => "A string" }) or warn $asn->error; btest 10, $ret = $asn->decode($result) or warn $asn->error; ntest 11, 1, $ret->{seq}{integer}; ntest 12, 0, $ret->{seq}{bool}; stest 13, "A string", $ret->{seq}{str}; $result = pack "H*", '300b090380fbcc090480fa9c34'; btest 14, $asn->prepare(q( SEQUENCE { real REAL, real2 REAL } )) or warn $asn->error; stest 15, $result, $asn->encode( real => 6.375, real2 => 624.8125) or warn $asn->error; btest 16, $ret = $asn->decode($result) or warn $asn->error; ntest 17, 6.375, $ret->{real}; ntest 18, 624.8125, $ret->{real2}; 04opt.t100644000765000765 260611764713076 14647 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test that the primitive operators are working # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..16\n"; # This testcase needs more tests btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( integer INTEGER OPTIONAL, str STRING )) or warn $asn->error; $result = pack("C*", 0x4, 0x3, ord('a'), ord('b'), ord('c')); %input = (str => "abc"); stest 3, $result, $asn->encode(%input) or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; rtest 5, \%input, $ret; $result = pack("C*", 0x2, 0x1, 0x9, 0x4, 0x3, ord('a'), ord('b'), ord('c')); %input = (integer => 9, str => "abc"); stest 6, $result, $asn->encode(%input) or warn $asn->error; btest 7, $ret = $asn->decode($result) or warn $asn->error; rtest 8, \%input, $ret; btest 9, not( $asn->encode(integer => 9)); btest 10, $asn->prepare( q( SEQUENCE { bar [0] SET OF INTEGER OPTIONAL, str OCTET STRING } )) or warn $asn->error; %input = (str => 'Fred'); $result = pack "H*", "3006040446726564"; stest 11, $result, $asn->encode(%input); btest 12, $ret = $asn->decode($result) or warn $asn->error; rtest 13, \%input, $ret; $result = pack "H*", "3011a009020101020105020103040446726564"; %input = (str => 'Fred', bar => [1,5,3]); stest 14, $result, $asn->encode(%input); btest 15, $ret = $asn->decode($result) or warn $asn->error; rtest 16, \%input, $ret; 08set.t100644000765000765 176011764713076 14644 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of sets # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..13\n"; btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( SET { integer INTEGER, bool BOOLEAN, str STRING } )) or warn $asn->error; my $result = pack("C*", 0x31, 0x10, 0x01, 0x01, 0x00, 0x02, 0x01, 0x09, 0x04, 0x08, 0x41, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67 ); stest 3, $result, $asn->encode(integer => 9, bool => 0, str => "A string") or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; ntest 5, 9, $ret->{integer}; ntest 6, 0, $ret->{bool}; stest 7, "A string", $ret->{str}; btest 8, $asn = Convert::ASN1->new or warn $asn->error; btest 9, $asn->prepare(q( SET { bool BOOLEAN, str STRING, integer INTEGER } )) or warn $asn->error; btest 10, $ret = $asn->decode($result) or warn $asn->error; ntest 11, 9, $ret->{integer}; ntest 12, 0, $ret->{bool}; stest 13, "A string", $ret->{str}; 12der.t100644000765000765 255711764713076 14623 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of sets # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..18\n"; btest 1, $asn = Convert::ASN1->new(encoding => 'DER') or warn $asn->error; btest 2, $asn->prepare(q( SET { integer INTEGER, str STRING, bool BOOLEAN } )) or warn $asn->error; my $result = pack("C*", 0x31, 0x10, 0x01, 0x01, 0x00, 0x02, 0x01, 0x09, 0x04, 0x08, 0x41, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67 ); stest 3, $result, $asn->encode(integer => 9, bool => 0, str => "A string") or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; ntest 5, 9, $ret->{integer}; ntest 6, 0, $ret->{bool}; stest 7, "A string", $ret->{str}; btest 8, $asn = Convert::ASN1->new or warn $asn->error; btest 9, $asn->prepare(q( SET { bool BOOLEAN, str STRING, integer INTEGER } )) or warn $asn->error; btest 10, $ret = $asn->decode($result) or warn $asn->error; ntest 11, 9, $ret->{integer}; ntest 12, 0, $ret->{bool}; stest 13, "A string", $ret->{str}; btest 14, $asn->prepare(q( SEQUENCE { true BOOLEAN, false BOOLEAN } )) or warn $asn->error; $result = pack("C*", 0x30, 0x06, 0x01, 0x01, 0xff, 0x01, 0x01, 0x00); stest 15, $result, $asn->encode(true => 99, false => 0) or warn $asn->error; btest 16, $ret = $asn->decode($result) or warn $asn->error; btest 17, $ret->{true}; btest 18, !$ret->{false}; 14any.t100644000765000765 407011764713076 14632 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Check whether the ANY DEFINED BY syntax is working # BEGIN { require 't/funcs.pl'} use Convert::ASN1; print "1..21\n"; btest 1, $asn_str=Convert::ASN1->new or warn $asn->error; btest 2, $asn_str->prepare("string STRING") or warn $asn->error; btest 3, $asn_seq=Convert::ASN1->new or warn $asn->error; btest 4, $asn_seq->prepare(q( SEQUENCE { integer INTEGER, str STRING } )) or warn $asn_seq->error; btest 5, $asn = Convert::ASN1->new or warn $asn->error; btest 6, $asn->prepare(q( type OBJECT IDENTIFIER, content ANY DEFINED BY type )) or warn $asn->error; # Bogus OIDs - testing only! btest 7, $asn->registeroid("1.1.1.1",$asn_str); btest 8, $asn->registeroid("1.1.1.2",$asn_seq); # Encode the first type my $result = pack("C*", 0x06, 0x03, 0x29, 0x01, 0x01, 0x04, 0x0d, 0x4a, 0x75, 0x73, 0x74, 0x20, 0x61, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67); stest 9, $result, $asn->encode(type => "1.1.1.1", content => {string=>"Just a string"}); btest 10, $ret = $asn->decode($result) or warn $asn->error; stest 11, "Just a string", $ret->{content}->{string}; # Now check the second $result = pack("C*", 0x06, 0x03, 0x29, 0x01, 0x02, 0x30, 0x11, 0x02, 0x01, 0x01, 0x04, 0x0c, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67); stest 12, $result, $asn->encode(type => "1.1.1.2", content => {integer=>1, str=>"and a string"}); btest 13, $ret = $asn->decode($result) or warn $asn->error; ntest 14, 1, $ret->{content}->{integer}; stest 15, "and a string", $ret->{content}->{str}; # Decoding ANY with indefinite length must include the trailing terminator btest 16, $asn = Convert::ASN1->new or warn $asn->error; btest 17, $asn->prepare(q( Test2 ::= ANY Test1 ::= SEQUENCE OF ANY )) or warn $asn->error; $result = pack("H*","3080020109308002010900000000"); btest 18, $ret = $asn->find('Test1')->decode($result); rtest 19, [pack("H*","020109"),pack("H*","30800201090000")], $ret; btest 20, $ret = $asn->find('Test2')->decode($result); stest 21, $result, $ret; aj2.cer100644000765000765 164411764713076 14664 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t000  *H 0F1 0 UDE10U  Allianz AG1"0 UAussendienst Smartcard CA0 050712121429Z 100713215959Z0~1 0 UDE10U  Allianz AG10 &,dNoValue1(0& *H  alexander.jung@allianz.de10UAlexander Jung00  *H 0##i`{YOm.ͅm&#o(hLVJ Sj򎄅&aKNd^FZ"cg`W.}xEeAyXv%)_[)دlb~#00U0U#0Tb?S#X[F0@U9070531/http://rootca.allianz.com/sc-ad-ca/sc-ad-ca.crl0 `HB0$U0alexander.jung@allianz.de01U%*0(++++0  *H ؐvnH8Y{./2n,4*Gd\ 3̡dz}XF} ԓ4Ir\Bh%˅|ְp! cE~='| ~bH5%z<]M{=2 }bO6y<! IyyXT̨AS~+7BЂ°6 *8t0h!*̴? 1޺CDpք:Jד'xMETA.json100644000765000765 224111764713076 14665 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26{ "abstract" : "Convert between perl data structures and ASN.1 encoded packets", "author" : [ "Graham Barr " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300015, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Convert-ASN1", "no_index" : { "directory" : [ "lib/Convert/ASN1", "t", "examples" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "test" : { "requires" : { "Math::BigInt" : "1.997", "Test::More" : "0.90" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/gbarr/perl-Convert-ASN1/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/gbarr/perl-Convert-ASN1.git", "web" : "https://github.com/gbarr/perl-Convert-ASN1" } }, "version" : "0.26" } SIGNATURE100644000765000765 751211764713076 14536 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.64. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 d8cc16795b04958d9fb14d778cce8f33b3906fdf ChangeLog SHA1 0433bbff935245e9752d7633fe7caea3ef6c8187 LICENSE SHA1 c13624a3ed1f79098255fd6ae6c8b19f047b3fe1 MANIFEST SHA1 00819c9c32d0342403226bfd2b972b9c6a06ab12 META.json SHA1 e7739aac83f786a9ed0c7652a340736eb7b43df8 META.yml SHA1 e04da0ebc1a22836315bb338a361f77c768acc49 Makefile.PL SHA1 34baa595be366d4d07d3719e0ffedec7598dd5cb OldChanges SHA1 8505ff40c7ae961f694d42fd0e5b3a71b3b43d3c README.md SHA1 96177abd8d9a3cba4927b4c1dd9e3bb8b5ec8d10 dist.ini SHA1 905b1f3ec388b43432882585f70627d81a2d64eb examples/ldap SHA1 731cdbffc8b4275c20f194422584b6278a728fa0 examples/ldap-search SHA1 e9c1b61ecaf01da809b2311e48e779d7855f2703 examples/x509decode SHA1 920dd8b717133163d660b2f3f50b3a13f3a35d5b lib/Convert/ASN1.pm SHA1 0ef40b5e868189a731383a02cbdca2277b192ae4 lib/Convert/ASN1.pod SHA1 62e208ac8cbbab5ef8bf9b60c280baf26da25799 lib/Convert/ASN1/Debug.pm SHA1 7edb4878201e763685d2a18607d203e4db3a46de lib/Convert/ASN1/IO.pm SHA1 d24aac21af4f3dc4d50fbf3d78ab4901d12b75cc lib/Convert/ASN1/_decode.pm SHA1 dc269fde8f2b589ac1848846fc6aa902ec9addaa lib/Convert/ASN1/_encode.pm SHA1 8e0c2240511d1858a32fad88b4451edfb6cd75b3 lib/Convert/ASN1/parser.pm SHA1 025eb26d2828ae9153d5b5e50eb2cafed8d91ec0 mkparse SHA1 f08e71dc2dcc80c129e91b856b5ec6845cf3f034 parser.y SHA1 47ea660ec5b7d891511376631ca8bc703152de52 t/00prim.t SHA1 be18a157f0146d6565ee8d408953fc4fb6b5a277 t/01tag.t SHA1 99d1ebf5730490b798bd72101a891098f274c106 t/02seq.t SHA1 1f2efdd0eb2c3105fa9004f29a6b48b58a3bb6a2 t/03seqof.t SHA1 052881761fe4f75b21be7d4f053e0b5ca7c3bf49 t/04opt.t SHA1 6ea952799c1f8e5fca2c56a87b8c75d4c1c3c2af t/05time.t SHA1 3eb1f4fddf2a2ed424e5efc833e258241b1340ca t/06bigint.t SHA1 eb66af2adefb38a4f3ba05374007a9fa6179c368 t/07input.dat SHA1 6ec4a7f978fab3e0e9afeb4a5ad23f8071994491 t/07io.t SHA1 7dd7bb7e54ae35e3cc1ae324c5a796aac37a98e1 t/08set.t SHA1 37137256d188382385b4751daa104fd9dcbe309b t/09contr.t SHA1 5db8faa253b5b05c8483bbe83417aef68d63b390 t/10choice.t SHA1 e19b783d36c747212c20cba92645c90439248c6e t/11explicit.t SHA1 6eec4adad72499b9e42bbe4e0e2b41b81771c2bb t/11indef.t SHA1 3d6b0ebe0f12297666e095388152adb695a389c5 t/12der.t SHA1 a6668ec882a88fcf18f16c0e45db93c358dbb764 t/13utf8.t SHA1 c07c93dcd8a0c0ecd346a9623735235e9aee09db t/14any.t SHA1 4ad9e59d332f55d19c1aa6b6dc851f93d08fba03 t/15extseq.t SHA1 204dcecb1793fc8347a58d54af27fd5fa87c3fd7 t/16extset.t SHA1 40041d7c6b861590d977f183801a5ee929a46801 t/17extchoice.t SHA1 a07dfd87a3d672f546500b302526710245ee611a t/18tagdefault.t SHA1 4478dba7f3c409d8cd4673022470301d7197eb74 t/aj.cer SHA1 b4dfb113e0d45ae9c5dce0311ec3c604d9913ba5 t/aj2.cer SHA1 a82a05d7a22a348abe1e01116ecaf118d22a67ff t/allianz_root.cer SHA1 59d0504e0044defc1b8fec9ee6ae6085db38f60e t/dsacert.der SHA1 86a8f5b8402ce9813e1467d61cd40bb0959866d1 t/funcs.pl SHA1 02fff6b3fc815c57e6832dfc3861851333b0c30b t/new_root_ca.cer SHA1 7ec9e04b1a926299ca3d4aa1a3e206f992043438 t/pgpextension.der SHA1 eef94a05ef12c316e052233a1d903d3850245de3 t/subca_2.cer SHA1 48994ae679ae98975889b7e60d004b6532ddd537 t/telesec_799972029.crt SHA1 273ee12457fdc4f90c55e82b56167f62f532e547 t/verisign.der SHA1 e908b8c53c098d96bb4499a56e1d5320173ccae9 t/x509.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk/TljsACgkQR0BL4gbYw3QmrQCdFfFeF1Lj0mld1dDXIzPLkd5R e5cAn1NPqkcxnP6DkkGHT6SBCjPH8VA/ =oA9b -----END PGP SIGNATURE----- OldChanges100644000765000765 1037611764713076 15226 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26Change 601 on 2000/09/18 by (Graham Barr) Fix typo in configure Change 600 on 2000/09/18 by (Graham Barr) More robust REAL encode Change 561 on 2000/08/14 by (Graham Barr) Fix typo in IO.pm Change 558 on 2000/08/01 by (Graham Barr) Added options for encode/decode of UTCTime and Generalized time Change 557 on 2000/08/01 by (Graham Barr) Add support to decode indefinate lengths Change 556 on 2000/08/01 by (Graham Barr) Performance tweaks to IO Change 555 on 2000/08/01 by (Graham Barr) asn_decode_length(), return a length of -1 for indefinate lengths Change 534 on 2000/06/05 by (Graham Barr) Another syntax change in Debug.pm for 5.004 support Change 531 on 2000/05/30 by (Graham Barr) Release 0.07 Change 530 on 2000/05/30 by (Graham Barr) Assert an error if there is nothing to encode for a CHOICE Change 528 on 2000/05/22 by (Graham Barr) One more for 5.004 Change 524 on 2000/05/22 by (Graham Barr) Release 0.06 Change 523 on 2000/05/22 by (Graham Barr) Now works with 5.004, tested on 5.004, 5.005_03, 5.6.0 Change 515 on 2000/05/12 by (Graham Barr) Release 0.05 Change 514 on 2000/05/11 by (Graham Barr) Fix bug in encoding an integer where one to few bytes would be encoded causing the sign to change on decode. Change 513 on 2000/05/09 by (Graham Barr) Fix to asn_read for unit warning when first char of L is > 0x80 Change 509 on 2000/05/04 by (Graham Barr) Convert::ASN1::IO - fix == instead of = typo Change 508 on 2000/05/04 by (Graham Barr) Convert::ASN1::IO - fix bug in asn_read where the FH was passed instead of the buffer to sysread - fix bug in asn_recv where we has substr($buf,$len) instead of substr($buf,0,$len) - make asn_recv break out of the loop if recv with MSG_PEEK gives less chars than what was asked for Change 497 on 2000/04/28 by (Graham Barr) * Fix undef warnings in asn_dump (patch from Chris Ridd * Change output of asn_dump for tags to [APPLICATION %d], etc Change 477 on 2000/04/03 by (Graham Barr) Release 0.04 Change 476 on 2000/03/31 by (Graham Barr) More documentation additions Change 475 on 2000/03/31 by (Graham Barr) Added IO tests Fixed bugs in asn_read and asn_get Change 474 on 2000/03/31 by (Graham Barr) - Ensure perl-5.6.0 always works in bytes, except in _decode_utf8 - Add workaround for bug in 5.6 by mentioning $1..$9 explicitly in the code Change 473 on 2000/03/30 by (Graham Barr) Added missing \ to quot $(PERL) Change 465 on 2000/03/29 by (Graham Barr) Add HTML generation Change 423 on 2000/03/28 by (Graham Barr) Documentation updates Change 406 on 2000/03/28 by (Graham Barr) Major code reorg, getting ready for an XS implementation Change 405 on 2000/03/27 by (Graham Barr) A few more optimization tweaks Moved utf8 code into ASN1.pm Added use strict Change 404 on 2000/03/24 by (Graham Barr) Rework of decoding, now upto 2X faster Change 403 on 2000/03/24 by (Graham Barr) Check for defined not truth on return from recv() Change 396 on 2000/03/22 by (Graham Barr) Fix for loops Change 386 on 2000/03/21 by (Graham Barr) - fix for undef warning in compile_one - moved options down a level in the object - added find, to create new objects referencing a given macro - added ldap example - add Debug module - fix for xx OF loop in _decode - fix typos in IO module - ensure CONSTRUCTOR bit is set Change 384 on 2000/03/18 by (Graham Barr) Add encode/decode routines fro UTF8 strings if running perl 5.6 or later. Change 383 on 2000/03/18 by (Graham Barr) Now supports hierarchical definition. It is now possible to copy ASN.1 from rfcs with minimal change Change 382 on 2000/03/14 by (Graham Barr) Initial version 00prim.t100644000765000765 1713111764713076 15027 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test that the primitive operators are working # use Convert::ASN1 qw(:all); print "1..186\n"; BEGIN { require 't/funcs.pl' } ntest 1, 129, asn_tag(ASN_CONTEXT, 1); ntest 2, 0x201f, asn_tag(ASN_UNIVERSAL, 32); ntest 3, 0x01825f, asn_tag(ASN_APPLICATION, 257); stest 4, pack("C*", 129), asn_encode_tag(129); stest 5, pack("C*", 0x1f,0x20), asn_encode_tag(0x201f); stest 6, pack("C*", 0x5f,0x82,0x01), asn_encode_tag(0x01825f); ntest 7, 129, asn_decode_tag(asn_encode_tag(asn_tag(ASN_CONTEXT, 1))); ntest 8, 0x201f, asn_decode_tag(asn_encode_tag(asn_tag(ASN_UNIVERSAL, 32))); ntest 9, 0x01825f, asn_decode_tag(asn_encode_tag(asn_tag(ASN_APPLICATION, 257))); ntest 10, 1, (asn_decode_tag(asn_encode_tag(asn_tag(ASN_CONTEXT, 1))))[0]; ntest 11, 2, (asn_decode_tag(asn_encode_tag(asn_tag(ASN_UNIVERSAL, 32))))[0]; ntest 12, 3, (asn_decode_tag(asn_encode_tag(asn_tag(ASN_APPLICATION, 257))))[0]; stest 13, pack("C*", 45), asn_encode_length(45); stest 14, pack("C*", 0x81,0x8b), asn_encode_length(139); stest 15, pack("C*", 0x82,0x12,0x34), asn_encode_length(0x1234); ntest 16, 45, asn_decode_length(asn_encode_length(45)); ntest 17, 139, asn_decode_length(asn_encode_length(139)); ntest 18, 0x1234, asn_decode_length(asn_encode_length(0x1234)); ntest 19, 1, (asn_decode_length(asn_encode_length(45)))[0]; ntest 20, 2, (asn_decode_length(asn_encode_length(139)))[0]; ntest 21, 3, (asn_decode_length(asn_encode_length(0x1234)))[0]; btest 22, $asn = Convert::ASN1->new; ## ## NULL ## print "# NULL\n"; $buf = pack("C*", 0x05, 0x00); btest 23, $asn->prepare(' null NULL ') or warn $asn->error; stest 24, $buf, $asn->encode(null => 1) or warn $asn->error; btest 25, $ret = $asn->decode($buf) or warn $asn->error; btest 26, $ret->{'null'}; ## ## BOOLEAN ## $test = 27; foreach $val (0,1,-99) { print "# BOOLEAN $val\n"; my $result = pack("C*", 0x01, 0x01, $val ? 0xFF : 0); btest $test++, $asn->prepare(' bool BOOLEAN') or warn $asn->error; stest $test++, $result, $asn->encode(bool => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; ntest $test++, !!$val, !!$ret->{'bool'}; } ## ## INTEGER (tests 13 - 21) ## my %INTEGER = ( pack("C*", 0x02, 0x02, 0x00, 0x80), 128, pack("C*", 0x02, 0x01, 0x80), -128, pack("C*", 0x02, 0x02, 0xff, 0x01), -255, pack("C*", 0x02, 0x01, 0x00), 0, pack("C*", 0x02, 0x03, 0x66, 0x77, 0x99), 0x667799, pack("C*", 0x02, 0x02, 0xFE, 0x37), -457, pack("C*", 0x02, 0x04, 0x40, 0x00, 0x00, 0x00), 2**30, pack("C*", 0x02, 0x04, 0xC0, 0x00, 0x00, 0x00), -2**30, ); while(($result,$val) = each %INTEGER) { print "# INTEGER $val\n"; btest $test++, $asn->prepare(' integer INTEGER') or warn $asn->error; stest $test++, $result, $asn->encode(integer => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; ntest $test++, $val, $ret->{integer}; } btest $test++, $asn->prepare('test ::= INTEGER '); $result = pack("C*", 0x02, 0x01, 0x09); stest $test++, $result, $asn->encode(9) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; btest $test++, $ret == 9; ## ## STRING ## my %STRING = ( pack("C*", 0x04, 0x00), "", pack("CCa*", 0x04, 0x08, "A string"), "A string", ); while(($result,$val) = each %STRING) { print "# STRING '$val'\n"; btest $test++, $asn->prepare('str STRING') or warn $asn->error; stest $test++, $result, $asn->encode(str => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; stest $test++, $val, $ret->{'str'}; } ## ## OBJECT_ID ## my %OBJECT_ID = ( pack("C*", 0x06, 0x04, 0x2A, 0x03, 0x04, 0x05), "1.2.3.4.5", pack("C*", 0x06, 0x03, 0x55, 0x83, 0x49), "2.5.457", pack("C*", 0x06, 0x07, 0x00, 0x11, 0x86, 0x05, 0x01, 0x01, 0x01), "0.0.17.773.1.1.1", pack("C*", 0x06, 0x04, 0x86, 0x8D, 0x6F, 0x63), "2.99999.99", ); while(($result,$val) = each %OBJECT_ID) { print "# OBJECT_ID $val\n"; btest $test++, $asn->prepare('oid OBJECT IDENTIFIER') or warn $asn->error; stest $test++, $result, $asn->encode(oid => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; stest $test++, $val, $ret->{'oid'}; } ## ## ENUM ## my %ENUM = ( pack("C*", 0x0A, 0x01, 0x00), 0, pack("C*", 0x0A, 0x01, 0x9D), -99, pack("C*", 0x0A, 0x03, 0x64, 0x4D, 0x90), 6573456, ); while(($result,$val) = each %ENUM) { print "# ENUM $val\n"; btest $test++, $asn->prepare('enum ENUMERATED') or warn $asn->error; stest $test++, $result, $asn->encode(enum => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; ntest $test++, $val, $ret->{'enum'}; } ## ## BIT STRING ## my %BSTR = ( pack("C*", 0x03, 0x02, 0x07, 0x00), [pack("B*",'0'), 1, pack("B*",'0')], pack("C*", 0x03, 0x02, 0x00, 0x33), pack("B*",'00110011'), pack("C*", 0x03, 0x04, 0x03, 0x6E, 0x5D, 0xC0), [pack("B*",'011011100101110111'), 21, pack("B*",'011011100101110111')], pack("C*", 0x03, 0x02, 0x01, 0x6E), [pack("B*",'011011111101110111'), 7, pack("B*", '01101110')] ); while(($result,$val) = each %BSTR) { print "# BIT STRING ", unpack("B*", ref($val) ? $val->[0] : $val), " ",(ref($val) ? $val->[1] : $val),"\n"; btest $test++, $asn->prepare('bit BIT STRING') or warn $asn->error; stest $test++, $result, $asn->encode( bit => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; stest $test++, (ref($val) ? $val->[2] : $val), $ret->{'bit'}[0]; ntest $test++, (ref($val) ? $val->[1] : 8*length$val), $ret->{'bit'}[1]; } ## ## REAL ## use POSIX qw(HUGE_VAL); my %REAL = ( pack("C*", 0x09, 0x00), 0, pack("C*", 0x09, 0x03, 0x80, 0xf9, 0xc0), 1.5, pack("C*", 0x09, 0x03, 0xc0, 0xfb, 0xb0), -5.5, pack("C*", 0x09, 0x01, 0x40), HUGE_VAL(), pack("C*", 0x09, 0x01, 0x41), - HUGE_VAL(), ); while(($result,$val) = each %REAL) { print "# REAL $val\n"; btest $test++, $asn->prepare('real REAL') or warn $asn->error; stest $test++, $result, $asn->encode( real => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; ntest $test++, $val, $ret->{'real'}; } ## ## RELATIVE-OID ## my %ROID = ( pack("C*", 0x0D, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05), "1.2.3.4.5", pack("C*", 0x0D, 0x04, 0x02, 0x05, 0x83, 0x49), "2.5.457", pack("C*", 0x0D, 0x08, 0x00, 0x00, 0x11, 0x86, 0x05, 0x01, 0x01, 0x01), "0.0.17.773.1.1.1", ); while(($result,$val) = each %ROID) { print "# RELATIVE-OID $val\n"; btest $test++, $asn->prepare('roid RELATIVE-OID') or warn $asn->error; stest $test++, $result, $asn->encode(roid => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; stest $test++, $val, $ret->{'roid'}; } ## ## BCDString ## my %BCD = ( pack("C*", 0x04, 0x09, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89), "123456789123456789", pack("C*", 0x04, 0x04, 0x12, 0x34, 0x56, 0x78), 12345678, pack("C*", 0x04, 0x02, 0x56, 0x4f), 564, pack("C*", 0x04, 0x00), "", pack("C*", 0x04, 0x00), -1, pack("C*", 0x04, 0x01, 0x0f), 0, pack("C*", 0x04, 0x01, 0x2f), 2.2, ); while(($result,$val) = each %BCD) { print "# BCDString $val\n"; btest $test++, $asn->prepare('bcd BCDString') or warn $asn->error; stest $test++, $result, $asn->encode(bcd => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; $val =~ s/\D.*//; stest $test++, $val, $ret->{'bcd'}; } 05time.t100644000765000765 562011764713076 15003 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test that the primitive operators are working # # Wolfgang Rosner use Convert::ASN1 qw(:all); print "1..24\n"; BEGIN { require 't/funcs.pl' } my $t = 1; btest $t++, $asn = Convert::ASN1->new or warn $asn->error; btest $t++, $asn->prepare('date UTCTime') or warn $asn->error; my $time = 987718268; # 2001-04-19 22:11:08 GMT my $result; my $ret; # One hour ahead $result = pack("C*", 0x17, 0x11, 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x32, 0x33, 0x31, 0x31, 0x30, 0x38, 0x2B, 0x30, 0x31, 0x30, 0x30 ); $asn->configure( encode => { timezone => +3600 } ); stest $t++, $result, $asn->encode(date => $time) or warn $asn->error; btest $t++, $ret = $asn->decode($result) or warn $asn->error; ntest $t++, $time, $ret->{date}; # 2 hours ahead $result = pack("C*", 0x17, 0x11, 0x30, 0x31, 0x30, 0x34, 0x32, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x38, 0x2b, 0x30, 0x32, 0x30, 0x30 ); $asn->configure( encode => { timezone => +7200 } ); stest $t++, $result, $asn->encode(date => $time) or warn $asn->error; btest $t++, $ret = $asn->decode($result) or warn $asn->error; ntest $t++, $time, $ret->{date}; # zulu $result = pack("C*", 0x17, 0x0D, 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x32, 0x32, 0x31, 0x31, 0x30, 0x38, 0x5A ); $asn->configure( encode => { 'time' => 'utctime' } ); stest $t++, $result, $asn->encode(date => $time) or warn $asn->error; btest $t++, $ret = $asn->decode($result) or warn $asn->error; ntest $t++, $time, $ret->{date}; # 1 hour ahead btest $t++, $asn = Convert::ASN1->new or warn $asn->error; btest $t++, $asn->prepare('date GeneralizedTime') or warn $asn->error; $result = pack("C*", 0x18, 0x13, 0x32, 0x30, 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x32, 0x33, 0x31, 0x31, 0x30, 0x38, 0x2B, 0x30, 0x31, 0x30, 0x30 ); $asn->configure( encode => { timezone => +3600 } ); stest $t++, $result, $asn->encode(date => $time) or warn $asn->error; btest $t++, $ret = $asn->decode($result) or warn $asn->error; ntest $t++, $time, $ret->{date}; # 4 hours behind btest $t++, $asn = Convert::ASN1->new or warn $asn->error; btest $t++, $asn->prepare('date GeneralizedTime') or warn $asn->error; $result = pack("C*", 0x18, 0x13, 0x32, 0x30, 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x31, 0x38, 0x31, 0x31, 0x30, 0x38, 0x2D, 0x30, 0x34, 0x30, 0x30 ); $asn->configure( encode => { timezone => -14400 } ); stest $t++, $result, $asn->encode(date => $time) or warn $asn->error; btest $t++, $ret = $asn->decode($result) or warn $asn->error; ntest $t++, $time, $ret->{date}; # fractional second $time += 0.5; $result = pack("C*", 0x18, 0x17, 0x32, 0x30, 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x32, 0x33, 0x31, 0x31, 0x30, 0x38, 0x2E, 0x35, 0x30, 0x30, 0x2B, 0x30, 0x31, 0x30, 0x30 ); $asn->configure( encode => { timezone => +3600 } ); stest $t++, $result, $asn->encode(date => $time) or warn $asn->error; btest $t++, $ret = $asn->decode($result) or warn $asn->error; ntest $t++, $time, $ret->{date}; 13utf8.t100644000765000765 223511764713076 14731 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of utf8 strings # use Convert::ASN1; BEGIN { require 't/funcs.pl' } if ($] < 5.007) { print "1..0\n"; exit; } print "1..12\n"; btest 1, $asn = Convert::ASN1->new() or warn $asn->error; btest 2, $asn->prepare(q( str STRING )) or warn $asn->error; my $result = pack("C*", 0x04, 0x07, 0x75, 0x74, 0x66, 0x38, 0x20, 0xc6, 0x81); stest 3, $result, $asn->encode(str => "utf8 " . chr(0x181)) or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; stest 5, "utf8 " . chr(0xc6) . chr(0x81), $ret->{str}; btest 6, $asn->prepare(q( str UTF8String )) or warn $asn->error; my $utf_str = "utf8 " . chr(0x181); $result = pack("C*", 0x0c, 0x07, 0x75, 0x74, 0x66, 0x38, 0x20, 0xc6, 0x81); stest 7, $result, $asn->encode(str => $utf_str) or warn $asn->error; btest 8, $ret = $asn->decode($result) or warn $asn->error; stest 9, $utf_str, $ret->{str}; # Test that UTF8String will upgrade on encoding $result = pack("C*", 0x0c, 0x02, 0xc2, 0x81); stest 10, $result, $asn->encode(str => chr(0x81)) or warn $asn->error; btest 11, $ret = $asn->decode($result) or warn $asn->error; stest 12, chr(0x81), $ret->{str}; funcs.pl100644000765000765 243511764713076 15167 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t sub ntest ($$$) { my $ret = 1; if ($_[1] != $_[2]) { printf "#$_[0]: expecting $_[1]\n"; printf "#$_[0]: got $_[2]\n"; printf "#line %d %s\n",(caller)[2,1]; print "not "; $ret = 0; } print "ok $_[0]\n"; $ret; } sub stest ($$$) { my $ret = 1; unless (defined $_[2] && $_[1] eq $_[2]) { printf "#$_[0]: expecting %s\n", $_[1] =~ /[^\.\d\w]/ ? "hex:".unpack("H*",$_[1]) : $_[1]; printf "#$_[0]: got %s\n", defined($_[2]) ? $_[2] =~ /[^\.\d\w]/ ? "hex:".unpack("H*",$_[2]) : $_[2] : 'undef'; printf "#line %d %s\n",(caller)[2,1]; print "not "; $ret = 0; } print "ok $_[0]\n"; $ret; } sub btest ($$) { unless ($_[1]) { printf "#line %d %s\n",(caller)[2,1]; print "not "; } print "ok $_[0]\n"; $_[1] } sub rtest ($$$) { unless (eval { require Data::Dumper } ) { print "ok $_[0] # skip need Data::Dumper\n"; return; } local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Useqq = 1; my $expect = Data::Dumper::Dumper($_[1]); my $got = Data::Dumper::Dumper($_[2]); my $ok = $expect eq $got; unless ($ok) { printf "#$_[0]: expecting %s\n", $expect; printf "#$_[0]: got %s\n", $got; printf "#line %d %s\n",(caller)[2,1]; print "not "; } print "ok $_[0]\n"; $ok; } 1; 03seqof.t100644000765000765 673511764713076 15170 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test that the primitive operators are working # BEGIN { require 't/funcs.pl' } use Convert::ASN1; print "1..35\n"; btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(' ints SEQUENCE OF INTEGER ') or warn $asn->error; $result = pack("C*", 0x30, 0x0C, 0x02, 0x01, 0x09, 0x02, 0x01, 0x05, 0x02, 0x01, 0x03, 0x02, 0x01, 0x01); stest 3, $result, $asn->encode(ints => [9,5,3,1]) or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; btest 5, exists $ret->{'ints'}; stest 6, "9:5:3:1", join(":", @{$ret->{'ints'}}); ## ## ## $result = pack("C*", 0x30, 0x25, 0x30, 0x11, 0x04, 0x04, ord('f'), ord('r'), ord('e'), ord('d'), 0x30, 0x09, 0x04, 0x01, ord('a'), 0x04, 0x01, ord('b'), 0x04, 0x01, ord('c'), 0x30, 0x10, 0x04, 0x03, ord('j'), ord('o'), ord('e'), 0x30, 0x09, 0x04, 0x01, ord('q'), 0x04, 0x01, ord('w'), 0x04, 0x01, ord('e'), ); btest 7, $asn->prepare(' seq SEQUENCE OF SEQUENCE { str STRING, val SEQUENCE OF STRING } ') or warn $asn->error; stest 8, $result, $asn->encode( seq => [ { str => 'fred', val => [qw(a b c)] }, { str => 'joe', val => [qw(q w e)] } ]) or warn $asn->error; btest 9, $ret = $asn->decode($result) or warn $asn->error; ntest 10, 1, scalar keys %$ret; btest 11, exists $ret->{'seq'}; ntest 12, 2, scalar @{$ret->{'seq'}}; stest 13, 'fred', $ret->{'seq'}[0]{'str'}; stest 14, 'joe', $ret->{'seq'}[1]{'str'}; stest 15, "a:b:c", join(":", @{$ret->{'seq'}[0]{'val'}}); stest 16, "q:w:e", join(":", @{$ret->{'seq'}[1]{'val'}}); btest 17, $asn = Convert::ASN1->new or warn $asn->error; btest 18, $asn->prepare(<<'EOS') or warn $asn->error; AttributeTypeAndValue ::= SEQUENCE { type STRING, value STRING } RelativeDistinguishedName ::= SET OF AttributeTypeAndValue RDNSequence ::= SEQUENCE OF RelativeDistinguishedName Name ::= CHOICE { -- only one possibility for now -- rdnSequence RDNSequence } Issuer ::= SEQUENCE { issuer Name } EOS btest 19, $asn = $asn->find('Issuer') or warn $asn->error; $result = pack("C*", 0x30, 0x26, 0x30, 0x24, 0x31, 0x10, 0x30, 0x06, 0x04, 0x01, 0x31, 0x04, 0x01, 0x61, 0x30, 0x06, 0x04, 0x01, 0x32, 0x04, 0x01, 0x62, 0x31, 0x10, 0x30, 0x06, 0x04, 0x01, 0x33, 0x04, 0x01, 0x63, 0x30, 0x06, 0x04, 0x01, 0x34, 0x04, 0x01, 0x64 ); stest 20, $result, $asn->encode( issuer => { rdnSequence => [ [{ type => "1", value => "a" }, { type => "2", value => "b" }], [{ type => "3", value => "c" }, { type => "4", value => "d" }], ] } ) or warn $asn->error; btest 21, $ret = $asn->decode($result) or warn $asn->error; ntest 22, 1, $ret->{issuer}{rdnSequence}[0][0]{type}; ntest 23, 2, $ret->{issuer}{rdnSequence}[0][1]{type}; ntest 24, 3, $ret->{issuer}{rdnSequence}[1][0]{type}; ntest 25, 4, $ret->{issuer}{rdnSequence}[1][1]{type}; stest 26, 'a', $ret->{issuer}{rdnSequence}[0][0]{value}; stest 27, 'b', $ret->{issuer}{rdnSequence}[0][1]{value}; stest 28, 'c', $ret->{issuer}{rdnSequence}[1][0]{value}; stest 29, 'd', $ret->{issuer}{rdnSequence}[1][1]{value}; btest 30, $asn = Convert::ASN1->new or warn $asn->error; btest 31, $asn->prepare('test ::= SEQUENCE OF INTEGER ') or warn $asn->error; $result = pack("C*", 0x30, 0x0C, 0x02, 0x01, 0x09, 0x02, 0x01, 0x05, 0x02, 0x01, 0x03, 0x02, 0x01, 0x01); stest 32, $result, $asn->encode([9,5,3,1]) or warn $asn->error; btest 33, $ret = $asn->decode($result) or warn $asn->error; btest 34, ref($ret) eq 'ARRAY'; stest 35, "9:5:3:1", join(":", @{$ret}); 09contr.t100644000765000765 72111764713076 15153 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the decode on constructed values # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..4\n"; btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( str STRING )) or warn $asn->error; my $buf = pack "C*", 0x24, 0x80, 0x04, 0x03, 0x61, 0x62, 0x63, 0x04, 0x03, 0x44, 0x45, 0x46, 0x00, 0x00; btest 3, $ret = $asn->decode($buf) or warn $asn->error; stest 4, "abcDEF", $ret->{str}; 11indef.t100644000765000765 223111764713076 15122 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/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; btest 2, $asn->prepare(q( GroupOfThis ::= [1] OCTET STRING GroupOfThat ::= [2] OCTET STRING Item ::= [3] SEQUENCE { aGroup GroupOfThis OPTIONAL, bGroup GroupOfThat OPTIONAL } Items ::= [4] SEQUENCE OF Item List ::= [5] SEQUENCE { list Items } )) or warn $asn->error; my $buf = pack( 'C*', 0xa5, 0x80, 0xa4, 0x80, 0xa3, 0x80, 0x81, 0x03, ( ord('A') ) x 3, @zz, 0xa3, 0x80, 0x82, 0x03, ( ord('B') ) x 3, @zz, 0xa3, 0x80, 0x81, 0x03, ( ord('C') ) x 3, 0x82, 0x03, ( ord('D') ) x 3, @zz, @zz, @zz, ); my $nl = $asn->find( 'List' ); my $seq = $nl->decode( $buf ) or warn $asn->error; btest 3, defined( $seq ) && exists( $seq->{list} ); stest 4, 'AAA', $seq->{list}->[0]->{aGroup}; stest 5, 'BBB', $seq->{list}->[1]->{bGroup}; stest 6, 'CCC', $seq->{list}->[2]->{aGroup}; stest 7, 'DDD', $seq->{list}->[2]->{bGroup}; Makefile.PL100644000765000765 203011764713076 15212 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Convert between perl data structures and ASN.1 encoded packets", "AUTHOR" => "Graham Barr ", "BUILD_REQUIRES" => { "Math::BigInt" => "1.997", "Test::More" => "0.90" }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Convert-ASN1", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Convert::ASN1", "PREREQ_PM" => {}, "VERSION" => "0.26", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); 06bigint.t100644000765000765 1067011764713076 15343 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test bigint INTEGER encoding/decoding # use Convert::ASN1; BEGIN { require 't/funcs.pl' } $^W=0 if $] < 5.005; # BigInt in 5.004 has undef issues print "1..67\n"; btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( integer INTEGER )) or warn $asn->error; use Math::BigInt; my $num = Math::BigInt->new("1092509802939879587398450394850984098031948509"); $asn->configure(decode => { bigint => 'Math::BigInt' }); $result = pack("C*", 0x2, 0x13, 0x30, 0xfd, 0x65, 0xc1, 0x01, 0xd9, 0xea, 0x2c, 0x94, 0x9e, 0xc5, 0x08, 0x50, 0x4a, 0x90, 0x43, 0xdb, 0x52, 0xdd); stest 3, $result, $asn->encode(integer => $num) or warn $asn->error; btest 4, $ret = $asn->decode($result) or warn $asn->error; btest 5, exists $ret->{integer}; btest 6, ref($ret->{integer}) eq 'Math::BigInt'; ntest 7, $num, $ret->{integer}; $num = (1<<17) * (1<<17); $result = pack("C*", 0x2, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0); stest 8, $result, $asn->encode(integer => $num) or warn $asn->error; btest 9, $ret = $asn->decode($result) or warn $asn->error; btest 10, exists $ret->{integer}; ntest 11, $num, $ret->{integer}; $num += 10; $result = pack("C*", 0x2, 0x5, 0x4, 0x0, 0x0, 0x0, 0xa); stest 12, $result, $asn->encode(integer => $num) or warn $asn->error; btest 13, $ret = $asn->decode($result) or warn $asn->error; btest 14, exists $ret->{integer}; ntest 15, $num, $ret->{integer}; $num = -$num; $result = pack("C*", 0x2, 0x5, 0xfb, 0xff, 0xff, 0xff, 0xf6); stest 16, $result, $asn->encode(integer => $num) or warn $asn->error; btest 17, $ret = $asn->decode($result) or warn $asn->error; btest 18, exists $ret->{integer}; ntest 19, $num, $ret->{integer}; $num += 10; $result = pack("C*", 0x2, 0x5, 0xfc, 0x0, 0x0, 0x0, 0x0); stest 20, $result, $asn->encode(integer => $num) or warn $asn->error; btest 21, $ret = $asn->decode($result) or warn $asn->error; btest 22, exists $ret->{integer}; ntest 23, $num, $ret->{integer}; $num = Math::BigInt->new("-1092509802939879587398450394850984098031948509"); $result = pack("C*", 0x2, 0x13, 0xcf, 0x2, 0x9a, 0x3e, 0xfe, 0x26, 0x15, 0xd3, 0x6b, 0x61, 0x3a, 0xf7, 0xaf, 0xb5, 0x6f, 0xbc, 0x24, 0xad, 0x23); stest 24, $result, $asn->encode(integer => $num) or warn $asn->error; btest 25, $ret = $asn->decode($result) or warn $asn->error; btest 26, exists $ret->{integer}; ntest 27, $num, $ret->{integer}; ## Test most-significant bit bug in 0.09. $num = Math::BigInt->new("1333280603684579469575805266526464216433260889799"); $result = pack("C*", 0x2, 0x15, 0x00, 0xe9, 0x8a, 0x5e, 0xb8, 0x3a, 0xfa, 0x3d, 0x4, 0x13, 0x7d, 0x19, 0xfc, 0x39, 0x36, 0xa3, 0x2b, 0xd2, 0x22, 0x06, 0xc7); stest 28, $result, $asn->encode(integer => $num) or warn $asn->error; btest 29, $ret = $asn->decode($result) or warn $asn->error; btest 30, exists $ret->{integer}; ntest 31, $num, $ret->{integer}; $num = Math::BigInt->new(-1 * (1<<24)) * Math::BigInt->new(1<<24); $result = pack("C*", 0x2, 0x7, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0); stest 32, $result, $asn->encode(integer => $num) or warn $asn->error; btest 33, $ret = $asn->decode($result) or warn $asn->error; btest 34, exists $ret->{integer}; ntest 35, $num, $ret->{integer}; my $test = 36; my %INTEGER = ( pack("C*", 0x02, 0x04, 0x40, 0x00, 0x00, 0x00), 2**30, pack("C*", 0x02, 0x05, 0x00, 0x80, 0x00, 0x00, 0x00), 2**31, pack("C*", 0x02, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00), 2**32, pack("C*", 0x02, 0x04, 0xC0, 0x00, 0x00, 0x00), -2**30, pack("C*", 0x02, 0x04, 0x80, 0x00, 0x00, 0x00), -2**31, pack("C*", 0x02, 0x05, 0xFF, 0x00, 0x00, 0x00, 0x00), -2**32, ); while(($result,$val) = each %INTEGER) { print "# INTEGER $val\n"; btest $test++, $asn->prepare(' integer INTEGER') or warn $asn->error; stest $test++, $result, $asn->encode(integer => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; ntest $test++, $val, $ret->{integer}; } my %BCD = ( pack("C*", 0x04, 0x05, 0x10, 0x73, 0x74, 0x18, 0x24), 2**30, pack("C*", 0x04, 0x00), -2**30, ); while(($result,$val) = each %BCD) { print "# BCDString $val\n"; btest $test++, $asn->prepare('bcd BCDString') or warn $asn->error; stest $test++, $result, $asn->encode(bcd => $val) or warn $asn->error; btest $test++, $ret = $asn->decode($result) or warn $asn->error; $val =~ s/\D.*//; stest $test++, $val, $ret->{'bcd'}; } 10choice.t100644000765000765 272311764713076 15274 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of choices # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..10\n"; btest 1, $asn = Convert::ASN1->new; btest 2, $asn->prepare( <<'[TheEnd]' ) or warn $asn->error; Natural ::= CHOICE { prime Prime, product Product } Prime ::= [1] INTEGER Product ::= CHOICE { perfect Perfect, plain Plain } Perfect ::= [2] INTEGER Plain ::= [3] INTEGER Naturals ::= [4] SEQUENCE OF Natural List ::= [5] SEQUENCE { list Naturals } [TheEnd] my $nl = $asn->find( 'List' ); my $buf = $nl->encode( list => [ { prime => 13 }, { product => { perfect => 28 } }, { product => { plain => 42 } }, ] ); $result = pack( 'C*', 0xa5, 0x0b, 0xa4, 0x09, 0x81, 0x01, 0x0d, 0x82, 0x01, 0x1c, 0x83, 0x01, 0x2a, ); stest 3, $result, $buf; my $seq = $nl->decode( $buf ) or warn $asn->error; btest 4, defined( $seq ) && exists( $seq->{list} ); ntest 5, 13, $seq->{list}->[0]->{prime}; ntest 6, 28, $seq->{list}->[1]->{product}->{perfect}; ntest 7, 42, $seq->{list}->[2]->{product}->{plain}; btest 8, $asn->prepare( 'Foo ::= [1] EXPLICIT CHOICE { a NULL }' ) or warn $asn->error; $nl = $asn->find('Foo'); $buf = $nl->encode( a => 1 ); $result = pack 'C*', map hex, qw(A1 02 05 00); stest 9, $result, $buf; $seq = $nl->decode( $result ) or warn $asn->error; btest 10, $seq->{a}; 15extseq.t100644000765000765 367211764713076 15364 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of sequences # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..27\n"; # Encode a "version 1" message btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( SEQUENCE { integer INTEGER, bool BOOLEAN, str STRING, ... } )) or warn $asn->error; btest 3, $pdu = $asn->encode(integer => 1, bool => 0, str => "A string") or warn $asn->error; btest 4, $ret = $asn->decode($pdu) or warn $asn->error; ntest 5, 1, $ret->{integer}; ntest 6, 0, $ret->{bool}; stest 7, "A string", $ret->{str}; # Decode a "version 1" message with a "version 2" decoder btest 8, $asn->prepare(q( SEQUENCE { integer INTEGER, bool BOOLEAN, str STRING, ..., integer2 INTEGER } )) or warn $asn->error; btest 9, $ret = $asn->decode($pdu) or warn $asn->error; ntest 10, 1, $ret->{integer}; ntest 11, 0, $ret->{bool}; stest 12, "A string", $ret->{str}; btest 13, !defined($ret->{integer2}); # Encode a "version 2" message btest 14, $pdu = $asn->encode(integer => 1, bool => 0, str => "A string", integer2 => 2) or warn $asn->error; btest 15, $ret = $asn->decode($pdu) or warn $asn->error; ntest 16, 1, $ret->{integer}; ntest 17, 0, $ret->{bool}; stest 18, "A string", $ret->{str}; ntest 19, 2, $ret->{integer2}; # Decode a "version 2" message with a "version 1" decoder btest 20, $asn->prepare(q( SEQUENCE { integer INTEGER, bool BOOLEAN, str STRING, ... } )) or warn $asn->error; btest 21, $ret = $asn->decode($pdu) or warn $asn->error; ntest 22, 1, $ret->{integer}; ntest 23, 0, $ret->{bool}; stest 24, "A string", $ret->{str}; btest 25, !defined($ret->{integer2}); # OPTIONAL-ity check: integer2 is NOT optional during encode. btest 26, $asn->prepare(q( SEQUENCE { integer INTEGER, bool BOOLEAN, str STRING, ..., integer2 INTEGER } )) or warn $asn->error; btest 27, !defined( $asn->encode(integer => 1, bool => 0, str => "A string") ); 16extset.t100644000765000765 373611764713076 15371 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test the use of sequences # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..27\n"; # Encode a "version 1" message btest 1, $asn = Convert::ASN1->new or warn $asn->error; btest 2, $asn->prepare(q( SET { integer [1] INTEGER, bool [2] BOOLEAN, str [3] STRING, ... } )) or warn $asn->error; btest 3, $pdu = $asn->encode(integer => 1, bool => 0, str => "A string") or warn $asn->error; btest 4, $ret = $asn->decode($pdu) or warn $asn->error; ntest 5, 1, $ret->{integer}; ntest 6, 0, $ret->{bool}; stest 7, "A string", $ret->{str}; # Decode a "version 1" message with a "version 2" decoder btest 8, $asn->prepare(q( SET { integer [1] INTEGER, bool [2] BOOLEAN, str [3] STRING, ..., integer2 [4] INTEGER } )) or warn $asn->error; btest 9, $ret = $asn->decode($pdu) or warn $asn->error; ntest 10, 1, $ret->{integer}; ntest 11, 0, $ret->{bool}; stest 12, "A string", $ret->{str}; btest 13, !defined($ret->{integer2}); # Encode a "version 2" message btest 14, $pdu = $asn->encode(integer => 1, bool => 0, str => "A string", integer2 => 2) or warn $asn->error; btest 15, $ret = $asn->decode($pdu) or warn $asn->error; ntest 16, 1, $ret->{integer}; ntest 17, 0, $ret->{bool}; stest 18, "A string", $ret->{str}; ntest 19, 2, $ret->{integer2}; # Decode a "version 2" message with a "version 1" decoder btest 20, $asn->prepare(q( SET { integer [1] INTEGER, bool [2] BOOLEAN, str [3] STRING, ... } )) or warn $asn->error; btest 21, $ret = $asn->decode($pdu) or warn $asn->error; ntest 22, 1, $ret->{integer}; ntest 23, 0, $ret->{bool}; stest 24, "A string", $ret->{str}; btest 25, !defined($ret->{integer2}); # OPTIONAL-ity check: integer2 is NOT optional during encode. btest 26, $asn->prepare(q( SET { integer [1] INTEGER, bool [2] BOOLEAN, str [3] STRING, ..., integer2 [4] INTEGER } )) or warn $asn->error; btest 27, !defined( $asn->encode(integer => 1, bool => 0, str => "A string") ); examples000755000765000765 011764713076 14723 5ustar00gbarrgbarr000000000000Convert-ASN1-0.26ldap100644000765000765 3214311764713076 15751 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/examples$desc = <<'ESQ'; LDAPMessage ::= SEQUENCE { messageID MessageID, protocolOp CHOICE { bindRequest BindRequest, bindResponse BindResponse, unbindRequest UnbindRequest, searchRequest SearchRequest, searchResEntry SearchResultEntry, searchResDone SearchResultDone, searchResRef SearchResultReference, modifyRequest ModifyRequest, modifyResponse ModifyResponse, addRequest AddRequest, addResponse AddResponse, delRequest DelRequest, delResponse DelResponse, modDNRequest ModifyDNRequest, modDNResponse ModifyDNResponse, compareRequest CompareRequest, compareResponse CompareResponse, abandonRequest AbandonRequest, extendedReq ExtendedRequest, extendedResp ExtendedResponse } controls [0] Controls OPTIONAL } MessageID ::= INTEGER -- (0 .. maxInt) -- maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- LDAPString ::= OCTET STRING LDAPOID ::= OCTET STRING LDAPDN ::= LDAPString RelativeLDAPDN ::= LDAPString AttributeType ::= LDAPString AttributeDescription ::= LDAPString AttributeDescriptionList ::= SEQUENCE OF AttributeDescription AttributeValue ::= OCTET STRING AttributeValueAssertion ::= SEQUENCE { attributeDesc AttributeDescription, assertionValue AssertionValue } AssertionValue ::= OCTET STRING Attribute ::= SEQUENCE { type AttributeDescription, vals SET OF AttributeValue } MatchingRuleId ::= LDAPString LDAPResult ::= SEQUENCE { resultCode ENUMERATED { success (0), operationsError (1), protocolError (2), timeLimitExceeded (3), sizeLimitExceeded (4), compareFalse (5), compareTrue (6), authMethodNotSupported (7), strongAuthRequired (8), -- 9 reserved -- referral (10), -- new adminLimitExceeded (11), -- new unavailableCriticalExtension (12), -- new confidentialityRequired (13), -- new saslBindInProgress (14), -- new noSuchAttribute (16), undefinedAttributeType (17), inappropriateMatching (18), constraintViolation (19), attributeOrValueExists (20), invalidAttributeSyntax (21), -- 22-31 unused -- noSuchObject (32), aliasProblem (33), invalidDNSyntax (34), -- 35 reserved for undefined isLeaf -- aliasDereferencingProblem (36), -- 37-47 unused -- inappropriateAuthentication (48), invalidCredentials (49), insufficientAccessRights (50), busy (51), unavailable (52), unwillingToPerform (53), loopDetect (54), -- 55-63 unused -- namingViolation (64), objectClassViolation (65), notAllowedOnNonLeaf (66), notAllowedOnRDN (67), entryAlreadyExists (68), objectClassModsProhibited (69), -- 70 reserved for CLDAP -- affectsMultipleDSAs (71), -- new -- 72-79 unused -- other (80)} -- 81-90 reserved for APIs -- matchedDN LDAPDN, errorMessage LDAPString, referral [3] Referral OPTIONAL } Referral ::= SEQUENCE OF LDAPURL LDAPURL ::= LDAPString -- limited to characters permitted in URLs Controls ::= SEQUENCE OF Control Control ::= SEQUENCE { controlType LDAPOID, criticality BOOLEAN , -- DEFAULT FALSE, controlValue OCTET STRING OPTIONAL } BindRequest ::= [APPLICATION 0] SEQUENCE { version INTEGER, -- (1 .. 127), name LDAPDN, authentication AuthenticationChoice } AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING, -- 1 and 2 reserved sasl [3] SaslCredentials } SaslCredentials ::= SEQUENCE { mechanism LDAPString, credentials OCTET STRING OPTIONAL } BindResponse ::= [APPLICATION 1] SEQUENCE { COMPONENTS OF LDAPResult, serverSaslCreds [7] OCTET STRING OPTIONAL } UnbindRequest ::= [APPLICATION 2] NULL SearchRequest ::= [APPLICATION 3] SEQUENCE { baseObject LDAPDN, scope ENUMERATED { baseObject (0), singleLevel (1), wholeSubtree (2) } derefAliases ENUMERATED { neverDerefAliases (0), derefInSearching (1), derefFindingBaseObj (2), derefAlways (3) } sizeLimit INTEGER , -- (0 .. maxInt), timeLimit INTEGER , -- (0 .. maxInt), typesOnly BOOLEAN, filter Filter, attributes AttributeDescriptionList } Filter ::= CHOICE { and [0] SET OF Filter, or [1] SET OF Filter, not [2] Filter, equalityMatch [3] AttributeValueAssertion, substrings [4] SubstringFilter, greaterOrEqual [5] AttributeValueAssertion, lessOrEqual [6] AttributeValueAssertion, present [7] AttributeDescription, approxMatch [8] AttributeValueAssertion, extensibleMatch [9] MatchingRuleAssertion } SubstringFilter ::= SEQUENCE { type AttributeDescription, -- at least one must be present substrings SEQUENCE OF CHOICE { initial [0] LDAPString, any [1] LDAPString, final [2] LDAPString } } MatchingRuleAssertion ::= SEQUENCE { matchingRule [1] MatchingRuleId OPTIONAL, type [2] AttributeDescription OPTIONAL, matchValue [3] AssertionValue, dnAttributes [4] BOOLEAN } -- DEFAULT FALSE } SearchResultEntry ::= [APPLICATION 4] SEQUENCE { objectName LDAPDN, attributes PartialAttributeList } PartialAttributeList ::= SEQUENCE OF SEQUENCE { type AttributeDescription, vals SET OF AttributeValue } SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL SearchResultDone ::= [APPLICATION 5] LDAPResult ModifyRequest ::= [APPLICATION 6] SEQUENCE { object LDAPDN, modification SEQUENCE OF SEQUENCE { operation ENUMERATED { add (0), delete (1), replace (2) } modification AttributeTypeAndValues } } AttributeTypeAndValues ::= SEQUENCE { type AttributeDescription, vals SET OF AttributeValue } ModifyResponse ::= [APPLICATION 7] LDAPResult AddRequest ::= [APPLICATION 8] SEQUENCE { entry LDAPDN, attributes AttributeList } AttributeList ::= SEQUENCE OF SEQUENCE { type AttributeDescription, vals SET OF AttributeValue } AddResponse ::= [APPLICATION 9] LDAPResult DelRequest ::= [APPLICATION 10] LDAPDN DelResponse ::= [APPLICATION 11] LDAPResult ModifyDNRequest ::= [APPLICATION 12] SEQUENCE { entry LDAPDN, newrdn RelativeLDAPDN, deleteoldrdn BOOLEAN, newSuperior [0] LDAPDN OPTIONAL } ModifyDNResponse ::= [APPLICATION 13] LDAPResult CompareRequest ::= [APPLICATION 14] SEQUENCE { entry LDAPDN, ava AttributeValueAssertion } CompareResponse ::= [APPLICATION 15] LDAPResult AbandonRequest ::= [APPLICATION 16] MessageID ExtendedRequest ::= [APPLICATION 23] SEQUENCE { requestName [0] LDAPOID, requestValue [1] OCTET STRING OPTIONAL } ExtendedResponse ::= [APPLICATION 24] SEQUENCE { COMPONENTS OF LDAPResult, responseName [10] LDAPOID OPTIONAL, response [11] OCTET STRING OPTIONAL } VirtualListViewRequest ::= SEQUENCE { beforeCount INTEGER , --(0 .. maxInt), afterCount INTEGER , --(0 .. maxInt), CHOICE { byIndex [0] SEQUENCE { index INTEGER , --(0 .. maxInt), contentCount INTEGER } --(0 .. maxInt) } byValue [1] AssertionValue } -- byValue [1] greaterThanOrEqual assertionValue } contextID OCTET STRING OPTIONAL } VirtualListViewResponse ::= SEQUENCE { targetPosition INTEGER , --(0 .. maxInt), contentCount INTEGER , --(0 .. maxInt), virtualListViewResult ENUMERATED { success (0), operatonsError (1), unwillingToPerform (53), insufficientAccessRights (50), busy (51), timeLimitExceeded (3), adminLimitExceeded (11), sortControlMissing (60), indexRangeError (61), other (80) } } ESQ use lib 'lib'; use Convert::ASN1; use Convert::ASN1::Debug qw(asn_dump asn_hexdump); $asn = Convert::ASN1->new; $asn->prepare($desc) or die $asn->error; #$asn->dump; $filter = $asn->find('Filter'); # A Filter # (&(!(desc=value))(|(xx=x*y*)(yy=*1*2))) $buf = $filter->encode( { and => [ { not => { equalityMatch => { attributeDesc => 'desc', assertionValue => 'value' } } }, { or => [ { substrings => { type => 'xx', substrings => [ { initial => 'x' }, { any => 'y' } ] } }, { substrings => { type => 'yy', substrings => [ { any => 1 }, { final => 2 } ] } } ] } ] } ) or die $filter->error; asn_dump($buf); $ret = $filter->decode($buf) or die $filter->error; use Data::Dumper; $Data::Dumper::Indent=1; $Data::Dumper::Quotekeys=0; print Dumper($ret); 07input.dat100644000765000765 240311764713076 15507 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/tad_DUSAT1_6USATT_m00001lP20050207100810_g-0600cP20050207100805_g-0600kP20050207100815_g-0600_I_= _nT"_#BatchControlInfoe_USD_RUSDPj_i__h_tfji_h_g-0600<7_8_:_ 8889991234_yvN_M1_~011ciG_4V4Vx_#Eg_Y_!vT2,P20041108150442_h__ _8_- 0000569253__;22{_z98765_ TAP Test Companyq_F12345_ CITY, UHf_4Vx4_&'$_Z11_3_4_J_KJP20041108150442_hFE_BD_i___@?_G00_>_A_D_UI_\I?_G01_>_A_D_UI_\ION_Q12_P[JP20041108150442_hjG_4V4Vx_4Vx_) _!4Vx_K,P20041108150627_h__E _8_- 0000569266__;ެ{_z98765_ TAP Test Companyq_F12345_ CITY, UHf_&'$_Z11_3_4_J_KJP20041108150627_hFE_BD_i@?_G00_>_AE_Dx_UI_\I?_G01_>_AE_Dx_UI_\ION_Q11_P[JP20041108150627_hoeP20041108150442_g-0600P20041108150627_g-0600`^_G00_q^_G01_q_b_a_+dsacert.der100644000765000765 143711764713076 15636 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t00٠ 790 *H80)1 0 Ude1 0 U foo1 0 Ubar0 090423110324Z 090523110324Z0)1 0 Ude1 0 U foo1 0 Ubar00+*H805CͣIUFu(>K|XSoqs?=fgQjO\鈪0hҊ-yZQl9ıt#ϡo*^ʗ CsP۹ OU0tӡBnDX[CgIFܑ(eδeV}7t3С4;ԛ|gQ5 -xxSWy4gSu[bFwڌ:QKۉ!DC5 DZKx'Ќk6"gyc Pu/ r'G,d # =xd{G'rb5%ds?p7o\_#'S.} } WCУ00UEiO2˨JmEF0YU#R0PEiO2˨JmEF-+0)1 0 Ude1 0 U foo1 0 Ubar 790 U00 *H810.˩qd,cfKdd.eT#D:'D-subca_2.cer100644000765000765 261711764713076 15527 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t00sC0  *H 01 0 UUS10U U.S. Government1#0!U Department of the Treasury1"0 U Certification Authorities10U US Treasury Root CA0 060211144045Z 120211151045Z01 0 UUS10U U.S. Government1#0!U Department of the Treasury1"0 U Certification Authorities10U US Treasury Public CA0"0  *H 0 CL 잌G6t]Rgd>,mfeM2`&68z[߽пЇ\쁱;A . 9?Qܬ?nrp-uP0$򇼣FV"}Ԙ%e:82̝QWA멛cA/yHI $4fL8;xNuՉC{yyO&F+C'p9Pi'TB5dQWxVv1hC00mUd0`0\XT01 0 UUS10U U.S. Government1#0!U Department of the Treasury1"0 U Certification Authorities10U US Treasury Root CA1 0 UCRL1ldap://ldap.treas.gov/cn=CRL1,ou=US%20Treasury%20Root%20CA,ou=Certification%20Authorities,ou=Department%20of%20the%20Treasury,o=U.S.%20Government,c=US?authorityRevocationList0 U0U#0Uڦ7ВT !Ӕ r.0UY_- YZJSp0 U00 *H}A 0 V7.10  *H z(%Ra=l]Q=c y՜QSK͒qO/,oͳBnߝMidF9˨H6(Dugj +x%N MW!`EPRR8mFJ:$#:a<-?9 <1a!i &z1 )Zt5l!ٙɽ`>4~<8zZ}new or warn $asn->error; btest 2, $asn->prepare(q( Message ::= CHOICE { a A, b B } A ::= [2] EXPLICIT INTEGER B ::= [3] EXPLICIT INTEGER )) || die $asn->error; my $mm = $asn->find("Message") || die $asn->error; my $buffer = pack("H*","a203020105"); my $input = { a => 5 }; my $result = $mm->encode($input) || die $mm->error; stest 3, $buffer, $result; rtest 4, $input, $mm->decode($buffer); verisign.der100644000765000765 140611764713076 16033 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t00kLꪘ>qӓ=:0  *H 01 0 UUS10U VeriSign, Inc.1<0:U 3Class 1 Public Primary Certification Authority - G21:08U 1(c) 1998 VeriSign, Inc. - For authorized use only10U VeriSign Trust Network0 980518000000Z 280801235959Z01 0 UUS10U VeriSign, Inc.1<0:U 3Class 1 Public Primary Certification Authority - G21:08U 1(c) 1998 VeriSign, Inc. - For authorized use only10U VeriSign Trust Network00  *H 0к-v1ʔVooR6nuV UC!e~!k2?4A5ݪY?SmO*ZĦE]>d$vͫo{Qan4A @s=ku0  *H O g,٨-u~;r~\- km`|Ő# \JЯ]Ƕ  vOÛu[kܬrNOdt{•AesXnew or warn $asn->error; btest 2, $asn->prepare(q( CHOICE { integer [1] INTEGER, bool [2] BOOLEAN, ... } )) or warn $asn->error; btest 3, $pdu = $asn->encode(integer => 1) or warn $asn->error; btest 4, $ret = $asn->decode($pdu) or warn $asn->error; ntest 5, 1, $ret->{integer}; btest 6, !defined($ret->{bool}); btest 7, !defined($ret->{str}); # Decode a "version 1" message with a "version 2" decoder btest 8, $asn->prepare(q( CHOICE { integer [1] INTEGER, bool [2] BOOLEAN, ..., str [3] STRING } )) or warn $asn->error; btest 9, $ret = $asn->decode($pdu) or warn $asn->error; ntest 10, 1, $ret->{integer}; btest 11, !defined($ret->{bool}); btest 12, !defined($ret->{str}); # Encode a "version 2" message btest 13, $pdu = $asn->encode(str => "A string") or warn $asn->error; btest 14, $ret = $asn->decode($pdu) or warn $asn->error; btest 15, !defined($ret->{int}); btest 16, !defined($ret->{bool}); stest 17, "A string", $ret->{str}; # Decode a "version 2" message with a "version 1" decoder btest 18, $asn->prepare(q( CHOICE { integer [1] INTEGER, bool [2] BOOLEAN, ... } )) or warn $asn->error; btest 19, !defined($ret = $asn->decode($pdu)); 18tagdefault.t100644000765000765 443111764713076 16170 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t#!/usr/local/bin/perl # # Test that default EXPLICIT tagging works. # use Convert::ASN1; BEGIN { require 't/funcs.pl' } print "1..25\n"; btest 1, $asn = Convert::ASN1->new(encoding=>'DER', tagdefault=>'EXPLICIT') or warn $asn->error; # Tests from X.690-0207, section 8.14.3 my $value = "Jones"; btest 2, $asn->prepare(q( Type1 ::= VisibleString Type2 ::= [APPLICATION 3] IMPLICIT Type1 Type3 ::= [2] Type2 Type4 ::= [APPLICATION 7] IMPLICIT Type3 Type5 ::= [2] IMPLICIT Type2 )) or warn $asn->error; # Type 1 btest 3, $type1 = $asn->find('Type1'); $result = pack("H*", "1A054A6F6E6573"); stest 4, $result, $type1->encode($value) or warn $asn->error; btest 5, $ret = $type1->decode($result) or warn $asn->error; stest 6, $value, $ret; # Type 2 btest 7, $type2 = $asn->find('Type2'); $result = pack("H*", "43054A6F6E6573"); stest 8, $result, $type2->encode($value) or warn $asn->error; btest 9, $ret = $type2->decode($result) or warn $asn->error; stest 10, $value, $ret; # Type 3 btest 11, $type3 = $asn->find('Type3'); $result = pack("H*", "A20743054A6F6E6573"); stest 12, $result, $type3->encode($value) or warn $asn->error; btest 13, $ret = $type3->decode($result) or warn $asn->error; stest 14, $value, $ret; # Type 4 btest 15, $type4 = $asn->find('Type4'); $result = pack("H*", "670743054A6F6E6573"); stest 16, $result, $type4->encode($value) or warn $asn->error; btest 17, $ret = $type4->decode($result) or warn $asn->error; stest 18, $value, $ret; # Type 5 btest 19, $type5 = $asn->find('Type5'); $result = pack("H*", "82054A6F6E6573"); stest 20, $result, $type5->encode($value) or warn $asn->error; btest 21, $ret = $type5->decode($result) or warn $asn->error; stest 22, $value, $ret; # Test EXPLICIT tagging a nested SEQUENCE. btest 23, $asn->prepare(q( X ::= [APPLICATION 10] Y Y ::= SEQUENCE { v [1] INTEGER, b [4] Z } Z ::= SEQUENCE { n [7] INTEGER, e [8] SEQUENCE OF INTEGER } )) or warn $asn->error; btest 24, $X = $asn->find('X'); $value = { v => 5,b => { n => 117, e=>[18,17,16,23] }}; $result = pack("H*", "6a20301ea103020105a4173015a703020175a80e300c020112020111020110020117"); stest 25, $result, $X->encode($value) or warn $asn->error; new_root_ca.cer100644000765000765 253011764713076 16502 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t0T0<D>:0  *H 01 0 UUS10U U.S. Government1#0!U Department of the Treasury1"0 U Certification Authorities10U US Treasury Root CA0 060805141630Z 260805144630Z01 0 UUS10U U.S. Government1#0!U Department of the Treasury1"0 U Certification Authorities10U US Treasury Root CA0"0  *H 0 $Y̘|dj;)HǻXߢ*h֋*@jn#TaviLhQ8 R6"Hwx.XP {7hbM sF鈓%m!6X ۭ"XB}~V1Ib`cpnO4˭&Cˏ$*j)Wn_O@BմQ{[̱>Dǣdhr{auvlRټ9f돚00U0U00+ 00-+0!http://pki.treas.gov/root_sia.p7c0+0ldap://ldap.treas.gov/ou=US%20Treasury%20Root%20CA,ou=Certification%20Authorities,ou=Department%20of%20the%20Treasury,o=U.S.%20Government,c=US?cACertificate;binary,crossCertificatePair;binary0 `HB0+U$0"20060805141630Z20160805024630Z0UhHTp-Xx<.Yd0 *H}A0V7.1:4.00  *H iW@hJ&bHy֨a6ոoczbIȋ^_;wqJFQw9vnU~@[``_dMpO>Ǥ0+]z: # ?OO|&OB"}3ۀNG9 $VcBLv$_tRp^Jx|,7YWoeb5:>IQ>.;^}0vKQװ7u2%4==/Ykc{allianz_root.cer100644000765000765 255511764713076 16707 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/t0i0Q0  *H 0E1 0 UDE10U  Allianz Group10UAllianz Group Root CA0 021213121313Z 121230230000Z0E1 0 UDE10U  Allianz Group10UAllianz Group Root CA0"0  *H 0 СXA\b.{4/X张 Ճe7 KBIJ>T8TJZn1|茞[&.an::a ^ Z?o0soSXה/6h =?eHR5VxjŽz1Ƌa 8 >_ u _Vy`Fv <ܳ%Dj*E♯3.oroj_n#~͇Kb0^0 `HB05U.0,0*(&$http://rootca.allianz.com/rootca.crl0U 00 +w00*+http://rootca.allianz.com/cps/0{+0o0Allianz Group Germany0LThis Certificate is issued by Allianz Group Root CA by Allianz Group Germany0U0 `HB/cps/0( `HBhttp://rootca.allianz.com0[ `HB NLThis Certificate is issued by Allianz Group Root CA by Allianz Group Germany0U00UQ2*P݄MgAE0mU#f0dQ2*P݄MgAEIG0E1 0 UDE10U  Allianz Group10UAllianz Group Root CA0  *H Q6Ɠdj-4DK j~?}SD}V_\ngV3PK|ijōLJbr@1k\(X2T 4'6QxU3p>RthtP_qOFApSrvnJ;?8l{QXY!Eɂ uΏ'NT~Ɩ& nmpzdPZp=5F-O}Ce ]Dt^Ѳ+ٳeg(%CK?M0ߔaX<[3ohZyk @bo<[-Ci۰b~PR*Ni炥d1$jtѰW -ey0u0U(̚l3G2Sy&Z'0U#0(̚l3G2Sy&Z'om0k1 0 UUS10U Fake Org1$0"U Digital Certificate Signing1#0!UFake Certificate Authority 9*[ @0 U00 U0 `HB0$ +I020101221050412Z0`UY0W0%#!http://ca.mayfirst.org/mfpl.crl0.,*(https://members.mayfirst.org/ca/mfpl.crl0  *H   Ğcw7qKH`og] UJ+_=GP$#-iNR=G*w}À"u}O=°ǽ*V|b |['oBxZU{j)ouK<yK9R'5ݹt  u 7Et&\] 3ٔů߂'o^= PεeAEM=طnew; $asn->prepare(<error; -- ASN.1 from RFC2459 and X.509(2001) -- Adapted for use with Convert::ASN1 -- attribute data types -- Attribute ::= SEQUENCE { type AttributeType, values SET OF AttributeValue -- at least one value is required -- } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= DirectoryString --ANY AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue } -- naming data types -- Name ::= CHOICE { -- only one possibility for now rdnSequence RDNSequence } RDNSequence ::= SEQUENCE OF RelativeDistinguishedName DistinguishedName ::= RDNSequence RelativeDistinguishedName ::= SET OF AttributeTypeAndValue --SET SIZE (1 .. MAX) OF -- Directory string type -- DirectoryString ::= CHOICE { teletexString TeletexString, --(SIZE (1..MAX)), printableString PrintableString, --(SIZE (1..MAX)), bmpString BMPString, --(SIZE (1..MAX)), universalString UniversalString, --(SIZE (1..MAX)), utf8String UTF8String, --(SIZE (1..MAX)), ia5String IA5String --added for EmailAddress } -- certificate and CRL specific structures begin here Certificate ::= SEQUENCE { tbsCertificate TBSCertificate, signatureAlgorithm AlgorithmIdentifier, signature BIT STRING } TBSCertificate ::= SEQUENCE { version [0] EXPLICIT Version OPTIONAL, --DEFAULT v1 serialNumber CertificateSerialNumber, signature AlgorithmIdentifier, issuer Name, validity Validity, subject Name, subjectPublicKeyInfo SubjectPublicKeyInfo, issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version shall be v2 or v3 subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version shall be v2 or v3 extensions [3] EXPLICIT Extensions OPTIONAL -- If present, version shall be v3 } Version ::= INTEGER --{ v1(0), v2(1), v3(2) } CertificateSerialNumber ::= INTEGER Validity ::= SEQUENCE { notBefore Time, notAfter Time } Time ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime } UniqueIdentifier ::= BIT STRING SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING } Extensions ::= SEQUENCE OF Extension --SIZE (1..MAX) OF Extension Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN OPTIONAL, --DEFAULT FALSE, extnValue OCTET STRING } AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY } --extensions AuthorityKeyIdentifier ::= SEQUENCE { keyIdentifier [0] KeyIdentifier OPTIONAL, authorityCertIssuer [1] GeneralNames OPTIONAL, authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL } -- authorityCertIssuer and authorityCertSerialNumber shall both -- be present or both be absent KeyIdentifier ::= OCTET STRING SubjectKeyIdentifier ::= KeyIdentifier -- key usage extension OID and syntax -- id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } KeyUsage ::= BIT STRING --{ -- digitalSignature (0), -- nonRepudiation (1), -- keyEncipherment (2), -- dataEncipherment (3), -- keyAgreement (4), -- keyCertSign (5), -- cRLSign (6), -- encipherOnly (7), -- decipherOnly (8) } -- private key usage period extension OID and syntax -- id-ce-privateKeyUsagePeriod OBJECT IDENTIFIER ::= { id-ce 16 } PrivateKeyUsagePeriod ::= SEQUENCE { notBefore [0] GeneralizedTime OPTIONAL, notAfter [1] GeneralizedTime OPTIONAL } -- either notBefore or notAfter shall be present -- certificate policies extension OID and syntax -- id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } CertificatePolicies ::= SEQUENCE OF PolicyInformation PolicyInformation ::= SEQUENCE { policyIdentifier CertPolicyId, policyQualifiers SEQUENCE OF PolicyQualifierInfo } --OPTIONAL } CertPolicyId ::= OBJECT IDENTIFIER PolicyQualifierInfo ::= SEQUENCE { policyQualifierId PolicyQualifierId, qualifier ANY } --DEFINED BY policyQualifierId } -- Implementations that recognize additional policy qualifiers shall -- augment the following definition for PolicyQualifierId PolicyQualifierId ::= OBJECT IDENTIFIER --( id-qt-cps | id-qt-unotice ) -- CPS pointer qualifier CPSuri ::= IA5String -- user notice qualifier UserNotice ::= SEQUENCE { noticeRef NoticeReference OPTIONAL, explicitText DisplayText OPTIONAL} NoticeReference ::= SEQUENCE { organization DisplayText, noticeNumbers SEQUENCE OF INTEGER } DisplayText ::= CHOICE { visibleString VisibleString , bmpString BMPString , utf8String UTF8String } -- policy mapping extension OID and syntax -- id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } PolicyMappings ::= SEQUENCE OF SEQUENCE { issuerDomainPolicy CertPolicyId, subjectDomainPolicy CertPolicyId } -- subject alternative name extension OID and syntax -- id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } SubjectAltName ::= GeneralNames GeneralNames ::= SEQUENCE OF GeneralName GeneralName ::= CHOICE { otherName [0] AnotherName, rfc822Name [1] IA5String, dNSName [2] IA5String, x400Address [3] ANY, --ORAddress, directoryName [4] Name, ediPartyName [5] EDIPartyName, uniformResourceIdentifier [6] IA5String, iPAddress [7] OCTET STRING, registeredID [8] OBJECT IDENTIFIER } -- AnotherName replaces OTHER-NAME ::= TYPE-IDENTIFIER, as -- TYPE-IDENTIFIER is not supported in the '88 ASN.1 syntax AnotherName ::= SEQUENCE { type OBJECT IDENTIFIER, value [0] EXPLICIT ANY } --DEFINED BY type-id } EDIPartyName ::= SEQUENCE { nameAssigner [0] DirectoryString OPTIONAL, partyName [1] DirectoryString } -- issuer alternative name extension OID and syntax -- id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } IssuerAltName ::= GeneralNames -- id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } SubjectDirectoryAttributes ::= SEQUENCE OF Attribute -- basic constraints extension OID and syntax -- id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } BasicConstraints ::= SEQUENCE { cA BOOLEAN OPTIONAL, --DEFAULT FALSE, pathLenConstraint INTEGER OPTIONAL } -- name constraints extension OID and syntax -- id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } NameConstraints ::= SEQUENCE { permittedSubtrees [0] GeneralSubtrees OPTIONAL, excludedSubtrees [1] GeneralSubtrees OPTIONAL } GeneralSubtrees ::= SEQUENCE OF GeneralSubtree GeneralSubtree ::= SEQUENCE { base GeneralName, minimum [0] BaseDistance OPTIONAL, --DEFAULT 0, maximum [1] BaseDistance OPTIONAL } BaseDistance ::= INTEGER -- policy constraints extension OID and syntax -- id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } PolicyConstraints ::= SEQUENCE { requireExplicitPolicy [0] SkipCerts OPTIONAL, inhibitPolicyMapping [1] SkipCerts OPTIONAL } SkipCerts ::= INTEGER -- CRL distribution points extension OID and syntax -- id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= {id-ce 31} cRLDistributionPoints ::= SEQUENCE OF DistributionPoint DistributionPoint ::= SEQUENCE { distributionPoint [0] DistributionPointName OPTIONAL, reasons [1] ReasonFlags OPTIONAL, cRLIssuer [2] GeneralNames OPTIONAL } DistributionPointName ::= CHOICE { fullName [0] GeneralNames, nameRelativeToCRLIssuer [1] RelativeDistinguishedName } ReasonFlags ::= BIT STRING --{ -- unused (0), -- keyCompromise (1), -- cACompromise (2), -- affiliationChanged (3), -- superseded (4), -- cessationOfOperation (5), -- certificateHold (6), -- privilegeWithdrawn (7), -- aACompromise (8) } -- extended key usage extension OID and syntax -- id-ce-extKeyUsage OBJECT IDENTIFIER ::= {id-ce 37} ExtKeyUsageSyntax ::= SEQUENCE OF KeyPurposeId KeyPurposeId ::= OBJECT IDENTIFIER -- extended key purpose OIDs -- id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } -- id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } -- id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } -- id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } -- id-kp-ipsecEndSystem OBJECT IDENTIFIER ::= { id-kp 5 } -- id-kp-ipsecTunnel OBJECT IDENTIFIER ::= { id-kp 6 } -- id-kp-ipsecUser OBJECT IDENTIFIER ::= { id-kp 7 } -- id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } ASN1 # decoders for basic types my $asn_BitString = Convert::ASN1->new(); $asn_BitString->prepare("bitString BIT STRING"); my $asn_OctetString = Convert::ASN1->new(); $asn_OctetString->prepare("octetString OCTET STRING"); # decoders for extensions my %extnoid2asn = ( '2.5.29.9' => $asn->find('SubjectDirectoryAttributes'), '2.5.29.14' => $asn_OctetString, #'SubjectKeyIdentifier', '2.5.29.15' => $asn_BitString, #'keyUsage', '2.5.29.16' => $asn->find('PrivateKeyUsagePeriod'), '2.5.29.17' => $asn->find('SubjectAltName'), '2.5.29.18' => $asn->find('IssuerAltName'), '2.5.29.19' => $asn->find('BasicConstraints'), # '2.5.29.20' => 'cRLNumber', # '2.5.29.21' => 'cRLReasons', # '2.5.29.23' => 'holdInstructionCode', # '2.5.29.24' => 'invalidityDate', # '2.5.29.27' => 'deltaCRLIndicator', # '2.5.29.28' => 'issuingDistributionPoint', # '2.5.29.29' => 'certificateIssuer', '2.5.29.30' => $asn->find('NameConstraints'), '2.5.29.31' => $asn->find('cRLDistributionPoints'), '2.5.29.32' => $asn->find('CertificatePolicies'), '2.5.29.33' => $asn->find('PolicyMappings'), '2.5.29.35' => $asn->find('AuthorityKeyIdentifier'), '2.5.29.36' => $asn->find('PolicyConstraints'), '2.5.29.37' => $asn->find('ExtKeyUsageSyntax'), # '2.5.29.40' => 'cRLStreamIdentifier', # '2.5.29.44' => 'cRLScope', # '2.5.29.45' => 'statusReferrals', # '2.5.29.46' => 'freshestCRL', # '2.5.29.47' => 'orderedList', # '2.5.29.51' => 'baseUpdateTime', # '2.5.29.53' => 'deltaInfo', # '2.5.29.54' => 'inhibitAnyPolicy', # netscape-cert-extensions '2.16.840.1.113730.1.1' => $asn_BitString, # netscape-cert-type '2.16.840.1.113730.1.2' => $asn->find('DirectoryString'), # netscape-base-url '2.16.840.1.113730.1.3' => $asn->find('DirectoryString'), # netscape-revocation-url '2.16.840.1.113730.1.4' => $asn->find('DirectoryString'), # netscape-ca-revocation-url '2.16.840.1.113730.1.7' => $asn->find('DirectoryString'), # netscape-cert-renewal-url '2.16.840.1.113730.1.8' => $asn->find('DirectoryString'), # netscape-ca-policy-url '2.16.840.1.113730.1.12' => $asn->find('DirectoryString'), # netscape-ssl-server-name '2.16.840.1.113730.1.13' => $asn->find('DirectoryString'), # netscape-comment ); my $asn_cert = $asn->find('Certificate'); while ( my $filename = shift ) { my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat $filename; open FILE, "<$filename" or die "no such file"; binmode FILE; my $der_cert; read FILE, $der_cert, $size; close FILE; decodeCert( $der_cert ); } sub decodeCert() { my $der_cert = shift; #asn_dump( $der_cert ); my $cert = $asn_cert->decode($der_cert) or die $asn_cert->error; #extensions foreach my $extension ( @{$cert->{'tbsCertificate'}->{'extensions'}} ) { #print "extension: ", $oid2extension{$extension->{'extnID'}}, "\n"; if ( exists $extnoid2asn{$extension->{'extnID'}} ) { $extension->{'extnValue'} = ($extnoid2asn{$extension->{'extnID'}})->decode( $extension->{'extnValue'} ); } else { print STDERR "unknown ", $extension->{'critical'} ? "critical " : "", "extension: ", $extension->{'extnID'}, "\n"; asn_dump( $extension->{'extnValue'} ); } } print Dumper( $cert ); } Convert000755000765000765 011764713076 15273 5ustar00gbarrgbarr000000000000Convert-ASN1-0.26/libASN1.pm100644000765000765 2366311764713076 16525 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/lib/Convert# Copyright (c) 2000-2002 Graham Barr . All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package Convert::ASN1; { $Convert::ASN1::VERSION = '0.26'; } use 5.004; use strict; use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS @opParts @opName $AUTOLOAD); use Exporter; use constant CHECK_UTF8 => $] > 5.007; BEGIN { local $SIG{__DIE__}; eval { require bytes and 'bytes'->import }; if (CHECK_UTF8) { require Encode; require utf8; } @ISA = qw(Exporter); %EXPORT_TAGS = ( io => [qw(asn_recv asn_send asn_read asn_write asn_get asn_ready)], debug => [qw(asn_dump asn_hexdump)], const => [qw(ASN_BOOLEAN ASN_INTEGER ASN_BIT_STR ASN_OCTET_STR ASN_NULL ASN_OBJECT_ID ASN_REAL ASN_ENUMERATED ASN_SEQUENCE ASN_SET ASN_PRINT_STR ASN_IA5_STR ASN_UTC_TIME ASN_GENERAL_TIME ASN_RELATIVE_OID ASN_UNIVERSAL ASN_APPLICATION ASN_CONTEXT ASN_PRIVATE ASN_PRIMITIVE ASN_CONSTRUCTOR ASN_LONG_LEN ASN_EXTENSION_ID ASN_BIT)], tag => [qw(asn_tag asn_decode_tag2 asn_decode_tag asn_encode_tag asn_decode_length asn_encode_length)] ); @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; $EXPORT_TAGS{all} = \@EXPORT_OK; @opParts = qw( cTAG cTYPE cVAR cLOOP cOPT cEXT cCHILD cDEFINE ); @opName = qw( opUNKNOWN opBOOLEAN opINTEGER opBITSTR opSTRING opNULL opOBJID opREAL opSEQUENCE opEXPLICIT opSET opUTIME opGTIME opUTF8 opANY opCHOICE opROID opBCD opEXTENSIONS ); foreach my $l (\@opParts, \@opName) { my $i = 0; foreach my $name (@$l) { my $j = $i++; no strict 'refs'; *{__PACKAGE__ . '::' . $name} = sub () { $j } } } } sub _internal_syms { my $pkg = caller; no strict 'refs'; for my $sub (@opParts,@opName,'dump_op') { *{$pkg . '::' . $sub} = \&{__PACKAGE__ . '::' . $sub}; } } sub ASN_BOOLEAN () { 0x01 } sub ASN_INTEGER () { 0x02 } sub ASN_BIT_STR () { 0x03 } sub ASN_OCTET_STR () { 0x04 } sub ASN_NULL () { 0x05 } sub ASN_OBJECT_ID () { 0x06 } sub ASN_REAL () { 0x09 } sub ASN_ENUMERATED () { 0x0A } sub ASN_RELATIVE_OID () { 0x0D } sub ASN_SEQUENCE () { 0x10 } sub ASN_SET () { 0x11 } sub ASN_PRINT_STR () { 0x13 } sub ASN_IA5_STR () { 0x16 } sub ASN_UTC_TIME () { 0x17 } sub ASN_GENERAL_TIME () { 0x18 } sub ASN_UNIVERSAL () { 0x00 } sub ASN_APPLICATION () { 0x40 } sub ASN_CONTEXT () { 0x80 } sub ASN_PRIVATE () { 0xC0 } sub ASN_PRIMITIVE () { 0x00 } sub ASN_CONSTRUCTOR () { 0x20 } sub ASN_LONG_LEN () { 0x80 } sub ASN_EXTENSION_ID () { 0x1F } sub ASN_BIT () { 0x80 } sub new { my $pkg = shift; my $self = bless {}, $pkg; $self->configure(@_); $self; } sub configure { my $self = shift; my %opt = @_; $self->{options}{encoding} = uc($opt{encoding} || 'BER'); unless ($self->{options}{encoding} =~ /^[BD]ER$/) { require Carp; Carp::croak("Unsupported encoding format '$opt{encoding}'"); } # IMPLICIT as defalt for backwards compatibility, even though it's wrong. $self->{options}{tagdefault} = uc($opt{tagdefault} || 'IMPLICIT'); unless ($self->{options}{tagdefault} =~ /^(?:EXPLICIT|IMPLICIT)$/) { require Carp; Carp::croak("Default tagging must be EXPLICIT/IMPLICIT. Not $opt{tagdefault}"); } for my $type (qw(encode decode)) { if (exists $opt{$type}) { while(my($what,$value) = each %{$opt{$type}}) { $self->{options}{"${type}_${what}"} = $value; } } } } sub find { my $self = shift; my $what = shift; return unless exists $self->{tree}{$what}; my %new = %$self; $new{script} = $new{tree}->{$what}; bless \%new, ref($self); } sub prepare { my $self = shift; my $asn = shift; $self = $self->new unless ref($self); my $tree; if( ref($asn) eq 'GLOB' ){ local $/ = undef; my $txt = <$asn>; $tree = Convert::ASN1::parser::parse($txt,$self->{options}{tagdefault}); } else { $tree = Convert::ASN1::parser::parse($asn,$self->{options}{tagdefault}); } unless ($tree) { $self->{error} = $@; return; ### If $self has been set to a new object, not returning ### this object here will destroy the object, so the caller ### won't be able to get at the error. } $self->{tree} = _pack_struct($tree); $self->{script} = (values %$tree)[0]; $self; } sub prepare_file { my $self = shift; my $asnp = shift; local *ASN; open( ASN, $asnp ) or do{ $self->{error} = $@; return; }; my $ret = $self->prepare( \*ASN ); close( ASN ); $ret; } sub registeroid { my $self = shift; my $oid = shift; my $handler = shift; $self->{options}{oidtable}{$oid}=$handler; $self->{oidtable}{$oid}=$handler; } sub registertype { my $self = shift; my $def = shift; my $type = shift; my $handler = shift; $self->{options}{handlers}{$def}{$type}=$handler; } # In XS the will convert the tree between perl and C structs sub _pack_struct { $_[0] } sub _unpack_struct { $_[0] } ## ## Encoding ## sub encode { my $self = shift; my $stash = @_ == 1 ? shift : { @_ }; my $buf = ''; local $SIG{__DIE__}; eval { _encode($self->{options}, $self->{script}, $stash, [], $buf) } or do { $self->{error} = $@; undef } } # Encode tag value for encoding. # We assume that the tag has been correctly generated with asn_tag() sub asn_encode_tag { $_[0] >> 8 ? $_[0] & 0x8000 ? $_[0] & 0x800000 ? pack("V",$_[0]) : substr(pack("V",$_[0]),0,3) : pack("v", $_[0]) : chr($_[0]); } # Encode a length. If < 0x80 then encode as a byte. Otherwise encode # 0x80 | num_bytes followed by the bytes for the number. top end # bytes of all zeros are not encoded sub asn_encode_length { if($_[0] >> 7) { my $lenlen = &num_length; return pack("Ca*", $lenlen | 0x80, substr(pack("N",$_[0]), -$lenlen)); } return pack("C", $_[0]); } ## ## Decoding ## sub decode { my $self = shift; my $ret; local $SIG{__DIE__}; eval { my (%stash, $result); my $script = $self->{script}; my $stash = \$result; while ($script) { my $child = $script->[0] or last; if (@$script > 1 or defined $child->[cVAR]) { $result = $stash = \%stash; last; } last if $child->[cTYPE] == opCHOICE or $child->[cLOOP]; $script = $child->[cCHILD]; } _decode( $self->{options}, $self->{script}, $stash, 0, length $_[0], undef, {}, $_[0]); $ret = $result; 1; } or $self->{'error'} = $@ || 'Unknown error'; $ret; } sub asn_decode_length { return unless length $_[0]; my $len = ord substr($_[0],0,1); if($len & 0x80) { $len &= 0x7f or return (1,-1); return if $len >= length $_[0]; return (1+$len, unpack("N", "\0" x (4 - $len) . substr($_[0],1,$len))); } return (1, $len); } sub asn_decode_tag { return unless length $_[0]; my $tag = ord $_[0]; my $n = 1; if(($tag & 0x1f) == 0x1f) { my $b; do { return if $n >= length $_[0]; $b = ord substr($_[0],$n,1); $tag |= $b << (8 * $n++); } while($b & 0x80); } ($n, $tag); } sub asn_decode_tag2 { return unless length $_[0]; my $tag = ord $_[0]; my $num = $tag & 0x1f; my $len = 1; if($num == 0x1f) { $num = 0; my $b; do { return if $len >= length $_[0]; $b = ord substr($_[0],$len++,1); $num = ($num << 7) + ($b & 0x7f); } while($b & 0x80); } ($len, $tag, $num); } ## ## Utilities ## # How many bytes are needed to encode a number sub num_length { $_[0] >> 8 ? $_[0] >> 16 ? $_[0] >> 24 ? 4 : 3 : 2 : 1 } # Convert from a bigint to an octet string sub i2osp { my($num, $biclass) = @_; eval "use $biclass"; $num = $biclass->new($num); my $neg = $num < 0 and $num = abs($num+1); my $base = $biclass->new(256); my $result = ''; while($num != 0) { my $r = $num % $base; $num = ($num-$r) / $base; $result .= chr($r); } $result ^= chr(255) x length($result) if $neg; return scalar reverse $result; } # Convert from an octet string to a bigint sub os2ip { my($os, $biclass) = @_; eval "require $biclass"; my $base = $biclass->new(256); my $result = $biclass->new(0); my $neg = ord($os) >= 0x80 and $os ^= chr(255) x length($os); for (unpack("C*",$os)) { $result = ($result * $base) + $_; } return $neg ? ($result + 1) * -1 : $result; } # Given a class and a tag, calculate an integer which when encoded # will become the tag. This means that the class bits are always # in the bottom byte, so are the tag bits if tag < 30. Otherwise # the tag is in the upper 3 bytes. The upper bytes are encoded # with bit8 representing that there is another byte. This # means the max tag we can do is 0x1fffff sub asn_tag { my($class,$value) = @_; die sprintf "Bad tag class 0x%x",$class if $class & ~0xe0; unless ($value & ~0x1f or $value == 0x1f) { return (($class & 0xe0) | $value); } die sprintf "Tag value 0x%08x too big\n",$value if $value & 0xffe00000; $class = ($class | 0x1f) & 0xff; my @t = ($value & 0x7f); unshift @t, (0x80 | ($value & 0x7f)) while $value >>= 7; unpack("V",pack("C4",$class,@t,0,0)); } BEGIN { # When we have XS &_encode will be defined by the XS code # so will all the subs in these required packages unless (defined &_encode) { require Convert::ASN1::_decode; require Convert::ASN1::_encode; require Convert::ASN1::IO; } require Convert::ASN1::parser; } sub AUTOLOAD { require Convert::ASN1::Debug if $AUTOLOAD =~ /dump/; goto &{$AUTOLOAD} if defined &{$AUTOLOAD}; require Carp; my $pkg = ref($_[0]) || ($_[0] =~ /^[\w\d]+(?:::[\w\d]+)*$/)[0]; if ($pkg and UNIVERSAL::isa($pkg, __PACKAGE__)) { # guess it was a method call $AUTOLOAD =~ s/.*:://; Carp::croak(sprintf q{Can't locate object method "%s" via package "%s"},$AUTOLOAD,$pkg); } else { Carp::croak(sprintf q{Undefined subroutine &%s called}, $AUTOLOAD); } } sub DESTROY {} sub error { $_[0]->{error} } 1; ldap-search100644000765000765 255511764713076 17200 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/examples# This is an example of a search PDU from the LDAP protocol use Convert::ASN1; use Data::Dumper; my %scope = qw(base 0 one 1 single 1 sub 2 subtree 2); my %deref = qw(never 0 search 1 find 2 always 3); my $search_pdu = Convert::ASN1->new; $search_pdu->prepare(q( SEQUENCE { mesgid INTEGER, [APPLICATION 3] SEQUENCE { base STRING, scope ENUM, deref ENUM, sizeLimit INTEGER, timeLimit INTEGER, typesOnly BOOLEAN, filter STRING, -- for test, should be ANY and the var should hold -- a pre-encoded filter attrs SEQUENCE OF STRING } control [0] SEQUENCE OF SEQUENCE { -- this should be optional but we cannot do that inline type STRING, critical BOOLEAN, value STRING OPTIONAL } } )) or die $search_pdu->error; $buf = $search_pdu->encode( mesgid => 3, base => "cn=base", scope => $scope{one}, deref => $deref{find}, sizeLimit => 0, timeLimit => 0, typesOnly => 0, filter => "A filter", attrs => [qw(cn postalAddress)], control => [ { type => "1.2.3.4", critical => 1 }, { type => "9.8.7.6", critical => 0, value => "abc" } ] ); $Data::Dumper::Indent = 1; print Dumper( $search_pdu->decode($buf)); $h = unpack("H*",$buf); $h =~ s/(..)/$1 /g; $h =~ s/(.{47}\s)/$1\n/g; print $h,"\n"; ASN1.pod100644000765000765 2704711764713076 16673 0ustar00gbarrgbarr000000000000Convert-ASN1-0.26/lib/Convert=head1 NAME Convert::ASN1 - ASN.1 Encode/Decode library =head1 VERSION version 0.26 =head1 SYNOPSYS use Convert::ASN1; $asn = Convert::ASN1->new; $asn->prepare(q< [APPLICATION 7] SEQUENCE { int INTEGER, str OCTET STRING } >); $pdu = $asn->encode( int => 7, str => "string"); $out = $asn->decode($pdu); print $out->{int}," ",$out->{str},"\n"; use Convert::ASN1 qw(:io); $peer = asn_recv($sock,$buffer,0); $nbytes = asn_read($fh, $buffer); $nbytes = asn_send($sock, $buffer, $peer); $nbytes = asn_send($sock, $buffer); $nbytes = asn_write($fh, $buffer); $buffer = asn_get($fh); $yes = asn_ready($fh) =head1 DESCRIPTION Convert::ASN1 encodes and decodes ASN.1 data structures using BER/DER rules. =head1 METHODS =head2 new ( [OPTIONS] ) Contructor, creates a new object. If given, B are the same ones as for L below. =head2 error () Returns the last error. =head2 configure ( OPTIONS ) Configure options to control how Convert::ASN1 will perform various tasks. Options are passed as name-value pairs. =over 4 =item encode Reference to a hash which contains various encode options. =item decode Reference to a hash which contains various decode options. =item encoding One of 'BER' or 'DER'. The default is 'BER' =item tagdefault One of 'EXPLICIT' or 'IMPLICIT'. Default tagging conventions are normally given in the ASN.1 module definition (not supported by the parser). The ASN.1 spec states EXPLICIT tagging is the default, but this option has IMPLICIT tagging default for backward compatibility reasons. =back Encode options =over 4 =item real Which encoding to use for real's. One of 'binary', 'nr1', 'nr2', 'nr3' =item time This controls how UTCTime and GeneralizedTime elements are encoded. The default is C. =over 4 =item utctime The value passed will be encoded without a zone, ie a UTC value. =item withzone The value will be encoded with a zone. By default it will be encoded using the local time offset. The offset may be set using the C configure option. =item raw The value passed should already be in the correct format and will be copied into the PDU as-is. =back =item timezone By default UTCTime and GeneralizedTime will be encoded using the local time offset from UTC. This will over-ride that. It is an offset from UTC in seconds. This option can be overridden by passing a reference to a list of two values as the time value. The list should contain the time value and the offset from UTC in seconds. =item bigint If during encoding an value greater than 32 bits is discovered and is not already a big integer object, then the value will first be converted into a big integer object. This option controls the big integer class into which the objects will be blessed. The default 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. =over 4 =item utctime The value returned will be a time value as returned by the C