2014-11-04 12:24:39 +11:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2014-11-04 12:24:39 +11:00
|
|
|
*
|
2021-06-03 08:37:05 +02:00
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2020-09-14 16:20:40 -07:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2014-11-04 12:24:39 +11:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RDATA_GENERIC_OPENPGPKEY_61_C
|
|
|
|
#define RDATA_GENERIC_OPENPGPKEY_61_C
|
|
|
|
|
|
|
|
#define RRTYPE_OPENPGPKEY_ATTRIBUTES 0
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromtext_openpgpkey(ARGS_FROMTEXT) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(callbacks);
|
|
|
|
UNUSED(options);
|
|
|
|
UNUSED(origin);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keyring.
|
|
|
|
*/
|
2019-01-04 15:20:04 +11:00
|
|
|
return (isc_base64_tobuffer(lexer, target, -2));
|
2014-11-04 12:24:39 +11:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
totext_openpgpkey(ARGS_TOTEXT) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_region_t sr;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keyring
|
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
|
2014-11-04 17:02:32 +11:00
|
|
|
RETERR(str_totext("( ", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-11-04 17:02:32 +11:00
|
|
|
|
2014-11-04 12:24:39 +11:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_NOCRYPTO) == 0) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (tctx->width == 0) { /* No splitting */
|
2014-11-04 12:24:39 +11:00
|
|
|
RETERR(isc_base64_totext(&sr, 60, "", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2014-11-04 12:24:39 +11:00
|
|
|
RETERR(isc_base64_totext(&sr, tctx->width - 2,
|
|
|
|
tctx->linebreak, target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
} else {
|
2014-11-04 12:24:39 +11:00
|
|
|
RETERR(str_totext("[omitted]", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-11-04 12:24:39 +11:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
|
2014-11-04 12:24:39 +11:00
|
|
|
RETERR(str_totext(" )", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-11-04 12:24:39 +11:00
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromwire_openpgpkey(ARGS_FROMWIRE) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_region_t sr;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(dctx);
|
|
|
|
UNUSED(options);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keyring.
|
|
|
|
*/
|
|
|
|
isc_buffer_activeregion(source, &sr);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < 1) {
|
2015-08-11 20:01:44 -07:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_buffer_forward(source, sr.length);
|
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
towire_openpgpkey(ARGS_TOWIRE) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_region_t sr;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
|
|
|
UNUSED(cctx);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
compare_openpgpkey(ARGS_COMPARE) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata1->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
return (isc_region_compare(&r1, &r2));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromstruct_openpgpkey(ARGS_FROMSTRUCT) {
|
2014-11-04 12:24:39 +11:00
|
|
|
dns_rdata_openpgpkey_t *sig = source;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_openpgpkey);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(sig != NULL);
|
2014-11-04 12:24:39 +11:00
|
|
|
REQUIRE(sig->common.rdtype == type);
|
|
|
|
REQUIRE(sig->common.rdclass == rdclass);
|
|
|
|
REQUIRE(sig->keyring != NULL && sig->length != 0);
|
|
|
|
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keyring.
|
|
|
|
*/
|
|
|
|
return (mem_tobuffer(target, sig->keyring, sig->length));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
tostruct_openpgpkey(ARGS_TOSTRUCT) {
|
|
|
|
isc_region_t sr;
|
2014-11-04 12:24:39 +11:00
|
|
|
dns_rdata_openpgpkey_t *sig = target;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(sig != NULL);
|
2014-11-04 12:24:39 +11:00
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
|
|
|
sig->common.rdclass = rdata->rdclass;
|
|
|
|
sig->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&sig->common, link);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keyring.
|
|
|
|
*/
|
|
|
|
sig->length = sr.length;
|
|
|
|
sig->keyring = mem_maybedup(mctx, sr.base, sig->length);
|
|
|
|
sig->mctx = mctx;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
freestruct_openpgpkey(ARGS_FREESTRUCT) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdata_openpgpkey_t *sig = (dns_rdata_openpgpkey_t *)source;
|
2014-11-04 12:24:39 +11:00
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(sig != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(sig->common.rdtype == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sig->mctx == NULL) {
|
2014-11-04 12:24:39 +11:00
|
|
|
return;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-11-04 12:24:39 +11:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sig->keyring != NULL) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_mem_free(sig->mctx, sig->keyring);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-11-04 12:24:39 +11:00
|
|
|
sig->mctx = NULL;
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
additionaldata_openpgpkey(ARGS_ADDLDATA) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(owner);
|
2014-11-04 12:24:39 +11:00
|
|
|
UNUSED(add);
|
|
|
|
UNUSED(arg);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
digest_openpgpkey(ARGS_DIGEST) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_region_t r;
|
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
2014-11-04 23:45:20 +00:00
|
|
|
dns_rdata_toregion(rdata, &r);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
2014-11-04 23:45:20 +00:00
|
|
|
return ((digest)(arg, &r));
|
2014-11-04 12:24:39 +11:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checkowner_openpgpkey(ARGS_CHECKOWNER) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
|
|
|
UNUSED(name);
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(wildcard);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2014-11-04 12:24:39 +11:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checknames_openpgpkey(ARGS_CHECKNAMES) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
|
|
|
UNUSED(owner);
|
|
|
|
UNUSED(bad);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2014-11-04 12:24:39 +11:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
casecompare_openpgpkey(ARGS_COMPARE) {
|
2014-11-04 12:24:39 +11:00
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata1->type == dns_rdatatype_openpgpkey);
|
2014-11-04 12:24:39 +11:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
|
|
|
|
return (isc_region_compare(&r1, &r2));
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#endif /* RDATA_GENERIC_OPENPGPKEY_61_C */
|