Skip to content

Commit 67fe7a3

Browse files
committed
Minor changes for code clean-up
1 parent 11e3b5a commit 67fe7a3

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

libs/libdecrypt/src/decryption.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ EVP_PKEY *Decryption::loadPrivateKey(const std::string& privateKeyString) {
103103
/**
104104
* @brief
105105
*
106-
* @param encoded he base64-encoded input string.
106+
* @param encoded The base64-encoded input string.
107107
* @return std::vector<unsigned char> The decoded dynamic array of characters.
108108
*/
109109
std::vector<unsigned char> Decryption::base64Decode(const std::string& encoded) {

libs/libencrypt/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ project(libencrypt)
44
find_package(PkgConfig REQUIRED)
55
pkg_search_module(OPENSSL REQUIRED openssl)
66

7+
set(SESSION_KEY_SIZE 16)
8+
add_definitions(-DSESSION_KEY_SIZE=${SESSION_KEY_SIZE})
9+
710
if(OPENSSL_FOUND)
811
include_directories(${OPENSSL_INCLUDE_DIRS})
912
message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")

libs/libencrypt/src/encryption.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#include "encryption.h"
22

3+
#ifdef SESSION_KEY_SIZE
4+
unsigned sessionKeySize = SESSION_KEY_SIZE;
5+
#else
6+
unsigned sessionKeySize = 16;
7+
#endif
8+
39
/**
410
* @brief Generates random session key
511
*
@@ -183,7 +189,7 @@ bool Encryption::encryptFile(const std::string& publicKeyFile, std::string& file
183189

184190
OpenSSL_add_all_algorithms();
185191
ERR_load_crypto_strings();
186-
unsigned char sessionKey[16];
192+
unsigned char sessionKey[sessionKeySize];
187193
generateSessionKey(sessionKey, sizeof(sessionKey));
188194

189195
//load public key
@@ -214,7 +220,7 @@ bool Encryption::encryptFile(const std::string& publicKeyFile, std::string& file
214220
unsigned char iv[EVP_MAX_IV_LENGTH];
215221
if (RAND_bytes(iv, sizeof(iv)) != 1) {
216222
std::cerr << "Error generating IV." << std::endl;
217-
return -1;
223+
return false;
218224
}
219225

220226
// Encrypt file contents

libs/libpugiutil/src/pugixml_loc.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ void loc_data::build_loc_data() {
4747
}
4848

4949
void loc_data::build_loc_data_from_string(char* filename_val, size_t buffersize) {
50-
//std::ptrdiff_t offset = 0;
51-
//char buffer[1024];
52-
//std::size_t size;
5350
for (std::size_t i = 0; i < buffersize; ++i) {
5451
if (filename_val[i] == '\0')
5552
break;

0 commit comments

Comments
 (0)