Skip to content

Commit

Permalink
not include *.c in obfs
Browse files Browse the repository at this point in the history
  • Loading branch information
breakwa11 committed Mar 14, 2017
1 parent 0111fa0 commit c2e5877
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 29 deletions.
2 changes: 2 additions & 0 deletions src/encrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ typedef struct enc_ctx {

void bytes_to_key_with_size(const char *pass, size_t len, uint8_t *md, size_t md_size);

int rand_bytes(uint8_t *output, int len);

int ss_encrypt_all(buffer_t *plaintext, int method, size_t capacity);
int ss_decrypt_all(buffer_t *ciphertext, int method, size_t capacity);
int ss_encrypt(buffer_t *plaintext, enc_ctx_t *ctx, size_t capacity);
Expand Down
12 changes: 12 additions & 0 deletions src/includeobfs.h
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
#ifndef _INCLUDEOBFSOBFS_H
#define _INCLUDEOBFSOBFS_H

#include "obfs/auth.c"
#include "obfs/tls1.2_ticket.c"
#include "obfs/verify.c"
#include "obfs/http_simple.c"
#include "obfs/obfsutil.c"
#include "obfs/base64.c"
#include "obfs/crc32.c"
#include "obfs/obfs.c"

#endif // _INCLUDEOBFSOBFS_H
6 changes: 6 additions & 0 deletions src/obfs/auth.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include <string.h>
#include <time.h>

#include "auth.h"
#include "obfsutil.h"
#include "crc32.h"
#include "base64.h"
#include "encrypt.h"

static int auth_simple_pack_unit_size = 2000;
typedef int (*hmac_with_key_func)(char *auth, char *msg, int msg_len, uint8_t *auth_key, int key_len);
Expand Down
8 changes: 5 additions & 3 deletions src/obfs/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Copyright (C) 2015 - 2016, Break Wa11 <[email protected]>
*/

#ifndef _AUTH_H
#define _AUTH_H
#ifndef _OBFS_AUTH_H
#define _OBFS_AUTH_H

struct obfs;

void * auth_simple_init_data();
obfs * auth_simple_new_obfs();
Expand All @@ -27,4 +29,4 @@ int auth_sha1_v4_client_post_decrypt(obfs *self, char **pplaindata, int dataleng
int auth_aes128_sha1_client_pre_encrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity);
int auth_aes128_sha1_client_post_decrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity);

#endif // _AUTH_H
#endif // _OBFS_AUTH_H
6 changes: 3 additions & 3 deletions src/obfs/base64.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __BASE64_H__
#define __BASE64_H__
#ifndef _OBFS_BASE64_H
#define _OBFS_BASE64_H

enum {BASE64_OK = 0, BASE64_INVALID};

Expand All @@ -13,4 +13,4 @@ int
base64_decode(const char *in, unsigned int inlen, unsigned char *out);


#endif /* __BASE64_H__ */
#endif // _OBFS_BASE64_H
20 changes: 20 additions & 0 deletions src/obfs/crc32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef _OBFS_CRC32_H
#define _OBFS_CRC32_H

void init_crc32_table(void);

uint32_t crc32(unsigned char *buffer, unsigned int size);

void fillcrc32to(unsigned char *buffer, unsigned int size, unsigned char *outbuffer);

void fillcrc32(unsigned char *buffer, unsigned int size);

void adler32_short(unsigned char *buffer, unsigned int size, uint32_t *a, uint32_t *b);

uint32_t adler32(unsigned char *buffer, unsigned int size);

void filladler32(unsigned char *buffer, unsigned int size);

int checkadler32(unsigned char *buffer, unsigned int size);

#endif // _OBFS_CRC32_H
7 changes: 7 additions & 0 deletions src/obfs/http_simple.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>

#include "http_simple.h"
#include "obfs.h"
#include "obfsutil.h"
#include "encrypt.h"

