From f30b6c9e6e55d4fd8cef49f441ecd43e5097d356 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 4 Dec 2018 12:54:48 -0500 Subject: [PATCH] const reference to vector of buffers --- libi2pd/Crypto.cpp | 6 +++--- libi2pd/Crypto.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index 5629e75e..1d79fc71 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -1174,7 +1174,7 @@ namespace crypto return ret; } - void AEADChaCha20Poly1305Encrypt (std::vector >& bufs, const uint8_t * key, const uint8_t * nonce, uint8_t * mac) + void AEADChaCha20Poly1305Encrypt (const std::vector >& bufs, const uint8_t * key, const uint8_t * nonce, uint8_t * mac) { if (bufs.empty ()) return; #if LEGACY_OPENSSL @@ -1188,7 +1188,7 @@ namespace crypto // encrypt buffers Chacha20SetCounter (state, 1); size_t size = 0; - for (auto& it: bufs) + for (const auto& it: bufs) { chacha::Chacha20Encrypt (state, it.first, it.second); polyHash.Update (it.first, it.second); // after encryption @@ -1216,7 +1216,7 @@ namespace crypto EVP_EncryptInit_ex(ctx, EVP_chacha20_poly1305(), 0, 0, 0); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, 12, 0); EVP_EncryptInit_ex(ctx, NULL, NULL, key, nonce); - for (auto& it: bufs) + for (const auto& it: bufs) EVP_EncryptUpdate(ctx, it.first, &outlen, it.first, it.second); EVP_EncryptFinal_ex(ctx, NULL, &outlen); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, 16, mac); diff --git a/libi2pd/Crypto.h b/libi2pd/Crypto.h index 9e110e66..b5b40631 100644 --- a/libi2pd/Crypto.h +++ b/libi2pd/Crypto.h @@ -283,7 +283,7 @@ namespace crypto // AEAD/ChaCha20/Poly1305 bool AEADChaCha20Poly1305 (const uint8_t * msg, size_t msgLen, const uint8_t * ad, size_t adLen, const uint8_t * key, const uint8_t * nonce, uint8_t * buf, size_t len, bool encrypt); // msgLen is len without tag - void AEADChaCha20Poly1305Encrypt (std::vector >& bufs, const uint8_t * key, const uint8_t * nonce, uint8_t * mac); // encrypt multiple buffers with zero ad + void AEADChaCha20Poly1305Encrypt (const std::vector >& bufs, const uint8_t * key, const uint8_t * nonce, uint8_t * mac); // encrypt multiple buffers with zero ad // init and terminate void InitCrypto (bool precomputation);