libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit f314a19419c3136dbf1af34acaf871ad3fce937e
parent 6049be901270ac051dca2d917b1a82ce23e6a596
Author: lash <dev@holbrook.no>
Date:   Sun,  2 Mar 2025 18:50:25 +0000

Populate parent_hash when calculated

Diffstat:
Msrc/lq/cert.c | 12++++++++----
Msrc/lq/cert.h | 3++-
2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/lq/cert.c b/src/lq/cert.c @@ -65,10 +65,11 @@ static int state_digest(LQCert *cert, char *out, int final) { p += c; if (cert->parent != NULL && !final) { - r = state_digest(cert->parent, p, 1); + r = state_digest(cert->parent, cert->parent_hash, 1); if (r != ERR_OK) { return r; } + lq_cpy(p, cert->parent_hash, LQ_DIGEST_LEN); c += LQ_DIGEST_LEN; p += LQ_DIGEST_LEN; } @@ -228,12 +229,12 @@ int lq_certificate_serialize(LQCert *cert, char *out, size_t *out_len) { return ERR_WRITE; } } else { - r = state_digest(cert, buf, 1); + r = state_digest(cert, cert->parent_hash, 1); if (r != ERR_OK) { return r; } c = LQ_DIGEST_LEN; - r = asn1_write_value(node, "Qaeda.Cert.parent", buf, c); + r = asn1_write_value(node, "Qaeda.Cert.parent", cert->parent_hash, c); if (r != ASN1_SUCCESS) { return ERR_WRITE; } @@ -337,8 +338,11 @@ int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len) { if (r != ASN1_SUCCESS) { return ERR_READ; } + p->parent = NULL; if (c == 1) { - p->parent = NULL; + lq_set(p->parent_hash, 0, LQ_DIGEST_LEN); + } else { + lq_cpy(p->parent_hash, tmp, LQ_DIGEST_LEN); } // \todo render parent if set diff --git a/src/lq/cert.h b/src/lq/cert.h @@ -31,13 +31,14 @@ */ typedef struct lq_certificate_t LQCert; struct lq_certificate_t { - LQCert *parent; char domain[LQ_CERT_DOMAIN_LEN]; LQMsg *request; LQSig *request_sig; LQMsg *response; LQSig *response_sig; LQCtx ctx; + LQCert *parent; + char parent_hash[LQ_DIGEST_LEN]; }; /***