In SSL literature, I've noticed the use of the term "ad-hoc MAC". I understand the meaning of MAC (Message Authentication Code) and how it works, but what does the term Ad-hoc MAC mean?
Ad hoc simply means:
Ad hoc is a Latin phrase meaning "for this". It generally signifies a solution designed for a specific problem or task, non-generalizable, and not intended to be able to be adapted to other purposes.
In security, using ad-hoc protocols is usually a bad thing. There are (now) well defined well-analyzed MAC protocols; e.g., HMAC (hash-based MAC) defined as:
HMAC(k, m) = H((k ^ opad) + H((k ^ ipad) ++ m)), where
H is a hash function (e.g., SHA128), opad is a block long hexadecimal constant
5c5c5c...5c, ipad is a
363636...36, k is the shared secret key (used to generate and validate the MAC),
^ is XOR,
+ is concatenation.
In SSLv3, the MAC described in section 18.104.22.168 at first glance looks like a HMAC:
The MAC is generated as: hash(MAC_write_secret + pad_2 + hash(MAC_write_secret + pad_1 + seq_num + SSLCompressed.type + SSLCompressed.length + SSLCompressed.fragment)); where "+" denotes concatenation. pad_1: The character 0x36 repeated 48 times for MD5 or 40 times for SHA. pad_2: The character 0x5c repeated 48 times for MD5 or 40 times for SHA.
but note XOR is never used -- its always concatenation. Note it is
H(k + opad + H(k + ipad + m)). Furthermore, the MAC write secret
k is simply
MD5(master_secret + SHA('A' + master_secret + ServerHello.random + ClientHello.random)) in the case of MD5 being the hash. It's quite possible that these non-standard constructions leak information to very powerful attackers.
Ad hoc use of message authentication codes: there are MAC constructions that have not been subject to analysis such as HMAC. Wagner and Schneier don't have any specific objections to them but the point is valid: it's better to use something that has withstood a fair amount of analysis than something that hasn't, particularly in fielded systems.
Granted going back to Wagner and Schneier's paper (PDF), it seems that SSLv3 is just using an old version of HMAC that was obsolete in 1996:
SSL protects the integrity of application data by using a cryptographic MAC. The SSL designers have chosen to use HMAC, a simple, fast hash-based construction with some strong theoretical evidence for its security [BCK96]. In an area where several initial ad-hoc proposals for MACs have been cryptanalyzed, these provable security results are very attractive. HMAC is rapidly becoming the gold standard of message authentication, and it is an excellent choice for SSL. Barring major unexpected cryptanalytic advances, it seems unlikely that HMAC will be broken in the near future.
We point out the SSL 3.0 uses an older obsolete version of the HMAC construction. SSL should move to the updated current HMAC format when convenient for maximal security.
Ad-Hoc Communication is the process by which participating Nodes(Machines) can transfer data between them directly without a centralized server. MAC can refer to Medium Acces Control
MAC Code is a unique identification code assigned to devices communicating in adhoc mode to identify each other.
MAC can also refer to Message Authentication Code which is used to authenticate messages as well as to preserve integrity.Hashing and Encryption is used to achieve this.
So Adhoc MAC Means the Code used to authenticate messages between Nodes in an Adhoc network.