mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-29 02:43:43 +00:00
format with .uncrustify.cfg (#1759)
* format with .uncrustify.cfg format with .uncrustify.cfg * format with .uncrustify.cfg * format with .uncrustify.cfg exclude json.* base64.* uthash.h * format with .uncrustify.cfg exclude json.* base64.* uthash.h
This commit is contained in:
+19
-21
@@ -264,10 +264,10 @@ aead_cipher_ctx_set_key(cipher_ctx_t *cipher_ctx, int enc)
|
||||
}
|
||||
|
||||
int err = crypto_hkdf(md,
|
||||
cipher_ctx->salt, cipher_ctx->cipher->key_len,
|
||||
cipher_ctx->cipher->key, cipher_ctx->cipher->key_len,
|
||||
(uint8_t *)SUBKEY_INFO, strlen(SUBKEY_INFO),
|
||||
cipher_ctx->skey, cipher_ctx->cipher->key_len);
|
||||
cipher_ctx->salt, cipher_ctx->cipher->key_len,
|
||||
cipher_ctx->cipher->key, cipher_ctx->cipher->key_len,
|
||||
(uint8_t *)SUBKEY_INFO, strlen(SUBKEY_INFO),
|
||||
cipher_ctx->skey, cipher_ctx->cipher->key_len);
|
||||
if (err) {
|
||||
FATAL("Unable to generate subkey");
|
||||
}
|
||||
@@ -358,9 +358,9 @@ aead_encrypt_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity)
|
||||
cipher_ctx_t cipher_ctx;
|
||||
aead_ctx_init(cipher, &cipher_ctx, 1);
|
||||
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t tag_len = cipher->tag_len;
|
||||
int err = CRYPTO_OK;
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t tag_len = cipher->tag_len;
|
||||
int err = CRYPTO_OK;
|
||||
|
||||
static buffer_t tmp = { 0, 0, 0, NULL };
|
||||
brealloc(&tmp, salt_len + tag_len + plaintext->len, capacity);
|
||||
@@ -395,9 +395,9 @@ aead_encrypt_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity)
|
||||
int
|
||||
aead_decrypt_all(buffer_t *ciphertext, cipher_t *cipher, size_t capacity)
|
||||
{
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t tag_len = cipher->tag_len;
|
||||
int err = CRYPTO_OK;
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t tag_len = cipher->tag_len;
|
||||
int err = CRYPTO_OK;
|
||||
|
||||
if (ciphertext->len <= salt_len + tag_len) {
|
||||
return CRYPTO_ERROR;
|
||||
@@ -469,7 +469,7 @@ aead_chunk_encrypt(cipher_ctx_t *ctx, uint8_t *p, uint8_t *c,
|
||||
sodium_increment(n, nlen);
|
||||
|
||||
clen = plen + tlen;
|
||||
err = aead_cipher_encrypt(ctx, c + CHUNK_SIZE_LEN + tlen, &clen,p, plen,
|
||||
err = aead_cipher_encrypt(ctx, c + CHUNK_SIZE_LEN + tlen, &clen, p, plen,
|
||||
NULL, 0, n, ctx->skey);
|
||||
if (err)
|
||||
return CRYPTO_ERROR;
|
||||
@@ -495,11 +495,11 @@ aead_encrypt(buffer_t *plaintext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
static buffer_t tmp = { 0, 0, 0, NULL };
|
||||
buffer_t *ciphertext;
|
||||
|
||||
cipher_t *cipher = cipher_ctx->cipher;
|
||||
int err = CRYPTO_ERROR;
|
||||
size_t salt_ofst = 0;
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t tag_len = cipher->tag_len;
|
||||
cipher_t *cipher = cipher_ctx->cipher;
|
||||
int err = CRYPTO_ERROR;
|
||||
size_t salt_ofst = 0;
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t tag_len = cipher->tag_len;
|
||||
|
||||
if (!cipher_ctx->init) {
|
||||
salt_ofst = salt_len;
|
||||
@@ -586,7 +586,7 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
|
||||
cipher_t *cipher = cipher_ctx->cipher;
|
||||
|
||||
size_t salt_len = cipher->key_len;
|
||||
size_t salt_len = cipher->key_len;
|
||||
|
||||
if (cipher_ctx->chunk == NULL) {
|
||||
cipher_ctx->chunk = (buffer_t *)ss_malloc(sizeof(buffer_t));
|
||||
@@ -621,7 +621,6 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
cipher_ctx->chunk->len -= salt_len;
|
||||
|
||||
cipher_ctx->init = 1;
|
||||
|
||||
}
|
||||
|
||||
size_t plen = 0;
|
||||
@@ -686,10 +685,10 @@ aead_key_init(int method, const char *pass, const char *key)
|
||||
|
||||
if (key != NULL)
|
||||
cipher->key_len = crypto_parse_key(key, cipher->key,
|
||||
supported_aead_ciphers_key_size[method]);
|
||||
supported_aead_ciphers_key_size[method]);
|
||||
else
|
||||
cipher->key_len = crypto_derive_key(pass, cipher->key,
|
||||
supported_aead_ciphers_key_size[method]);
|
||||
supported_aead_ciphers_key_size[method]);
|
||||
|
||||
if (cipher->key_len == 0) {
|
||||
FATAL("Cannot generate key and nonce");
|
||||
@@ -719,4 +718,3 @@ aead_init(const char *pass, const char *key, const char *method)
|
||||
}
|
||||
return aead_key_init(m, pass, key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user