Skip to content
Permalink
Browse files

Prepare for review:

  astyle -w -s2
  • Loading branch information...
ctz
ctz committed Jul 31, 2014
1 parent 3172d79 commit 4c4aac9a4d612f076969b4d6aa69f08ca84ab078
Showing with 7,215 additions and 7,140 deletions.
  1. +1,289 −1,258 src/auth.c
  2. +39 −39 src/auth.h
  3. +126 −126 src/b64.c
  4. +5 −5 src/b64.h
  5. +380 −380 src/context.c
  6. +47 −47 src/context.h
  7. +52 −52 src/context_priv.c
  8. +38 −38 src/context_priv.h
  9. +340 −340 src/dh.c
  10. +22 −22 src/dh.h
  11. +163 −163 src/instag.c
  12. +8 −8 src/instag.h
  13. +83 −83 src/mem.c
  14. +1 −1 src/mem.h
  15. +1,717 −1,717 src/message.c
  16. +276 −276 src/message.h
  17. +13 −13 src/privkey-t.h
  18. +655 −655 src/privkey.c
  19. +22 −22 src/privkey.h
  20. +892 −875 src/proto.c
  21. +47 −47 src/proto.h
  22. +51 −51 src/serial.h
  23. +665 −665 src/sm.c
  24. +13 −13 src/sm.h
  25. +196 −170 src/tests.c
  26. +52 −51 src/tlv.c
  27. +5 −5 src/tlv.h
  28. +13 −13 src/userstate.c
  29. +5 −5 src/userstate.h
2,547 src/auth.c

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -27,57 +27,57 @@


typedef enum {
OTRL_AUTHSTATE_NONE,
OTRL_AUTHSTATE_AWAITING_DHKEY,
OTRL_AUTHSTATE_AWAITING_REVEALSIG,
OTRL_AUTHSTATE_AWAITING_SIG,
OTRL_AUTHSTATE_V1_SETUP
OTRL_AUTHSTATE_NONE,
OTRL_AUTHSTATE_AWAITING_DHKEY,
OTRL_AUTHSTATE_AWAITING_REVEALSIG,
OTRL_AUTHSTATE_AWAITING_SIG,
OTRL_AUTHSTATE_V1_SETUP
} OtrlAuthState;

typedef struct {
OtrlAuthState authstate; /* Our state */
OtrlAuthState authstate; /* Our state */

struct context *context; /* The context which points to us */
struct context *context; /* The context which points to us */

DH_keypair our_dh; /* Our D-H key */
unsigned int our_keyid; /* ...and its keyid */
DH_keypair our_dh; /* Our D-H key */
unsigned int our_keyid; /* ...and its keyid */

unsigned char *encgx; /* The encrypted value of g^x */
size_t encgx_len; /* ...and its length */
unsigned char r[16]; /* The encryption key */
unsigned char *encgx; /* The encrypted value of g^x */
size_t encgx_len; /* ...and its length */
unsigned char r[16]; /* The encryption key */

unsigned char hashgx[32]; /* SHA256(g^x) */
unsigned char hashgx[32]; /* SHA256(g^x) */

gcry_mpi_t their_pub; /* Their D-H public key */
unsigned int their_keyid; /* ...and its keyid */
gcry_mpi_t their_pub; /* Their D-H public key */
unsigned int their_keyid; /* ...and its keyid */


gcry_cipher_hd_t enc_c, enc_cp; /* c and c' encryption keys */
gcry_md_hd_t mac_m1, mac_m1p; /* m1 and m1' MAC keys */
gcry_md_hd_t mac_m2, mac_m2p; /* m2 and m2' MAC keys */
gcry_cipher_hd_t enc_c, enc_cp; /* c and c' encryption keys */
gcry_md_hd_t mac_m1, mac_m1p; /* m1 and m1' MAC keys */
gcry_md_hd_t mac_m2, mac_m2p; /* m2 and m2' MAC keys */

unsigned char their_fingerprint[20]; /* The fingerprint of their
unsigned char their_fingerprint[20]; /* The fingerprint of their
long-term signing key */

int initiated; /* Did we initiate this
int initiated; /* Did we initiate this
authentication? */

unsigned int protocol_version; /* The protocol version number
unsigned int protocol_version; /* The protocol version number
used to authenticate. */

unsigned char secure_session_id[20]; /* The secure session id */
size_t secure_session_id_len; /* And its actual length,
unsigned char secure_session_id[20]; /* The secure session id */
size_t secure_session_id_len; /* And its actual length,
which may be either 20 (for
v1) or 8 (for v2) */
OtrlSessionIdHalf session_id_half; /* Which half of the session
OtrlSessionIdHalf session_id_half; /* Which half of the session
id gets shown in bold */

char *lastauthmsg; /* The last auth message
char *lastauthmsg; /* The last auth message
(base-64 encoded) we sent,
in case we need to
retransmit it. */

time_t commit_sent_time; /* The time we last sent the
time_t commit_sent_time; /* The time we last sent the
lastauthmsg, if it was a
COMMIT message, and this is
a master context. 0
@@ -109,15 +109,15 @@ gcry_error_t otrl_auth_start_v23(OtrlAuthInfo *auth, int version);
* keypair to use.
*/
gcry_error_t otrl_auth_handle_commit(OtrlAuthInfo *auth,
const char *commitmsg, int version);
const char *commitmsg, int version);