static char* g_useragent[] = {
"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0",
Expand Down
8 changes: 5 additions & 3 deletions src/obfs/http_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Copyright (C) 2015 - 2016, Break Wa11 <[email protected]>
*/

#ifndef _HTTP_SIMPLE_H
#define _HTTP_SIMPLE_H
#ifndef _OBFS_HTTP_SIMPLE_H
#define _OBFS_HTTP_SIMPLE_H

struct obfs;

obfs * http_simple_new_obfs();
void http_simple_dispose(obfs *self);
Expand All @@ -15,4 +17,4 @@ int http_simple_client_decode(obfs *self, char **pencryptdata, int datalength, s

int http_post_client_encode(obfs *self, char **pencryptdata, int datalength, size_t* capacity);

#endif // _HTTP_SIMPLE_H
#endif // _OBFS_HTTP_SIMPLE_H
17 changes: 8 additions & 9 deletions src/obfs/obfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
#include "obfs.h"

int rand_bytes(uint8_t *output, int len);
#define OBFS_HMAC_SHA1_LEN 10

#include "obfsutil.c"
#include "crc32.c"
#include "base64.c"
#include "http_simple.c"
#include "tls1.2_ticket.c"
#include "verify.c"
#include "auth.c"

#include "obfsutil.h"
#include "crc32.h"
#include "base64.h"
#include "http_simple.h"
#include "tls1.2_ticket.h"
#include "verify.h"
#include "auth.h"

void * init_data() {
return malloc(1);
Expand Down
8 changes: 5 additions & 3 deletions src/obfs/obfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
* Copyright (C) 2015 - 2016, Break Wa11 <[email protected]>
*/

#ifndef _OBFS_H
#define _OBFS_H
#ifndef _OBFS_OBFS_H
#define _OBFS_OBFS_H

#include <stdint.h>
#include <unistd.h>

#define OBFS_HMAC_SHA1_LEN 10

typedef struct server_info {
char host[64];
uint16_t port;
Expand Down Expand Up @@ -72,4 +74,4 @@ void get_server_info(obfs *self, server_info *server);
obfs * new_obfs();
void dispose_obfs(obfs *self);

#endif // _OBFS_H
#endif // _OBFS_OBFS_H
5 changes: 5 additions & 0 deletions src/obfs/obfsutil.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include <stdint.h>
#include <time.h>

#include "obfsutil.h"

int get_head_size(char *plaindata, int size, int def_size) {
if (plaindata == NULL || size < 2)
return def_size;
Expand Down
10 changes: 10 additions & 0 deletions src/obfs/obfsutil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef _OBFS_OBFSUTIL_H
#define _OBFS_OBFSUTIL_H

int get_head_size(char *plaindata, int size, int def_size);

void init_shift128plus(void);

uint64_t xorshift128plus(void);

#endif // _OBFS_OBFSUTIL_H
7 changes: 7 additions & 0 deletions src/obfs/tls1.2_ticket.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>

#include "tls1.2_ticket.h"
#include "obfs.h"
#include "obfsutil.h"
#include "encrypt.h"

typedef struct tls12_ticket_auth_global_data {
uint8_t local_client_id[32];
Expand Down
12 changes: 7 additions & 5 deletions src/obfs/tls1.2_ticket.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/*
* http_simple.h - Define shadowsocksR server's buffers and callbacks
* tls1.2_ticket.h - Define shadowsocksR server's buffers and callbacks
*
* Copyright (C) 2015 - 2016, Break Wa11 <[email protected]>
* Copyright (C) 2015 - 2017, Break Wa11 <[email protected]>
*/

#ifndef _TLS1_2_TICKET_H
#define _TLS1_2_TICKET_H
#ifndef _OBFS_TLS1_2_TICKET_H
#define _OBFS_TLS1_2_TICKET_H

struct obfs;

void * tls12_ticket_auth_init_data();
obfs * tls12_ticket_auth_new_obfs();
Expand All @@ -14,4 +16,4 @@ void tls12_ticket_auth_dispose(obfs *self);
int tls12_ticket_auth_client_encode(obfs *self, char **pencryptdata, int datalength, size_t* capacity);
int tls12_ticket_auth_client_decode(obfs *self, char **pencryptdata, int datalength, size_t* capacity, int *needsendback);

#endif // _TLS1_2_TICKET_H
#endif // _OBFS_TLS1_2_TICKET_H
5 changes: 5 additions & 0 deletions src/obfs/verify.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include <stdlib.h>

#include "verify.h"
#include "obfs.h"
#include "obfsutil.h"
#include "crc32.h"
#include "encrypt.h"

static int verify_simple_pack_unit_size = 2000;

Expand Down
8 changes: 5 additions & 3 deletions src/obfs/verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
* Copyright (C) 2015 - 2016, Break Wa11 <[email protected]>
*/

#ifndef _VERIFY_H
#define _VERIFY_H
#ifndef _OBFS_VERIFY_H
#define _OBFS_VERIFY_H

struct obfs;

obfs * verify_simple_new_obfs();
void verify_simple_dispose(obfs *self);

int verify_simple_client_pre_encrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity);
int verify_simple_client_post_decrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity);

#endif // _VERIFY_H
#endif // _OBFS_VERIFY_H

0 comments on commit c2e5877

Please sign in to comment.