|
| 1 | +diff --git a/.gitignore b/.gitignore |
| 2 | +index b064303ce..bc4b814ee 100644 |
| 3 | +--- a/.gitignore |
| 4 | ++++ b/.gitignore |
| 5 | +@@ -6,3 +6,4 @@ wpaspy/build |
| 6 | + **/parallel-vm.log |
| 7 | + tags |
| 8 | + build/ |
| 9 | ++*.a |
| 10 | +diff --git a/src/crypto/Makefile b/src/crypto/Makefile |
| 11 | +index ce0997091..2320cbdf2 100644 |
| 12 | +--- a/src/crypto/Makefile |
| 13 | ++++ b/src/crypto/Makefile |
| 14 | +@@ -1,7 +1,3 @@ |
| 15 | +-CFLAGS += -DCONFIG_CRYPTO_INTERNAL |
| 16 | +-CFLAGS += -DCONFIG_TLS_INTERNAL_CLIENT |
| 17 | +-CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER |
| 18 | +-#CFLAGS += -DALL_DH_GROUPS |
| 19 | + CFLAGS += -DCONFIG_SHA256 |
| 20 | + CFLAGS += -DCONFIG_SHA384 |
| 21 | + CFLAGS += -DCONFIG_HMAC_SHA384_KDF |
| 22 | +@@ -14,45 +10,34 @@ LIB_OBJS= \ |
| 23 | + aes-eax.o \ |
| 24 | + aes-encblock.o \ |
| 25 | + aes-gcm.o \ |
| 26 | +- aes-internal.o \ |
| 27 | +- aes-internal-dec.o \ |
| 28 | +- aes-internal-enc.o \ |
| 29 | +- aes-omac1.o \ |
| 30 | +- aes-siv.o \ |
| 31 | +- aes-unwrap.o \ |
| 32 | +- aes-wrap.o \ |
| 33 | +- des-internal.o \ |
| 34 | + dh_group5.o \ |
| 35 | + dh_groups.o \ |
| 36 | +- md4-internal.o \ |
| 37 | + md5.o \ |
| 38 | +- md5-internal.o \ |
| 39 | + milenage.o \ |
| 40 | + ms_funcs.o \ |
| 41 | +- rc4.o \ |
| 42 | + sha1.o \ |
| 43 | +- sha1-internal.o \ |
| 44 | +- sha1-pbkdf2.o \ |
| 45 | + sha1-prf.o \ |
| 46 | + sha1-tlsprf.o \ |
| 47 | + sha1-tprf.o \ |
| 48 | + sha256.o \ |
| 49 | + sha256-prf.o \ |
| 50 | + sha256-tlsprf.o \ |
| 51 | +- sha256-internal.o \ |
| 52 | + sha384.o \ |
| 53 | + sha384-prf.o \ |
| 54 | +- sha384-internal.o \ |
| 55 | + sha512.o \ |
| 56 | + sha512-prf.o \ |
| 57 | +- sha512-internal.o |
| 58 | ++ md4-internal.o \ |
| 59 | ++ crypto_openssl.o \ |
| 60 | ++ crypto_internal-rsa.o \ |
| 61 | ++ crypto_openssl.o \ |
| 62 | ++ tls_openssl.o |
| 63 | ++ |
| 64 | ++ifndef CONFIG_TLS_DEFAULT_CIPHERS |
| 65 | ++CONFIG_TLS_DEFAULT_CIPHERS = "DEFAULT:!EXP:!LOW" |
| 66 | ++endif |
| 67 | ++ |
| 68 | ++CFLAGS += -DTLS_DEFAULT_CIPHERS=\"$(CONFIG_TLS_DEFAULT_CIPHERS)\" |
| 69 | + |
| 70 | +-LIB_OBJS += crypto_internal.o |
| 71 | +-LIB_OBJS += crypto_internal-cipher.o |
| 72 | +-LIB_OBJS += crypto_internal-modexp.o |
| 73 | +-LIB_OBJS += crypto_internal-rsa.o |
| 74 | +-LIB_OBJS += tls_internal.o |
| 75 | +-LIB_OBJS += fips_prf_internal.o |
| 76 | + ifndef TEST_FUZZ |
| 77 | + LIB_OBJS += random.o |
| 78 | + endif |
| 79 | +diff --git a/src/cryptowpa b/src/cryptowpa |
| 80 | +new file mode 120000 |
| 81 | +index 000000000..2e8fb9de5 |
| 82 | +--- /dev/null |
| 83 | ++++ b/src/cryptowpa |
| 84 | +@@ -0,0 +1 @@ |
| 85 | ++crypto |
| 86 | +\ No newline at end of file |
| 87 | +diff --git a/src/lib.rules b/src/lib.rules |
| 88 | +index 947617b07..01e1802a3 100644 |
| 89 | +--- a/src/lib.rules |
| 90 | ++++ b/src/lib.rules |
| 91 | +@@ -1,5 +1,11 @@ |
| 92 | + _LIBMK := $(lastword $(wordlist 1,$(shell expr $(words $(MAKEFILE_LIST)) - 1),$(MAKEFILE_LIST))) |
| 93 | + _LIBNAME := $(notdir $(patsubst %/,%,$(dir $(abspath $(_LIBMK))))) |
| 94 | ++ |
| 95 | ++# hack to rename the 'crypto' library to 'cryptowpa' to avoid conflicts |
| 96 | ++ifeq ($(_LIBNAME),crypto) |
| 97 | ++ _LIBNAME := $(_LIBNAME)wpa |
| 98 | ++endif |
| 99 | ++ |
| 100 | + ALL := $(OUT)lib$(_LIBNAME).a |
| 101 | + LIB_RULES := $(lastword $(MAKEFILE_LIST)) |
| 102 | + include $(dir $(LIB_RULES))build.rules |
| 103 | +diff --git a/tests/Makefile b/tests/Makefile |
| 104 | +index 8ec154bb3..3fc700044 100644 |
| 105 | +--- a/tests/Makefile |
| 106 | ++++ b/tests/Makefile |
| 107 | +@@ -27,11 +27,12 @@ CFLAGS += -DCONFIG_TDLS |
| 108 | + |
| 109 | + CFLAGS += -I../src |
| 110 | + CFLAGS += -I../src/utils |
| 111 | ++CFLAGS += -g |
| 112 | + |
| 113 | + SLIBS = ../src/utils/libutils.a |
| 114 | + |
| 115 | +-DLIBS = ../src/crypto/libcrypto.a \ |
| 116 | +- ../src/tls/libtls.a |
| 117 | ++DLIBS = ../src/cryptowpa/libcryptowpa.a \ |
| 118 | ++ ../src/tls/libtls.a |
| 119 | + |
| 120 | + _OBJS_VAR := LLIBS |
| 121 | + include ../src/objs.mk |
| 122 | +@@ -46,6 +47,10 @@ LLIBS = -Wl,--start-group $(DLIBS) -Wl,--end-group $(SLIBS) |
| 123 | + # glibc < 2.17 needs -lrt for clock_gettime() |
| 124 | + LLIBS += -lrt |
| 125 | + |
| 126 | ++# need to append our libs to the end of the list, so LDFLAGS is not sufficient |
| 127 | ++# for the linker to find them |
| 128 | ++LLIBS += $(LIBS_EXTRA) |
| 129 | ++ |
| 130 | + test-aes: $(call BUILDOBJ,test-aes.o) $(LIBS) |
| 131 | + $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS) |
| 132 | + |
| 133 | +@@ -84,7 +89,7 @@ test-x509v3: $(call BUILDOBJ,test-x509v3.o) $(LIBS) |
| 134 | + |
| 135 | + |
| 136 | + # We could cut this down more by enabling fewer options (above) |
| 137 | +-ELIBS += $(SRC)/crypto/libcrypto.a |
| 138 | ++ELIBS += $(SRC)/cryptowpa/libcryptowpa.a |
| 139 | + ELIBS += $(SRC)/tls/libtls.a |
| 140 | + |
| 141 | + WPAS_SRC=../wpa_supplicant |
| 142 | +@@ -138,7 +143,7 @@ include ../src/objs.mk |
| 143 | + LIBS=$(SLIBS) $(DLIBS) $(WPA_LIBS) $(ELIBS) |
| 144 | + |
| 145 | + test-bss: $(call BUILDOBJ,test-bss.o) $(WPA_OBJS) $(LIBS) |
| 146 | +- $(LDO) $(LDFLAGS) -o $@ $< $(LLIBS) $(WPA_CFLAGS) $(WPA_OBJS) $(LIBS) |
| 147 | ++ $(LDO) $(LDFLAGS) -o $@ $< $(WPA_CFLAGS) $(WPA_OBJS) $(LIBS) $(LLIBS) |
| 148 | + |
| 149 | + run-tests: $(ALL) |
| 150 | + ./test-aes |
| 151 | +diff --git a/tests/test-https.c b/tests/test-https.c |
| 152 | +index a72e56f9d..930c47c84 100644 |
| 153 | +--- a/tests/test-https.c |
| 154 | ++++ b/tests/test-https.c |
| 155 | +@@ -12,7 +12,6 @@ |
| 156 | + #include "common.h" |
| 157 | + #include "crypto/tls.h" |
| 158 | + |
| 159 | +- |
| 160 | + static void https_tls_event_cb(void *ctx, enum tls_event ev, |
| 161 | + union tls_event_data *data) |
| 162 | + { |
| 163 | +@@ -75,7 +74,7 @@ static int https_client(int s, const char *path) |
| 164 | + struct tls_connection *conn; |
| 165 | + struct wpabuf *in, *out, *appl; |
| 166 | + int res = -1; |
| 167 | +- int need_more_data; |
| 168 | ++ int need_more_data = 0; |
| 169 | + |
| 170 | + os_memset(&conf, 0, sizeof(conf)); |
| 171 | + conf.event_cb = https_tls_event_cb; |
| 172 | +@@ -93,8 +92,7 @@ static int https_client(int s, const char *path) |
| 173 | + |
| 174 | + for (;;) { |
| 175 | + appl = NULL; |
| 176 | +- out = tls_connection_handshake2(tls, conn, in, &appl, |
| 177 | +- &need_more_data); |
| 178 | ++ out = tls_connection_handshake(tls, conn, in, &appl); |
| 179 | + wpabuf_free(in); |
| 180 | + in = NULL; |
| 181 | + if (out == NULL) { |
| 182 | +@@ -152,11 +150,11 @@ static int https_client(int s, const char *path) |
| 183 | + |
| 184 | + wpa_printf(MSG_INFO, "Reading HTTP response"); |
| 185 | + for (;;) { |
| 186 | +- int need_more_data; |
| 187 | ++ int need_more_data = 0; |
| 188 | + in = https_recv(s); |
| 189 | + if (in == NULL) |
| 190 | + goto done; |
| 191 | +- out = tls_connection_decrypt2(tls, conn, in, &need_more_data); |
| 192 | ++ out = tls_connection_decrypt(tls, conn, in); |
| 193 | + if (need_more_data) |
| 194 | + wpa_printf(MSG_DEBUG, "HTTP: Need more data"); |
| 195 | + wpabuf_free(in); |
| 196 | +diff --git a/tests/test-https_server.c b/tests/test-https_server.c |
| 197 | +index 33b448682..67b6aaabf 100644 |
| 198 | +--- a/tests/test-https_server.c |
| 199 | ++++ b/tests/test-https_server.c |
| 200 | +@@ -11,6 +11,12 @@ |
| 201 | + #include "common.h" |
| 202 | + #include "crypto/tls.h" |
| 203 | + |
| 204 | ++void tls_connection_set_log_cb(struct tls_connection *conn, |
| 205 | ++ void (*log_cb)(void *ctx, const char *msg), |
| 206 | ++ void *ctx) |
| 207 | ++{ |
| 208 | ++} |
| 209 | ++ |
| 210 | + |
| 211 | + static void https_tls_event_cb(void *ctx, enum tls_event ev, |
| 212 | + union tls_event_data *data) |
| 213 | +@@ -147,12 +153,12 @@ static int https_server(int s) |
| 214 | + |
| 215 | + wpa_printf(MSG_INFO, "Reading HTTP request"); |
| 216 | + for (;;) { |
| 217 | +- int need_more_data; |
| 218 | ++ int need_more_data = 0; |
| 219 | + |
| 220 | + in = https_recv(s, 5000); |
| 221 | + if (!in) |
| 222 | + goto done; |
| 223 | +- out = tls_connection_decrypt2(tls, conn, in, &need_more_data); |
| 224 | ++ out = tls_connection_decrypt(tls, conn, in); |
| 225 | + wpabuf_free(in); |
| 226 | + in = NULL; |
| 227 | + if (need_more_data) { |
0 commit comments