Browse Source

changed check_handshake to return a success or failure value

cecylia 6 years ago
parent
commit
ba3752bf02
2 changed files with 7 additions and 3 deletions
  1. 6 2
      relay_station/crypto.c
  2. 1 1
      relay_station/crypto.h

+ 6 - 2
relay_station/crypto.c

@@ -1585,7 +1585,7 @@ end:
  *  Output:
  *  	none
  */
-void check_handshake(struct packet_info *info){
+int check_handshake(struct packet_info *info){
 
     FILE *fp;
     int res, code;
@@ -1600,6 +1600,8 @@ void check_handshake(struct packet_info *info){
 
     code = handshake_hdr->type;
 
+    res = 1;
+
     if (code == 0x01){
         p += CLIENT_HELLO_HEADER_LEN;
         //now pointing to hello random :D
@@ -1640,7 +1642,7 @@ void check_handshake(struct packet_info *info){
                 flow_ptr = add_flow(info);
                 if(flow_ptr == NULL){
                     fprintf(stderr, "Memory failure\n");
-                    return;
+                    return 0;
                 }
 
                 for(int i=0; i<16; i++){
@@ -1671,6 +1673,8 @@ void check_handshake(struct packet_info *info){
 
         }
     }
+
+    return !res;
 }
 
 /* Check the given tag with the given context and private key.  Return 0

+ 1 - 1
relay_station/crypto.h

@@ -65,7 +65,7 @@ int mark_finished_hash(flow *f, uint8_t *hs);
 int init_ciphers(flow *f);
 void generate_client_super_keys(uint8_t *secret, client *c);
 int super_encrypt(client *c, uint8_t *data, uint32_t len);
-void check_handshake(struct packet_info *info);
+int check_handshake(struct packet_info *info);
 
 int check_tag(byte key[16], const byte privkey[PTWIST_BYTES],
         const byte tag[PTWIST_TAG_BYTES], const byte *context,