keydata_65533.c revision 3d17a3ba61a303d5c4d9867068d0fbe9f24d2988
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
7e4d75a5daeaaf8a7f559f9bd7fbf540184e235cMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
7e4d75a5daeaaf8a7f559f9bd7fbf540184e235cMark Andrews * purpose with or without fee is hereby granted, provided that the above
7e4d75a5daeaaf8a7f559f9bd7fbf540184e235cMark Andrews * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15a44745412679c30a6d022733925af70a38b715David Lawrence * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15a44745412679c30a6d022733925af70a38b715David Lawrence * PERFORMANCE OF THIS SOFTWARE.
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews/* $Id: keydata_65533.c,v 1.3 2009/12/04 21:09:33 marka Exp $ */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews#define RRTYPE_KEYDATA_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC)
35c842e05dc6382ce1d9161a658d3ff4b2c3d4c9Bob Halley /* refresh timer */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ed71ea51c6ecb5d7d659b6e6a20f6b3f5c2678c6David Lawrence RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &refresh));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* add hold-down */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &addhd));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* remove hold-down */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &removehd));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETTOK(dns_keyflags_fromtext(&flags, &token.value.as_textregion));
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence /* protocol */
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence RETTOK(dns_secproto_fromtext(&proto, &token.value.as_textregion));
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence /* algorithm */
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* No Key? */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews return (isc_base64_tobuffer(lexer, target, -1));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews unsigned int flags;
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews unsigned char algorithm;
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews unsigned long when;
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* refresh timer */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* add hold-down */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* remove hold-down */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* protocol */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* algorithm */
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence /* No Key? */
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence RETERR(isc_base64_totext(&sr, tctx->width - 2,
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence if ((tctx->flags & DNS_STYLEFLAG_COMMENT) != 0)
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews if ((tctx->flags & DNS_STYLEFLAG_COMMENT) != 0) {
6add3af8397580475ab9fa10ac8c1269465cff87Mark Andrews /* Skip over refresh, addhd, and removehd */
6add3af8397580475ab9fa10ac8c1269465cff87Mark Andrews sprintf(buf, "%u", dst_region_computeid(&tmpr, algorithm));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews return (mem_tobuffer(target, sr.base, sr.length));
1a03b5e68553c37e9cc0097368909dfc37fb8cefMark Andrews return (mem_tobuffer(target, sr.base, sr.length));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrewsstatic inline int
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence /* Refresh timer */
ca81c3971cd0c9cfd830c0a18289d4d1b0f9de01David Lawrence RETERR(uint32_tobuffer(keydata->refresh, target));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* Add hold-down */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(uint32_tobuffer(keydata->addhd, target));
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence /* Remove hold-down */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(uint32_tobuffer(keydata->removehd, target));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(uint16_tobuffer(keydata->flags, target));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* Protocol */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(uint8_tobuffer(keydata->protocol, target));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* Algorithm */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews RETERR(uint8_tobuffer(keydata->algorithm, target));
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews return (mem_tobuffer(target, keydata->data, keydata->datalen));
ed71ea51c6ecb5d7d659b6e6a20f6b3f5c2678c6David Lawrence /* Refresh timer */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* Add hold-down */
347ccc2716b45b8c72a1021d7a74faab49d3eefaBrian Wellington /* Remove hold-down */
347ccc2716b45b8c72a1021d7a74faab49d3eefaBrian Wellington keydata->removehd = uint32_fromregion(&sr);
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* Protocol */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews /* Algorithm */
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews keydata->data = mem_maybedup(mctx, sr.base, keydata->datalen);
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrewsstatic inline void
ed71ea51c6ecb5d7d659b6e6a20f6b3f5c2678c6David Lawrence dns_rdata_keydata_t *keydata = (dns_rdata_keydata_t *) source;
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrewsstatic inline int
7d2b275f7e9238e2c709737601f6260b5a9a4ee1Mark Andrews#endif /* GENERIC_KEYDATA_65533_C */