Package: entropybroker / 2.9-5

crypto++-8.3.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From b949ef738a97dd2c7b649721c20b288cd504e935 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Sun, 18 Aug 2019 22:19:04 -0700
Subject: [PATCH] Add casts for crypto++ v6 compatibility

In crypto++ commit 953252e44d25 ("Move from 'static' to 'enum' for class
constants") the macro CRYPTOPP_CONSTANT changed from adding a static
const int to the class to an enum, which does not take up space.

Therefore, definitions such as

    CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = KeyBase::DEFAULT_KEYLENGTH)

now create DEFAULT_KEYLENGTH as an unnamed enum and not an int. The
result is that DEFAULT_KEYLENGTH is now no longer directly comparable
with ints, thanks to C++'s enum type conversion rules.

The fix is simple: cast to int, as was done in the crypto++ project in
the commit following the aforementioned: commit f5aa6f1f06b9 ("Cast
enums to int for comparison")

Closes: #8
---
 encrypt_stream_aes.cpp      | 2 +-
 encrypt_stream_camellia.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/encrypt_stream_aes.cpp b/encrypt_stream_aes.cpp
index 41446d0..6a7cddd 100644
--- a/encrypt_stream_aes.cpp
+++ b/encrypt_stream_aes.cpp
@@ -39,7 +39,7 @@ bool encrypt_stream_aes::init(unsigned char *key_in, int key_len, unsigned char
 #endif
 
 	unsigned char key_use[CryptoPP::AES::DEFAULT_KEYLENGTH] = { 0 };
-	memcpy(key_use, key_in, std::min(CryptoPP::AES::DEFAULT_KEYLENGTH, key_len));
+	memcpy(key_use, key_in, std::min((int)CryptoPP::AES::DEFAULT_KEYLENGTH, key_len));
 
 	if (enc)
 		delete enc;
diff --git a/encrypt_stream_camellia.cpp b/encrypt_stream_camellia.cpp
index 40420b5..2b772bd 100644
--- a/encrypt_stream_camellia.cpp
+++ b/encrypt_stream_camellia.cpp
@@ -39,7 +39,7 @@ bool encrypt_stream_camellia::init(unsigned char *key_in, int key_len, unsigned
 #endif
 
 	unsigned char temp_key[CryptoPP::Camellia::DEFAULT_KEYLENGTH] = { 0 };
-	memcpy(temp_key, key_in, std::min(CryptoPP::Camellia::DEFAULT_KEYLENGTH, key_len));
+	memcpy(temp_key, key_in, std::min((int)CryptoPP::Camellia::DEFAULT_KEYLENGTH, key_len));
 
 	if (enc)
 		delete enc;