Fixed compiler warnings for msvc x64
This commit is contained in:
parent
96632f87ee
commit
1931602a38
@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace GhettoCipher
|
||||
{
|
||||
constexpr int BLOCK_SIZE = 512;
|
||||
constexpr int N_ROUNDS = 64;
|
||||
constexpr std::size_t BLOCK_SIZE = 512;
|
||||
constexpr std::size_t N_ROUNDS = 64;
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
#include <bitset>
|
||||
#include <cstdint>
|
||||
#include "Config.h"
|
||||
|
||||
namespace GhettoCipher
|
||||
{
|
||||
constexpr int HALFBLOCK_SIZE = (BLOCK_SIZE / 2);
|
||||
constexpr std::size_t HALFBLOCK_SIZE = (BLOCK_SIZE / 2);
|
||||
typedef std::bitset<HALFBLOCK_SIZE> Halfblock;
|
||||
}
|
||||
|
@ -8,27 +8,27 @@
|
||||
namespace GhettoCipher
|
||||
{
|
||||
//! Mod-operator that works with negative values
|
||||
inline int Mod(int numerator, int denominator)
|
||||
inline int Mod(const int numerator, const int denominator)
|
||||
{
|
||||
return (denominator + (numerator % denominator)) % denominator;
|
||||
}
|
||||
|
||||
//! Will perform a wrapping left-bitshift on a bitset
|
||||
template <std::size_t T>
|
||||
inline std::bitset<T> Shiftl(const std::bitset<T>& bits, std::size_t amount)
|
||||
inline std::bitset<T> Shiftl(const std::bitset<T>& bits, const std::size_t amount)
|
||||
{
|
||||
std::stringstream ss;
|
||||
const std::string bitss = bits.to_string();
|
||||
|
||||
for (std::size_t i = 0; i < bitss.size(); i++)
|
||||
ss << bitss[Mod((i + amount), bitss.size())];
|
||||
ss << bitss[Mod((int)(i + amount), (int)bitss.size())];
|
||||
|
||||
return std::bitset<T>(ss.str());
|
||||
}
|
||||
|
||||
//! Will perform a wrapping right-bitshift on a bitset
|
||||
template <std::size_t T>
|
||||
inline std::bitset<T> Shiftr(const std::bitset<T>& bits, std::size_t amount)
|
||||
inline std::bitset<T> Shiftr(const std::bitset<T>& bits, const std::size_t amount)
|
||||
{
|
||||
std::stringstream ss;
|
||||
const std::string bitss = bits.to_string();
|
||||
@ -159,10 +159,10 @@ namespace GhettoCipher
|
||||
std::size_t value;
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
// Is it a number?
|
||||
value = (c - '0') + 0;
|
||||
value = ((std::size_t)c - '0') + 0;
|
||||
else if ((c >= 'a') && (c <= 'f'))
|
||||
// Else, it is a lowercase letter
|
||||
value = (c - 'a') + 10;
|
||||
value = ((std::size_t)c - 'a') + 10;
|
||||
else
|
||||
throw std::logic_error("non-hex string detected in HexstringToBits()");
|
||||
|
||||
@ -186,10 +186,10 @@ namespace GhettoCipher
|
||||
std::size_t value;
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
// Is it a number?
|
||||
value = (c - '0') + 0;
|
||||
value = ((std::size_t)c - '0') + 0;
|
||||
else if ((c >= 'a') && (c <= 'f'))
|
||||
// Else, it is a lowercase letter
|
||||
value = (c - 'a') + 10;
|
||||
value = ((std::size_t)c - 'a') + 10;
|
||||
else
|
||||
throw std::logic_error("non-hex string detected in HexstringToBits()");
|
||||
|
||||
|
@ -28,6 +28,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/*** ./../GhettoCrypt/Version.h ***/
|
||||
|
||||
#pragma once
|
||||
#define GHETTOCRYPT_VERSION 0.1
|
||||
|
||||
/*** ./../GhettoCrypt/GhettoCryptWrapper.h ***/
|
||||
|
||||
#pragma once
|
||||
@ -75,19 +80,15 @@ namespace GhettoCipher
|
||||
typedef std::string Flexblock;
|
||||
}
|
||||
|
||||
/*** ./../GhettoCrypt/Version.h ***/
|
||||
|
||||
#pragma once
|
||||
#define GHETTOCRYPT_VERSION 0.1
|
||||
|
||||
/*** ./../GhettoCrypt/Config.h ***/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace GhettoCipher
|
||||
{
|
||||
constexpr int BLOCK_SIZE = 512;
|
||||
constexpr int N_ROUNDS = 64;
|
||||
constexpr std::size_t BLOCK_SIZE = 512;
|
||||
constexpr std::size_t N_ROUNDS = 64;
|
||||
}
|
||||
|
||||
/*** ./../GhettoCrypt/Block.h ***/
|
||||
@ -110,27 +111,27 @@ namespace GhettoCipher
|
||||
namespace GhettoCipher
|
||||
{
|
||||
//! Mod-operator that works with negative values
|
||||
inline int Mod(int numerator, int denominator)
|
||||
inline int Mod(const int numerator, const int denominator)
|
||||
{
|
||||
return (denominator + (numerator % denominator)) % denominator;
|
||||
}
|
||||
|
||||
//! Will perform a wrapping left-bitshift on a bitset
|
||||
template <std::size_t T>
|
||||
inline std::bitset<T> Shiftl(const std::bitset<T>& bits, std::size_t amount)
|
||||
inline std::bitset<T> Shiftl(const std::bitset<T>& bits, const std::size_t amount)
|
||||
{
|
||||
std::stringstream ss;
|
||||
const std::string bitss = bits.to_string();
|
||||
|
||||
for (std::size_t i = 0; i < bitss.size(); i++)
|
||||
ss << bitss[Mod((i + amount), bitss.size())];
|
||||
ss << bitss[Mod((int)(i + amount), (int)bitss.size())];
|
||||
|
||||
return std::bitset<T>(ss.str());
|
||||
}
|
||||
|
||||
//! Will perform a wrapping right-bitshift on a bitset
|
||||
template <std::size_t T>
|
||||
inline std::bitset<T> Shiftr(const std::bitset<T>& bits, std::size_t amount)
|
||||
inline std::bitset<T> Shiftr(const std::bitset<T>& bits, const std::size_t amount)
|
||||
{
|
||||
std::stringstream ss;
|
||||
const std::string bitss = bits.to_string();
|
||||
@ -261,10 +262,10 @@ namespace GhettoCipher
|
||||
std::size_t value;
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
// Is it a number?
|
||||
value = (c - '0') + 0;
|
||||
value = ((std::size_t)c - '0') + 0;
|
||||
else if ((c >= 'a') && (c <= 'f'))
|
||||
// Else, it is a lowercase letter
|
||||
value = (c - 'a') + 10;
|
||||
value = ((std::size_t)c - 'a') + 10;
|
||||
else
|
||||
throw std::logic_error("non-hex string detected in HexstringToBits()");
|
||||
|
||||
@ -288,10 +289,10 @@ namespace GhettoCipher
|
||||
std::size_t value;
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
// Is it a number?
|
||||
value = (c - '0') + 0;
|
||||
value = ((std::size_t)c - '0') + 0;
|
||||
else if ((c >= 'a') && (c <= 'f'))
|
||||
// Else, it is a lowercase letter
|
||||
value = (c - 'a') + 10;
|
||||
value = ((std::size_t)c - 'a') + 10;
|
||||
else
|
||||
throw std::logic_error("non-hex string detected in HexstringToBits()");
|
||||
|
||||
@ -361,17 +362,6 @@ namespace GhettoCipher
|
||||
}
|
||||
}
|
||||
|
||||
/*** ./../GhettoCrypt/Halfblock.h ***/
|
||||
|
||||
#pragma once
|
||||
#include <bitset>
|
||||
|
||||
namespace GhettoCipher
|
||||
{
|
||||
constexpr int HALFBLOCK_SIZE = (BLOCK_SIZE / 2);
|
||||
typedef std::bitset<HALFBLOCK_SIZE> Halfblock;
|
||||
}
|
||||
|
||||
/*** ./../GhettoCrypt/Keyset.h ***/
|
||||
|
||||
#pragma once
|
||||
@ -382,6 +372,18 @@ namespace GhettoCipher
|
||||
typedef std::array<Block, N_ROUNDS> Keyset;
|
||||
}
|
||||
|
||||
/*** ./../GhettoCrypt/Halfblock.h ***/
|
||||
|
||||
#pragma once
|
||||
#include <bitset>
|
||||
#include <cstdint>
|
||||
|
||||
namespace GhettoCipher
|
||||
{
|
||||
constexpr std::size_t HALFBLOCK_SIZE = (BLOCK_SIZE / 2);
|
||||
typedef std::bitset<HALFBLOCK_SIZE> Halfblock;
|
||||
}
|
||||
|
||||
/*** ./../GhettoCrypt/Feistel.h ***/
|
||||
|
||||
#pragma once
|
||||
|
Loading…
x
Reference in New Issue
Block a user