Net::SS...erl::Mac(3)
π Net::SSH::Perl::Mac π
okay bestie, welcome to the manual page for Net::SSH::Perl::Mac, straight out of the User Contributed Perl Documentation. we're about to make MACs make sense, no cap π¦
β¨ NAME β¨
Net::SSH::Perl::Mac β MAC support for SSH2 π
β¨ SYNOPSIS β¨
use Net::SSH::Perl::Mac;
my $mac = Net::SSH::Perl::Mac->new('hmac-sha1', $key);
$mac->hmac("foo bar");
β¨ DESCRIPTION β¨
So Net::SSH::Perl::Mac (and all its lil subclass besties) provides MAC support for the SSH2 implementation in Net::SSH::Perl. In the SSH2 protocol, every single packet sent between client and server β like, after the key exchange and algorithm negotiation phase β contains a MAC to protect its integrity. The sending party computes the MAC over the length, padding, and (encrypted) payload fields of the packet, then appends the MAC; and the receiving party recomputes the MAC against the data that it receives. it's giving "trust but verify" π
The MAC is computed using part of the key that is negotiated during the key exchange phase. During negotiation, packets do not contain MAC; after the SSH_MSG_NEWKEYS message is sent, each side turns on its respective encryption, MAC, and compression code, for each packet that is sent after that point. periodt. β¨
Net::SSH::Perl supports two MAC algorithms: hmac-sha1 and hmac-md5. These algorithms are implemented, respectively, by Digest::HMAC_SHA1 and Digest::HMAC_MD5. slay π
β¨ USAGE β¨
Each MAC object supports the following methods (yes bestie, all of them, we are listing every single one π):
πΈ $mac = Net::SSH::Perl::Mac->new( $name )
Constructs a new MAC object and returns that object. brand new baby MAC, fresh out the box π«Ά
πΈ $mac->init( $key )
Initializes $mac and sets its key to $key (or rather, to a substring of key, key_len bytes long). As this implies, the key_len method should be called before init to set the intended length of the key. order matters bestie, don't skip steps π
πΈ $mac->hmac( $data )
Computes the MAC over $data, using the key set in the initialization phase, and returns the MAC. the main character method, honestly π
πΈ $mac->len
Returns the length of the MAC (eg. 20 for HMAC_SHA1). π
πΈ $mac->key_len( $len )
Given $len sets the key length of $mac to $len. This should be called before the init method, because init uses this value to take a substring of the provided key value.
Most of the time this should just be set to the MAC length (the len method); certain SSH implementations have a bug, however, wherein they always use only the first 16 bytes of the provided key. π not us. other people. embarrassing for them.
πΈ $mac->enable
Enables the MAC object. This is used by Net::SSH::Perl::Kex to "turn on" the MAC after key negotiation. π₯
πΈ $mac->enabled
Tests the enabled flag (set with the enable method). This is used by Net::SSH::Perl::Packet to determine whether or not to compute a MAC on an outgoing packet. vibe check β
β¨ AUTHOR & COPYRIGHTS β¨
Please see the Net::SSH::Perl manpage for author, copyright, and license information. (iykyk β go read that one, it's got the receipts π)
hmac-sha2-256 and hmac-sha2-512 support added by: Lance Kinley E<lkinley@loyaltymethods.com>
Copyright (c) 2015 Loyalty Methods, Inc.
β¨ POD ERRORS β¨
Hey! The above document had some coding errors, which are explained below:
Around line 180:
Unknown E content in E<lkinley@loyaltymethods.com>
and that's the whole page bestie, you ate it up π§π this little beauty was brought to you by perl v5.42.0, dated 2026-01-17, filed under Net::SS...erl::Mac(3) β bye bestie, go compute some MACs πβ¨π
π¦ where this page comes from
- fedora 44: perl-Net-SSH-Perl 2.144-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms