1#!/usr/local/bin/perl
2
3#
4# Misc tests from github reported issues
5#
6
7use Convert::ASN1;
8BEGIN { require './t/funcs.pl' }
9
10print "1..2\n";
11
12{    # github issue 8
13
14  my $hexdata = "30 53 30 51 30 4f 30 4d 30 4b 30 09 06 05 2b 0e
15                 03 02 1a 05 00 04 14 a0 72 0e a0 6a 7c 62 02 54
16                 f2 a8 f5 9d d2 7b a4 f3 b7 2f a4 04 14 b0 b0 4a
17                 fd 1c 75 28 f8 1c 61 aa 13 f6 fa c1 90 3d 6b 16
18                 a3 02 12 11 21 bc 57 28 6f 30 08 db 49 63 f6 ae
19                 89 3a de f6 d1 ff e0";
20  $hexdata =~ s/ //g;
21  $hexdata =~ s/\n//g;
22
23# parse ASN.1 descriptions
24  my $asn = Convert::ASN1->new;
25  $asn->prepare(<<ASN1) or die "prepare: ", $asn->error;
26  OCSPRequest     ::=     SEQUENCE {
27      tbsRequest                  TBSRequest,
28      optionalSignature   [0]     EXPLICIT ANY OPTIONAL }
29
30  TBSRequest      ::=     SEQUENCE {
31      version             [0]     EXPLICIT INTEGER OPTIONAL,
32      requestorName       [1]     EXPLICIT ANY OPTIONAL,
33      requestList                 SEQUENCE OF Request,
34      requestExtensions   [2]     EXPLICIT ANY OPTIONAL }
35
36  Request         ::=     SEQUENCE {
37      reqCert                     CertID,
38      singleRequestExtensions     [0] EXPLICIT ANY OPTIONAL }
39
40  CertID          ::=     SEQUENCE {
41      hashAlgorithm       ANY,
42      issuerNameHash      OCTET STRING, -- Hash of Issuer's DN
43      issuerKeyHash       OCTET STRING, -- Hash of Issuers public key
44      serialNumber        INTEGER }
45ASN1
46
47  my $asn_ocspreq = $asn->find('OCSPRequest');
48
49  my $OCSPREQDER = pack("H*", $hexdata);
50
51  my $ocspreq = $asn_ocspreq->decode($OCSPREQDER);
52  my $err = $asn_ocspreq->error;
53  $err =~ s/ at .*line \d.*//s if $err;
54  stest 1, "decode error 85 87", $err;
55
56  btest 2, !!$asn_ocspreq->decode(substr($OCSPREQDER, 0, -2));
57
58}
59
60
61