* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#include <assert.h>
#include <libdnssec/binary.h>
#include <libdnssec/crypto.h>
#include <libdnssec/error.h>
bool kr_ds_algo_support(const knot_rrset_t *ta)
{
- assert(ta && ta->type == KNOT_RRTYPE_DS && ta->rclass == KNOT_CLASS_IN);
+ if (!kr_assume(ta && ta->type == KNOT_RRTYPE_DS && ta->rclass == KNOT_CLASS_IN))
+ return false;
/* Check if at least one DS has a usable algorithm pair. */
knot_rdata_t *rdata_i = ta->rrs.rdata;
for (uint16_t i = 0; i < ta->rrs.count;
const bool ok = pkt && keys && ta && ta->rrs.count && ta->rrs.rdata
&& ta->type == KNOT_RRTYPE_DS;
- if (!ok) {
- assert(false);
+ if (!kr_assume(ok))
return kr_error(EINVAL);
- }
/* RFC4035 5.2, bullet 1
* The supplied DS record has been authenticated.
/* RFC4035 5.3.1, bullet 8 */ /* ZSK */
/* LATER(optim.): more efficient way to iterate than _at() */
knot_rdata_t *krr = knot_rdataset_at(&keys->rrs, i);
- if (!kr_dnssec_key_zsk(krr->data) || kr_dnssec_key_revoked(krr->data)) {
+ if (!kr_dnssec_key_zsk(krr->data) || kr_dnssec_key_revoked(krr->data))
continue;
- }
-
+
struct dseckey *key = NULL;
- if (kr_dnssec_key_from_rdata(&key, keys->owner, krr->data, krr->len) != 0) {
+ if (kr_dnssec_key_from_rdata(&key, keys->owner, krr->data, krr->len) != 0)
continue;
- }
if (kr_authenticate_referral(ta, (dnssec_key_t *) key) != 0) {
kr_dnssec_key_free(&key);
continue;
continue;
}
kr_dnssec_key_free(&key);
- assert (vctx->result == 0);
+ (void)!kr_assume(vctx->result == 0);
return vctx->result;
}
void kr_dnssec_key_free(struct dseckey **key)
{
- assert(key);
+ if (!kr_assume(key))
+ return;
dnssec_key_free((dnssec_key_t *) *key);
*key = NULL;
int ret = kr_error(ENOENT);
for (size_t i = 0; i < rrs->len; ++i) {
const ranked_rr_array_entry_t *entry = rrs->at[i];
- assert(!entry->in_progress);
+ if (!kr_assume(!entry->in_progress))
+ return kr_error(EINVAL);
const knot_rrset_t *nsec = entry->rr;
if (entry->qry_uid != qry_uid || entry->yielded) {
continue;