mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-24 00:54:02 +00:00
Fix #931
This commit is contained in:
+4
-3
@@ -1289,6 +1289,7 @@ enc_key_init(int method, const char *pass)
|
||||
#endif
|
||||
|
||||
cipher_t cipher;
|
||||
memset(&cipher, 0, sizeof(cipher_t));
|
||||
|
||||
// Initialize sodium for random generator
|
||||
if (sodium_init() == -1) {
|
||||
@@ -1297,6 +1298,7 @@ enc_key_init(int method, const char *pass)
|
||||
|
||||
if (method == SALSA20 || method == CHACHA20 || method == CHACHA20IETF) {
|
||||
#if defined(USE_CRYPTO_OPENSSL)
|
||||
cipher.info = NULL;
|
||||
cipher.key_len = supported_ciphers_key_size[method];
|
||||
cipher.iv_len = supported_ciphers_iv_size[method];
|
||||
#endif
|
||||
@@ -1317,7 +1319,7 @@ enc_key_init(int method, const char *pass)
|
||||
cipher.info = (cipher_kt_t *)get_cipher_type(method);
|
||||
}
|
||||
|
||||
if (cipher.info == NULL) {
|
||||
if (cipher.info == NULL && cipher.key_len == 0) {
|
||||
do {
|
||||
#if defined(USE_CRYPTO_POLARSSL) && defined(USE_CRYPTO_APPLECC)
|
||||
if (supported_ciphers_applecc[method] != kCCAlgorithmInvalid) {
|
||||
@@ -1338,8 +1340,7 @@ enc_key_init(int method, const char *pass)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
LOGE("Cipher %s not found in crypto library",
|
||||
supported_ciphers[method]);
|
||||
LOGE("Cipher %s not found in crypto library", supported_ciphers[method]);
|
||||
FATAL("Cannot initialize cipher");
|
||||
} while (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user