ns_sign.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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:
* msg message to be sent
* msglen input - length of message
* output - length of signed message
* msgsize length of buffer containing message
* error value to put in the error field
* key tsig key used for signing
* querysig (response), the signature in the query
* querysiglen (response), the length of the signature in the query
* sig a buffer to hold the generated signature
* siglen input - length of signature buffer
* output - length of signature
*
* Errors:
* - bad input data (-1)
* - bad key / sign failed (-BADKEY)
* - 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);
}