mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-01 23:43:41 +00:00
integrate libsodium as a submodule
This commit is contained in:
@@ -11,6 +11,7 @@ AM_LDFLAGS = -static
|
||||
SS_COMMON_LIBS = $(top_builddir)/libev/libev.la \
|
||||
$(top_builddir)/libipset/libipset.la \
|
||||
$(top_builddir)/libcork/libcork.la \
|
||||
$(top_builddir)/libsodium/src/libsodium/libsodium.la \
|
||||
$(INET_NTOP_LIB)
|
||||
|
||||
bin_PROGRAMS = ss-local ss-tunnel
|
||||
|
||||
+406
-323
File diff suppressed because it is too large
Load Diff
+11
-8
@@ -26,6 +26,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SODIUM_H
|
||||
#define HAVE_SODIUM_H
|
||||
#endif
|
||||
|
||||
#if defined(USE_CRYPTO_OPENSSL)
|
||||
|
||||
#include <openssl/md5.h>
|
||||
@@ -709,6 +713,11 @@ void cipher_context_set_iv(cipher_ctx_t *ctx, uint8_t *iv, size_t iv_len,
|
||||
|
||||
void cipher_context_release(cipher_ctx_t *ctx)
|
||||
{
|
||||
#ifdef HAVE_SODIUM_H
|
||||
if (enc_method >= SALSA20)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef USE_CRYPTO_APPLECC
|
||||
cipher_cc_t *cc = &ctx->cc;
|
||||
if (cc->cryptor != NULL) {
|
||||
@@ -793,10 +802,7 @@ char * ss_encrypt_all(int buf_size, char *plaintext, ssize_t *len, int method)
|
||||
*len = iv_len + c_len;
|
||||
free(plaintext);
|
||||
|
||||
#ifdef HAVE_SODIUM_H
|
||||
if (method < SALSA20)
|
||||
#endif
|
||||
cipher_context_release(&evp);
|
||||
cipher_context_release(&evp);
|
||||
|
||||
return ciphertext;
|
||||
|
||||
@@ -928,10 +934,7 @@ char * ss_decrypt_all(int buf_size, char *ciphertext, ssize_t *len, int method)
|
||||
*len = p_len;
|
||||
free(ciphertext);
|
||||
|
||||
#ifdef HAVE_SODIUM_H
|
||||
if (method < SALSA20)
|
||||
#endif
|
||||
cipher_context_release(&evp);
|
||||
cipher_context_release(&evp);
|
||||
|
||||
return plaintext;
|
||||
} else {
|
||||
|
||||
+3
-3
@@ -92,7 +92,7 @@ typedef struct {
|
||||
#ifdef USE_CRYPTO_APPLECC
|
||||
cipher_cc_t cc;
|
||||
#endif
|
||||
#if HAVE_SODIUM_H
|
||||
#ifdef HAVE_SODIUM_H
|
||||
uint8_t iv[MAX_IV_LENGTH];
|
||||
#endif
|
||||
} cipher_ctx_t;
|
||||
@@ -103,7 +103,7 @@ typedef struct {
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SODIUM_H
|
||||
#ifdef HAVE_SODIUM_H
|
||||
#define SODIUM_BLOCK_SIZE 64
|
||||
#define CIPHER_NUM 17
|
||||
#else
|
||||
@@ -136,7 +136,7 @@ typedef struct {
|
||||
|
||||
struct enc_ctx {
|
||||
uint8_t init;
|
||||
#if HAVE_SODIUM_H
|
||||
#ifdef HAVE_SODIUM_H
|
||||
uint64_t counter;
|
||||
#endif
|
||||
cipher_ctx_t evp;
|
||||
|
||||
Reference in New Issue
Block a user