| 152 | |
| 153 | |
| 154 | class _TLSMACField(StrField): |
| 155 | def i2len(self, pkt, i): |
| 156 | if i is not None: |
| 157 | return len(i) |
| 158 | return pkt.tls_session.wcs.mac_len |
| 159 | |
| 160 | def i2m(self, pkt, x): |
| 161 | if x is None: |
| 162 | return b"" |
| 163 | return x |
| 164 | |
| 165 | def addfield(self, pkt, s, val): |
| 166 | # We add nothing here. This is done in .post_build() if needed. |
| 167 | return s |
| 168 | |
| 169 | def getfield(self, pkt, s): |
| 170 | if ( |
| 171 | pkt.tls_session.rcs.cipher.type != "aead" and |
| 172 | False in pkt.tls_session.rcs.cipher.ready.values() |
| 173 | ): |
| 174 | # XXX Find a more proper way to handle the still-encrypted case |
| 175 | return s, b"" |
| 176 | tmp_len = pkt.tls_session.rcs.mac_len |
| 177 | return s[tmp_len:], self.m2i(pkt, s[:tmp_len]) |
| 178 | |
| 179 | def i2repr(self, pkt, x): |
| 180 | # XXX Provide status when dissection has been performed successfully? |
| 181 | return repr(self.i2m(pkt, x)) |
| 182 | |
| 183 | |
| 184 | class _TLSPadField(StrField): |