/*
* Handle an incoming D-H Key Message. If no error is returned, and
* *havemsgp is 1, the message to sent will be left in auth->lastauthmsg.
* Use the given private authentication key to sign messages.
*/
gcry_error_t otrl_auth_handle_key(OtrlAuthInfo *auth, const char *keymsg,
int *havemsgp, OtrlPrivKey *privkey);
int *havemsgp, OtrlPrivKey *privkey);

/*
* Handle an incoming Reveal Signature Message. If no error is
@@ -127,9 +127,9 @@ gcry_error_t otrl_auth_handle_key(OtrlAuthInfo *auth, const char *keymsg,
* successful.
*/
gcry_error_t otrl_auth_handle_revealsig(OtrlAuthInfo *auth,
const char *revealmsg, int *havemsgp, OtrlPrivKey *privkey,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);
const char *revealmsg, int *havemsgp, OtrlPrivKey *privkey,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);

/*
* Handle an incoming Signature Message. If no error is returned, and
@@ -138,9 +138,9 @@ gcry_error_t otrl_auth_handle_revealsig(OtrlAuthInfo *auth,
* authentication is successful.
*/
gcry_error_t otrl_auth_handle_signature(OtrlAuthInfo *auth,
const char *sigmsg, int *havemsgp,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);
const char *sigmsg, int *havemsgp,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);

/*
* Start a fresh AKE (version 1) using the given OtrlAuthInfo. If
@@ -150,7 +150,7 @@ gcry_error_t otrl_auth_handle_signature(OtrlAuthInfo *auth,
* transmit will be contained in auth->lastauthmsg.
*/
gcry_error_t otrl_auth_start_v1(OtrlAuthInfo *auth, DH_keypair *our_dh,
unsigned int our_keyid, OtrlPrivKey *privkey);
unsigned int our_keyid, OtrlPrivKey *privkey);

/*
* Handle an incoming v1 Key Exchange Message. If no error is returned,
@@ -161,10 +161,10 @@ gcry_error_t otrl_auth_start_v1(OtrlAuthInfo *auth, DH_keypair *our_dh,
* the given keyid.
*/
gcry_error_t otrl_auth_handle_v1_key_exchange(OtrlAuthInfo *auth,
const char *keyexchmsg, int *havemsgp, OtrlPrivKey *privkey,
DH_keypair *our_dh, unsigned int our_keyid,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);
const char *keyexchmsg, int *havemsgp, OtrlPrivKey *privkey,
DH_keypair *our_dh, unsigned int our_keyid,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);

/*
* Copy relevant information from the master OtrlAuthInfo to an
Oops, something went wrong.

0 comments on commit 4c4aac9

Please sign in to comment.
You can’t perform that action at this time.