[Pkg-privacy-commits] [libotr] 10/225: * src/message.h: * src/message.c: Move ops to be the first param of new_fingerprint, as it is with all the other callbacks.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository libotr.
commit f382e0b19c1336d984b21edde1311f0e8556d418
Author: cypherpunk <cypherpunk>
Date: Fri Jul 29 15:53:47 2005 +0000
* src/message.h:
* src/message.c: Move ops to be the first param of
new_fingerprint, as it is with all the other callbacks.
* src/context.h:
* src/context.c (otrl_context_set_preshared_secret):
* src/dh.h:
* src/dh.c (otrl_dh_session, otrl_dh_cmpctr):
* src/message.h:
* src/message.c (otrl_message_sending, send_or_error, process_kem)
(otrl_message_receiving, otrl_message_disconnect):
* src/privkey.h:
* src/privkey.c (otrl_privkey_hash_to_human):
* src/proto.h:
* src/proto.c (otrl_proto_create_data):
* src/tlv.h:
* src/tlv.c (otrl_tlv_new, otrl_tlv_parse): Add missing "const"s.
* src/tlv.c (otrl_tlv_new, otrl_tlv_parse, otrl_tlv_seriallen)
(otrl_tlv_serialize): Add missing "const"s.
---
ChangeLog | 20 ++++++++++++++++++--
src/context.c | 2 +-
src/context.h | 2 +-
src/dh.c | 5 +++--
src/dh.h | 5 +++--
src/message.c | 18 ++++++++++--------
src/message.h | 11 ++++++-----
src/privkey.c | 2 +-
src/privkey.h | 2 +-
src/proto.c | 2 +-
src/proto.h | 2 +-
src/tlv.c | 7 ++++---
src/tlv.h | 7 ++++---
13 files changed, 54 insertions(+), 31 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af01053..8599fb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,30 @@
2005-07-29
+ * src/message.h:
+ * src/message.c: Move ops to be the first param of
+ new_fingerprint, as it is with all the other callbacks.
+
+ * src/context.h:
+ * src/context.c (otrl_context_set_preshared_secret):
+ * src/dh.h:
+ * src/dh.c (otrl_dh_session, otrl_dh_cmpctr):
+ * src/message.h:
+ * src/message.c (otrl_message_sending, send_or_error, process_kem)
+ (otrl_message_receiving, otrl_message_disconnect):
+ * src/privkey.h:
+ * src/privkey.c (otrl_privkey_hash_to_human):
+ * src/proto.h:
+ * src/proto.c (otrl_proto_create_data):
* src/tlv.h:
- * src/tlv.c (otrl_tlv_new, otrl_tlv_parse): Add missing "const"s.
+ * src/tlv.c (otrl_tlv_new, otrl_tlv_parse, otrl_tlv_seriallen)
+ (otrl_tlv_serialize): Add missing "const"s.
2005-06-24
* README:
* configure.ac:
* packaging/fedora/libotr.spec:
- * src/version.h: Change version to 3.0.0
+ * src/version.h: Change version to 3.0.0 (but don't yet release)
* Protocol: Clarify that, if the user requests to see the secure
session id in the middle of the conversation, the value
diff --git a/src/context.c b/src/context.c
index 8f136c2..bdcd1b7 100644
--- a/src/context.c
+++ b/src/context.c
@@ -168,7 +168,7 @@ void otrl_context_set_trust(Fingerprint *fprint, const char *trust)
* currently only stores the secret in the ConnContext structure, but
* doesn't yet do anything with it. */
void otrl_context_set_preshared_secret(ConnContext *context,
- unsigned char *secret, size_t secret_len)
+ const unsigned char *secret, size_t secret_len)
{
free(context->preshared_secret);
context->preshared_secret = NULL;
diff --git a/src/context.h b/src/context.h
index 2dd6940..aca4a7b 100644
--- a/src/context.h
+++ b/src/context.h
@@ -129,7 +129,7 @@ void otrl_context_set_trust(Fingerprint *fprint, const char *trust);
* currently only stores the secret in the ConnContext structure, but
* doesn't yet do anything with it. */
void otrl_context_set_preshared_secret(ConnContext *context,
- unsigned char *secret, size_t secret_len);
+ const unsigned char *secret, size_t secret_len);
/* Force a context into the CONN_SETUP state (so that it only has local
* DH keys). */
diff --git a/src/dh.c b/src/dh.c
index 9179440..a159b5f 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -94,7 +94,8 @@ gcry_error_t otrl_dh_gen_keypair(unsigned int groupid, DH_keypair *kp)
* Construct session keys from a DH keypair and someone else's public
* key.
*/
-gcry_error_t otrl_dh_session(DH_sesskeys *sess, DH_keypair *kp, gcry_mpi_t y)
+gcry_error_t otrl_dh_session(DH_sesskeys *sess, const DH_keypair *kp,
+ gcry_mpi_t y)
{
gcry_mpi_t gab;
size_t gablen;
@@ -234,7 +235,7 @@ void otrl_dh_incctr(unsigned char *ctr)
/* Compare two counter values (8 bytes each). Return 0 if ctr1 == ctr2,
* < 0 if ctr1 < ctr2 (as unsigned 64-bit values), > 0 if ctr1 > ctr2. */
-int otrl_dh_cmpctr(unsigned char *ctr1, unsigned char *ctr2)
+int otrl_dh_cmpctr(const unsigned char *ctr1, const unsigned char *ctr2)
{
int i;
for (i=0;i<8;++i) {
diff --git a/src/dh.h b/src/dh.h
index 78cba4f..1ed1982 100644
--- a/src/dh.h
+++ b/src/dh.h
@@ -71,7 +71,8 @@ gcry_error_t otrl_dh_gen_keypair(unsigned int groupid, DH_keypair *kp);
* Construct session keys from a DH keypair and someone else's public
* key.
*/
-gcry_error_t otrl_dh_session(DH_sesskeys *sess, DH_keypair *kp, gcry_mpi_t y);
+gcry_error_t otrl_dh_session(DH_sesskeys *sess, const DH_keypair *kp,
+ gcry_mpi_t y);
/*
* Deallocate the contents of a DH_sesskeys (but not the DH_sesskeys
@@ -89,6 +90,6 @@ void otrl_dh_incctr(unsigned char *ctr);
/* Compare two counter values (8 bytes each). Return 0 if ctr1 == ctr2,
* < 0 if ctr1 < ctr2 (as unsigned 64-bit values), > 0 if ctr1 > ctr2. */
-int otrl_dh_cmpctr(unsigned char *ctr1, unsigned char *ctr2);
+int otrl_dh_cmpctr(const unsigned char *ctr1, const unsigned char *ctr2);
#endif
diff --git a/src/message.c b/src/message.c
index 61e6355..c36994a 100644
--- a/src/message.c
+++ b/src/message.c
@@ -63,8 +63,9 @@ void otrl_message_free(char *message)
* should replace your message with the contents of *messagep, and
* send that instead. Call otrl_message_free(*messagep) when you're
* done with it. */
-gcry_error_t otrl_message_sending(OtrlUserState us, OtrlMessageAppOps
- *ops, void *opdata, const char *accountname, const char *protocol,
+gcry_error_t otrl_message_sending(OtrlUserState us,
+ const OtrlMessageAppOps *ops,
+ void *opdata, const char *accountname, const char *protocol,
const char *recipient, const char *message, OtrlTLV *tlvs,
char **messagep,
void (*add_appdata)(void *data, ConnContext *context),
@@ -239,7 +240,7 @@ gcry_error_t otrl_message_sending(OtrlUserState us, OtrlMessageAppOps
/* If err == 0, send the message to the given user. Otherwise, display
* an appripriate error dialog. Return the value of err that was
* passed. */
-static gcry_error_t send_or_error(OtrlMessageAppOps *ops, void *opdata,
+static gcry_error_t send_or_error(const OtrlMessageAppOps *ops, void *opdata,
gcry_error_t err, const char *accountname, const char *protocol,
const char *who, const char *msg)
{
@@ -270,8 +271,9 @@ static gcry_error_t send_or_error(OtrlMessageAppOps *ops, void *opdata,
* either we were in CONN_CONNECTED, and we're again in CONN_CONNECTED,
* but with new keys, or else we weren't in CONN_CONNECTED before and
* now we are. */
-static int process_kem(OtrlUserState us, OtrlMessageAppOps *ops, void *opdata,
- ConnContext *context, Fingerprint *fprint, OTRKeyExchangeMsg kem)
+static int process_kem(OtrlUserState us, const OtrlMessageAppOps *ops,
+ void *opdata, ConnContext *context, Fingerprint *fprint,
+ OTRKeyExchangeMsg kem)
{
gcry_error_t err;
char *msgtosend;
@@ -361,7 +363,7 @@ static int process_kem(OtrlUserState us, OtrlMessageAppOps *ops, void *opdata,
* If otrl_message_receiving returns 0 and *messagep is NULL, then this
* was an ordinary, non-OTR message, which should just be delivered to
* the user without modification. */
-int otrl_message_receiving(OtrlUserState us, OtrlMessageAppOps *ops,
+int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
void *opdata, const char *accountname, const char *protocol,
const char *sender, const char *message, char **newmessagep,
OtrlTLV **tlvsp,
@@ -509,7 +511,7 @@ int otrl_message_receiving(OtrlUserState us, OtrlMessageAppOps *ops,
if (!found_print) {
/* Inform the user of the new fingerprint */
if (ops->new_fingerprint) {
- ops->new_fingerprint(us, opdata,
+ ops->new_fingerprint(opdata, us,
accountname, protocol, sender, kem);
}
process_kem(us, ops, opdata, context, NULL, kem);
@@ -900,7 +902,7 @@ int otrl_message_receiving(OtrlUserState us, OtrlMessageAppOps *ops,
/* Put a connection into the UNCONNECTED state, first sending the
* other side a notice that we're doing so if we're currently CONNECTED,
* and we think he's logged in. */
-void otrl_message_disconnect(OtrlUserState us, OtrlMessageAppOps *ops,
+void otrl_message_disconnect(OtrlUserState us, const OtrlMessageAppOps *ops,
void *opdata, const char *accountname, const char *protocol,
const char *username)
{
diff --git a/src/message.h b/src/message.h
index 2f19bbf..2a47ec3 100644
--- a/src/message.h
+++ b/src/message.h
@@ -85,7 +85,7 @@ typedef struct s_OtrlMessageAppOps {
void (*protocol_name_free)(void *opdata, const char *protocol_name);
/* A new fingerprint for the given user has been received. */
- void (*new_fingerprint)(OtrlUserState us, void *opdata,
+ void (*new_fingerprint)(void *opdata, OtrlUserState us,
const char *accountname, const char *protocol,
const char *username, OTRKeyExchangeMsg kem);
@@ -131,8 +131,9 @@ void otrl_message_free(char *message);
* should replace your message with the contents of *messagep, and
* send that instead. Call otrl_message_free(*messagep) when you're
* done with it. */
-gcry_error_t otrl_message_sending(OtrlUserState us, OtrlMessageAppOps
- *ops, void *opdata, const char *accountname, const char *protocol,
+gcry_error_t otrl_message_sending(OtrlUserState us,
+ const OtrlMessageAppOps *ops,
+ void *opdata, const char *accountname, const char *protocol,
const char *recipient, const char *message, OtrlTLV *tlvs,
char **messagep,
void (*add_appdata)(void *data, ConnContext *context),
@@ -162,7 +163,7 @@ gcry_error_t otrl_message_sending(OtrlUserState us, OtrlMessageAppOps
* If otrl_message_receiving returns 0 and *messagep is NULL, then this
* was an ordinary, non-OTR message, which should just be delivered to
* the user without modification. */
-int otrl_message_receiving(OtrlUserState us, OtrlMessageAppOps *ops,
+int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
void *opdata, const char *accountname, const char *protocol,
const char *sender, const char *message, char **newmessagep,
OtrlTLV **tlvsp,
@@ -172,7 +173,7 @@ int otrl_message_receiving(OtrlUserState us, OtrlMessageAppOps *ops,
/* Put a connection into the DISCONNECTED state, first sending the
* other side a notice that we're doing so if we're currently CONNECTED,
* and we think he's logged in. */
-void otrl_message_disconnect(OtrlUserState us, OtrlMessageAppOps *ops,
+void otrl_message_disconnect(OtrlUserState us, const OtrlMessageAppOps *ops,
void *opdata, const char *accountname, const char *protocol,
const char *username);
diff --git a/src/privkey.c b/src/privkey.c
index 56133a4..80879a7 100644
--- a/src/privkey.c
+++ b/src/privkey.c
@@ -31,7 +31,7 @@
#include "privkey.h"
/* Convert a 20-byte hash value to a 45-byte human-readable value */
-void otrl_privkey_hash_to_human(char human[45], unsigned char hash[20])
+void otrl_privkey_hash_to_human(char human[45], const unsigned char hash[20])
{
int word, byte;
char *p = human;
diff --git a/src/privkey.h b/src/privkey.h
index b0066f0..d4a399d 100644
--- a/src/privkey.h
+++ b/src/privkey.h
@@ -37,7 +37,7 @@ typedef struct s_PrivKey {
#include "userstate.h"
/* Convert a 20-byte hash value to a 45-byte human-readable value */
-void otrl_privkey_hash_to_human(char human[45], unsigned char hash[20]);
+void otrl_privkey_hash_to_human(char human[45], const unsigned char hash[20]);
/* Calculate a human-readable hash of our DSA public key. Return it in
* the passed fingerprint buffer. Return NULL on error, or a pointer to
diff --git a/src/proto.c b/src/proto.c
index e18f242..9998071 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -722,7 +722,7 @@ gcry_error_t otrl_proto_accept_key_exchange(OtrlUserState us,
* optional chain of TLVs. A newly-allocated string will be returned in
* *encmessagep. */
gcry_error_t otrl_proto_create_data(char **encmessagep, ConnContext *context,
- const char *msg, OtrlTLV *tlvs)
+ const char *msg, const OtrlTLV *tlvs)
{
size_t justmsglen = strlen(msg);
size_t msglen = justmsglen + 1 + otrl_tlv_seriallen(tlvs);
diff --git a/src/proto.h b/src/proto.h
index 546b6a4..de98242 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -123,7 +123,7 @@ gcry_error_t otrl_proto_accept_key_exchange(OtrlUserState us,
* optional chain of TLVs. A newly-allocated string will be returned in
* *encmessagep. */
gcry_error_t otrl_proto_create_data(char **encmessagep, ConnContext *context,
- const char *msg, OtrlTLV *tlvs);
+ const char *msg, const OtrlTLV *tlvs);
/* Accept an OTR Data Message in datamsg. Decrypt it and put the
* plaintext into *plaintextp, and any TLVs into tlvsp. */
diff --git a/src/tlv.c b/src/tlv.c
index ea9c854..d840ad1 100644
--- a/src/tlv.c
+++ b/src/tlv.c
@@ -69,7 +69,7 @@ void otrl_tlv_free(OtrlTLV *tlv)
}
/* Find the serialized length of a chain of TLVs */
-size_t otrl_tlv_seriallen(OtrlTLV *tlv)
+size_t otrl_tlv_seriallen(const OtrlTLV *tlv)
{
size_t totlen = 0;
while (tlv) {
@@ -81,7 +81,7 @@ size_t otrl_tlv_seriallen(OtrlTLV *tlv)
/* Serialize a chain of TLVs. The supplied buffer must already be large
* enough. */
-void otrl_tlv_serialize(unsigned char *buf, OtrlTLV *tlv)
+void otrl_tlv_serialize(unsigned char *buf, const OtrlTLV *tlv)
{
while (tlv) {
buf[0] = (tlv->type >> 8) & 0xff;
@@ -96,7 +96,8 @@ void otrl_tlv_serialize(unsigned char *buf, OtrlTLV *tlv)
}
/* Return the first TLV with the given type in the chain, or NULL if one
- * isn't found.*/
+ * isn't found. (The tlvs argument isn't const because the return type
+ * needs to be non-const.) */
OtrlTLV *otrl_tlv_find(OtrlTLV *tlvs, unsigned short type)
{
while (tlvs) {
diff --git a/src/tlv.h b/src/tlv.h
index 0fceace..ee30370 100644
--- a/src/tlv.h
+++ b/src/tlv.h
@@ -47,14 +47,15 @@ OtrlTLV *otrl_tlv_parse(const unsigned char *serialized, size_t seriallen);
void otrl_tlv_free(OtrlTLV *tlv);
/* Find the serialized length of a chain of TLVs */
-size_t otrl_tlv_seriallen(OtrlTLV *tlv);
+size_t otrl_tlv_seriallen(const OtrlTLV *tlv);
/* Serialize a chain of TLVs. The supplied buffer must already be large
* enough. */
-void otrl_tlv_serialize(unsigned char *buf, OtrlTLV *tlv);
+void otrl_tlv_serialize(unsigned char *buf, const OtrlTLV *tlv);
/* Return the first TLV with the given type in the chain, or NULL if one
- * isn't found.*/
+ * isn't found. (The tlvs argument isn't const because the return type
+ * needs to be non-const.) */
OtrlTLV *otrl_tlv_find(OtrlTLV *tlvs, unsigned short type);
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git
More information about the Pkg-privacy-commits
mailing list