/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999 by Internet Software Consortium, Inc.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef lint
#endif
/* Import. */
#include "port_before.h"
#include "fd_setsize.h"
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <isc/assertions.h>
#include "port_after.h"
do { \
return(NS_TSIG_ERROR_NO_SPACE); \
} \
} while (0)
/*%
* ns_sign
*
* Parameters:
*\li msg message to be sent
*\li msglen input - length of message
* output - length of signed message
*\li msgsize length of buffer containing message
*\li error value to put in the error field
*\li key tsig key used for signing
*\li querysig (response), the signature in the query
*\li querysiglen (response), the length of the signature in the query
*\li sig a buffer to hold the generated signature
*\li siglen input - length of signature buffer
* output - length of signature
*
* Errors:
*\li - bad input data (-1)
*\li - bad key / sign failed (-BADKEY)
*\li - not enough space (NS_TSIG_ERROR_NO_SPACE)
*/
int
{
}
int
{
int n;
dst_init();
return (-1);
/* Name. */
if (n != -1)
} else {
if (n != -1)
}
if (n < 0)
return (NS_TSIG_ERROR_NO_SPACE);
cp += n;
/* Type, class, ttl, length (not filled in yet). */
cp += 2;
/* Alg. */
return (-ns_r_badkey);
}
else
if (n < 0)
return (NS_TSIG_ERROR_NO_SPACE);
cp += n;
/* Time. */
if (error != ns_r_badtime)
else
/* Compute the signature. */
void *ctx;
int n;
/* Digest the query signature, if this is a response. */
}
/* Digest the message. */
NULL, 0);
/* Digest the key name. */
INSIST(n > 0);
/* Digest the class and TTL. */
NULL, 0);
/* Digest the algorithm. */
INSIST(n > 0);
/* Digest the time signed, fudge, error, and other data */
if (error != ns_r_badtime)
else
if (error != ns_r_badtime)
else {
}
NULL, 0);
if (n < 0)
return (-ns_r_badkey);
*siglen = n;
} else
*siglen = 0;
/* Add the signature. */
/* The original message ID & error. */
/* Other data. */
if (error != ns_r_badtime)
else {
}
/* Go back and fill in the length. */
return (0);
}
int
{
dst_init();
return (-1);
return (-ns_r_badkey);
return (-1);
return (0);
}
int
{
}
int
{
int n;
return (-1);
}
NULL, 0);
return (0);
/* Name. */
if (n < 0)
return (NS_TSIG_ERROR_NO_SPACE);
cp += n;
/* Type, class, ttl, length (not filled in yet). */
cp += 2;
/* Alg. */
if (n < 0)
return (NS_TSIG_ERROR_NO_SPACE);
cp += n;
/* Time. */
/*
* Compute the signature.
*/
/* Digest the time signed and fudge. */
if (n < 0)
return (-ns_r_badkey);
/* Add the signature. */
/* The original message ID & error. */
/* Other data. */
/* Go back and fill in the length. */
return (0);
}
/*! \file */