code: def _tls_hmac_add(self, hdr, msg):
          
          write_seq_num = struct.pack("!Q", self.tls_session.wcs.seq_num)
          self.tls_session.wcs.seq_num += 1
  
          alg = self.tls_session.wcs.hmac
          version = struct.unpack("!H", hdr[1:3])[0]
          if version > 0x300:
              h = alg.digest(write_seq_num + hdr + msg)
          elif version == 0x300:
              h = alg.digest_sslv3(write_seq_num + hdr[:1] + hdr[3:5] + msg)
          else:
              raise Exception("Unrecognized version.")
          return msg + h
docs: Provided with the record header (concatenation of the TLSCompressed
          type, version and length fields) and the TLSCompressed.fragment,
          return the concatenation of the TLSCompressed.fragment and the HMAC.
  
          Meant to be used with a block cipher or a stream cipher.
          It would fail with an AEAD cipher, because wcs.hmac would be None.
          See RFC 5246, section 6.2.3.