integrate libsodium as a submodule

This commit is contained in:
Max Lv
2014-12-13 11:58:13 +08:00
parent ae85d6f36b
commit bca8a499f9
25 changed files with 3005 additions and 2489 deletions
+1
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+11 -8
View File
@@ -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
View File
@@ -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;