* Compute TCP-MD5 hash of an *INBOUND* TCP segment. * Parameters: * m pointer to head of mbuf chain * th pointer to TCP header * buf pointer to storage for computed MD5 digest * * Return 0 if successful, otherwise return -1. */
| 254 | * Return 0 if successful, otherwise return -1. |
| 255 | */ |
| 256 | static int |
| 257 | tcp_ipsec_input(struct mbuf *m, struct tcphdr *th, u_char *buf) |
| 258 | { |
| 259 | char tmpdigest[TCP_SIGLEN]; |
| 260 | struct secasindex saidx; |
| 261 | struct secasvar *sav; |
| 262 | |
| 263 | setsockaddrs(m, &saidx.src, &saidx.dst); |
| 264 | saidx.proto = IPPROTO_TCP; |
| 265 | saidx.mode = IPSEC_MODE_TCPMD5; |
| 266 | saidx.reqid = 0; |
| 267 | sav = key_allocsa_tcpmd5(&saidx); |
| 268 | if (sav == NULL) { |
| 269 | KMOD_TCPSTAT_INC(tcps_sig_err_buildsig); |
| 270 | return (EACCES); |
| 271 | } |
| 272 | /* |
| 273 | * tcp_input() operates with TCP header fields in host |
| 274 | * byte order. We expect them in network byte order. |
| 275 | */ |
| 276 | tcp_fields_to_net(th); |
| 277 | tcp_signature_compute(m, th, sav, tmpdigest); |
| 278 | tcp_fields_to_host(th); |
| 279 | key_freesav(&sav); |
| 280 | if (bcmp(buf, tmpdigest, TCP_SIGLEN) != 0) { |
| 281 | KMOD_TCPSTAT_INC(tcps_sig_rcvbadsig); |
| 282 | return (EACCES); |
| 283 | } |
| 284 | KMOD_TCPSTAT_INC(tcps_sig_rcvgoodsig); |
| 285 | return (0); |
| 286 | } |
| 287 | |
| 288 | /* |
| 289 | * Compute TCP-MD5 hash of an *OUTBOUND* TCP segment. |
nothing calls this directly
no test coverage detected