Skip to content

Commit

Permalink
Merge pull request #14 from muflihun/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
abumq authored Mar 8, 2018
2 parents 0717e08 + cf12d82 commit b06b4ef
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
logs
CMakeFiles
build
CMakeLists.txt.user
CMakeLists.txt.user*
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
2 changes: 1 addition & 1 deletion build.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// modules for ease of development
///

$lib_version = "1.1.3";
$lib_version = "1.1.4";

$header_template = <<<EOT
//
Expand Down
2 changes: 2 additions & 0 deletions dist/npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linux/mine
darwin/mine
23 changes: 23 additions & 0 deletions dist/npm/darwin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "mine-darwin",
"version": "1.1.4",
"description": "Mine cryptography CLI tool (macOS)",
"homepage": "https://github.com/muflihun/mine",
"author": "Muflihun Labs <info@muflihun.com>",
"license": "Apache-2.0",
"bin": "./mine",
"repository": {
"type": "git",
"url": "http://github.com/muflihun/mine.git"
},
"files": [
"mine"
],
"keywords": [
"aes",
"rsa",
"darwin",
"crypto",
"zlib"
]
}
23 changes: 23 additions & 0 deletions dist/npm/linux/package.json
Original file line number Diff line number Diff line change
@@ -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 <info@muflihun.com>",
"license": "Apache-2.0",
"bin": "./mine",
"repository": {
"type": "git",
"url": "http://github.com/muflihun/mine.git"
},
"files": [
"mine"
],
"keywords": [
"aes",
"rsa",
"linux",
"crypto",
"zlib"
]
}
8 changes: 4 additions & 4 deletions package/mine.cc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -31,7 +31,7 @@

using namespace mine;
#ifndef MINE_VERSION
#define MINE_VERSION "1.1.3"
#define MINE_VERSION "1.1.4"
#endif


Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package/mine.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/aes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
25 changes: 18 additions & 7 deletions test/aes-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);


}

Expand Down

0 comments on commit b06b4ef

Please sign in to comment.