1Net::SSH::Perl::Mac(3)User Contributed Perl DocumentationNet::SSH::Perl::Mac(3)
2
3
4

NAME

6       Net::SSH::Perl::Mac - MAC support for SSH2
7

SYNOPSIS

9           use Net::SSH::Perl::Mac;
10           my $mac = Net::SSH::Perl::Mac->new('hmac-sha1', $key);
11           $mac->hmac("foo bar");
12

DESCRIPTION

14       Net::SSH::Perl::Mac (and its subclasses) provides MAC support for the
15       SSH2 implementation in Net::SSH::Perl. In the SSH2 protocol, each
16       packet sent between client and server (after the key exchange and algo‐
17       rithm negotiation phase) contains a MAC to protect its integrity. The
18       sending party computes the MAC over the length, padding, and
19       (encrypted) payload fields of the packet, then appends the MAC; and the
20       receiving party recomputes the MAC against the data that it receives.
21
22       The MAC is computed using part of the key that is negotiated during the
23       key exchange phase. During negotiation, packets do not contain MAC;
24       after the SSH_MSG_NEWKEYS message is sent, each side turns on its
25       respective encryption, MAC, and compression code, for each packet that
26       is sent after that point.
27
28       Net::SSH::Perl supports two MAC algorithms: hmac-sha1 and hmac-md5.
29       These algorithms are implemented, respectively, by Digest::HMAC_SHA1
30       and Digest::HMAC_MD5.
31

USAGE

33       Each MAC object supports the following methods:
34
35       $mac = Net::SSH::Perl::Mac->new( $name )
36
37       Constructs a new MAC object and returns that object.
38
39       $mac->init( $key )
40
41       Initializes $mac and sets its key to $key (or rather, to a substring of
42       key, key_len bytes long). As this implies, the key_len method should be
43       called before init to set the intended length of the key.
44
45       $mac->hmac( $data )
46
47       Computes the MAC over $data, using the key set in the initialization
48       phase, and returns the MAC.
49
50       $mac->len
51
52       Returns the length of the MAC (eg. 20 for HMAC_SHA1).
53
54       $mac->key_len( $len )
55
56       Given $len sets the key length of $mac to $len.  This should be called
57       before the init method, because init uses this value to take a sub‐
58       string of the provided key value.
59
60       Most of the time this should just be set to the MAC length (the len
61       method); certain SSH implementations have a bug, however, wherein they
62       always use only the first 16 bytes of the provided key.
63
64       $mac->enable
65
66       Enables the MAC object. This is used by Net::SSH::Perl::Kex to "turn
67       on" the MAC after key negotiation.
68
69       $mac->enabled
70
71       Tests the enabled flag (set with the enable method).  This is used by
72       Net::SSH::Perl::Packet to determine whether or not to compute a MAC on
73       an outgoing packet.
74

AUTHOR & COPYRIGHTS

76       Please see the Net::SSH::Perl manpage for author, copyright, and
77       license information.
78
79
80
81perl v5.8.8                       2003-12-03            Net::SSH::Perl::Mac(3)
Impressum