mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-01 23:43:41 +00:00
Fix MinGW PolarSSL build and update readme
This commit is contained in:
+16
-3
@@ -3,19 +3,26 @@
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(USE_CRYPTO_OPENSSL)
|
||||
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#elif defined(USE_CRYPTO_POLARSSL)
|
||||
|
||||
#include <polarssl/md5.h>
|
||||
#include <polarssl/entropy.h>
|
||||
#include <polarssl/ctr_drbg.h>
|
||||
#include <polarssl/version.h>
|
||||
#define CIPHER_UNSUPPORTED "unsupported"
|
||||
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
@@ -371,7 +378,9 @@ int rand_bytes(uint8_t *output, int len)
|
||||
#endif
|
||||
entropy_init(&ec);
|
||||
if (ctr_drbg_init(&cd_ctx, entropy_func, &ec, (const unsigned char *) rand_buffer.buffer, 8) != 0) {
|
||||
#if POLARSSL_VERSION_NUMBER >= 0x01030000
|
||||
entropy_free(&ec);
|
||||
#endif
|
||||
FATAL("Failed to initialize random generator");
|
||||
}
|
||||
rand_initialised = 1;
|
||||
@@ -460,9 +469,6 @@ void cipher_context_init(cipher_ctx_t *evp, int method, int enc)
|
||||
if (cipher_init_ctx(evp, cipher) != 0) {
|
||||
FATAL("Cannot initialize PolarSSL cipher context");
|
||||
}
|
||||
if (method > RC4) {
|
||||
cipher_set_padding_mode(evp, POLARSSL_PADDING_PKCS7);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -485,6 +491,7 @@ void cipher_context_set_iv(cipher_ctx_t *evp, uint8_t *iv, size_t iv_len, int en
|
||||
cipher_free_ctx(evp);
|
||||
FATAL("Cannot set PolarSSL cipher key");
|
||||
}
|
||||
#if POLARSSL_VERSION_NUMBER >= 0x01030000
|
||||
if (cipher_set_iv(evp, iv, iv_len) != 0) {
|
||||
cipher_free_ctx(evp);
|
||||
FATAL("Cannot set PolarSSL cipher IV");
|
||||
@@ -493,6 +500,12 @@ void cipher_context_set_iv(cipher_ctx_t *evp, uint8_t *iv, size_t iv_len, int en
|
||||
cipher_free_ctx(evp);
|
||||
FATAL("Cannot finalize PolarSSL cipher context");
|
||||
}
|
||||
#else
|
||||
if(cipher_reset(evp, iv) != 0) {
|
||||
cipher_free_ctx(evp);
|
||||
FATAL("Cannot set PolarSSL cipher IV");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
dump("IV", iv);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(USE_CRYPTO_OPENSSL)
|
||||
|
||||
#include <openssl/evp.h>
|
||||
typedef EVP_CIPHER cipher_kt_t;
|
||||
typedef EVP_CIPHER_CTX cipher_ctx_t;
|
||||
@@ -29,7 +30,9 @@ typedef EVP_MD digest_type_t;
|
||||
#define MAX_KEY_LENGTH EVP_MAX_KEY_LENGTH
|
||||
#define MAX_IV_LENGTH EVP_MAX_IV_LENGTH
|
||||
#define MAX_MD_SIZE EVP_MAX_MD_SIZE
|
||||
|
||||
#elif defined(USE_CRYPTO_POLARSSL)
|
||||
|
||||
#include <polarssl/cipher.h>
|
||||
#include <polarssl/md.h>
|
||||
typedef cipher_info_t cipher_kt_t;
|
||||
@@ -38,6 +41,7 @@ typedef md_info_t digest_type_t;
|
||||
#define MAX_KEY_LENGTH 64
|
||||
#define MAX_IV_LENGTH POLARSSL_MAX_IV_LENGTH
|
||||
#define MAX_MD_SIZE POLARSSL_MD_MAX_SIZE
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ void usage()
|
||||
printf(" ss-[local|redir|server]\n");
|
||||
printf(" -s <server_host> host name or ip address of your remote server\n");
|
||||
printf(" -p <server_port> port number of your remote server\n");
|
||||
printf(" -l <local_port>> port number of your local server\n");
|
||||
printf(" -l <local_port> port number of your local server\n");
|
||||
printf(" -k <password> password of your remote server\n");
|
||||
printf("\n");
|
||||
printf(" [-m <encrypt_method>] encrypt method, supporting table, rc4,\n");
|
||||
|
||||
Reference in New Issue
Block a user