00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef RDATA_GENERIC_OPENPGPKEY_61_C
00018 #define RDATA_GENERIC_OPENPGPKEY_61_C
00019
00020 #define RRTYPE_OPENPGPKEY_ATTRIBUTES 0
00021
00022 static inline isc_result_t
00023 fromtext_openpgpkey(ARGS_FROMTEXT) {
00024
00025 REQUIRE(type == 61);
00026
00027 UNUSED(type);
00028 UNUSED(rdclass);
00029 UNUSED(callbacks);
00030 UNUSED(options);
00031 UNUSED(origin);
00032
00033
00034
00035
00036 return (isc_base64_tobuffer(lexer, target, -1));
00037 }
00038
00039 static inline isc_result_t
00040 totext_openpgpkey(ARGS_TOTEXT) {
00041 isc_region_t sr;
00042
00043 REQUIRE(rdata->type == 61);
00044 REQUIRE(rdata->length != 0);
00045
00046 dns_rdata_toregion(rdata, &sr);
00047
00048
00049
00050
00051 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
00052 RETERR(str_totext("( ", target));
00053
00054 if ((tctx->flags & DNS_STYLEFLAG_NOCRYPTO) == 0) {
00055 if (tctx->width == 0)
00056 RETERR(isc_base64_totext(&sr, 60, "", target));
00057 else
00058 RETERR(isc_base64_totext(&sr, tctx->width - 2,
00059 tctx->linebreak, target));
00060 } else
00061 RETERR(str_totext("[omitted]", target));
00062
00063 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
00064 RETERR(str_totext(" )", target));
00065
00066 return (ISC_R_SUCCESS);
00067 }
00068
00069 static inline isc_result_t
00070 fromwire_openpgpkey(ARGS_FROMWIRE) {
00071 isc_region_t sr;
00072
00073 REQUIRE(type == 61);
00074
00075 UNUSED(type);
00076 UNUSED(rdclass);
00077 UNUSED(dctx);
00078 UNUSED(options);
00079
00080
00081
00082
00083 isc_buffer_activeregion(source, &sr);
00084 isc_buffer_forward(source, sr.length);
00085 return (mem_tobuffer(target, sr.base, sr.length));
00086 }
00087
00088 static inline isc_result_t
00089 towire_openpgpkey(ARGS_TOWIRE) {
00090 isc_region_t sr;
00091
00092 REQUIRE(rdata->type == 61);
00093 REQUIRE(rdata->length != 0);
00094
00095 UNUSED(cctx);
00096
00097 dns_rdata_toregion(rdata, &sr);
00098 return (mem_tobuffer(target, sr.base, sr.length));
00099 }
00100
00101 static inline int
00102 compare_openpgpkey(ARGS_COMPARE) {
00103 isc_region_t r1;
00104 isc_region_t r2;
00105
00106 REQUIRE(rdata1->type == rdata2->type);
00107 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00108 REQUIRE(rdata1->type == 61);
00109 REQUIRE(rdata1->length != 0);
00110 REQUIRE(rdata2->length != 0);
00111
00112 dns_rdata_toregion(rdata1, &r1);
00113 dns_rdata_toregion(rdata2, &r2);
00114 return (isc_region_compare(&r1, &r2));
00115 }
00116
00117 static inline isc_result_t
00118 fromstruct_openpgpkey(ARGS_FROMSTRUCT) {
00119 dns_rdata_openpgpkey_t *sig = source;
00120
00121 REQUIRE(type == 61);
00122 REQUIRE(source != NULL);
00123 REQUIRE(sig->common.rdtype == type);
00124 REQUIRE(sig->common.rdclass == rdclass);
00125 REQUIRE(sig->keyring != NULL && sig->length != 0);
00126
00127 UNUSED(type);
00128 UNUSED(rdclass);
00129
00130
00131
00132
00133 return (mem_tobuffer(target, sig->keyring, sig->length));
00134 }
00135
00136 static inline isc_result_t
00137 tostruct_openpgpkey(ARGS_TOSTRUCT) {
00138 isc_region_t sr;
00139 dns_rdata_openpgpkey_t *sig = target;
00140
00141 REQUIRE(rdata->type == 61);
00142 REQUIRE(target != NULL);
00143 REQUIRE(rdata->length != 0);
00144
00145 sig->common.rdclass = rdata->rdclass;
00146 sig->common.rdtype = rdata->type;
00147 ISC_LINK_INIT(&sig->common, link);
00148
00149 dns_rdata_toregion(rdata, &sr);
00150
00151
00152
00153
00154 sig->length = sr.length;
00155 sig->keyring = mem_maybedup(mctx, sr.base, sig->length);
00156 if (sig->keyring == NULL)
00157 goto cleanup;
00158
00159 sig->mctx = mctx;
00160 return (ISC_R_SUCCESS);
00161
00162 cleanup:
00163 return (ISC_R_NOMEMORY);
00164 }
00165
00166 static inline void
00167 freestruct_openpgpkey(ARGS_FREESTRUCT) {
00168 dns_rdata_openpgpkey_t *sig = (dns_rdata_openpgpkey_t *) source;
00169
00170 REQUIRE(source != NULL);
00171 REQUIRE(sig->common.rdtype == 61);
00172
00173 if (sig->mctx == NULL)
00174 return;
00175
00176 if (sig->keyring != NULL)
00177 isc_mem_free(sig->mctx, sig->keyring);
00178 sig->mctx = NULL;
00179 }
00180
00181 static inline isc_result_t
00182 additionaldata_openpgpkey(ARGS_ADDLDATA) {
00183 REQUIRE(rdata->type == 61);
00184
00185 UNUSED(rdata);
00186 UNUSED(add);
00187 UNUSED(arg);
00188
00189 return (ISC_R_SUCCESS);
00190 }
00191
00192 static inline isc_result_t
00193 digest_openpgpkey(ARGS_DIGEST) {
00194 isc_region_t r;
00195
00196 REQUIRE(rdata->type == 61);
00197
00198 dns_rdata_toregion(rdata, &r);
00199
00200 return ((digest)(arg, &r));
00201 }
00202
00203 static inline isc_boolean_t
00204 checkowner_openpgpkey(ARGS_CHECKOWNER) {
00205
00206 REQUIRE(type == 61);
00207
00208 UNUSED(name);
00209 UNUSED(type);
00210 UNUSED(rdclass);
00211 UNUSED(wildcard);
00212
00213 return (ISC_TRUE);
00214 }
00215
00216 static inline isc_boolean_t
00217 checknames_openpgpkey(ARGS_CHECKNAMES) {
00218
00219 REQUIRE(rdata->type == 61);
00220
00221 UNUSED(rdata);
00222 UNUSED(owner);
00223 UNUSED(bad);
00224
00225 return (ISC_TRUE);
00226 }
00227
00228 static inline int
00229 casecompare_openpgpkey(ARGS_COMPARE) {
00230 isc_region_t r1;
00231 isc_region_t r2;
00232
00233 REQUIRE(rdata1->type == rdata2->type);
00234 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00235 REQUIRE(rdata1->type == 61);
00236 REQUIRE(rdata1->length != 0);
00237 REQUIRE(rdata2->length != 0);
00238
00239 dns_rdata_toregion(rdata1, &r1);
00240 dns_rdata_toregion(rdata2, &r2);
00241
00242 return (isc_region_compare(&r1, &r2));
00243 }
00244
00245 #endif