Skip to content

Commit 8d058d5

Browse files
committed
Unsafe cast removed
1 parent 650693c commit 8d058d5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

configure.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if ($build -eq 0 -or $build -eq 64) {
3636
}
3737
Set-Location "build64"
3838
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=$release -G "Visual Studio 17 2022" -A x64 ../..
39-
cmake --build --config ${release} .
39+
cmake --build . --config ${release}
4040
Set-Location ..
4141
}
4242

include/craper/key.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,28 @@ const std::unordered_map<CipherAlgorithm, std::string> cipher_to_string = {
7878

7979
class KeyType {
8080
public:
81-
KeyType(size_t key_size, CipherAlgorithm algorithm) :
81+
KeyType(DWORD key_size, CipherAlgorithm algorithm) :
8282
key_size_(key_size), algorithm_(algorithm) {};
8383

84-
size_t GetSize() const;
84+
DWORD GetSize() const;
8585
CipherAlgorithm GetAlgorithm() const;
8686
std::string GetAlgorithmAsString() const;
8787

8888
private:
89-
size_t key_size_;
89+
DWORD key_size_;
9090
CipherAlgorithm algorithm_;
9191
};
9292

9393
class Key {
9494
public:
9595
Key() : cipher_type_(kError, CipherAlgorithm::kError), key_() {};
96-
Key(size_t key_size, CipherAlgorithm algorithm, unsigned char* key);
96+
Key(DWORD key_size, CipherAlgorithm algorithm, unsigned char* key);
9797
Key(const Key& other) :
9898
cipher_type_(other.cipher_type_),
9999
key_(other.key_ ? std::make_unique<std::vector<unsigned char>>(*other.key_) : nullptr) {};
100100
Key& operator=(const Key& other) = default;
101101

102-
size_t GetSize() const { return cipher_type_.GetSize(); };
102+
DWORD GetSize() const { return cipher_type_.GetSize(); };
103103
std::string GetAlgorithm() const { return cipher_type_.GetAlgorithmAsString(); };
104104
std::string GetCipherType() const;
105105
virtual std::vector<unsigned char> GetKey() const;

src/key.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using namespace std;
1212
using namespace error_handling;
1313

1414
namespace key_scanner {
15-
Key::Key(size_t key_size, CipherAlgorithm algorithm, unsigned char* key) : cipher_type_(key_size, algorithm), key_() {
15+
Key::Key(DWORD key_size, CipherAlgorithm algorithm, unsigned char* key) : cipher_type_(key_size, algorithm), key_() {
1616

1717
try {
1818
key_ = make_unique<vector<unsigned char>>(vector<unsigned char>(key, key + cipher_type_.GetSize()));
@@ -73,8 +73,8 @@ bool Key::operator==(const Key& other) const {
7373
return (this->GetKey() == other.GetKey());
7474
}
7575

76-
std::size_t KeyType::GetSize() const {
77-
return static_cast<std::size_t>(key_size_);
76+
DWORD KeyType::GetSize() const {
77+
return key_size_;
7878
}
7979

8080
CipherAlgorithm KeyType::GetAlgorithm() const {

0 commit comments

Comments
 (0)