3 use Convert::ASN1 qw(:tag);
4 use Digest::MD5 qw(md5);
9 my $asn=Convert::ASN1->new;
10 $asn->prepare("oid OBJECT IDENTIFIER");
11 $encoded=$asn->encode(oid => $oid);
12 Convert::ASN1::asn_dump($encoded);
13 print Dumper($asn->decode($encoded));
15 @entries=unpack("C*",$encoded);
17 print "DER representation: ";
18 foreach $entry (@entries) {
24 $digest = md5($encoded);
25 # We only want the first 10 characters;
26 # Conversations with the authors suggest that we want to use all of the
27 # characters of the digest.
28 #$digest = substr($digest,0,10);
29 print "gsskeyex representation: ",encode_base64($digest),"\n";
31 sub encode_object_id {
34 my @data = ($_[0] =~ /(\d+)/g);
40 my $first = $data[1] + ($data[0] * 40);
41 splice(@data,0,2,$first);
44 # my $l = length $string;
45 $string .= pack("cw*", 0, @data);
46 # substr($string,$l,1) = asn_encode_length(length($string) - $l - 1);