xform_ah.c revision 1.89
1/* $NetBSD: xform_ah.c,v 1.89 2018/04/16 17:32:34 maxv Exp $ */ 2/* $FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */ 3/* $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */ 4/* 5 * The authors of this code are John Ioannidis (ji@tla.org), 6 * Angelos D. Keromytis (kermit@csd.uch.gr) and 7 * Niels Provos (provos@physnet.uni-hamburg.de). 8 * 9 * The original version of this code was written by John Ioannidis 10 * for BSD/OS in Athens, Greece, in November 1995. 11 * 12 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, 13 * by Angelos D. Keromytis. 14 * 15 * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis 16 * and Niels Provos. 17 * 18 * Additional features in 1999 by Angelos D. Keromytis and Niklas Hallqvist. 19 * 20 * Copyright (c) 1995, 1996, 1997, 1998, 1999 by John Ioannidis, 21 * Angelos D. Keromytis and Niels Provos. 22 * Copyright (c) 1999 Niklas Hallqvist. 23 * Copyright (c) 2001 Angelos D. Keromytis. 24 * 25 * Permission to use, copy, and modify this software with or without fee 26 * is hereby granted, provided that this entire notice is included in 27 * all copies of any software which is or includes a copy or 28 * modification of this software. 29 * You may use this code under the GNU public license if you so wish. Please 30 * contribute changes back to the authors under this freer than GPL license 31 * so that we may further the use of strong encryption without limitations to 32 * all. 33 * 34 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 35 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY 36 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 37 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 38 * PURPOSE. 39 */ 40 41#include <sys/cdefs.h> 42__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.89 2018/04/16 17:32:34 maxv Exp $"); 43 44#if defined(_KERNEL_OPT) 45#include "opt_inet.h" 46#include "opt_ipsec.h" 47#endif 48 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/mbuf.h> 52#include <sys/socket.h> 53#include <sys/syslog.h> 54#include <sys/kernel.h> 55#include <sys/sysctl.h> 56#include <sys/pool.h> 57#include <sys/pserialize.h> 58#include <sys/kmem.h> 59 60#include <net/if.h> 61 62#include <netinet/in.h> 63#include <netinet/in_systm.h> 64#include <netinet/ip.h> 65#include <netinet/ip_ecn.h> 66#include <netinet/ip_var.h> 67#include <netinet/ip6.h> 68 69#include <net/route.h> 70#include <netipsec/ipsec.h> 71#include <netipsec/ipsec_private.h> 72#include <netipsec/ah.h> 73#include <netipsec/ah_var.h> 74#include <netipsec/xform.h> 75 76#ifdef INET6 77#include <netinet6/ip6_var.h> 78#include <netinet6/scope6_var.h> 79#include <netipsec/ipsec6.h> 80#endif 81 82#include <netipsec/key.h> 83#include <netipsec/key_debug.h> 84 85#include <opencrypto/cryptodev.h> 86 87/* 88 * Return header size in bytes. The old protocol did not support 89 * the replay counter; the new protocol always includes the counter. 90 */ 91#define HDRSIZE(sav) \ 92 (((sav)->flags & SADB_X_EXT_OLD) ? \ 93 sizeof(struct ah) : sizeof(struct ah) + sizeof(uint32_t)) 94/* 95 * Return authenticator size in bytes. The old protocol is known 96 * to use a fixed 16-byte authenticator. The new algorithm gets 97 * this size from the xform but is (currently) always 12. 98 */ 99#define AUTHSIZE(sav) \ 100 ((sav->flags & SADB_X_EXT_OLD) ? 16 : (sav)->tdb_authalgxform->authsize) 101 102percpu_t *ahstat_percpu; 103 104int ah_enable = 1; /* control flow of packets with AH */ 105int ip4_ah_cleartos = 1; /* clear ip_tos when doing AH calc */ 106 107static unsigned char ipseczeroes[256]; /* larger than an ip6 extension hdr */ 108 109int ah_max_authsize; /* max authsize over all algorithms */ 110 111static int ah_input_cb(struct cryptop *); 112static int ah_output_cb(struct cryptop *); 113 114const uint8_t ah_stats[256] = { SADB_AALG_STATS_INIT }; 115 116static pool_cache_t ah_tdb_crypto_pool_cache; 117static size_t ah_pool_item_size; 118 119/* 120 * NB: this is public for use by the PF_KEY support. 121 */ 122const struct auth_hash * 123ah_algorithm_lookup(int alg) 124{ 125 126 switch (alg) { 127 case SADB_X_AALG_NULL: 128 return &auth_hash_null; 129 case SADB_AALG_MD5HMAC: 130 return &auth_hash_hmac_md5_96; 131 case SADB_AALG_SHA1HMAC: 132 return &auth_hash_hmac_sha1_96; 133 case SADB_X_AALG_RIPEMD160HMAC: 134 return &auth_hash_hmac_ripemd_160_96; 135 case SADB_X_AALG_MD5: 136 return &auth_hash_key_md5; 137 case SADB_X_AALG_SHA: 138 return &auth_hash_key_sha1; 139 case SADB_X_AALG_SHA2_256: 140 return &auth_hash_hmac_sha2_256; 141 case SADB_X_AALG_SHA2_384: 142 return &auth_hash_hmac_sha2_384; 143 case SADB_X_AALG_SHA2_512: 144 return &auth_hash_hmac_sha2_512; 145 case SADB_X_AALG_AES_XCBC_MAC: 146 return &auth_hash_aes_xcbc_mac_96; 147 } 148 return NULL; 149} 150 151size_t 152ah_hdrsiz(const struct secasvar *sav) 153{ 154 size_t size; 155 156 if (sav != NULL) { 157 int authsize; 158 KASSERT(sav->tdb_authalgxform != NULL); 159 /*XXX not right for null algorithm--does it matter??*/ 160 authsize = AUTHSIZE(sav); 161 size = roundup(authsize, sizeof(uint32_t)) + HDRSIZE(sav); 162 } else { 163 /* default guess */ 164 size = sizeof(struct ah) + sizeof(uint32_t) + ah_max_authsize; 165 } 166 return size; 167} 168 169/* 170 * NB: public for use by esp_init. 171 */ 172int 173ah_init0(struct secasvar *sav, const struct xformsw *xsp, 174 struct cryptoini *cria) 175{ 176 const struct auth_hash *thash; 177 int keylen; 178 179 thash = ah_algorithm_lookup(sav->alg_auth); 180 if (thash == NULL) { 181 DPRINTF(("%s: unsupported authentication algorithm %u\n", 182 __func__, sav->alg_auth)); 183 return EINVAL; 184 } 185 /* 186 * Verify the replay state block allocation is consistent with 187 * the protocol type. We check here so we can make assumptions 188 * later during protocol processing. 189 */ 190 /* NB: replay state is setup elsewhere (sigh) */ 191 if (((sav->flags&SADB_X_EXT_OLD) == 0) ^ (sav->replay != NULL)) { 192 DPRINTF(("%s: replay state block inconsistency, " 193 "%s algorithm %s replay state\n", __func__, 194 (sav->flags & SADB_X_EXT_OLD) ? "old" : "new", 195 sav->replay == NULL ? "without" : "with")); 196 return EINVAL; 197 } 198 if (sav->key_auth == NULL) { 199 DPRINTF(("%s: no authentication key for %s algorithm\n", 200 __func__, thash->name)); 201 return EINVAL; 202 } 203 keylen = _KEYLEN(sav->key_auth); 204 if (keylen != thash->keysize && thash->keysize != 0) { 205 DPRINTF(("%s: invalid keylength %d, algorithm %s requires " 206 "keysize %d\n", __func__, 207 keylen, thash->name, thash->keysize)); 208 return EINVAL; 209 } 210 211 sav->tdb_xform = xsp; 212 sav->tdb_authalgxform = thash; 213 214 /* Initialize crypto session. */ 215 memset(cria, 0, sizeof(*cria)); 216 cria->cri_alg = sav->tdb_authalgxform->type; 217 cria->cri_klen = _KEYBITS(sav->key_auth); 218 cria->cri_key = _KEYBUF(sav->key_auth); 219 220 return 0; 221} 222 223/* 224 * ah_init() is called when an SPI is being set up. 225 */ 226static int 227ah_init(struct secasvar *sav, const struct xformsw *xsp) 228{ 229 struct cryptoini cria; 230 int error; 231 232 error = ah_init0(sav, xsp, &cria); 233 if (!error) 234 error = crypto_newsession(&sav->tdb_cryptoid, 235 &cria, crypto_support); 236 return error; 237} 238 239/* 240 * Paranoia. 241 * 242 * NB: public for use by esp_zeroize (XXX). 243 */ 244int 245ah_zeroize(struct secasvar *sav) 246{ 247 int err; 248 249 if (sav->key_auth) { 250 explicit_memset(_KEYBUF(sav->key_auth), 0, 251 _KEYLEN(sav->key_auth)); 252 } 253 254 err = crypto_freesession(sav->tdb_cryptoid); 255 sav->tdb_cryptoid = 0; 256 sav->tdb_authalgxform = NULL; 257 sav->tdb_xform = NULL; 258 return err; 259} 260 261/* 262 * Massage IPv4/IPv6 headers for AH processing. 263 */ 264static int 265ah_massage_headers(struct mbuf **m0, int proto, int skip, int alg, int out) 266{ 267 struct mbuf *m = *m0; 268 unsigned char *ptr; 269 int off, count; 270#ifdef INET 271 struct ip *ip; 272#endif 273#ifdef INET6 274 struct ip6_ext *ip6e; 275 struct ip6_hdr ip6; 276 struct ip6_rthdr *rh; 277 int alloc, ad, nxt; 278#endif 279 280 switch (proto) { 281#ifdef INET 282 case AF_INET: 283 /* 284 * This is the least painful way of dealing with IPv4 header 285 * and option processing -- just make sure they're in 286 * contiguous memory. 287 */ 288 *m0 = m = m_pullup(m, skip); 289 if (m == NULL) { 290 DPRINTF(("%s: m_pullup failed\n", __func__)); 291 return ENOBUFS; 292 } 293 294 /* Fix the IP header */ 295 ip = mtod(m, struct ip *); 296 if (ip4_ah_cleartos) 297 ip->ip_tos = 0; 298 ip->ip_ttl = 0; 299 ip->ip_sum = 0; 300 ip->ip_off = htons(ntohs(ip->ip_off) & ip4_ah_offsetmask); 301 302 if (alg == CRYPTO_MD5_KPDK || alg == CRYPTO_SHA1_KPDK) 303 ip->ip_off &= htons(IP_DF); 304 else 305 ip->ip_off = 0; 306 307 ptr = mtod(m, unsigned char *); 308 309 /* IPv4 option processing */ 310 for (off = sizeof(struct ip); off < skip;) { 311 if (ptr[off] == IPOPT_EOL || ptr[off] == IPOPT_NOP || 312 off + 1 < skip) 313 ; 314 else { 315 DPRINTF(("%s: illegal IPv4 option length for " 316 "option %d\n", __func__, ptr[off])); 317 318 m_freem(m); 319 return EINVAL; 320 } 321 322 switch (ptr[off]) { 323 case IPOPT_EOL: 324 off = skip; /* End the loop. */ 325 break; 326 327 case IPOPT_NOP: 328 off++; 329 break; 330 331 case IPOPT_SECURITY: /* 0x82 */ 332 case 0x85: /* Extended security. */ 333 case 0x86: /* Commercial security. */ 334 case 0x94: /* Router alert */ 335 case 0x95: /* RFC1770 */ 336 /* Sanity check for option length. */ 337 if (ptr[off + 1] < 2) { 338 DPRINTF(("%s: illegal IPv4 option " 339 "length for option %d\n", __func__, 340 ptr[off])); 341 342 m_freem(m); 343 return EINVAL; 344 } 345 346 off += ptr[off + 1]; 347 break; 348 349 case IPOPT_LSRR: 350 case IPOPT_SSRR: 351 /* Sanity check for option length. */ 352 if (ptr[off + 1] < 2) { 353 DPRINTF(("%s: illegal IPv4 option " 354 "length for option %d\n", __func__, 355 ptr[off])); 356 357 m_freem(m); 358 return EINVAL; 359 } 360 361 /* 362 * On output, if we have either of the 363 * source routing options, we should 364 * swap the destination address of the 365 * IP header with the last address 366 * specified in the option, as that is 367 * what the destination's IP header 368 * will look like. 369 */ 370 if (out) 371 memcpy(&ip->ip_dst, 372 ptr + off + ptr[off + 1] - 373 sizeof(struct in_addr), 374 sizeof(struct in_addr)); 375 376 /* Fall through */ 377 default: 378 /* Sanity check for option length. */ 379 if (ptr[off + 1] < 2) { 380 DPRINTF(("%s: illegal IPv4 option " 381 "length for option %d\n", __func__, 382 ptr[off])); 383 m_freem(m); 384 return EINVAL; 385 } 386 387 /* Zeroize all other options. */ 388 count = ptr[off + 1]; 389 memcpy(ptr + off, ipseczeroes, count); 390 off += count; 391 break; 392 } 393 394 /* Sanity check. */ 395 if (off > skip) { 396 DPRINTF(("%s: malformed IPv4 options header\n", 397 __func__)); 398 m_freem(m); 399 return EINVAL; 400 } 401 } 402 403 break; 404#endif /* INET */ 405 406#ifdef INET6 407 case AF_INET6: /* Ugly... */ 408 /* Copy and "cook" the IPv6 header. */ 409 m_copydata(m, 0, sizeof(ip6), &ip6); 410 411 /* We don't do IPv6 Jumbograms. */ 412 if (ip6.ip6_plen == 0) { 413 DPRINTF(("%s: unsupported IPv6 jumbogram\n", __func__)); 414 m_freem(m); 415 return EMSGSIZE; 416 } 417 418 ip6.ip6_flow = 0; 419 ip6.ip6_hlim = 0; 420 ip6.ip6_vfc &= ~IPV6_VERSION_MASK; 421 ip6.ip6_vfc |= IPV6_VERSION; 422 423 /* Scoped address handling. */ 424 if (IN6_IS_SCOPE_LINKLOCAL(&ip6.ip6_src)) 425 ip6.ip6_src.s6_addr16[1] = 0; 426 if (IN6_IS_SCOPE_LINKLOCAL(&ip6.ip6_dst)) 427 ip6.ip6_dst.s6_addr16[1] = 0; 428 429 /* Done with IPv6 header. */ 430 m_copyback(m, 0, sizeof(struct ip6_hdr), &ip6); 431 432 /* Let's deal with the remaining headers (if any). */ 433 if (skip - sizeof(struct ip6_hdr) > 0) { 434 if (m->m_len <= skip) { 435 ptr = malloc(skip - sizeof(struct ip6_hdr), 436 M_XDATA, M_NOWAIT); 437 if (ptr == NULL) { 438 DPRINTF(("%s: failed to allocate " 439 "memory for IPv6 headers\n", 440 __func__)); 441 m_freem(m); 442 return ENOBUFS; 443 } 444 445 /* 446 * Copy all the protocol headers after 447 * the IPv6 header. 448 */ 449 m_copydata(m, sizeof(struct ip6_hdr), 450 skip - sizeof(struct ip6_hdr), ptr); 451 alloc = 1; 452 } else { 453 /* No need to allocate memory. */ 454 ptr = mtod(m, unsigned char *) + 455 sizeof(struct ip6_hdr); 456 alloc = 0; 457 } 458 } else 459 break; 460 461 nxt = ip6.ip6_nxt & 0xff; /* Next header type. */ 462 463 for (off = 0; off < skip - sizeof(struct ip6_hdr);) { 464 int noff; 465 466 switch (nxt) { 467 case IPPROTO_HOPOPTS: 468 case IPPROTO_DSTOPTS: 469 ip6e = (struct ip6_ext *)(ptr + off); 470 noff = off + ((ip6e->ip6e_len + 1) << 3); 471 472 /* Sanity check. */ 473 if (noff > skip - sizeof(struct ip6_hdr)) { 474 goto error6; 475 } 476 477 /* 478 * Zero out mutable options. 479 */ 480 for (count = off + sizeof(struct ip6_ext); 481 count < noff;) { 482 if (ptr[count] == IP6OPT_PAD1) { 483 count++; 484 continue; 485 } 486 487 if (count + 1 >= noff) { 488 goto error6; 489 } 490 ad = ptr[count + 1] + 2; 491 492 if (count + ad > noff) { 493 goto error6; 494 } 495 496 if (ptr[count] & IP6OPT_MUTABLE) { 497 memset(ptr + count, 0, ad); 498 } 499 500 count += ad; 501 } 502 503 if (count != noff) { 504 goto error6; 505 } 506 507 /* Advance. */ 508 off += ((ip6e->ip6e_len + 1) << 3); 509 nxt = ip6e->ip6e_nxt; 510 break; 511 512 case IPPROTO_ROUTING: 513 /* 514 * Always include routing headers in 515 * computation. 516 */ 517 ip6e = (struct ip6_ext *)(ptr + off); 518 rh = (struct ip6_rthdr *)(ptr + off); 519 /* 520 * must adjust content to make it look like 521 * its final form (as seen at the final 522 * destination). 523 * we only know how to massage type 0 routing 524 * header. 525 */ 526 if (out && rh->ip6r_type == IPV6_RTHDR_TYPE_0) { 527 struct ip6_rthdr0 *rh0; 528 struct in6_addr *addr, finaldst; 529 int i; 530 531 rh0 = (struct ip6_rthdr0 *)rh; 532 addr = (struct in6_addr *)(rh0 + 1); 533 534 for (i = 0; i < rh0->ip6r0_segleft; i++) 535 in6_clearscope(&addr[i]); 536 537 finaldst = addr[rh0->ip6r0_segleft - 1]; 538 memmove(&addr[1], &addr[0], 539 sizeof(struct in6_addr) * 540 (rh0->ip6r0_segleft - 1)); 541 542 m_copydata(m, 0, sizeof(ip6), &ip6); 543 addr[0] = ip6.ip6_dst; 544 ip6.ip6_dst = finaldst; 545 m_copyback(m, 0, sizeof(ip6), &ip6); 546 547 rh0->ip6r0_segleft = 0; 548 } 549 550 /* advance */ 551 off += ((ip6e->ip6e_len + 1) << 3); 552 nxt = ip6e->ip6e_nxt; 553 break; 554 555 default: 556 DPRINTF(("%s: unexpected IPv6 header type %d\n", 557 __func__, off)); 558error6: 559 if (alloc) 560 free(ptr, M_XDATA); 561 m_freem(m); 562 return EINVAL; 563 } 564 } 565 566 /* Copyback and free, if we allocated. */ 567 if (alloc) { 568 m_copyback(m, sizeof(struct ip6_hdr), 569 skip - sizeof(struct ip6_hdr), ptr); 570 free(ptr, M_XDATA); 571 } 572 573 break; 574#endif /* INET6 */ 575 } 576 577 return 0; 578} 579 580/* 581 * ah_input() gets called to verify that an input packet 582 * passes authentication. 583 */ 584static int 585ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff) 586{ 587 const struct auth_hash *ahx; 588 struct tdb_crypto *tc = NULL; 589 struct newah *ah; 590 int hl, rplen, authsize, error, stat = AH_STAT_HDROPS; 591 struct cryptodesc *crda; 592 struct cryptop *crp = NULL; 593 bool pool_used; 594 uint8_t nxt; 595 596 IPSEC_SPLASSERT_SOFTNET(__func__); 597 598 KASSERT(sav != NULL); 599 KASSERT(sav->key_auth != NULL); 600 KASSERT(sav->tdb_authalgxform != NULL); 601 602 /* Figure out header size. */ 603 rplen = HDRSIZE(sav); 604 605 /* XXX don't pullup, just copy header */ 606 IP6_EXTHDR_GET(ah, struct newah *, m, skip, rplen); 607 if (ah == NULL) { 608 DPRINTF(("%s: cannot pullup header\n", __func__)); 609 error = ENOBUFS; 610 stat = AH_STAT_HDROPS; /*XXX*/ 611 goto bad; 612 } 613 614 nxt = ah->ah_nxt; 615 616 /* Check replay window, if applicable. */ 617 if (sav->replay && !ipsec_chkreplay(ntohl(ah->ah_seq), sav)) { 618 char buf[IPSEC_LOGSASTRLEN]; 619 DPRINTF(("%s: packet replay failure: %s\n", __func__, 620 ipsec_logsastr(sav, buf, sizeof(buf)))); 621 stat = AH_STAT_REPLAY; 622 error = ENOBUFS; 623 goto bad; 624 } 625 626 /* Verify AH header length. */ 627 hl = ah->ah_len * sizeof(uint32_t); 628 ahx = sav->tdb_authalgxform; 629 authsize = AUTHSIZE(sav); 630 if (hl != authsize + rplen - sizeof(struct ah)) { 631 char buf[IPSEC_ADDRSTRLEN]; 632 DPRINTF(("%s: bad authenticator length %u (expecting %lu)" 633 " for packet in SA %s/%08lx\n", __func__, 634 hl, (u_long) (authsize + rplen - sizeof(struct ah)), 635 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), 636 (u_long) ntohl(sav->spi))); 637 stat = AH_STAT_BADAUTHL; 638 error = EACCES; 639 goto bad; 640 } 641 if (skip + authsize + rplen > m->m_pkthdr.len) { 642 char buf[IPSEC_ADDRSTRLEN]; 643 DPRINTF(("%s: bad mbuf length %u (expecting >= %lu)" 644 " for packet in SA %s/%08lx\n", __func__, 645 m->m_pkthdr.len, (u_long)(skip + authsize + rplen), 646 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), 647 (u_long) ntohl(sav->spi))); 648 stat = AH_STAT_BADAUTHL; 649 error = EACCES; 650 goto bad; 651 } 652 653 AH_STATADD(AH_STAT_IBYTES, m->m_pkthdr.len - skip - hl); 654 655 /* Get crypto descriptors. */ 656 crp = crypto_getreq(1); 657 if (crp == NULL) { 658 DPRINTF(("%s: failed to acquire crypto descriptor\n", __func__)); 659 stat = AH_STAT_CRYPTO; 660 error = ENOBUFS; 661 goto bad; 662 } 663 664 crda = crp->crp_desc; 665 KASSERT(crda != NULL); 666 667 crda->crd_skip = 0; 668 crda->crd_len = m->m_pkthdr.len; 669 crda->crd_inject = skip + rplen; 670 671 /* Authentication operation. */ 672 crda->crd_alg = ahx->type; 673 crda->crd_key = _KEYBUF(sav->key_auth); 674 crda->crd_klen = _KEYBITS(sav->key_auth); 675 676 /* Allocate IPsec-specific opaque crypto info. */ 677 size_t size = sizeof(*tc); 678 size_t extra = skip + rplen + authsize; 679 size += extra; 680 681 if (__predict_true(size <= ah_pool_item_size)) { 682 tc = pool_cache_get(ah_tdb_crypto_pool_cache, PR_NOWAIT); 683 pool_used = true; 684 } else { 685 /* size can exceed on IPv6 packets with large options. */ 686 tc = kmem_intr_zalloc(size, KM_NOSLEEP); 687 pool_used = false; 688 } 689 if (tc == NULL) { 690 DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__)); 691 stat = AH_STAT_CRYPTO; 692 error = ENOBUFS; 693 goto bad; 694 } 695 696 error = m_makewritable(&m, 0, extra, M_NOWAIT); 697 if (error) { 698 DPRINTF(("%s: failed to m_makewritable\n", __func__)); 699 goto bad; 700 } 701 702 /* 703 * Save the authenticator, the skipped portion of the packet, 704 * and the AH header. 705 */ 706 m_copydata(m, 0, extra, (tc + 1)); 707 /* Zeroize the authenticator on the packet. */ 708 m_copyback(m, skip + rplen, authsize, ipseczeroes); 709 710 /* "Massage" the packet headers for crypto processing. */ 711 error = ah_massage_headers(&m, sav->sah->saidx.dst.sa.sa_family, 712 skip, ahx->type, 0); 713 if (error != 0) { 714 /* NB: mbuf is free'd by ah_massage_headers */ 715 m = NULL; 716 goto bad; 717 } 718 719 { 720 int s = pserialize_read_enter(); 721 722 /* 723 * Take another reference to the SA for opencrypto callback. 724 */ 725 if (__predict_false(sav->state == SADB_SASTATE_DEAD)) { 726 pserialize_read_exit(s); 727 stat = AH_STAT_NOTDB; 728 error = ENOENT; 729 goto bad; 730 } 731 KEY_SA_REF(sav); 732 pserialize_read_exit(s); 733 } 734 735 /* Crypto operation descriptor. */ 736 crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ 737 crp->crp_flags = CRYPTO_F_IMBUF; 738 crp->crp_buf = m; 739 crp->crp_callback = ah_input_cb; 740 crp->crp_sid = sav->tdb_cryptoid; 741 crp->crp_opaque = tc; 742 743 /* These are passed as-is to the callback. */ 744 tc->tc_spi = sav->spi; 745 tc->tc_dst = sav->sah->saidx.dst; 746 tc->tc_proto = sav->sah->saidx.proto; 747 tc->tc_nxt = nxt; 748 tc->tc_protoff = protoff; 749 tc->tc_skip = skip; 750 tc->tc_sav = sav; 751 752 DPRINTF(("%s: hash over %d bytes, skip %d: " 753 "crda len %d skip %d inject %d\n", __func__, 754 crp->crp_ilen, tc->tc_skip, 755 crda->crd_len, crda->crd_skip, crda->crd_inject)); 756 757 return crypto_dispatch(crp); 758 759bad: 760 if (tc != NULL) { 761 if (__predict_true(pool_used)) 762 pool_cache_put(ah_tdb_crypto_pool_cache, tc); 763 else 764 kmem_intr_free(tc, size); 765 } 766 if (crp != NULL) 767 crypto_freereq(crp); 768 if (m != NULL) 769 m_freem(m); 770 AH_STATINC(stat); 771 return error; 772} 773 774#ifdef INET6 775#define IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) do { \ 776 if (saidx->dst.sa.sa_family == AF_INET6) { \ 777 error = ipsec6_common_input_cb(m, sav, skip, protoff); \ 778 } else { \ 779 error = ipsec4_common_input_cb(m, sav, skip, protoff); \ 780 } \ 781} while (0) 782#else 783#define IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) \ 784 (error = ipsec4_common_input_cb(m, sav, skip, protoff)) 785#endif 786 787/* 788 * AH input callback from the crypto driver. 789 */ 790static int 791ah_input_cb(struct cryptop *crp) 792{ 793 char buf[IPSEC_ADDRSTRLEN]; 794 int rplen, error, skip, protoff; 795 unsigned char calc[AH_ALEN_MAX]; 796 struct mbuf *m; 797 struct tdb_crypto *tc; 798 struct secasvar *sav; 799 struct secasindex *saidx; 800 uint8_t nxt; 801 char *ptr; 802 int authsize; 803 uint16_t dport; 804 uint16_t sport; 805 bool pool_used; 806 size_t size; 807 IPSEC_DECLARE_LOCK_VARIABLE; 808 809 KASSERT(crp->crp_opaque != NULL); 810 tc = crp->crp_opaque; 811 skip = tc->tc_skip; 812 nxt = tc->tc_nxt; 813 protoff = tc->tc_protoff; 814 m = crp->crp_buf; 815 816 817 /* find the source port for NAT-T */ 818 nat_t_ports_get(m, &dport, &sport); 819 820 IPSEC_ACQUIRE_GLOBAL_LOCKS(); 821 822 sav = tc->tc_sav; 823 saidx = &sav->sah->saidx; 824 KASSERTMSG(saidx->dst.sa.sa_family == AF_INET || 825 saidx->dst.sa.sa_family == AF_INET6, 826 "unexpected protocol family %u", saidx->dst.sa.sa_family); 827 828 /* Figure out header size. */ 829 rplen = HDRSIZE(sav); 830 authsize = AUTHSIZE(sav); 831 832 size = sizeof(*tc) + skip + rplen + authsize; 833 if (__predict_true(size <= ah_pool_item_size)) 834 pool_used = true; 835 else 836 pool_used = false; 837 838 /* Check for crypto errors. */ 839 if (crp->crp_etype) { 840 if (sav->tdb_cryptoid != 0) 841 sav->tdb_cryptoid = crp->crp_sid; 842 843 if (crp->crp_etype == EAGAIN) { 844 IPSEC_RELEASE_GLOBAL_LOCKS(); 845 return crypto_dispatch(crp); 846 } 847 848 AH_STATINC(AH_STAT_NOXFORM); 849 DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); 850 error = crp->crp_etype; 851 goto bad; 852 } else { 853 AH_STATINC(AH_STAT_HIST + ah_stats[sav->alg_auth]); 854 crypto_freereq(crp); /* No longer needed. */ 855 crp = NULL; 856 } 857 858 if (ipsec_debug) 859 memset(calc, 0, sizeof(calc)); 860 861 /* Copy authenticator off the packet. */ 862 m_copydata(m, skip + rplen, authsize, calc); 863 864 ptr = (char *)(tc + 1); 865 const uint8_t *pppp = ptr + skip + rplen; 866 867 /* Verify authenticator. */ 868 if (!consttime_memequal(pppp, calc, authsize)) { 869 DPRINTF(("%s: authentication hash mismatch " \ 870 "over %d bytes " \ 871 "for packet in SA %s/%08lx:\n" \ 872 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x, " \ 873 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", 874 __func__, authsize, 875 ipsec_address(&saidx->dst, buf, sizeof(buf)), 876 (u_long) ntohl(sav->spi), 877 calc[0], calc[1], calc[2], calc[3], 878 calc[4], calc[5], calc[6], calc[7], 879 calc[8], calc[9], calc[10], calc[11], 880 pppp[0], pppp[1], pppp[2], pppp[3], 881 pppp[4], pppp[5], pppp[6], pppp[7], 882 pppp[8], pppp[9], pppp[10], pppp[11] 883 )); 884 AH_STATINC(AH_STAT_BADAUTH); 885 error = EACCES; 886 goto bad; 887 } 888 889 /* Fix the Next Protocol field. */ 890 ptr[protoff] = nxt; 891 892 /* Copyback the saved (uncooked) network headers. */ 893 m_copyback(m, 0, skip, ptr); 894 895 if (__predict_true(pool_used)) 896 pool_cache_put(ah_tdb_crypto_pool_cache, tc); 897 else 898 kmem_intr_free(tc, size); 899 tc = NULL; 900 901 /* 902 * Header is now authenticated. 903 */ 904 m->m_flags |= M_AUTHIPHDR|M_AUTHIPDGM; 905 906 /* 907 * Update replay sequence number, if appropriate. 908 */ 909 if (sav->replay) { 910 uint32_t seq; 911 912 m_copydata(m, skip + offsetof(struct newah, ah_seq), 913 sizeof(seq), &seq); 914 if (ipsec_updatereplay(ntohl(seq), sav)) { 915 AH_STATINC(AH_STAT_REPLAY); 916 error = ENOBUFS; /* XXX as above */ 917 goto bad; 918 } 919 } 920 921 /* 922 * Remove the AH header and authenticator from the mbuf. 923 */ 924 error = m_striphdr(m, skip, rplen + authsize); 925 if (error) { 926 DPRINTF(("%s: mangled mbuf chain for SA %s/%08lx\n", __func__, 927 ipsec_address(&saidx->dst, buf, sizeof(buf)), 928 (u_long) ntohl(sav->spi))); 929 930 AH_STATINC(AH_STAT_HDROPS); 931 goto bad; 932 } 933 934 IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff); 935 936 KEY_SA_UNREF(&sav); 937 IPSEC_RELEASE_GLOBAL_LOCKS(); 938 return error; 939 940bad: 941 if (sav) 942 KEY_SA_UNREF(&sav); 943 IPSEC_RELEASE_GLOBAL_LOCKS(); 944 if (m != NULL) 945 m_freem(m); 946 if (tc != NULL) { 947 if (pool_used) 948 pool_cache_put(ah_tdb_crypto_pool_cache, tc); 949 else 950 kmem_intr_free(tc, size); 951 } 952 if (crp != NULL) 953 crypto_freereq(crp); 954 return error; 955} 956 957/* 958 * AH output routine, called by ipsec[46]_process_packet(). 959 */ 960static int 961ah_output(struct mbuf *m, const struct ipsecrequest *isr, struct secasvar *sav, 962 struct mbuf **mp, int skip, int protoff) 963{ 964 char buf[IPSEC_ADDRSTRLEN]; 965 const struct auth_hash *ahx; 966 struct cryptodesc *crda; 967 struct tdb_crypto *tc; 968 struct mbuf *mi; 969 struct cryptop *crp; 970 uint16_t iplen; 971 int error, rplen, authsize, maxpacketsize, roff; 972 uint8_t prot; 973 struct newah *ah; 974 size_t ipoffs; 975 bool pool_used; 976 977 IPSEC_SPLASSERT_SOFTNET(__func__); 978 979 KASSERT(sav != NULL); 980 KASSERT(sav->tdb_authalgxform != NULL); 981 ahx = sav->tdb_authalgxform; 982 983 AH_STATINC(AH_STAT_OUTPUT); 984 985 /* Figure out header size. */ 986 rplen = HDRSIZE(sav); 987 988 /* Check for maximum packet size violations. */ 989 switch (sav->sah->saidx.dst.sa.sa_family) { 990#ifdef INET 991 case AF_INET: 992 maxpacketsize = IP_MAXPACKET; 993 ipoffs = offsetof(struct ip, ip_len); 994 break; 995#endif 996#ifdef INET6 997 case AF_INET6: 998 maxpacketsize = IPV6_MAXPACKET; 999 ipoffs = offsetof(struct ip6_hdr, ip6_plen); 1000 break; 1001#endif 1002 default: 1003 DPRINTF(("%s: unknown/unsupported protocol " 1004 "family %u, SA %s/%08lx\n", __func__, 1005 sav->sah->saidx.dst.sa.sa_family, 1006 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), 1007 (u_long) ntohl(sav->spi))); 1008 AH_STATINC(AH_STAT_NOPF); 1009 error = EPFNOSUPPORT; 1010 goto bad; 1011 } 1012 authsize = AUTHSIZE(sav); 1013 if (rplen + authsize + m->m_pkthdr.len > maxpacketsize) { 1014 DPRINTF(("%s: packet in SA %s/%08lx got too big " 1015 "(len %u, max len %u)\n", __func__, 1016 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), 1017 (u_long) ntohl(sav->spi), 1018 rplen + authsize + m->m_pkthdr.len, maxpacketsize)); 1019 AH_STATINC(AH_STAT_TOOBIG); 1020 error = EMSGSIZE; 1021 goto bad; 1022 } 1023 1024 /* Update the counters. */ 1025 AH_STATADD(AH_STAT_OBYTES, m->m_pkthdr.len - skip); 1026 1027 m = m_clone(m); 1028 if (m == NULL) { 1029 DPRINTF(("%s: cannot clone mbuf chain, SA %s/%08lx\n", __func__, 1030 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), 1031 (u_long) ntohl(sav->spi))); 1032 AH_STATINC(AH_STAT_HDROPS); 1033 error = ENOBUFS; 1034 goto bad; 1035 } 1036 1037 /* Inject AH header. */ 1038 mi = m_makespace(m, skip, rplen + authsize, &roff); 1039 if (mi == NULL) { 1040 DPRINTF(("%s: failed to inject %u byte AH header for SA " 1041 "%s/%08lx\n", __func__, 1042 rplen + authsize, 1043 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), 1044 (u_long) ntohl(sav->spi))); 1045 AH_STATINC(AH_STAT_HDROPS); 1046 error = ENOBUFS; 1047 goto bad; 1048 } 1049 1050 /* 1051 * The AH header is guaranteed by m_makespace() to be in 1052 * contiguous memory, at roff bytes offset into the returned mbuf. 1053 */ 1054 ah = (struct newah *)(mtod(mi, char *) + roff); 1055 1056 /* Initialize the AH header. */ 1057 m_copydata(m, protoff, sizeof(uint8_t), &ah->ah_nxt); 1058 ah->ah_len = (rplen + authsize - sizeof(struct ah)) / sizeof(uint32_t); 1059 ah->ah_reserve = 0; 1060 ah->ah_spi = sav->spi; 1061 1062 /* Zeroize authenticator. */ 1063 m_copyback(m, skip + rplen, authsize, ipseczeroes); 1064 1065 /* Insert packet replay counter, as requested. */ 1066 if (sav->replay) { 1067 if (sav->replay->count == ~0 && 1068 (sav->flags & SADB_X_EXT_CYCSEQ) == 0) { 1069 DPRINTF(("%s: replay counter wrapped for SA %s/%08lx\n", 1070 __func__, ipsec_address(&sav->sah->saidx.dst, buf, 1071 sizeof(buf)), (u_long) ntohl(sav->spi))); 1072 AH_STATINC(AH_STAT_WRAP); 1073 error = EINVAL; 1074 goto bad; 1075 } 1076#ifdef IPSEC_DEBUG 1077 /* Emulate replay attack when ipsec_replay is TRUE. */ 1078 if (!ipsec_replay) 1079#endif 1080 sav->replay->count++; 1081 ah->ah_seq = htonl(sav->replay->count); 1082 } 1083 1084 /* Get crypto descriptors. */ 1085 crp = crypto_getreq(1); 1086 if (crp == NULL) { 1087 DPRINTF(("%s: failed to acquire crypto descriptors\n", 1088 __func__)); 1089 AH_STATINC(AH_STAT_CRYPTO); 1090 error = ENOBUFS; 1091 goto bad; 1092 } 1093 1094 crda = crp->crp_desc; 1095 1096 crda->crd_skip = 0; 1097 crda->crd_inject = skip + rplen; 1098 crda->crd_len = m->m_pkthdr.len; 1099 1100 /* Authentication operation. */ 1101 crda->crd_alg = ahx->type; 1102 crda->crd_key = _KEYBUF(sav->key_auth); 1103 crda->crd_klen = _KEYBITS(sav->key_auth); 1104 1105 /* Allocate IPsec-specific opaque crypto info. */ 1106 size_t size = sizeof(*tc) + skip; 1107 1108 if (__predict_true(size <= ah_pool_item_size)) { 1109 tc = pool_cache_get(ah_tdb_crypto_pool_cache, PR_NOWAIT); 1110 pool_used = true; 1111 } else { 1112 /* size can exceed on IPv6 packets with large options. */ 1113 tc = kmem_intr_zalloc(size, KM_NOSLEEP); 1114 pool_used = false; 1115 } 1116 if (tc == NULL) { 1117 DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__)); 1118 AH_STATINC(AH_STAT_CRYPTO); 1119 error = ENOBUFS; 1120 goto bad_crp; 1121 } 1122 1123 uint8_t *pext = (char *)(tc + 1); 1124 /* Save the skipped portion of the packet. */ 1125 m_copydata(m, 0, skip, pext); 1126 1127 /* 1128 * Fix IP header length on the header used for 1129 * authentication. We don't need to fix the original 1130 * header length as it will be fixed by our caller. 1131 */ 1132 memcpy(&iplen, pext + ipoffs, sizeof(iplen)); 1133 iplen = htons(ntohs(iplen) + rplen + authsize); 1134 m_copyback(m, ipoffs, sizeof(iplen), &iplen); 1135 1136 /* Fix the Next Header field in saved header. */ 1137 pext[protoff] = IPPROTO_AH; 1138 1139 /* Update the Next Protocol field in the IP header. */ 1140 prot = IPPROTO_AH; 1141 m_copyback(m, protoff, sizeof(prot), &prot); 1142 1143 /* "Massage" the packet headers for crypto processing. */ 1144 error = ah_massage_headers(&m, sav->sah->saidx.dst.sa.sa_family, 1145 skip, ahx->type, 1); 1146 if (error != 0) { 1147 m = NULL; /* mbuf was free'd by ah_massage_headers. */ 1148 goto bad_tc; 1149 } 1150 1151 { 1152 int s = pserialize_read_enter(); 1153 1154 /* 1155 * Take another reference to the SP and the SA for opencrypto callback. 1156 */ 1157 if (__predict_false(isr->sp->state == IPSEC_SPSTATE_DEAD || 1158 sav->state == SADB_SASTATE_DEAD)) { 1159 pserialize_read_exit(s); 1160 AH_STATINC(AH_STAT_NOTDB); 1161 error = ENOENT; 1162 goto bad_tc; 1163 } 1164 KEY_SP_REF(isr->sp); 1165 KEY_SA_REF(sav); 1166 pserialize_read_exit(s); 1167 } 1168 1169 /* Crypto operation descriptor. */ 1170 crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ 1171 crp->crp_flags = CRYPTO_F_IMBUF; 1172 crp->crp_buf = m; 1173 crp->crp_callback = ah_output_cb; 1174 crp->crp_sid = sav->tdb_cryptoid; 1175 crp->crp_opaque = tc; 1176 1177 /* These are passed as-is to the callback. */ 1178 tc->tc_isr = isr; 1179 tc->tc_spi = sav->spi; 1180 tc->tc_dst = sav->sah->saidx.dst; 1181 tc->tc_proto = sav->sah->saidx.proto; 1182 tc->tc_skip = skip; 1183 tc->tc_protoff = protoff; 1184 tc->tc_sav = sav; 1185 1186 return crypto_dispatch(crp); 1187 1188bad_tc: 1189 if (__predict_true(pool_used)) 1190 pool_cache_put(ah_tdb_crypto_pool_cache, tc); 1191 else 1192 kmem_intr_free(tc, size); 1193bad_crp: 1194 crypto_freereq(crp); 1195bad: 1196 if (m) 1197 m_freem(m); 1198 return (error); 1199} 1200 1201/* 1202 * AH output callback from the crypto driver. 1203 */ 1204static int 1205ah_output_cb(struct cryptop *crp) 1206{ 1207 int skip, error; 1208 struct tdb_crypto *tc; 1209 const struct ipsecrequest *isr; 1210 struct secasvar *sav; 1211 struct mbuf *m; 1212 void *ptr; 1213 int err; 1214 size_t size; 1215 bool pool_used; 1216 IPSEC_DECLARE_LOCK_VARIABLE; 1217 1218 KASSERT(crp->crp_opaque != NULL); 1219 tc = crp->crp_opaque; 1220 skip = tc->tc_skip; 1221 ptr = (tc + 1); 1222 m = crp->crp_buf; 1223 size = sizeof(*tc) + skip; 1224 pool_used = size <= ah_pool_item_size; 1225 1226 IPSEC_ACQUIRE_GLOBAL_LOCKS(); 1227 1228 isr = tc->tc_isr; 1229 sav = tc->tc_sav; 1230 1231 /* Check for crypto errors. */ 1232 if (crp->crp_etype) { 1233 if (sav->tdb_cryptoid != 0) 1234 sav->tdb_cryptoid = crp->crp_sid; 1235 1236 if (crp->crp_etype == EAGAIN) { 1237 IPSEC_RELEASE_GLOBAL_LOCKS(); 1238 return crypto_dispatch(crp); 1239 } 1240 1241 AH_STATINC(AH_STAT_NOXFORM); 1242 DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); 1243 error = crp->crp_etype; 1244 goto bad; 1245 } 1246 1247 AH_STATINC(AH_STAT_HIST + ah_stats[sav->alg_auth]); 1248 1249 /* 1250 * Copy original headers (with the new protocol number) back 1251 * in place. 1252 */ 1253 m_copyback(m, 0, skip, ptr); 1254 1255 /* No longer needed. */ 1256 if (__predict_true(pool_used)) 1257 pool_cache_put(ah_tdb_crypto_pool_cache, tc); 1258 else 1259 kmem_intr_free(tc, size); 1260 crypto_freereq(crp); 1261 1262#ifdef IPSEC_DEBUG 1263 /* Emulate man-in-the-middle attack when ipsec_integrity is TRUE. */ 1264 if (ipsec_integrity) { 1265 int alen; 1266 1267 /* 1268 * Corrupt HMAC if we want to test integrity verification of 1269 * the other side. 1270 */ 1271 alen = AUTHSIZE(sav); 1272 m_copyback(m, m->m_pkthdr.len - alen, alen, ipseczeroes); 1273 } 1274#endif 1275 1276 /* NB: m is reclaimed by ipsec_process_done. */ 1277 err = ipsec_process_done(m, isr, sav); 1278 KEY_SA_UNREF(&sav); 1279 KEY_SP_UNREF(&isr->sp); 1280 IPSEC_RELEASE_GLOBAL_LOCKS(); 1281 return err; 1282bad: 1283 if (sav) 1284 KEY_SA_UNREF(&sav); 1285 KEY_SP_UNREF(&isr->sp); 1286 IPSEC_RELEASE_GLOBAL_LOCKS(); 1287 if (m) 1288 m_freem(m); 1289 if (__predict_true(pool_used)) 1290 pool_cache_put(ah_tdb_crypto_pool_cache, tc); 1291 else 1292 kmem_intr_free(tc, size); 1293 crypto_freereq(crp); 1294 return error; 1295} 1296 1297static struct xformsw ah_xformsw = { 1298 .xf_type = XF_AH, 1299 .xf_flags = XFT_AUTH, 1300 .xf_name = "IPsec AH", 1301 .xf_init = ah_init, 1302 .xf_zeroize = ah_zeroize, 1303 .xf_input = ah_input, 1304 .xf_output = ah_output, 1305 .xf_next = NULL, 1306}; 1307 1308void 1309ah_attach(void) 1310{ 1311 ahstat_percpu = percpu_alloc(sizeof(uint64_t) * AH_NSTATS); 1312 1313#define MAXAUTHSIZE(name) \ 1314 if ((auth_hash_ ## name).authsize > ah_max_authsize) \ 1315 ah_max_authsize = (auth_hash_ ## name).authsize 1316 1317 ah_max_authsize = 0; 1318 MAXAUTHSIZE(null); 1319 MAXAUTHSIZE(md5); 1320 MAXAUTHSIZE(sha1); 1321 MAXAUTHSIZE(key_md5); 1322 MAXAUTHSIZE(key_sha1); 1323 MAXAUTHSIZE(hmac_md5); 1324 MAXAUTHSIZE(hmac_sha1); 1325 MAXAUTHSIZE(hmac_ripemd_160); 1326 MAXAUTHSIZE(hmac_md5_96); 1327 MAXAUTHSIZE(hmac_sha1_96); 1328 MAXAUTHSIZE(hmac_ripemd_160_96); 1329 MAXAUTHSIZE(hmac_sha2_256); 1330 MAXAUTHSIZE(hmac_sha2_384); 1331 MAXAUTHSIZE(hmac_sha2_512); 1332 MAXAUTHSIZE(aes_xcbc_mac_96); 1333 MAXAUTHSIZE(gmac_aes_128); 1334 MAXAUTHSIZE(gmac_aes_192); 1335 MAXAUTHSIZE(gmac_aes_256); 1336 IPSECLOG(LOG_DEBUG, "ah_max_authsize=%d\n", ah_max_authsize); 1337 1338#undef MAXAUTHSIZE 1339 1340 ah_pool_item_size = sizeof(struct tdb_crypto) + 1341 sizeof(struct ip) + MAX_IPOPTLEN + 1342 sizeof(struct ah) + sizeof(uint32_t) + ah_max_authsize; 1343 ah_tdb_crypto_pool_cache = pool_cache_init(ah_pool_item_size, 1344 coherency_unit, 0, 0, "ah_tdb_crypto", NULL, IPL_SOFTNET, 1345 NULL, NULL, NULL); 1346 1347 xform_register(&ah_xformsw); 1348} 1349