11edba515SAndy Fiddaman.\" 21edba515SAndy Fiddaman.\" The contents of this file are subject to the terms of the Common 31edba515SAndy Fiddaman.\" Development and Distribution License (the "License"). You may not use 41edba515SAndy Fiddaman.\" this file except in compliance with the License. 51edba515SAndy Fiddaman.\" 61edba515SAndy Fiddaman.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or 71edba515SAndy Fiddaman.\" http://www.opensolaris.org/os/licensing. See the License for the 81edba515SAndy Fiddaman.\" specific language governing permissions and limitations under the 91edba515SAndy Fiddaman.\" License. 101edba515SAndy Fiddaman.\" 111edba515SAndy Fiddaman.\" When distributing Covered Code, include this CDDL HEADER in each file 121edba515SAndy Fiddaman.\" and include the License file at usr/src/OPENSOLARIS.LICENSE. If 131edba515SAndy Fiddaman.\" applicable, add the following below this CDDL HEADER, with the fields 141edba515SAndy Fiddaman.\" enclosed by brackets "[]" replaced with your own identifying 151edba515SAndy Fiddaman.\" information: Portions Copyright [yyyy] [name of copyright owner] 161edba515SAndy Fiddaman.\" 171edba515SAndy Fiddaman.\" Copyright (C) 2008, Sun Microsystems, Inc. All Rights Reserved 181edba515SAndy Fiddaman.\" Copyright 2024 Oxide Computer Company 191edba515SAndy Fiddaman.\" 20*c2cbc6b8SAndy Fiddaman.Dd August 14, 2024 211edba515SAndy Fiddaman.Dt TCPKEY 8 221edba515SAndy Fiddaman.Os 231edba515SAndy Fiddaman.Sh NAME 241edba515SAndy Fiddaman.Nm tcpkey 251edba515SAndy Fiddaman.Nd Manages the Security Association Database (SADB) for TCP 261edba515SAndy Fiddaman.Sh SYNOPSIS 271edba515SAndy Fiddaman.Nm 281edba515SAndy Fiddaman.Op Fl nvp 291edba515SAndy Fiddaman.Nm 301edba515SAndy Fiddaman.Op Fl nvp 311edba515SAndy Fiddaman.Fl f Ar filename 321edba515SAndy Fiddaman.Nm 331edba515SAndy Fiddaman.Fl c Ar filename 341edba515SAndy Fiddaman.Nm 351edba515SAndy Fiddaman.Op Fl nvp 361edba515SAndy Fiddaman.Cm get 371edba515SAndy Fiddaman.Brq Ar Extension value Ns No \&... 381edba515SAndy Fiddaman.Nm 391edba515SAndy Fiddaman.Op Fl nvp 401edba515SAndy Fiddaman.Cm delete 411edba515SAndy Fiddaman.Brq Ar Extension value Ns No \&... 421edba515SAndy Fiddaman.Nm 431edba515SAndy Fiddaman.Op Fl nvp 441edba515SAndy Fiddaman.Cm flush 451edba515SAndy Fiddaman.Nm 461edba515SAndy Fiddaman.Op Fl nvp 471edba515SAndy Fiddaman.Cm dump 481edba515SAndy Fiddaman.Nm 491edba515SAndy Fiddaman.Op Fl nvp 501edba515SAndy Fiddaman.Cm save 511edba515SAndy Fiddaman.Op Ar filename 521edba515SAndy Fiddaman.Sh DESCRIPTION 531edba515SAndy FiddamanThe 541edba515SAndy Fiddaman.Nm 551edba515SAndy Fiddamancommand is used to manually manipulate the 561edba515SAndy Fiddaman.Xr tcp 4P 57*c2cbc6b8SAndy Fiddamansecurity association 58*c2cbc6b8SAndy Fiddaman.Pq SA 59*c2cbc6b8SAndy Fiddamandatabase. 60*c2cbc6b8SAndy Fiddaman.Pp 61*c2cbc6b8SAndy FiddamanTCP SAs are in one of three states: 62*c2cbc6b8SAndy Fiddaman.Bl -tag -width indent 63*c2cbc6b8SAndy Fiddaman.It Sy mature 64*c2cbc6b8SAndy FiddamanA newly added SA starts in the mature state and will remain there unless it 65*c2cbc6b8SAndy Fiddamanis configured with any limits on its lifetime. 66*c2cbc6b8SAndy Fiddaman.It Sy dying 67*c2cbc6b8SAndy FiddamanA mature SA which exceeds a soft lifetime limit will transition into the 68*c2cbc6b8SAndy Fiddaman.Sy dying 69*c2cbc6b8SAndy Fiddamanstate. 70*c2cbc6b8SAndy FiddamanThis state is informational only; the SA can continue to be used. 71*c2cbc6b8SAndy FiddamanA 72*c2cbc6b8SAndy Fiddaman.Sy dying 73*c2cbc6b8SAndy FiddamanSA can be moved back to the 74*c2cbc6b8SAndy Fiddaman.Sy mature 75*c2cbc6b8SAndy Fiddamanstate by updating its lifetime limits via the 76*c2cbc6b8SAndy Fiddaman.Ic update 77*c2cbc6b8SAndy Fiddamancommand, so that they are no longer exceeded. 78*c2cbc6b8SAndy FiddamanA 79*c2cbc6b8SAndy Fiddaman.Sy dying 80*c2cbc6b8SAndy FiddamanSA will transition to 81*c2cbc6b8SAndy Fiddaman.Sy dead 82*c2cbc6b8SAndy Fiddamanand be removed when it is either deleted via a 83*c2cbc6b8SAndy Fiddaman.Ic delete 84*c2cbc6b8SAndy Fiddamanor 85*c2cbc6b8SAndy Fiddaman.Ic flush 86*c2cbc6b8SAndy Fiddamancommand, or subsequently exceeds a hard lifetime limit. 87*c2cbc6b8SAndy Fiddaman.It Sy dead 88*c2cbc6b8SAndy FiddamanAn SA which exceeds a hard lifetime limit will transition into the 89*c2cbc6b8SAndy Fiddaman.Sy dead 90*c2cbc6b8SAndy Fiddamanstate, be unavailable for use on any new connections, and be removed from the 91*c2cbc6b8SAndy Fiddamansystem as soon as it is no longer used by any established TCP session. 92*c2cbc6b8SAndy Fiddaman.El 931edba515SAndy Fiddaman.Pp 941edba515SAndy FiddamanWhile the 951edba515SAndy Fiddaman.Nm 961edba515SAndy Fiddamanutility has only a limited number of general options, it supports a rich 971edba515SAndy Fiddamancommand language. 981edba515SAndy FiddamanThe user may specify requests to be delivered by means of a programmatic 991edba515SAndy Fiddamaninterface specific for manual keying. 1001edba515SAndy FiddamanSee 1011edba515SAndy Fiddaman.Xr pf_key 4P . 1021edba515SAndy FiddamanWhen 1031edba515SAndy Fiddaman.Nm 1041edba515SAndy Fiddamanis invoked with no arguments, it will enter an interactive mode which prints a 1051edba515SAndy Fiddamanprompt 1061edba515SAndy Fiddaman.Pq Dq tcpkey> 1071edba515SAndy Fiddamanto the standard output and accepts commands from the standard input until the 1081edba515SAndy Fiddamanend-of-file is reached. 1091edba515SAndy Fiddaman.Pp 1101edba515SAndy Fiddaman.Nm 1111edba515SAndy Fiddamanuses a 112*c2cbc6b8SAndy Fiddaman.Xr pf_key 4P 1131edba515SAndy Fiddamansocket and the message types 1141edba515SAndy Fiddaman.Dv SADB_ADD , 115*c2cbc6b8SAndy Fiddaman.Dv SADB_UPDATE , 1161edba515SAndy Fiddaman.Dv SADB_DELETE , 1171edba515SAndy Fiddaman.Dv SADB_GET 1181edba515SAndy Fiddamanand 1191edba515SAndy Fiddaman.Dv SADB_FLUSH . 1201edba515SAndy FiddamanThus, you must have the 1211edba515SAndy Fiddaman.Dv PRIV_SYS_IP_CONFIG 1221edba515SAndy Fiddamanprivilege to use this command. 1231edba515SAndy Fiddaman.Sh OPTIONS 1241edba515SAndy Fiddaman.Bl -tag -width Ds 1251edba515SAndy Fiddaman.It Fl c Op Ar filename 1261edba515SAndy FiddamanAnalogous to the 1271edba515SAndy Fiddaman.Fl f 1281edba515SAndy Fiddamanoption 1291edba515SAndy Fiddaman.Pq see following , 1301edba515SAndy Fiddamanexcept that the input is not executed but only checked for syntactical 1311edba515SAndy Fiddamancorrectness. 1321edba515SAndy FiddamanErrors are reported to 1331edba515SAndy Fiddaman.Dv stderr . 1341edba515SAndy FiddamanThis option is provided to debug configurations without making changes. 1351edba515SAndy Fiddaman.It Fl f Op Ar filename 1361edba515SAndy FiddamanRead commands from an input file, 1371edba515SAndy Fiddaman.Ar filename . 1381edba515SAndy FiddamanThe lines of the input file are identical to the command line language. 1391edba515SAndy FiddamanThe 1401edba515SAndy Fiddaman.Ic save 1411edba515SAndy Fiddamancommand can generate files readable by the 1421edba515SAndy Fiddaman.Fl f 1431edba515SAndy Fiddamanargument. 1441edba515SAndy Fiddaman.It Fl n 1451edba515SAndy FiddamanPrevent attempts to print host and network names symbolically when reporting 1461edba515SAndy Fiddamanactions. 1471edba515SAndy FiddamanThis is useful, for example, when all name servers are down or are otherwise 1481edba515SAndy Fiddamanunreachable. 1491edba515SAndy Fiddaman.It Fl p 1501edba515SAndy FiddamanParanoid. 1511edba515SAndy FiddamanDo not print any keying material, even if saving. 1521edba515SAndy FiddamanInstead of an actual hexadecimal digit, print an 1531edba515SAndy Fiddaman.Sq X 1541edba515SAndy Fiddamanwhen this flag is turned on. 1551edba515SAndy Fiddaman.It Fl v 1561edba515SAndy FiddamanVerbose. 1571edba515SAndy FiddamanPrint the messages being sent into the 158*c2cbc6b8SAndy Fiddaman.Xr pf_key 4P 1591edba515SAndy Fiddamansocket, and print raw seconds values for lifetimes. 1601edba515SAndy Fiddaman.El 1611edba515SAndy Fiddaman.Sh COMMANDS 1621edba515SAndy Fiddaman.Bl -tag -width Ds 1631edba515SAndy Fiddaman.It Ic add 1641edba515SAndy FiddamanAdd an SA. 165*c2cbc6b8SAndy FiddamanBecause it involves the transfer of keying material, this command and its 166*c2cbc6b8SAndy Fiddamanparameters cannot be passed in as arguments to 167*c2cbc6b8SAndy Fiddaman.Nm , 168*c2cbc6b8SAndy Fiddamanlest the keys be visible in 1691edba515SAndy Fiddaman.Xr ps 1 1701edba515SAndy Fiddamanoutput. 171*c2cbc6b8SAndy FiddamanIt can be used either from the interactive 172*c2cbc6b8SAndy Fiddaman.Sq tcpkey> 173*c2cbc6b8SAndy Fiddamanprompt or in a command file specified by the 1741edba515SAndy Fiddaman.Fl f 1751edba515SAndy Fiddamanoption. 1761edba515SAndy FiddamanThe 1771edba515SAndy Fiddaman.Ic add 1781edba515SAndy Fiddamancommand accepts all extension-value pairs described below. 179*c2cbc6b8SAndy Fiddaman.It Ic update 180*c2cbc6b8SAndy FiddamanUpdate SA lifetime extensions. 181*c2cbc6b8SAndy FiddamanLike 182*c2cbc6b8SAndy Fiddaman.Ic add 183*c2cbc6b8SAndy Fiddamanthis command can only be used either from the interactive 184*c2cbc6b8SAndy Fiddaman.Sq tcpkey> 185*c2cbc6b8SAndy Fiddamanprompt or in a command file specified by the 186*c2cbc6b8SAndy Fiddaman.Fl f 187*c2cbc6b8SAndy Fiddamanoption. 188*c2cbc6b8SAndy FiddamanThe 189*c2cbc6b8SAndy Fiddaman.Ic update 190*c2cbc6b8SAndy Fiddamancommand accepts all extension-value pairs described below with the exception 191*c2cbc6b8SAndy Fiddamanof those used to configure algorithm or keying material, which cannot be 192*c2cbc6b8SAndy Fiddamanchanged once an SA is established. 1931edba515SAndy Fiddaman.It Ic delete 1941edba515SAndy FiddamanDelete a specific SA. 1951edba515SAndy FiddamanThis command requires the 1961edba515SAndy Fiddaman.Sy src 1971edba515SAndy Fiddamanextension, and the 1981edba515SAndy Fiddaman.Sy dest 1991edba515SAndy Fiddamanextension. 2001edba515SAndy FiddamanIf the SA is in use, it will be marked for deletion and no longer used for new 2011edba515SAndy Fiddamanconnection setup. 202*c2cbc6b8SAndy FiddamanExisting connections will however continue to use it until they are closed. 2031edba515SAndy Fiddaman.It Ic get 2041edba515SAndy FiddamanLook up and display a security association. 2051edba515SAndy FiddamanLike 2061edba515SAndy Fiddaman.Ic delete , 2071edba515SAndy Fiddamanthis command only requires 2081edba515SAndy Fiddaman.Sy src 2091edba515SAndy Fiddamanand 2101edba515SAndy Fiddaman.Sy dest . 2111edba515SAndy Fiddaman.It Ic flush 2121edba515SAndy FiddamanRemove all SAs. 2131edba515SAndy Fiddaman.It Ic dump 2141edba515SAndy FiddamanWill display all SAs. 2151edba515SAndy FiddamanBecause of the large amount of data generated by this command, there is no 2161edba515SAndy Fiddamanguarantee that all SA information will be successfully delivered, or that this 2171edba515SAndy Fiddamancommand will even complete. 2181edba515SAndy Fiddaman.It Ic save 2191edba515SAndy FiddamanIs the command analog of the 2201edba515SAndy Fiddaman.Fl s 2211edba515SAndy Fiddamanoption. 2221edba515SAndy Fiddaman.It Sy help 2231edba515SAndy FiddamanPrints a brief summary of commands. 2241edba515SAndy Fiddaman.El 2251edba515SAndy Fiddaman.Sh EXTENSION VALUE TYPES 2261edba515SAndy FiddamanCommands like 2271edba515SAndy Fiddaman.Ic add , 2281edba515SAndy Fiddaman.Ic delete , 2291edba515SAndy Fiddaman.Ic get , 2301edba515SAndy Fiddamanand 2311edba515SAndy Fiddaman.Ic update 2321edba515SAndy Fiddamanrequire that certain extensions and associated values be specified. 2331edba515SAndy FiddamanThe extensions will be listed here, followed by the commands that use them, and 2341edba515SAndy Fiddamanthe commands that require them. 2351edba515SAndy Fiddaman.Pp 2361edba515SAndy Fiddaman.Bl -tag -width xxxxxxxxxxxxxxxxxxxx -compact 2371edba515SAndy Fiddaman.It Cm src Ar addr | name 2381edba515SAndy FiddamanSource address of the SA. 2391edba515SAndy Fiddaman.It Cm src6 Ar IPv6addr 2401edba515SAndy Fiddaman.Pp 2411edba515SAndy Fiddaman.It Cm dst Ar addr | name 2421edba515SAndy FiddamanDestination address of the SA. 2431edba515SAndy Fiddaman.It Cm dst6 Ar IPv6addr 2441edba515SAndy Fiddaman.Pp 2451edba515SAndy Fiddaman.It Cm sport Ar port 2461edba515SAndy FiddamanSource port number. 2471edba515SAndy FiddamanIf unspecified, the SA will match any source port. 2481edba515SAndy Fiddaman.Pp 2491edba515SAndy Fiddaman.It Cm dport Ar port 2501edba515SAndy FiddamanDestination port number. 2511edba515SAndy FiddamanIf unspecified, the SA will match any destination port. 2521edba515SAndy Fiddaman.Pp 2531edba515SAndy Fiddaman.It Cm authalg Ar algorithm 2541edba515SAndy FiddamanAuthentication algorithm. 2551edba515SAndy FiddamanThe only supported value is 2561edba515SAndy Fiddaman.Sq md5 . 2571edba515SAndy Fiddaman.It Cm authstring Ar string 2581edba515SAndy FiddamanAuthentication string. 2591edba515SAndy FiddamanOnly ASCII characters are supported and the authentication string must be no 2601edba515SAndy Fiddamanlonger than 80 characters. 2611edba515SAndy Fiddaman.El 262*c2cbc6b8SAndy Fiddaman.Pp 263*c2cbc6b8SAndy FiddamanThe next four extensions are lifetime extensions. 264*c2cbc6b8SAndy FiddamanThere are two varieties, 265*c2cbc6b8SAndy Fiddaman.Dq hard 266*c2cbc6b8SAndy Fiddamanand 267*c2cbc6b8SAndy Fiddaman.Dq soft . 268*c2cbc6b8SAndy FiddamanIf a hard lifetime expires, the SA will be deleted automatically by the system, 269*c2cbc6b8SAndy Fiddamanor marked for deletion and no longer used for new connection setup if it is 270*c2cbc6b8SAndy Fiddamanin use. 271*c2cbc6b8SAndy FiddamanExisting connections will continue to use the SA until they are closed. 272*c2cbc6b8SAndy FiddamanIf a soft lifetime expires, its state is downgraded to dying from mature. 273*c2cbc6b8SAndy FiddamanIn either case, an 274*c2cbc6b8SAndy Fiddaman.Dv SADB_EXPIRE 275*c2cbc6b8SAndy Fiddamanmessage will be queued by the system and transmitted upstream on the 276*c2cbc6b8SAndy Fiddaman.Xr pf_key 4P 277*c2cbc6b8SAndy Fiddamansocket the next time a downstream command is received. 278*c2cbc6b8SAndy FiddamanThe 279*c2cbc6b8SAndy Fiddaman.Xr ipseckey 8 280*c2cbc6b8SAndy Fiddaman.Ic monitor 281*c2cbc6b8SAndy Fiddamancommand to key allows you to view 282*c2cbc6b8SAndy Fiddaman.Dv SADB_EXPIRE 283*c2cbc6b8SAndy Fiddamanmessages. 284*c2cbc6b8SAndy Fiddaman.Pp 285*c2cbc6b8SAndy Fiddaman.Bl -tag -width xxxxxxxxxxxxxxxxxxxx -compact 286*c2cbc6b8SAndy Fiddaman.It Cm soft_addtime 287*c2cbc6b8SAndy Fiddaman.It Cm hard_addtime 288*c2cbc6b8SAndy FiddamanSpecifies the number of seconds that this SA can exist after being added. 289*c2cbc6b8SAndy FiddamanUpdating an SA does not reset the initial time that it was added. 290*c2cbc6b8SAndy FiddamanIf the system clock has been altered since the SA was established, you may need 291*c2cbc6b8SAndy Fiddamanto adjust the specified duration to achieve the desired outcome. 292*c2cbc6b8SAndy FiddamanIf this extension is not present, the default value is zero, which means the SA 293*c2cbc6b8SAndy Fiddamanwill not expire based on how long it has been since it was added. 294*c2cbc6b8SAndy FiddamanThis extension is used by the 295*c2cbc6b8SAndy Fiddaman.Ic add 296*c2cbc6b8SAndy Fiddamanand 297*c2cbc6b8SAndy Fiddaman.Ic update 298*c2cbc6b8SAndy Fiddamancommands. 299*c2cbc6b8SAndy Fiddaman.It Cm soft_usetime 300*c2cbc6b8SAndy Fiddaman.It Cm hard_usetime 301*c2cbc6b8SAndy FiddamanSpecifies the number of seconds this SA can exist after first being used. 302*c2cbc6b8SAndy FiddamanIf the system clock has been altered since the SA was first used, you may need 303*c2cbc6b8SAndy Fiddamanto adjust the specified duration to achieve the desired outcome. 304*c2cbc6b8SAndy FiddamanIf this extension is not present, the default value is zero, which means the SA 305*c2cbc6b8SAndy Fiddamanwill not expire based on how long it has been since it was first used. 306*c2cbc6b8SAndy FiddamanThis extension is used by the 307*c2cbc6b8SAndy Fiddaman.Ic add 308*c2cbc6b8SAndy Fiddamanand 309*c2cbc6b8SAndy Fiddaman.Ic update 310*c2cbc6b8SAndy Fiddamancommands. 311*c2cbc6b8SAndy Fiddaman.El 3121edba515SAndy Fiddaman.Sh FILES 3131edba515SAndy Fiddaman.Bl -tag -width Ds 3141edba515SAndy Fiddaman.It Pa /etc/inet/secret/tcpkeys 3151edba515SAndy FiddamanDefault configuration file used at boot time. 3161edba515SAndy Fiddaman.El 3171edba515SAndy Fiddaman.Sh EXAMPLES 3181edba515SAndy Fiddaman.Bl -tag -width 4 3191edba515SAndy Fiddaman.It Sy Example 1 No Empting Out All SAs 3201edba515SAndy Fiddaman.Bd -literal 3211edba515SAndy Fiddaman# tcpkey flush 3221edba515SAndy Fiddaman.Ed 3231edba515SAndy Fiddaman.It Sy Example 2 No Saving All SAs To Standard Output 3241edba515SAndy Fiddaman.Bd -literal 3251edba515SAndy Fiddaman# tcpkey save 3261edba515SAndy Fiddaman.Ed 3271edba515SAndy Fiddaman.It Sy Example 3 No Adding a pair of SAs 3281edba515SAndy Fiddaman.Pp 3291edba515SAndy FiddamanNote that the second SA specifies 179 as the 3301edba515SAndy Fiddaman.Em source 3311edba515SAndy Fiddamanport so that it matches reply traffic. 3321edba515SAndy Fiddaman.Bd -literal 3331edba515SAndy Fiddaman# tcpkey 3341edba515SAndy Fiddamantcpkey> add src 192.168.1.1 dst 192.168.1.2 dport 179 \e 3351edba515SAndy Fiddaman authalg md5 authstring s3kr1t 3361edba515SAndy Fiddamantcpkey> add src 192.168.1.2 dst 192.168.1.1 sport 179 \e 3371edba515SAndy Fiddaman authalg md5 authstring s3kr1t 3381edba515SAndy Fiddamantcpkey> exit 3391edba515SAndy Fiddaman.Ed 3401edba515SAndy Fiddaman.It Sy Example 4 No Displaying all SAs 3411edba515SAndy Fiddaman.Bd -literal 3421edba515SAndy Fiddaman# tcpkey dump 3431edba515SAndy FiddamanBase message (version 2) type DUMP, SA type TCPSIG. 3441edba515SAndy FiddamanMessage length 112 bytes, seq=5, pid=649091. 3451edba515SAndy FiddamanSRC: Source address (proto=6/tcp) 3461edba515SAndy FiddamanSRC: AF_INET6: port 0, ::ffff:192.168.1.1/32 (host.example.com). 3471edba515SAndy FiddamanDST: Destination address (proto=6/tcp) 3481edba515SAndy FiddamanDST: AF_INET6: port 179, ::ffff:192.168.1.2/32 <unknown>. 3491edba515SAndy FiddamanAST: Authentication string. 3501edba515SAndy FiddamanAST: "s3kr1t" 3511edba515SAndy Fiddaman.Ed 3521edba515SAndy Fiddaman.El 3531edba515SAndy Fiddaman.Sh INTERFACE STABILITY 3541edba515SAndy FiddamanThe command line interface of 3551edba515SAndy Fiddaman.Nm 3561edba515SAndy Fiddamanis 3571edba515SAndy Fiddaman.Sy Uncommitted . 3581edba515SAndy FiddamanThe command line interface of 3591edba515SAndy Fiddaman.Nm 3601edba515SAndy Fiddamanis 3611edba515SAndy Fiddaman.Sy Not-An-Interface 3621edba515SAndy Fiddamanand may change at any time. 3631edba515SAndy Fiddaman.Sh SEE ALSO 3641edba515SAndy Fiddaman.Xr ps 1 , 365*c2cbc6b8SAndy Fiddaman.Xr pf_key 4P , 3661edba515SAndy Fiddaman.Xr ipseckey 8 367