]> andersk Git - gssapi-openssh.git/blob - openssh/makegssname.pl
openssh-3.6.1p2-gssapi-20030430.diff from Simon
[gssapi-openssh.git] / openssh / makegssname.pl
1 #!/usr/bin/perl
2
3 use Convert::ASN1 qw(:tag);
4 use Digest::MD5 qw(md5);
5 use MIME::Base64;
6 use Data::Dumper;
7  
8 $oid=shift;
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));
14
15 @entries=unpack("C*",$encoded);
16
17 print "DER representation: ";
18 foreach $entry (@entries) {
19   print "\\x";
20   printf "%02X",$entry;
21 }
22 print "\n";
23
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";
30
31 sub encode_object_id {
32   $string="";
33
34   my @data = ($_[0] =~ /(\d+)/g);
35
36   if(@data < 2) {
37       @data = (0);
38   }
39   else {
40       my $first = $data[1] + ($data[0] * 40);
41       splice(@data,0,2,$first);
42   }
43
44 #  my $l = length $string;
45   $string .= pack("cw*", 0, @data);
46 #  substr($string,$l,1) = asn_encode_length(length($string) - $l - 1);
47   return $string;
48 }
49
50
This page took 0.041832 seconds and 5 git commands to generate.