1*b5677b36Schristos.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 2*b5677b36Schristos.\" Copyright (c) 1995-1999 by Internet Software Consortium 3*b5677b36Schristos.\" 4*b5677b36Schristos.\" Permission to use, copy, modify, and distribute this software for any 5*b5677b36Schristos.\" purpose with or without fee is hereby granted, provided that the above 6*b5677b36Schristos.\" copyright notice and this permission notice appear in all copies. 7*b5677b36Schristos.\" 8*b5677b36Schristos.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 9*b5677b36Schristos.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*b5677b36Schristos.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 11*b5677b36Schristos.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*b5677b36Schristos.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13*b5677b36Schristos.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 14*b5677b36Schristos.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*b5677b36Schristos.\" 16*b5677b36Schristos.\" Id: tsig.man3,v 1.2 2009/01/21 00:12:34 each Exp 17*b5677b36Schristos.\" 18*b5677b36Schristos.Dd January 1, 1996 19*b5677b36Schristos.Os BSD 4 20*b5677b36Schristos.Dt TSIG 21*b5677b36Schristos.Sh NAME 22*b5677b36Schristos.Nm ns_sign , 23*b5677b36Schristos.Nm ns_sign_tcp , 24*b5677b36Schristos.Nm ns_sign_tcp_init , 25*b5677b36Schristos.Nm ns_verify , 26*b5677b36Schristos.Nm ns_verify_tcp , 27*b5677b36Schristos.Nm ns_verify_tcp_init , 28*b5677b36Schristos.Nm ns_find_tsig 29*b5677b36Schristos.Nd TSIG system 30*b5677b36Schristos.Sh SYNOPSIS 31*b5677b36Schristos.Ft int 32*b5677b36Schristos.Fo ns_sign 33*b5677b36Schristos.Fa "u_char *msg" 34*b5677b36Schristos.Fa "int *msglen" 35*b5677b36Schristos.Fa "int msgsize" 36*b5677b36Schristos.Fa "int error" 37*b5677b36Schristos.Fa "void *k" 38*b5677b36Schristos.Fa "const u_char *querysig" 39*b5677b36Schristos.Fa "int querysiglen" 40*b5677b36Schristos.Fa "u_char *sig" 41*b5677b36Schristos.Fa "int *siglen" 42*b5677b36Schristos.Fa "time_t in_timesigned" 43*b5677b36Schristos.Fc 44*b5677b36Schristos.Ft int 45*b5677b36Schristos.Fn ns_sign_tcp "u_char *msg" "int *msglen" "int msgsize" "int error" \ 46*b5677b36Schristos "ns_tcp_tsig_state *state" "int done" 47*b5677b36Schristos.Ft int 48*b5677b36Schristos.Fn ns_sign_tcp_init "void *k" "const u_char *querysig" "int querysiglen" \ 49*b5677b36Schristos "ns_tcp_tsig_state *state" 50*b5677b36Schristos.Ft int 51*b5677b36Schristos.Fo ns_verify 52*b5677b36Schristos.Fa "u_char *msg" 53*b5677b36Schristos.Fa "int *msglen" 54*b5677b36Schristos.Fa "void *k" 55*b5677b36Schristos.Fa "const u_char *querysig" 56*b5677b36Schristos.Fa "int querysiglen" 57*b5677b36Schristos.Fa "u_char *sig" 58*b5677b36Schristos.Fa "int *siglen" 59*b5677b36Schristos.Fa "time_t in_timesigned" 60*b5677b36Schristos.Fa "int nostrip" 61*b5677b36Schristos.Fc 62*b5677b36Schristos.Ft int 63*b5677b36Schristos.Fn ns_verify_tcp "u_char *msg" "int *msglen" "ns_tcp_tsig_state *state" \ 64*b5677b36Schristos "int required" 65*b5677b36Schristos.Ft int 66*b5677b36Schristos.Fn ns_verify_tcp_init "void *k" "const u_char *querysig" "int querysiglen" \ 67*b5677b36Schristos "ns_tcp_tsig_state *state" 68*b5677b36Schristos.Ft u_char * 69*b5677b36Schristos.Fn ns_find_tsig "u_char *msg" "u_char *eom" 70*b5677b36Schristos.Sh DESCRIPTION 71*b5677b36SchristosThe TSIG routines are used to implement transaction/request security of 72*b5677b36SchristosDNS messages. 73*b5677b36Schristos.Pp 74*b5677b36Schristos.Fn ns_sign 75*b5677b36Schristosand 76*b5677b36Schristos.Fn ns_verify 77*b5677b36Schristosare the basic routines. 78*b5677b36Schristos.Fn ns_sign_tcp 79*b5677b36Schristosand 80*b5677b36Schristos.Fn ns_verify_tcp 81*b5677b36Schristosare used to sign/verify TCP messages that may be split into multiple packets, 82*b5677b36Schristossuch as zone transfers, and 83*b5677b36Schristos.Fn ns_sign_tcp_init , 84*b5677b36Schristos.Fn ns_verify_tcp_init 85*b5677b36Schristosinitialize the state structure necessary for TCP operations. 86*b5677b36Schristos.Fn ns_find_tsig 87*b5677b36Schristoslocates the TSIG record in a message, if one is present. 88*b5677b36Schristos.Pp 89*b5677b36Schristos.Fn ns_sign 90*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 91*b5677b36Schristos.It Dv msg 92*b5677b36Schristosthe incoming DNS message, which will be modified 93*b5677b36Schristos.It Dv msglen 94*b5677b36Schristosthe length of the DNS message, on input and output 95*b5677b36Schristos.It Dv msgsize 96*b5677b36Schristosthe size of the buffer containing the DNS message on input 97*b5677b36Schristos.It Dv error 98*b5677b36Schristosthe value to be placed in the TSIG error field 99*b5677b36Schristos.It Dv key 100*b5677b36Schristosthe (DST_KEY *) to sign the data 101*b5677b36Schristos.It Dv querysig 102*b5677b36Schristosfor a response, the signature contained in the query 103*b5677b36Schristos.It Dv querysiglen 104*b5677b36Schristosthe length of the query signature 105*b5677b36Schristos.It Dv sig 106*b5677b36Schristosa buffer to be filled with the generated signature 107*b5677b36Schristos.It Dv siglen 108*b5677b36Schristosthe length of the signature buffer on input, the signature length on output 109*b5677b36Schristos.El 110*b5677b36Schristos.Pp 111*b5677b36Schristos.Fn ns_sign_tcp 112*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 113*b5677b36Schristos.It Dv msg 114*b5677b36Schristosthe incoming DNS message, which will be modified 115*b5677b36Schristos.It Dv msglen 116*b5677b36Schristosthe length of the DNS message, on input and output 117*b5677b36Schristos.It Dv msgsize 118*b5677b36Schristosthe size of the buffer containing the DNS message on input 119*b5677b36Schristos.It Dv error 120*b5677b36Schristosthe value to be placed in the TSIG error field 121*b5677b36Schristos.It Dv state 122*b5677b36Schristosthe state of the operation 123*b5677b36Schristos.It Dv done 124*b5677b36Schristosnon-zero value signifies that this is the last packet 125*b5677b36Schristos.El 126*b5677b36Schristos.Pp 127*b5677b36Schristos.Fn ns_sign_tcp_init 128*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 129*b5677b36Schristos.It Dv k 130*b5677b36Schristosthe (DST_KEY *) to sign the data 131*b5677b36Schristos.It Dv querysig 132*b5677b36Schristosfor a response, the signature contained in the query 133*b5677b36Schristos.It Dv querysiglen 134*b5677b36Schristosthe length of the query signature 135*b5677b36Schristos.It Dv state 136*b5677b36Schristosthe state of the operation, which this initializes 137*b5677b36Schristos.El 138*b5677b36Schristos.Pp 139*b5677b36Schristos.Fn ns_verify 140*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 141*b5677b36Schristos.It Dv msg 142*b5677b36Schristosthe incoming DNS message, which will be modified 143*b5677b36Schristos.It Dv msglen 144*b5677b36Schristosthe length of the DNS message, on input and output 145*b5677b36Schristos.It Dv key 146*b5677b36Schristosthe (DST_KEY *) to sign the data 147*b5677b36Schristos.It Dv querysig 148*b5677b36Schristosfor a response, the signature contained in the query 149*b5677b36Schristos.It Dv querysiglen 150*b5677b36Schristosthe length of the query signature 151*b5677b36Schristos.It Dv sig 152*b5677b36Schristosa buffer to be filled with the signature contained 153*b5677b36Schristos.It Dv siglen 154*b5677b36Schristosthe length of the signature buffer on input, the signature length on output 155*b5677b36Schristos.It Dv nostrip 156*b5677b36Schristosnon-zero value means that the TSIG is left intact 157*b5677b36Schristos.El 158*b5677b36Schristos.Pp 159*b5677b36Schristos.Fn ns_verify_tcp 160*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 161*b5677b36Schristos.It Dv msg 162*b5677b36Schristosthe incoming DNS message, which will be modified 163*b5677b36Schristos.It Dv msglen 164*b5677b36Schristosthe length of the DNS message, on input and output 165*b5677b36Schristos.It Dv state 166*b5677b36Schristosthe state of the operation 167*b5677b36Schristos.It Dv required 168*b5677b36Schristosnon-zero value signifies that a TSIG record must be present at this step 169*b5677b36Schristos.El 170*b5677b36Schristos.Pp 171*b5677b36Schristos.Fn ns_verify_tcp_init 172*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 173*b5677b36Schristos.It Dv k 174*b5677b36Schristosthe (DST_KEY *) to verify the data 175*b5677b36Schristos.It Dv querysig 176*b5677b36Schristosfor a response, the signature contained in the query 177*b5677b36Schristos.It Dv querysiglen 178*b5677b36Schristosthe length of the query signature 179*b5677b36Schristos.It Dv state 180*b5677b36Schristosthe state of the operation, which this initializes 181*b5677b36Schristos.El 182*b5677b36Schristos.Pp 183*b5677b36Schristos.Fn ns_find_tsig 184*b5677b36Schristos.Bl -tag -width "in_timesigned" -compact -offset indent 185*b5677b36Schristos.It Dv msg 186*b5677b36Schristosthe incoming DNS message 187*b5677b36Schristos.It Dv msglen 188*b5677b36Schristosthe length of the DNS message 189*b5677b36Schristos.El 190*b5677b36Schristos.Sh RETURN VALUES 191*b5677b36Schristos.Fn ns_find_tsig 192*b5677b36Schristosreturns a pointer to the TSIG record if one is found, and NULL otherwise. 193*b5677b36Schristos.Pp 194*b5677b36SchristosAll other routines return 0 on success, modifying arguments when necessary. 195*b5677b36Schristos.Pp 196*b5677b36Schristos.Fn ns_sign 197*b5677b36Schristosand 198*b5677b36Schristos.Fn ns_sign_tcp 199*b5677b36Schristosreturn the following errors: 200*b5677b36Schristos.Bl -tag -width "NS_TSIG_ERROR_NO_SPACE" -compact -offset indent 201*b5677b36Schristos.It Dv (-1) 202*b5677b36Schristosbad input data 203*b5677b36Schristos.It Dv (-ns_r_badkey) 204*b5677b36SchristosThe key was invalid, or the signing failed 205*b5677b36Schristos.It Dv NS_TSIG_ERROR_NO_SPACE 206*b5677b36Schristosthe message buffer is too small. 207*b5677b36Schristos.El 208*b5677b36Schristos.Pp 209*b5677b36Schristos.Fn ns_verify 210*b5677b36Schristosand 211*b5677b36Schristos.Fn ns_verify_tcp 212*b5677b36Schristosreturn the following errors: 213*b5677b36Schristos.Bl -tag -width "NS_TSIG_ERROR_NO_SPACE" -compact -offset indent 214*b5677b36Schristos.It Dv (-1) 215*b5677b36Schristosbad input data 216*b5677b36Schristos.It Dv NS_TSIG_ERROR_FORMERR 217*b5677b36SchristosThe message is malformed 218*b5677b36Schristos.It Dv NS_TSIG_ERROR_NO_TSIG 219*b5677b36SchristosThe message does not contain a TSIG record 220*b5677b36Schristos.It Dv NS_TSIG_ERROR_ID_MISMATCH 221*b5677b36SchristosThe TSIG original ID field does not match the message ID 222*b5677b36Schristos.It Dv (-ns_r_badkey) 223*b5677b36SchristosVerification failed due to an invalid key 224*b5677b36Schristos.It Dv (-ns_r_badsig) 225*b5677b36SchristosVerification failed due to an invalid signature 226*b5677b36Schristos.It Dv (-ns_r_badtime) 227*b5677b36SchristosVerification failed due to an invalid timestamp 228*b5677b36Schristos.It Dv ns_r_badkey 229*b5677b36SchristosVerification succeeded but the message had an error of BADKEY 230*b5677b36Schristos.It Dv ns_r_badsig 231*b5677b36SchristosVerification succeeded but the message had an error of BADSIG 232*b5677b36Schristos.It Dv ns_r_badtime 233*b5677b36SchristosVerification succeeded but the message had an error of BADTIME 234*b5677b36Schristos.El 235*b5677b36Schristos.Pp 236*b5677b36Schristos.Sh SEE ALSO 237*b5677b36Schristos.Xr resolver 3 . 238*b5677b36Schristos.Sh AUTHORS 239*b5677b36SchristosBrian Wellington, TISLabs at Network Associates 240*b5677b36Schristos.\" .Sh BUGS 241