commit a9d909ce5055ae81336d2c87e061fdff45260595
parent 4e5182885f8a59c8ed62fa8d05163a7e96ff5048
Author: lash <dev@holbrook.no>
Date: Mon, 31 Mar 2025 01:31:36 +0100
Remove ctx from cert
Diffstat:
5 files changed, 12 insertions(+), 41 deletions(-)
diff --git a/src/cli/main.c b/src/cli/main.c
@@ -56,6 +56,10 @@ static LQPrivKey *get_key(const char *passphrase) {
int main(int argc, char **argv) {
int r;
+ LQCert *cert;
+ LQMsg *req;
+ LQMsg *res;
+ LQCtx ctx;
r = lq_ui_init();
if (r) {
diff --git a/src/lq/cert.c b/src/lq/cert.c
@@ -24,7 +24,7 @@ static LQSig nosig = {
.impl = zeros,
};
-LQCert* lq_certificate_new(LQCert *parent, LQCtx *ctx, LQMsg *req, LQMsg *rsp) {
+LQCert* lq_certificate_new(LQCert *parent, LQMsg *req, LQMsg *rsp) {
LQCert *cert;
cert = lq_alloc(sizeof(LQCert));
@@ -255,11 +255,8 @@ int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve
char tmp[4096];
asn1_node node;
asn1_node item;
- LQCtx ctx;
LQCert *p;
- // \todo ctx make it make sense here
- lq_set(&ctx, 0, sizeof(LQCtx));
lq_set(&node, 0, sizeof(node));
lq_set(&item, 0, sizeof(item));
r = asn1_array2tree(defs_asn1_tab, &node, err);
@@ -283,7 +280,7 @@ int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve
return ERR_READ;
}
- p = lq_certificate_new(NULL, &ctx, NULL, NULL);
+ p = lq_certificate_new(NULL, NULL, NULL);
lq_certificate_set_domain(p, tmp);
c = 4096;
diff --git a/src/lq/cert.h b/src/lq/cert.h
@@ -6,7 +6,6 @@
#include "lq/crypto.h"
#include "lq/msg.h"
-#include "lq/ctx.h"
#include "lq/store.h"
#ifndef LQ_CERT_DOMAIN_LEN
@@ -27,7 +26,6 @@ struct lq_certificate_t {
LQSig *request_sig; ///< Signature over a request message and the linked certificate. If the linked certificate is NULL, the certificate data used in the signature with be a LQ_DIGEST_LEN string with all bytes set to 0.
LQMsg *response; ///< A response message encapsulates an arbitrary string of data that confirms a request. This field must be NULL unless a signed requests exists.
LQSig *response_sig; ///< Signature over a response message. This field must be NULL unless a response message is set. The signature is calculated over both the response and the signed request.
- LQCtx ctx; ///< Context reflecting the behavior of state, validation and serialization of the certificate. (unused)
LQCert *parent; ///< Link to previous certificate. Optional. Set to NULL if no link exists.
char parent_hash[LQ_DIGEST_LEN];
};
@@ -43,7 +41,7 @@ struct lq_certificate_t {
* \todo request and response message does not make sense to set without option to set signature, factor out to separate functions.
* \see lq_certificate_free
*/
-LQCert* lq_certificate_new(LQCert *parent, LQCtx *ctx, LQMsg *req, LQMsg *rsp);
+LQCert* lq_certificate_new(LQCert *parent, LQMsg *req, LQMsg *rsp);
/**
* @brief Set the domain of the certificate. If not set, the default domain value will be used, which is LQ_DOMAIN_LEN bytes set to 0.
diff --git a/src/store/file.c b/src/store/file.c
@@ -149,21 +149,3 @@ LQStore* lq_store_new(const char *spec) {
lq_cpy(store->userdata, spec, l);
return store;
}
-
-//LQStore* lq_file_content_new(const char *dir) {
-// char path[1024];
-// LQStore *store;
-//
-// store = lq_alloc(sizeof(LQStore));
-// if (store == NULL) {
-// return NULL;
-// }
-// store->get = lq_file_content_get;
-// store->put = lq_file_content_put;
-//
-// return store;
-//}
-//
-//void lq_file_content_free(LQStore *store) {
-// lq_free(store->userdata);
-//}
diff --git a/src/test/test_cert.c b/src/test/test_cert.c
@@ -34,11 +34,9 @@ START_TEST(check_cert_symmetric_nomsg) {
int r;
size_t c;
LQCert *cert;
- LQCtx ctx;
char buf[4096];
- lq_set(&ctx, 0, sizeof(LQCtx));
- cert = lq_certificate_new(NULL, &ctx, NULL, NULL);
+ cert = lq_certificate_new(NULL, NULL, NULL);
c = 4096;
r = lq_certificate_serialize(cert, buf, &c, NULL);
ck_assert_int_eq(r, 0);
@@ -55,12 +53,10 @@ START_TEST(check_cert_symmetric_req_nosig) {
size_t c;
LQCert *cert;
LQMsg *req;
- LQCtx ctx;
char buf[4096];
- lq_set(&ctx, 0, sizeof(LQCtx));
req = lq_msg_new(data, strlen(data) + 1);
- cert = lq_certificate_new(NULL, &ctx, req, NULL);
+ cert = lq_certificate_new(NULL, req, NULL);
c = 4096;
r = lq_certificate_serialize(cert, buf, &c, NULL);
ck_assert_int_eq(r, 0);
@@ -78,13 +74,11 @@ START_TEST(check_cert_symmetric_req_sig) {
LQCert *cert;
LQMsg *req;
LQPrivKey *pk;
- LQCtx ctx;
char buf[4096];
pk = lq_privatekey_new(passphrase, 32);
- lq_set(&ctx, 0, sizeof(LQCtx));
req = lq_msg_new(data, strlen(data) + 1);
- cert = lq_certificate_new(NULL, &ctx, req, NULL);
+ cert = lq_certificate_new(NULL, req, NULL);
lq_privatekey_unlock(pk, passphrase, 32);
r = lq_certificate_sign(cert, pk);
ck_assert_int_eq(r, 0);
@@ -107,14 +101,12 @@ START_TEST(check_cert_symmetric_rsp_onesig) {
LQMsg *req;
LQMsg *rsp;
LQPrivKey *pk;
- LQCtx ctx;
char buf[4096];
pk = lq_privatekey_new(passphrase, 32);
- lq_set(&ctx, 0, sizeof(LQCtx));
req = lq_msg_new(data, strlen(data) + 1);
rsp = lq_msg_new(data_two, strlen(data_two) + 1);
- cert = lq_certificate_new(NULL, &ctx, req, NULL);
+ cert = lq_certificate_new(NULL, req, NULL);
lq_privatekey_unlock(pk, passphrase, 32);
r = lq_certificate_sign(cert, pk);
ck_assert_int_eq(r, 0);
@@ -137,13 +129,11 @@ START_TEST(check_cert_symmetric_rsp_bothsig) {
LQCert *cert;
LQMsg *req;
LQPrivKey *pk;
- LQCtx ctx;
char buf[4096];
pk = lq_privatekey_new(passphrase, 32);
- lq_set(&ctx, 0, sizeof(LQCtx));
req = lq_msg_new(data, strlen(data) + 1);
- cert = lq_certificate_new(NULL, &ctx, req, NULL);
+ cert = lq_certificate_new(NULL, req, NULL);
lq_privatekey_unlock(pk, passphrase, 32);
r = lq_certificate_sign(cert, pk);
ck_assert_int_eq(r, 0);