libqaeda

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

commit e8b0df236debe5f9500acba4eec72c230edfa6ac
parent 6796465aadfdbbbdcb1c4acce5b7407beef9bbdb
Author: lash <dev@holbrook.no>
Date:   Mon,  7 Apr 2025 16:23:22 +0100

Change order of serialization functions

Diffstat:
Msrc/lq/cert.c | 14+++++++-------
Msrc/lq/cert.h | 77+++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
Msrc/lq/msg.c | 12++++--------
Msrc/lq/msg.h | 97++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/test/test_cert.c | 40++++++++++++++++++++--------------------
Msrc/test/test_msg.c | 4++--
6 files changed, 138 insertions(+), 106 deletions(-)

diff --git a/src/lq/cert.c b/src/lq/cert.c @@ -31,7 +31,7 @@ static LQSig nosig = { .impl = zeros, }; -LQCert* lq_certificate_new(LQCert *parent) { //, LQMsg *req, LQMsg *rsp) { +LQCert* lq_certificate_new(LQCert *parent) { LQCert *cert; cert = lq_alloc(sizeof(LQCert)); @@ -215,7 +215,7 @@ static int asn_except(asn1_node *node, int err) { return err; } -int lq_certificate_serialize(LQCert *cert, char *out, size_t *out_len, LQResolve *resolve) { +int lq_certificate_serialize(LQCert *cert, LQResolve *resolve, char *out, size_t *out_len) { size_t c; int r; size_t mx; @@ -251,7 +251,7 @@ int lq_certificate_serialize(LQCert *cert, char *out, size_t *out_len, LQResolve msg = &nomsg; } c = mx - LQ_CERT_DOMAIN_LEN; - r = lq_msg_serialize(msg, buf, &c, resolve); + r = lq_msg_serialize(msg, resolve, buf, &c); if (r != ERR_OK) { return asn_except(&item, r); } @@ -285,7 +285,7 @@ int lq_certificate_serialize(LQCert *cert, char *out, size_t *out_len, LQResolve msg = &nomsg; } c = mx - LQ_CERT_DOMAIN_LEN; - r = lq_msg_serialize(msg, buf, &c, resolve); + r = lq_msg_serialize(msg, resolve, buf, &c); if (r != ERR_OK) { return asn_except(&item, r); } @@ -346,7 +346,7 @@ int lq_certificate_serialize(LQCert *cert, char *out, size_t *out_len, LQResolve return ERR_OK; } -int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve *resolve) { +int lq_certificate_deserialize(LQCert **cert, LQResolve *resolve, char *in, size_t in_len) { int r; int c; char err[LQ_ERRSIZE]; @@ -381,7 +381,7 @@ int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve if (r != ASN1_SUCCESS) { return asn_except(&item, ERR_READ); } - r = lq_msg_deserialize(&p->request, tmp, c, resolve); + r = lq_msg_deserialize(&p->request, resolve, tmp, c); if (r != ERR_OK) { return asn_except(&item, r); } @@ -404,7 +404,7 @@ int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve lq_msg_free(p->request); return asn_except(&item, ERR_READ); } - r = lq_msg_deserialize(&p->response, tmp, c, resolve); + r = lq_msg_deserialize(&p->response, resolve, tmp, c); if (r != ERR_OK) { lq_signature_free(p->request_sig); lq_msg_free(p->request); diff --git a/src/lq/cert.h b/src/lq/cert.h @@ -49,7 +49,9 @@ LQCert* lq_certificate_new(LQCert *parent); void lq_certificate_set_domain(LQCert *cert, const char *domain); /** - * @brief Sign the next pending message in the certificate. If the request message is set but not signed, the request message will be signed. If the response message is set but not signed, the response message will be signed. The limitations described in the struct declaration apply. + * \brief Sign the next pending message in the certificate. + * + * If the request message is set but not signed, the request message will be signed. If the response message is set but not signed, the response message will be signed. The limitations described in the struct declaration apply. * * Depending on the state of the certificate, additional data will be prepended to the message before calculating the digest, where <value> means a required value, [value] means and optional value, and "|" means concatenate. * @@ -61,47 +63,52 @@ void lq_certificate_set_domain(LQCert *cert, const char *domain); * * If the certificate has the response_signature it will be used as the response_signature value. The response_signature may not exist without the request_signature. * - * @param[in] Instantiated certificate to perform signature on. - * @param[in] Private key to use for signature. - * @return ERR_OK on successful signature, or: + * \param[in] Instantiated certificate to perform signature on. + * \param[in] Private key to use for signature. + * \return ERR_OK on successful signature, or: * * ERR_REQUEST if request has already been signed (and response is not set) * * ERR_RESPONSE if response has already been signed. * * ERR_ENCODING if calculateing the signature failed. * * ERR_INIT if no message eligible for signature exists. + * + * \see lq_certificate_request + * \see lq_certificate_respond */ int lq_certificate_sign(LQCert *cert, LQPrivKey *pk); /** - * @brief Serialize certificate data payload for storage and transport. - * @param[in] Certificate to serialize - * @param[out] Buffer to write data to. - * @param[out] Value behind pointer must contain the capacity of the output buffer. Will be overwritten with the actual number of bytes written. - * @param[in] Store implementations to use for storing serialized certificate and message data. - * @return ERR_OK if serialization is successful, or: + * \brief Serialize certificate data payload for storage and transport. + * + * \param[in] Certificate to serialize + * \param[in] Store implementations to use for storing serialized certificate and message data. If NULL, content will not be stored in resolver. + * \param[out] Buffer to write data to. + * \param[out] Value behind pointer must contain the capacity of the output buffer. Will be overwritten with the actual number of bytes written. + * \return ERR_OK if serialization is successful, or: * * ERR_INIT if the serialization object couldn't be instantiated. * * ERR_OVERFLOW if output exceeded the available space in output buffer. * * ERR_WRITE if serialization of an element failed. * * ERR_ENCODING if generating the final serialization string failed. */ -int lq_certificate_serialize(LQCert *cert, char *out, size_t *out_len, LQResolve *resolve); +int lq_certificate_serialize(LQCert *cert, LQResolve *resolve, char *out, size_t *out_len); /** - * @brief Deserialize certificate data payload from storage or transport. - * @param[out] Pointer to instantiated certificate. It is the caller's responsibility to free the certificate object. - * @param[in] Serialized data. - * @param[in] Length of serialized data. - * @param[in] Store implementations to use for resolving content key from deserialized message and certificate data. - * @return ERR_OK if deserialization is successful, or: + * \brief Deserialize certificate data payload from storage or transport. + * + * \param[out] Pointer to instantiated certificate. It is the caller's responsibility to free the certificate object. + * \param[in] Store implementations to use for resolving content key from deserialized message and certificate data. If NULL, content will not be resolved. + * \param[in] Serialized data. + * \param[in] Length of serialized data. + * \return ERR_OK if deserialization is successful, or: * * ERR_INIT if the serialization object couldn't be instantiated. * * ERR_READ if deserialization of an element failed. * * ERR_ENCODING if interpretation of the serialized data failed. - * @see lq_certificate_free + * \see lq_certificate_free */ -int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve *resolve); +int lq_certificate_deserialize(LQCert **cert, LQResolve *resolve, char *in, size_t in_len); /** - * @brief Verify the integrity of a certificate. Specifically that signatures in the certificate match given keys and data. + * \brief Verify the integrity of a certificate. Specifically that signatures in the certificate match given keys and data. * * The cert must have either * - no message (NOOP) @@ -110,25 +117,43 @@ int lq_certificate_deserialize(LQCert **cert, char *in, size_t in_len, LQResolve * * Messages must have public key set. * - * @param[in] Certificate to verify - * @return ERR_OK if verified, or: + * \param[in] Certificate to verify + * \return ERR_OK if verified. */ int lq_certificate_verify(LQCert *cert); /*** - * \brief + * \brief Add and optionally sign a request message to the certificate. * - * Certificate object takes responsibility to free the message object when it is freed. + * The signature will be calculated over the certificate data. * + * Fails if a request or response message and/or signature already exists. + * + * Message is freed as part of lq_certificate_free. + * + * \param[in] Certificate to manipulate. + * \param[in] Request message + * \param[in] If not NULL, sign request with the given private key. + * \return ERR_OK on success. */ int lq_certificate_request(LQCert *cert, LQMsg *req, LQPrivKey *pk); /*** - * \brief + * \brief Add and optionally sign a response message to the certificate. + * + * The signature will be calculated over the certificate data and the existing request. + * + * Fails if a request and/or signature does not exist. + * + * Fails if a response and/or signature already exists. * - * Certificate object takes responsibility to free the message object when it is freed. + * Message is freed as part of lq_certificate_free. * + * \param[in] Certificate to manipulate. + * \param[in] Response message + * \param[in] If not NULL, sign response with the given private key. + * \return ERR_OK on success. */ int lq_certificate_respond(LQCert *cert, LQMsg *rsp, LQPrivKey *pk); diff --git a/src/lq/msg.c b/src/lq/msg.c @@ -42,7 +42,6 @@ LQSig* lq_msg_sign(LQMsg *msg, LQPrivKey *pk, const char *salt) { static int msg_to_sign(LQMsg *msg, char *out, const char *extra, size_t extra_len) { int l; - int r; char data[LQ_BLOCKSIZE]; l = msg->len; @@ -86,7 +85,6 @@ LQSig* lq_msg_sign_extra(LQMsg *msg, LQPrivKey *pk, const char *salt, const char int lq_msg_verify_extra(LQMsg *msg, LQSig *sig, const char *salt, const char *extra, size_t extra_len) { int r; char digest[LQ_DIGEST_LEN]; - LQMsg msg_valid; if (msg->pubkey == NULL) { return debug_logerr(LLOG_DEBUG, ERR_NONSENSE, "missing pubkey"); @@ -125,9 +123,7 @@ static int asn_except(asn1_node *node, int err) { } /// TODO check upper bound of data contents -int lq_msg_serialize(LQMsg *msg, char *out, size_t *out_len, LQResolve *resolve) { - char *p; - char resolved; +int lq_msg_serialize(LQMsg *msg, LQResolve *resolve, char *out, size_t *out_len) { size_t c; int r; size_t mx; @@ -222,7 +218,7 @@ int lq_msg_serialize(LQMsg *msg, char *out, size_t *out_len, LQResolve *resolve) *out_len = mx; r = asn1_der_coding(item, "Msg", out, (int*)out_len, err); if (r != ASN1_SUCCESS) { - debug_logerr(LLOG_WARNING, ERR_ENCODING, asn1_strerror(r)); + debug_logerr(LLOG_WARNING, ERR_ENCODING, (char*)asn1_strerror(r)); return asn_except(&item, ERR_ENCODING); } @@ -234,7 +230,7 @@ int lq_msg_serialize(LQMsg *msg, char *out, size_t *out_len, LQResolve *resolve) return ERR_OK; } -int lq_msg_deserialize(LQMsg **msg, const char *in, size_t in_len, LQResolve *resolve) { +int lq_msg_deserialize(LQMsg **msg, LQResolve *resolve, const char *in, size_t in_len) { int r; size_t c; size_t l; @@ -262,7 +258,7 @@ int lq_msg_deserialize(LQMsg **msg, const char *in, size_t in_len, LQResolve *re c = LQ_DIGEST_LEN; r = asn1_read_value(item, "data", z, (int*)&c); if (r != ASN1_SUCCESS) { - debug_logerr(LLOG_WARNING, ERR_READ, asn1_strerror(r)); + debug_logerr(LLOG_WARNING, ERR_READ, (char*)asn1_strerror(r)); return asn_except(&item, ERR_READ); } diff --git a/src/lq/msg.h b/src/lq/msg.h @@ -29,81 +29,92 @@ struct lq_msg_t { typedef struct lq_msg_t LQMsg; /** - * @brief Instantiate a new message object. - * @param[in] Message data. Data will be copied. - * @param[in] Length of message data. - * @return Instantiated message object. It is the caller's responsibility to free to object. - * @see lq_msg_free + * \brief Instantiate a new message object. + * + * \param[in] Message data. Data will be copied. + * \param[in] Length of message data. + * \return Instantiated message object. It is the caller's responsibility to free to object. + * \see lq_msg_free */ LQMsg* lq_msg_new(const char *msg_data, size_t msg_len); /** - * @brief Calculate a signature over the message. Uses default salt value. - * @param[in] Message to sign. - * @param[in] Private key to sign with. - * @param[in] Salt data to secure signature with. Set to NULL if salt is not to be used. - * @return Signature object. Object will be NULL if signature calculation failed. It is the caller's responsibility to free the signature object. - * @see lq_signature_free + * \brief Calculate a signature over the message. Uses default salt value. + * + * \param[in] Message to sign. + * \param[in] Private key to sign with. + * \param[in] Salt data to secure signature with. Set to NULL if salt is not to be used. + * \return Signature object. Object will be NULL if signature calculation failed. It is the caller's responsibility to free the signature object. + * + * \see lq_signature_free */ LQSig* lq_msg_sign(LQMsg *msg, LQPrivKey *pk, const char *salt); /** - * @brief Calculate a signature over the message with a specified salt value. The salt value length must be LQ_SALT_LEN. - * @param[in] Message to sign. - * @param[in] Private key to sign with. - * @param[in] Salt data to secure signature with. Set to NULL if salt is not to be used. - * @param[in] Extra data to prefix message data with when calculating digest. If set to NULL, only message data will be used in digest. - * @param[in] Length of extra data. Ignored if extra data is NULL. - * @return Signature object. Object will be NULL if signature calculation failed. It is the caller's responsibility to free the signature object. - * @see lq_signature_free + * \brief Calculate a signature over the message with a specified salt value. The salt value length must be LQ_SALT_LEN. + * + * \param[in] Message to sign. + * \param[in] Private key to sign with. + * \param[in] Salt data to secure signature with. Set to NULL if salt is not to be used. + * \param[in] Extra data to prefix message data with when calculating digest. If set to NULL, only message data will be used in digest. + * \param[in] Length of extra data. Ignored if extra data is NULL. + * \return Signature object. Object will be NULL if signature calculation failed. It is the caller's responsibility to free the signature object. + * + * \see lq_signature_free */ LQSig* lq_msg_sign_extra(LQMsg *msg, LQPrivKey *pk, const char *salt, const char *extra, size_t extra_len); /** - * @brief Verify the signature over the message with specified salt value. The salt value length must be LQ_SALT_LEN. + * \brief Verify the signature over the message with specified salt value. The salt value length must be LQ_SALT_LEN. * * The message will be verified against the public key defined in the message structure. * - * @param[in] Message to verify. (Must have the publickey member set). - * @param[in] Salt data to secure signature with. Set to NULL if salt is not to be used. - * @param[in] Extra data to prefix message data with when calculating digest. If set to NULL, only message data will be used in digest. - * @param[in] Length of extra data. Ignored if extra data is NULL. - * @return ERR_OK on valid signature, ERR_NONSENSE if publickey missing. Any other value indicates failure. - * @see lq_signature_free + * \param[in] Message to verify. (Must have the publickey member set). + * \param[in] Signature to verify. + * \param[in] Salt data that was used when calculating signature. Set to NULL if salt is not to be used. + * \param[in] Extra data to prefix message data with when calculating digest. If set to NULL, only message data will be used in digest. + * \param[in] Length of extra data. Ignored if extra data is NULL. + * \return ERR_OK on valid signature, ERR_NONSENSE if publickey missing. Any other value indicates failure. + * + * \see lq_signature_free */ int lq_msg_verify_extra(LQMsg *msg, LQSig *sig, const char *salt, const char *extra, size_t extra_len); /** - * @brief Serialize message data payload for inclusion in certificate. - * @param[in] Message to serialize. - * @param[out] Output buffer. - * @param[out] Value behind pointer must contain the capacity of output buffer. Will be overwritten with the actual number of bytes written. - * @param[in] Store implementations to use for storing serialized message data. - * @return ERR_OK if serialization is successful, or: + * \brief Serialize message data payload for inclusion in certificate. + * + * \param[in] Message to serialize. + * \param[in] Store implementations to use for storing serialized message data. If NULL, content will not be stored in resolver. + * \param[out] Output buffer. + * \param[out] Value behind pointer must contain the capacity of output buffer. Will be overwritten with the actual number of bytes written. + * \return ERR_OK if serialization is successful, or: * * ERR_INIT if the serialization object couldn't be instantiated. * * ERR_OVERFLOW if output exceeded the available space in output buffer. * * ERR_WRITE if serialization of an element failed. * * ERR_ENCODING if generating the final serialization string failed. */ -int lq_msg_serialize(LQMsg *msg, char *out, size_t *out_len, LQResolve *resolve); +int lq_msg_serialize(LQMsg *msg, LQResolve *resolve, char *out, size_t *out_len); /** - * @brief Deserialize message data payload from certificate. - * @param[out] Pointer to instantiated message. It is the caller's responsibility to free the message object. - * @param[in] Serialized data. - * @param[in] Length of serialized data. - * @param[in] Store implementations to use for resolving content key from deserialized message data. - * @return ERR_OK if deserialization is successful, or: + * \brief Deserialize message data payload from certificate. + * + * \param[out] Pointer to instantiated message. It is the caller's responsibility to free the message object. + * \param[in] Store implementations to use for resolving content key from deserialized message data. If NULL, content will not be resolved. + * \param[in] Serialized data. + * \param[in] Length of serialized data. + * \return ERR_OK if deserialization is successful, or: * * ERR_INIT if the serialization object couldn't be instantiated. * * ERR_READ if deserialization of an element failed. * * ERR_ENCODING if interpretation of the serialized data failed. - * @see lq_msg_free + * + * \see lq_msg_free */ -int lq_msg_deserialize(LQMsg **msg, const char *in, size_t in_len, LQResolve *resolve); +int lq_msg_deserialize(LQMsg **msg, LQResolve *resolve, const char *in, size_t in_len); /** - * @brief Free an instantiated message. - * @param[in] Message to free. + * \brief Free an instantiated message. + * + * \param[in] Message to free. */ void lq_msg_free(LQMsg *msg); diff --git a/src/test/test_cert.c b/src/test/test_cert.c @@ -36,9 +36,9 @@ START_TEST(check_cert_sig_req) { LQMsg *req; LQPrivKey *pk; - pk = lq_privatekey_new(passphrase, strlen(passphrase)); + pk = lq_privatekey_new(passphrase, sizeof(passphrase)); ck_assert_ptr_nonnull(pk); - r = lq_privatekey_unlock(pk, passphrase, strlen(passphrase)); + r = lq_privatekey_unlock(pk, passphrase, sizeof(passphrase)); ck_assert_int_eq(r, 0); cert = lq_certificate_new(NULL); @@ -67,12 +67,12 @@ START_TEST(check_cert_sig_res) { pk_alice = lq_privatekey_new(passphrase, LQ_PRIVKEY_LEN); ck_assert_ptr_nonnull(pk_alice); - r = lq_privatekey_unlock(pk_alice, passphrase, strlen(passphrase)); + r = lq_privatekey_unlock(pk_alice, passphrase, sizeof(passphrase)); ck_assert_int_eq(r, 0); pk_bob = lq_privatekey_new(passphrase, LQ_PRIVKEY_LEN); ck_assert_ptr_nonnull(pk_bob); - r = lq_privatekey_unlock(pk_bob, passphrase, strlen(passphrase)); + r = lq_privatekey_unlock(pk_bob, passphrase, sizeof(passphrase)); ck_assert_int_eq(r, 0); cert = lq_certificate_new(NULL); @@ -106,13 +106,13 @@ START_TEST(check_cert_symmetric_ser_nomsg) { cert = lq_certificate_new(NULL); ck_assert_ptr_nonnull(cert); c = LQ_BLOCKSIZE; - r = lq_certificate_serialize(cert, buf, &c, NULL); + r = lq_certificate_serialize(cert, NULL, buf, &c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); cert = lq_certificate_new(NULL); ck_assert_ptr_nonnull(cert); - r = lq_certificate_deserialize(&cert, buf, c, NULL); + r = lq_certificate_deserialize(&cert, NULL, buf, c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); } @@ -133,13 +133,13 @@ START_TEST(check_cert_symmetric_ser_req_nosig) { r = lq_certificate_request(cert, req, NULL); c = LQ_BLOCKSIZE; - r = lq_certificate_serialize(cert, buf, &c, NULL); + r = lq_certificate_serialize(cert, NULL, buf, &c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); cert = lq_certificate_new(NULL); ck_assert_ptr_nonnull(cert); - r = lq_certificate_deserialize(&cert, buf, c, NULL); + r = lq_certificate_deserialize(&cert, NULL, buf, c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); } @@ -168,11 +168,11 @@ START_TEST(check_cert_symmetric_ser_req_sig) { ck_assert_int_eq(r, 0); c = LQ_BLOCKSIZE; - r = lq_certificate_serialize(cert, buf, &c, NULL); + r = lq_certificate_serialize(cert, NULL, buf, &c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); - r = lq_certificate_deserialize(&cert, buf, c, NULL); + r = lq_certificate_deserialize(&cert, NULL , buf, c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); @@ -189,7 +189,7 @@ START_TEST(check_cert_symmetric_ser_rsp_onesig) { LQPrivKey *pk; char buf[4096]; - pk = lq_privatekey_new(passphrase, strlen(passphrase)); + pk = lq_privatekey_new(passphrase, sizeof(passphrase)); ck_assert_ptr_nonnull(pk); req = lq_msg_new(data, strlen(data) + 1); ck_assert_ptr_nonnull(req); @@ -197,16 +197,16 @@ START_TEST(check_cert_symmetric_ser_rsp_onesig) { ck_assert_ptr_nonnull(res); cert = lq_certificate_new(NULL); - lq_privatekey_unlock(pk, passphrase, strlen(passphrase)); + lq_privatekey_unlock(pk, passphrase, sizeof(passphrase)); r = lq_certificate_request(cert, req, pk); ck_assert_int_eq(r, 0); c = LQ_BLOCKSIZE; - r = lq_certificate_serialize(cert, buf, &c, NULL); + r = lq_certificate_serialize(cert, NULL, buf, &c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); - r = lq_certificate_deserialize(&cert, buf, c, NULL); + r = lq_certificate_deserialize(&cert, NULL, buf, c); ck_assert_int_eq(r, 0); r = lq_certificate_respond(cert, res, pk); ck_assert_int_eq(r, 0); @@ -226,13 +226,13 @@ START_TEST(check_cert_symmetric_ser_rsp_bothsig) { LQPrivKey *pk_bob; char buf[LQ_BLOCKSIZE]; - pk_alice = lq_privatekey_new(passphrase, strlen(passphrase)); + pk_alice = lq_privatekey_new(passphrase, sizeof(passphrase)); ck_assert_ptr_nonnull(pk_alice); - pk_bob = lq_privatekey_new(passphrase, strlen(passphrase)); + pk_bob = lq_privatekey_new(passphrase, sizeof(passphrase)); ck_assert_ptr_nonnull(pk_bob); - r = lq_privatekey_unlock(pk_alice, passphrase, strlen(passphrase)); + r = lq_privatekey_unlock(pk_alice, passphrase, sizeof(passphrase)); ck_assert_int_eq(r, 0); - r = lq_privatekey_unlock(pk_bob, passphrase, strlen(passphrase)); + r = lq_privatekey_unlock(pk_bob, passphrase, sizeof(passphrase)); ck_assert_int_eq(r, 0); cert = lq_certificate_new(NULL); ck_assert_ptr_nonnull(cert); @@ -248,11 +248,11 @@ START_TEST(check_cert_symmetric_ser_rsp_bothsig) { ck_assert_int_eq(r, 0); c = LQ_BLOCKSIZE; - r = lq_certificate_serialize(cert, buf, &c, NULL); + r = lq_certificate_serialize(cert, NULL, buf, &c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); - r = lq_certificate_deserialize(&cert, buf, c, NULL); + r = lq_certificate_deserialize(&cert, NULL, buf, c); ck_assert_int_eq(r, 0); lq_certificate_free(cert); } diff --git a/src/test/test_msg.c b/src/test/test_msg.c @@ -39,11 +39,11 @@ START_TEST(check_msg_symmetric) { msg->pubkey = lq_publickey_new(data); c = LQ_BLOCKSIZE; - r = lq_msg_serialize(msg, buf, &c, &resolve); + r = lq_msg_serialize(msg, &resolve, buf, &c); ck_assert_int_eq(r, 0); lq_msg_free(msg); - r = lq_msg_deserialize(&msg, buf, c, &resolve); + r = lq_msg_deserialize(&msg, &resolve, buf, c); ck_assert_ptr_nonnull(msg); ck_assert_int_eq(r, 0); lq_msg_free(msg);