diff options
author | Ted Lemon <source@isc.org> | 2001-01-16 22:34:47 +0000 |
---|---|---|
committer | Ted Lemon <source@isc.org> | 2001-01-16 22:34:47 +0000 |
commit | 5abf0a44199693867fc2eb278dd9298364cc46f6 (patch) | |
tree | c7fcb801a7a6ee628ed6840a1b7f5f5b0a8e866e /minires/ns_sign.c | |
parent | 948274cfe71b1fb709018a2b4b7ed892b49e5547 (diff) | |
download | isc-dhcp-5abf0a44199693867fc2eb278dd9298364cc46f6.tar.gz |
Use ISC result codes instead of NS rcodes to report update errors.
Diffstat (limited to 'minires/ns_sign.c')
-rw-r--r-- | minires/ns_sign.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/minires/ns_sign.c b/minires/ns_sign.c index 60d9693d..641751f5 100644 --- a/minires/ns_sign.c +++ b/minires/ns_sign.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2000/02/02 19:59:15 mellon Exp $"; +static const char rcsid[] = "$Id: ns_sign.c,v 1.3 2001/01/16 22:33:10 mellon Exp $"; #endif /* Import. */ @@ -44,8 +44,7 @@ static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2000/02/02 19:59:15 mellon Exp #define BOUNDS_CHECK(ptr, count) \ do { \ if ((ptr) + (count) > eob) { \ - errno = EMSGSIZE; \ - return(NS_TSIG_ERROR_NO_SPACE); \ + return ISC_R_NOSPACE; \ } \ } while (0) @@ -68,7 +67,7 @@ static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2000/02/02 19:59:15 mellon Exp * - bad key / sign failed (-BADKEY) * - not enough space (NS_TSIG_ERROR_NO_SPACE) */ -int +isc_result_t ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k, const u_char *querysig, unsigned querysiglen, u_char *sig, unsigned *siglen, time_t in_timesigned) @@ -83,7 +82,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k, dst_init(); if (msg == NULL || msglen == NULL || sig == NULL || siglen == NULL) - return (-1); + ISC_R_INVALIDARG; /* Name. */ if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) @@ -92,7 +91,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k, else n = dn_comp("", cp, (unsigned)(eob - cp), NULL, NULL); if (n < 0) - return (NS_TSIG_ERROR_NO_SPACE); + return ISC_R_NOSPACE; name = cp; cp += n; @@ -107,14 +106,14 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k, /* Alg. */ if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) { if (key->dk_alg != KEY_HMAC_MD5) - return (-ns_r_badkey); + return ISC_R_BADKEY; n = dn_comp(NS_TSIG_ALG_HMAC_MD5, cp, (unsigned)(eob - cp), NULL, NULL); } else n = dn_comp("", cp, (unsigned)(eob - cp), NULL, NULL); if (n < 0) - return (NS_TSIG_ERROR_NO_SPACE); + ISC_R_NOSPACE; alg = cp; cp += n; @@ -186,7 +185,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k, n = dst_sign_data(SIG_MODE_FINAL, key, &ctx, NULL, 0, sig, *siglen); if (n < 0) - return (-ns_r_badkey); + ISC_R_BADKEY; *siglen = n; } else *siglen = 0; @@ -218,28 +217,29 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k, hp->arcount = htons(ntohs(hp->arcount) + 1); *msglen = (cp - msg); - return (0); + return ISC_R_SUCCESS; } -int +#if 0 +isc_result_t ns_sign_tcp_init(void *k, const u_char *querysig, unsigned querysiglen, ns_tcp_tsig_state *state) { dst_init(); if (state == NULL || k == NULL || querysig == NULL || querysiglen < 0) - return (-1); + return ISC_R_INVALIDARG; state->counter = -1; state->key = k; if (state->key->dk_alg != KEY_HMAC_MD5) - return (-ns_r_badkey); + return ISC_R_BADKEY; if (querysiglen > sizeof(state->sig)) - return (-1); + return ISC_R_NOSPACE; memcpy(state->sig, querysig, querysiglen); state->siglen = querysiglen; - return (0); + return ISC_R_SUCCESS; } -int +isc_result_t ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, ns_tcp_tsig_state *state, int done) { @@ -250,13 +250,13 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, int n; if (msg == NULL || msglen == NULL || state == NULL) - return (-1); + return ISC_R_INVALIDARG; state->counter++; if (state->counter == 0) - return (ns_sign(msg, msglen, msgsize, error, state->key, - state->sig, state->siglen, - state->sig, &state->siglen, 0)); + return ns_sign(msg, msglen, msgsize, error, state->key, + state->sig, state->siglen, + state->sig, &state->siglen, 0); if (state->siglen > 0) { u_int16_t siglen_n = htons(state->siglen); @@ -273,7 +273,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, NULL, 0); if (done == 0 && (state->counter % 100 != 0)) - return (0); + return ISC_R_SUCCESS; cp = msg + *msglen; eob = msg + msgsize; @@ -282,7 +282,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, n = dn_comp(state->key->dk_key_name, cp, (unsigned)(eob - cp), NULL, NULL); if (n < 0) - return (NS_TSIG_ERROR_NO_SPACE); + return ISC_R_NOSPACE; cp += n; /* Type, class, ttl, length (not filled in yet). */ @@ -297,7 +297,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, n = dn_comp(NS_TSIG_ALG_HMAC_MD5, cp, (unsigned)(eob - cp), NULL, NULL); if (n < 0) - return (NS_TSIG_ERROR_NO_SPACE); + return ISC_R_NOSPACE; cp += n; /* Time. */ @@ -323,7 +323,7 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, n = dst_sign_data(SIG_MODE_FINAL, state->key, &state->ctx, NULL, 0, state->sig, sizeof(state->sig)); if (n < 0) - return (-ns_r_badkey); + return ISC_R_BADKEY; state->siglen = n; /* Add the signature. */ @@ -346,5 +346,6 @@ ns_sign_tcp(u_char *msg, unsigned *msglen, unsigned msgsize, int error, hp->arcount = htons(ntohs(hp->arcount) + 1); *msglen = (cp - msg); - return (0); + return ISC_R_SUCCESS; } +#endif |