diff --git a/.gitignore b/.gitignore index a4189d1..40ab26e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ logs CMakeFiles build -CMakeLists.txt.user +CMakeLists.txt.user* diff --git a/CHANGELOG.md b/CHANGELOG.md index b64d0f1..1abc66a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [1.1.4] - 08-03-2018 +### Fixes +- Fix cross-encoding with issue 11 + ## [1.1.3] - 08-03-2018 ### Fixes - Issue 11 - (AES) Invalid padding when input is equal to block size diff --git a/CMakeLists.txt b/CMakeLists.txt index fd8147d..fc604c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,8 @@ option (test_main_header "Test main header (mine.h)" OFF) option (test_wstring_conversions "Test std::wstring (wchar_t*) conversions for encodings" ON) -set (MINE_VERSION "1.1.3") ## Also update build.php -set (MINE_SOVERSION "1.1.3") +set (MINE_VERSION "1.1.4") ## Also update build.php +set (MINE_SOVERSION "1.1.4") add_definitions (-DMINE_VERSION="${MINE_VERSION}") diff --git a/build.php b/build.php index ff8e426..5502012 100644 --- a/build.php +++ b/build.php @@ -6,7 +6,7 @@ /// modules for ease of development /// -$lib_version = "1.1.3"; +$lib_version = "1.1.4"; $header_template = <<", + "license": "Apache-2.0", + "bin": "./mine", + "repository": { + "type": "git", + "url": "http://github.com/muflihun/mine.git" + }, + "files": [ + "mine" + ], + "keywords": [ + "aes", + "rsa", + "darwin", + "crypto", + "zlib" + ] +} diff --git a/dist/npm/linux/package.json b/dist/npm/linux/package.json new file mode 100644 index 0000000..9b6756d --- /dev/null +++ b/dist/npm/linux/package.json @@ -0,0 +1,23 @@ +{ + "name": "mine-linux", + "version": "1.1.4", + "description": "Mine cryptography CLI tool (Linux)", + "homepage": "https://github.com/muflihun/mine", + "author": "Muflihun Labs ", + "license": "Apache-2.0", + "bin": "./mine", + "repository": { + "type": "git", + "url": "http://github.com/muflihun/mine.git" + }, + "files": [ + "mine" + ], + "keywords": [ + "aes", + "rsa", + "linux", + "crypto", + "zlib" + ] +} diff --git a/package/mine.cc b/package/mine.cc index 4d3ba5c..0f3a4cc 100644 --- a/package/mine.cc +++ b/package/mine.cc @@ -1,7 +1,7 @@ // // Bismillah ar-Rahmaan ar-Raheem // -// Mine (1.1.3) +// Mine (1.1.4) // Single header minimal cryptography library // // Copyright (c) 2017-present Muflihun Labs @@ -31,7 +31,7 @@ using namespace mine; #ifndef MINE_VERSION -#define MINE_VERSION "1.1.3" +#define MINE_VERSION "1.1.4" #endif @@ -998,7 +998,7 @@ std::string AES::encrypt(const std::string& input, const std::string& key, MineC { Key keyArr = Base16::fromString(key); ByteArray inp = resolveInputMode(input, inputEncoding); - if (pkcs5Padding && inputEncoding == MineCommon::Encoding::Raw && inp.size() % kBlockSize == 0) { + if (pkcs5Padding && inp.size() % kBlockSize == 0) { // input size is multiple of block size, increase // input size for padding auto sz = inp.size(); @@ -1013,7 +1013,7 @@ std::string AES::encrypt(const std::string& input, const std::string& key, std:: { Key keyArr = Base16::fromString(key); ByteArray inp = resolveInputMode(input, inputEncoding); - if (pkcs5Padding && inputEncoding == MineCommon::Encoding::Raw && inp.size() % kBlockSize == 0) { + if (pkcs5Padding && inp.size() % kBlockSize == 0) { // input size is multiple of block size, increase // input size for padding auto sz = inp.size(); diff --git a/package/mine.h b/package/mine.h index cd9db1f..87021fd 100644 --- a/package/mine.h +++ b/package/mine.h @@ -1,7 +1,7 @@ // // Bismillah ar-Rahmaan ar-Raheem // -// Mine (1.1.3) +// Mine (1.1.4) // Single header minimal cryptography library // // Copyright (c) 2017-present Muflihun Labs diff --git a/src/aes.cc b/src/aes.cc index 8af8e6e..d0bc5a6 100644 --- a/src/aes.cc +++ b/src/aes.cc @@ -857,7 +857,7 @@ std::string AES::encrypt(const std::string& input, const std::string& key, MineC { Key keyArr = Base16::fromString(key); ByteArray inp = resolveInputMode(input, inputEncoding); - if (pkcs5Padding && inputEncoding == MineCommon::Encoding::Raw && inp.size() % kBlockSize == 0) { + if (pkcs5Padding && inp.size() % kBlockSize == 0) { // input size is multiple of block size, increase // input size for padding auto sz = inp.size(); @@ -872,7 +872,7 @@ std::string AES::encrypt(const std::string& input, const std::string& key, std:: { Key keyArr = Base16::fromString(key); ByteArray inp = resolveInputMode(input, inputEncoding); - if (pkcs5Padding && inputEncoding == MineCommon::Encoding::Raw && inp.size() % kBlockSize == 0) { + if (pkcs5Padding && inp.size() % kBlockSize == 0) { // input size is multiple of block size, increase // input size for padding auto sz = inp.size(); diff --git a/test/aes-test.h b/test/aes-test.h index cee1d1c..1c872e8 100644 --- a/test/aes-test.h +++ b/test/aes-test.h @@ -516,7 +516,7 @@ TEST(AESTest, RawCipherDirect) for (auto& item : RawCipherData) { std::string expected = PARAM(2); - std::string output = aes.encrypt(PARAM(0), PARAM(1), MineCommon::Encoding::Base16); + std::string output = aes.encrypt(PARAM(0), PARAM(1), MineCommon::Encoding::Base16, MineCommon::Encoding::Base16, false); // case insensitive comparison because hex can be upper or lower case ASSERT_STRCASEEQ(expected.c_str(), output.c_str()); } @@ -1104,17 +1104,28 @@ TEST(AESTest, EncryptResultsForLongTextMatchesRipe) AES aes; aes.setKey(key); - auto run = [&](const std::string& inp, const std::string& exp) { + auto run = [&](const std::string& inp, const std::string& exp, MineCommon::Encoding enc) { std::string ivCopy = iv; - std::string output = aes.encr(inp, ivCopy, MineCommon::Encoding::Raw, MineCommon::Encoding::Base16); + std::string output = aes.encr(inp, ivCopy, enc, MineCommon::Encoding::Base16); LOG(INFO) << "Ripe: echo " << output << " | ripe -d --aes --key " << key << " --iv " << iv << " --hex"; ASSERT_STRCASEEQ(exp.c_str(), output.c_str()); }; - run(input15, input15Enc); - run(input16, input16Enc); - run(input17, input17Enc); - run(input32, input32Enc); + run(input15, input15Enc, MineCommon::Encoding::Raw); + run(input16, input16Enc, MineCommon::Encoding::Raw); + run(input17, input17Enc, MineCommon::Encoding::Raw); + run(input32, input32Enc, MineCommon::Encoding::Raw); + + run(Base16::encode(input15), input15Enc, MineCommon::Encoding::Base16); + run(Base16::encode(input16), input16Enc, MineCommon::Encoding::Base16); + run(Base16::encode(input17), input17Enc, MineCommon::Encoding::Base16); + run(Base16::encode(input32), input32Enc, MineCommon::Encoding::Base16); + + run(Base64::encode(input15), input15Enc, MineCommon::Encoding::Base64); + run(Base64::encode(input16), input16Enc, MineCommon::Encoding::Base64); + run(Base64::encode(input17), input17Enc, MineCommon::Encoding::Base64); + run(Base64::encode(input32), input32Enc, MineCommon::Encoding::Base64); + }