issue_owner_repo listlengths 2 2 | issue_body stringlengths 0 261k ⌀ | issue_title stringlengths 1 925 | issue_comments_url stringlengths 56 81 | issue_comments_count int64 0 2.5k | issue_created_at stringlengths 20 20 | issue_updated_at stringlengths 20 20 | issue_html_url stringlengths 37 62 | issue_github_id int64 387k 2.46B | issue_number int64 1 127k |
|---|---|---|---|---|---|---|---|---|---|
[
"weidai11",
"cryptopp"
] | Otherwise it can't compiled under UNICODE mode. Because the code always use an ANSI char to receive the result:
```
char temp[MAX_ADDRSTRLEN]; // ANSI char
// ...
if (WSAStringToAddress(temp, af, NULL, (struct sockaddr *)&ss, &size) == 0) { // ...
```
`WSAStringToAddress` is mapping to `WSAStringToAddressW` under UNICODE version, and `WSAStringToAddressA` under the ANSI version. Explicitly using `WSAStringToAddressA` if you always want to use the ANSI one. | Don't use WSAStringToAddress, use WSAStringToAddressA instead | https://api.github.com/repos/weidai11/cryptopp/issues/385/comments | 8 | 2017-03-01T21:25:23Z | 2017-03-14T14:23:46Z | https://github.com/weidai11/cryptopp/issues/385 | 211,212,816 | 385 |
[
"weidai11",
"cryptopp"
] | If we do something like this:
`new RSAES< OAEP<CryptoPP::SHA1> >::Decryptor(*thRng, nKeyLen);`
_aligned_free will be failed on the x64 target compiled by VC 2005:
```
Integer Integer::Plus(const Integer& b) const
{
Integer sum((word)0, STDMAX2(reg.size(), b.reg.size()));
// ...
return sum; // <--- here
}
```
because, `if (T_Align16 && size*sizeof(T) >= 16)` is false so `UnalignedAllocate` is used in sum's constructor, but under the destructor, `if (T_Align16 && size*sizeof(T) >= 16)` is ture, so `AlignedDeallocate` launched.
If I change line
`typedef SecBlock<word, AllocatorWithCleanup<word, CRYPTOPP_BOOL_X86> > IntegerSecBlock;`
to
`typedef SecBlock<word, AllocatorWithCleanup<word, true> > IntegerSecBlock;`
then every thing is fine.
Could I use this as a temporarily workaround fix ?
This bug only occur in MSW VC2005 x64. It's fine under MSW VC2005 x86 or Linux GCC x64/x86. | [BUG] VC 2005 x64: _aligned_free failed | https://api.github.com/repos/weidai11/cryptopp/issues/384/comments | 1 | 2017-03-01T21:03:33Z | 2017-03-01T23:54:28Z | https://github.com/weidai11/cryptopp/issues/384 | 211,207,391 | 384 |
[
"weidai11",
"cryptopp"
] | C++11 provides `nullptr_t` and a null pointer `nullptr`. It adds type safety for `NULL`, and it improves analysis in some situations. Currently, Crypto++ uses a mix of `NULL` and `0` for the null pointer. The library's use of `NULL` and `0` ensures a very dirty C++11 compile with `-Wzero-as-null-pointer-constant`. In addition, GCC is tightening the way pointers can be compared to the `nullptr` in C++11 and above.
We have an opportunity to improve it, but we need to ensure we don't break C++03. Assuming we can use `NULLPTR` as a macro, we can do something like the following. The wildcard is, will others use the `NULLPTR` macro and define it to something unexpected, like `-1`.
```
#if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)
# define NULLPTR nullptr
#elif !defined(NULLPTR)
# define NULLPTR NULL
#endif // CRYPTOPP_CXX11_NULLPTR
```
The choice for C++03 and `#define NULLPTR NULL` is driven by the fact `sizeof(int) != sizeof(void*)` (or they may not be equal). We are trying to avoid the wrong overload or specialization by making it someone else's problem. The "someone else" in this case is the compiler. | Add support for C++11 nullptr | https://api.github.com/repos/weidai11/cryptopp/issues/383/comments | 1 | 2017-03-01T09:52:39Z | 2017-03-02T04:40:00Z | https://github.com/weidai11/cryptopp/issues/383 | 211,029,778 | 383 |
[
"weidai11",
"cryptopp"
] | `BufferedTransformation` includes the following:
```
class BufferedTransformation : public Algorithm, public Waitable
{
public:
// placed up here for CW8, same as DEFAULT_CHANNEL, for backwards compatibility
static const std::string &NULL_CHANNEL;
...
};
```
`NULL_CHANNEL` dates back to the Crypto++ 4.0 (and earlier) days. In addition, Code Warrior 8 is older than the .Net compilers we support. Finally, `NULL_CHANNEL` contributes to [Static Initialization Order Fiasco](https://www.cryptopp.com/wiki/Static_Initialization_Order_Fiasco).
For the upcoming Crypto++ 6.0 release, we will remove the deprecated channel name and Code Warrior support.
| Remove NULL_CHANNEL and Code Warrior 8 workaround | https://api.github.com/repos/weidai11/cryptopp/issues/382/comments | 1 | 2017-03-01T08:48:47Z | 2017-03-01T10:26:45Z | https://github.com/weidai11/cryptopp/issues/382 | 211,015,057 | 382 |
[
"weidai11",
"cryptopp"
] | I'm trying to use ecdsa to sign and verify messages, but the [example at your official site](https://www.cryptopp.com/wiki/User_Guide:_eccrypto.h) is not working. The `ECPrivateKey ` and `ECPublicKey ` are not declared and nowhere to be found, there is no type named ECPrivateKey in the latest 5.6.5 source.
I tried to replace them with `DL_PublicKey_EC` but it is a template, which requires a class type inside. Does anyone know how to make it work? Thanks.
P.S. I'm using ubuntu 16.04, building from source. I'm sure I have it installed correctly because the [RSA example](https://www.cryptopp.com/wiki/User_Guide:_rsa.h) can run successfully. | ECDSA examples not working | https://api.github.com/repos/weidai11/cryptopp/issues/381/comments | 3 | 2017-02-28T14:22:20Z | 2017-03-03T15:19:18Z | https://github.com/weidai11/cryptopp/issues/381 | 210,800,423 | 381 |
[
"weidai11",
"cryptopp"
] | After compiling CRYPTOPP_5_6_5 and linking my program with the static library libcryptopp.a using mingw, this program was surprisingly crashing on some computers and not on others.
After many hours of investigation, I discovered that the flag -march=native was used and that was the reason why the program may not work when copied and pasted to other computers.
Note: it was extremely difficult to understand the reason of the crash, the stack being unhelpful (see the end of the email) and gdb was stopping immediately.
Having a dedicated option to activate or not this flag would be welcome - currently, the flag is set if ((NOT CRYPTOPP_CROSS_COMPILE) AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU|Intel")).
Documenting the default use of the flag in README.txt could probably save a lot of time when investigating the problem.
I hope it helps!
```
=============================
Stack using catchsegv provided by drmingw
=============================
C:\Program Files (x86)\MyProgram>catchsegv MyProgram.exe
MyProgram.exe caused an Illegal Instruction at location 000000000089D6EC in module MyProgram.exe.
Registers:
eax=0000001e ebx=00d0fe60 ecx=4dfaeb02 edx=00000001 esi=00180000 edi=00000010
eip=0089d6ec esp=00d0fe50 ebp=00d0ff80 iopl=0 nv up ei pl nz na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010202
AddrPC Params
0089D6EC 0024A000 747662A0 BF165E62 MyProgram.exe!CryptoPP::DetectX86Features
747662C4 0024A000 18364849 00000000 KERNEL32.DLL!@BaseThreadInitThunk@12
778D0FD9 FFFFFFFF 778F2EE9 00000000 ntdll.dll!__RtlUserThreadStart
778D0FA4 004014C0 0024A000 00000000 ntdll.dll!__RtlUserThreadStart@8
``` | Random crashes on different computers because option -march=native is active 'by default' | https://api.github.com/repos/weidai11/cryptopp/issues/380/comments | 20 | 2017-02-23T16:55:14Z | 2017-09-17T08:51:29Z | https://github.com/weidai11/cryptopp/issues/380 | 209,820,516 | 380 |
[
"weidai11",
"cryptopp"
] | On occasion users will [ask about missing symbols in the library, like `GlobalRNG()`](https://groups.google.com/forum/#!topic/cryptopp-users/CCAsd0MZaAM). It has come up on several occasions, including Stack Overflow and the User Group.
The problem appears to stem from creating a project with an external build system (like CodeBlocks, Eclipse or Xcode), and adding all the header and source files to the project. On our side, its not readily apparent a symbol like `GlobalRNG()` is part of Testing and Evaluation.
At this point, we are going to keep the code in `regtest.cpp` out of `Test::`. The functions are used for an object registry, and they are useful to the library and testing. In the future, we will make more use of it when the Engine like interface gets cut-in.
This bug report tracks the addition of a `Test::` namespace within `CryptoPP::` namespace.
-----
Adding the namespace is just maintenance work. There's no thinking required. At the same time, we will pull GCC's deprecated warning suppression (no longer needed), and `USING_NAMESPACE(std)` (no longer needed for most files). Its more mindless work. | Add Test namespace within CryptoPP namespace | https://api.github.com/repos/weidai11/cryptopp/issues/379/comments | 1 | 2017-02-21T06:57:13Z | 2017-02-22T00:59:37Z | https://github.com/weidai11/cryptopp/issues/379 | 209,057,905 | 379 |
[
"weidai11",
"cryptopp"
] | osrng.h checks for a preprocessor define named OS_NO_DEPENDENCE:
```
#if !defined(OS_NO_DEPENDENCE) && defined(OS_RNG_AVAILABLE)
```
But config.h optionally defines NO_OS_DEPENDENCE, and all other files use this variant:
```
// Define this if you want to disable all OS-dependent features,
// such as sockets and OS-provided random number generators
// #define NO_OS_DEPENDENCE
```
This name difference seems like a typo in osrng.h.
| OS_NO_DEPENDENCE in osrng.h, NO_OS_DEPENDENCE everywhere else | https://api.github.com/repos/weidai11/cryptopp/issues/377/comments | 1 | 2017-02-18T22:11:49Z | 2017-02-18T22:41:52Z | https://github.com/weidai11/cryptopp/issues/377 | 208,675,522 | 377 |
[
"weidai11",
"cryptopp"
] | In base 64 decode you will find the following code:
```
const int *Base64Decoder::GetDecodingLookupArray()
{
static volatile bool s_initialized = false;
static int s_array[256];
if (!s_initialized)
{
InitializeDecodingLookupArray(s_array, s_stdVec, 64, false);
s_initialized = true;
}
return s_array;
}
```
The function `InitializeDecodingLookupArray` may run on more than one thread concurrently which may lead to fire `CRYPTOPP_ASSERT(lookup[alphabet[i]] == -1);` in `InitializeDecodingLookupArray` line 193 of basecode.cpp (based on commit 26e2e12b6a7d4c27832bd0cf522457012d5aa7a7)
| Intialization of base64 and other decoders are not threadsafe | https://api.github.com/repos/weidai11/cryptopp/issues/376/comments | 5 | 2017-02-17T18:06:54Z | 2017-03-01T07:25:31Z | https://github.com/weidai11/cryptopp/issues/376 | 208,515,184 | 376 |
[
"weidai11",
"cryptopp"
] | PHP defaults to bcrypt for password hashing: http://php.net/password_hash
Could bcrypt be supported by crypto++ as well to allow interoperability? | bcrypt support | https://api.github.com/repos/weidai11/cryptopp/issues/375/comments | 9 | 2017-02-17T13:25:09Z | 2018-11-05T14:02:55Z | https://github.com/weidai11/cryptopp/issues/375 | 208,440,976 | 375 |
[
"weidai11",
"cryptopp"
] | I am trying to build latest crypto++ with CMake generated XCode project
```
macOS 10.12.3
XCode 8.2.1
cmake version 3.7.2
mkdir build
cd build
cmake -G Xcode ..
open cryptopp.xcodeproj
build
```
Getting following error:
```
echo "Creating symlinks"
Creating symlinks
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_symlink_library /Users/user1/dev/cryptopp/build/Debug/libcryptopp.5.7.dylib /Users/user1/dev/cryptopp/build/Debug/libcryptopp.5.7.dylib /Users/user1/dev/cryptopp/build/Debug/libcryptopp.dylib
CMake Error: cmake_symlink_library: System Error: No such file or directory
```
I commented out a part of makefile that sets SOVERSION, this helped
```
- if (BUILD_SHARED)
- set_target_properties(cryptopp-shared
- PROPERTIES
- SOVERSION ${COMPAT_VERSION}
- OUTPUT_NAME cryptopp)
- endif()
+ #if (BUILD_SHARED)
+ # set_target_properties(cryptopp-shared
+ # PROPERTIES
+ # SOVERSION ${COMPAT_VERSION}
+ # OUTPUT_NAME cryptopp)
+ #endif()
```
But not for long, then I got this:
```
Ld build/Debug/cryptest.exe normal x86_64
cd /Users/user1/dev/cryptopp
export MACOSX_DEPLOYMENT_TARGET=10.12
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -L/Users/user1/dev/cryptopp/build/Debug -F/Users/user1/dev/cryptopp/build/Debug -filelist /Users/user1/dev/cryptopp/build/cryptopp.build/Debug/cryptest.build/Objects-normal/x86_64/cryptest.exe.LinkFileList -mmacosx-version-min=10.12 -Xlinker -object_path_lto -Xlinker /Users/user1/dev/cryptopp/build/cryptopp.build/Debug/cryptest.build/Objects-normal/x86_64/cryptest.exe_lto.o -Xlinker -no_deduplicate -march=native /Users/user1/dev/cryptopp/build/Debug/libcryptopp.a -Xlinker -dependency_info -Xlinker /Users/user1/dev/cryptopp/build/cryptopp.build/Debug/cryptest.build/Objects-normal/x86_64/cryptest.exe_dependency_info.dat -o /Users/user1/dev/cryptopp/build/Debug/cryptest.exe
clang: error: no such file or directory: '/Users/user1/dev/cryptopp/build/Debug/libcryptopp.a'
```
`cryptest` wants to link to static library and it wants it to be named `libcryptopp.a`, but XCode thinks otherwise. XCode produces a file `build/cryptopp.build/Debug/cryptopp-object.build/Objects-normal/libcryptopp-object.a`
At this point I am not sure what I need to change to make it work, the makefile looks too complicated for me | CMake XCode build on macOS fails | https://api.github.com/repos/weidai11/cryptopp/issues/374/comments | 4 | 2017-02-16T15:09:56Z | 2017-09-16T22:40:17Z | https://github.com/weidai11/cryptopp/issues/374 | 208,148,268 | 374 |
[
"weidai11",
"cryptopp"
] | Is windows xp still supported? This very simple dll static linking to libcryptopp cannot be loaded on xp, there's a **loader lock** problem.
#include <windows.h>
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include "cryptopp/md5.h"
CryptoPP::Weak::MD5 _md5;
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, PVOID pvReserved) {
switch(reason) {
case DLL_PROCESS_ATTACH:
MessageBox(0, "DllMain", "", 0);
break;
}
return TRUE;
}
Load this dll with `regsvr32 my_dll.dll` (regsvr32 calls loadlibrary), it will hang **regsvr32** process and the MessageBox in **DllMain** won't be executed. I dumped the process with **windbg**, here's the output:
BLOCKING_THREAD: 000000e8
DEFAULT_BUCKET_ID: APPLICATION_HANG_HungIn_LoaderLock
PRIMARY_PROBLEM_CLASS: APPLICATION_HANG_HungIn_LoaderLock
LAST_CONTROL_TRANSFER: from 7c92df3c to 7c92e4f4
FAULTING_THREAD: 00000000
STACK_TEXT:
0007dde4 7c92df3c 7c9546b0 00000744 00000000 ntdll!KiFastSystemCallRet
0007dde8 7c9546b0 00000744 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
0007de14 7c95452b 00000768 00000000 7c946405 ntdll!RtlpInitializeTimerThreadPool+0xe1
0007de58 7c94d6c9 00000000 0007de8c 7c95327e ntdll!RtlpInitializeWorkerThreadPool+0x1c
0007de64 7c95327e 00000000 0009f834 00000768 ntdll!RtlpAcquireWorker+0x16
0007de8c 7c821205 0009f834 00000768 00b52b20 ntdll!RtlRegisterWait+0x93
0007deb4 00b4b4b8 0009f834 00000768 00b52b20 kernel32!RegisterWaitForSingleObject+0x6f
0007df24 00b6077e 0007df98 0009f650 0007df64 MSVCR120D!Concurrency::details::SchedulerBase::SchedulerBase+0x388 [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 147]
0007df34 00b608f7 0007df98 a284c84b 00b3c0e1 MSVCR120D!Concurrency::details::ThreadScheduler::ThreadScheduler+0x1e [f:\dd\vctools\crt\crtw32\concrt\threadscheduler.cpp @ 26]
0007df64 00b4d33c 0007df98 0007df74 0007df88 MSVCR120D!Concurrency::details::ThreadScheduler::Create+0x67 [f:\dd\vctools\crt\crtw32\concrt\threadscheduler.cpp @ 34]
0007df7c 00b4e64a 0007df98 a284c887 00aef754 MSVCR120D!Concurrency::details::SchedulerBase::CreateWithoutInitializing+0x1c [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 285]
0007dfa8 00b4d22b 1011ec30 00000000 0007dfc4 MSVCR120D!Concurrency::details::SchedulerBase::GetDefaultScheduler+0x8a [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 654]
0007dfb8 00b28045 0007dff8 0007dfec 00b39760 MSVCR120D!Concurrency::details::SchedulerBase::CreateContextFromDefaultScheduler+0xb [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 571]
0007dfc4 00b39760 0007e02c 00bcfef0 a24183ef MSVCR120D!Concurrency::details::SchedulerBase::CurrentContext+0x15 [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.h @ 399]
0007dfec 00b3b483 ffffffff 0007e004 00000000 MSVCR120D!Concurrency::details::LockQueueNode::LockQueueNode+0x40 [f:\dd\vctools\crt\crtw32\concrt\rtlocks.cpp @ 619]
0007e018 00a125e9 0007e074 7c92d7ec 7c9333f6 MSVCR120D!Concurrency::critical_section::lock+0x13 [f:\dd\vctools\crt\crtw32\concrt\rtlocks.cpp @ 1026]
0007e058 00a1295e 101e3294 00000000 0007e078 MSVCP120D!mtx_do_lock+0x99 [f:\dd\vctools\crt\crtw32\stdcpp\thr\mutex.c @ 67]
0007e068 10048710 101e3294 0007e194 0007e088 MSVCP120D!_Mtx_lock+0xe [f:\dd\vctools\crt\crtw32\stdcpp\thr\mutex.c @ 153]
0007e078 10049617 101e3294 101e3294 0007e094 my_dll!std::_Mtx_lockX+0x10 [g:\vs\vc\include\thr\xthread @ 68]
0007e088 10041a80 0007e0b4 0007e0d0 10046d1b my_dll!std::_Mutex_base::lock+0x17 [g:\vs\vc\include\mutex @ 41]
0007e094 10046d1b 101e3294 a2851cf1 cccccccc my_dll!std::lock_guard<std::mutex>::lock_guard<std::mutex>+0x20 [g:\vs\vc\include\mutex @ 184]
0007e0d0 10001eb4 cc00cccc 0007e0e4 00aeebba my_dll!CryptoPP::Singleton<CryptoPP::Integer,CryptoPP::NewObject<CryptoPP::Integer>,0>::Ref+0xcb [g:\cryptopp\misc.h @ 296]
0007e0dc 00aeebba 0007e128 1011ea13 1018b264 my_dll!CryptoPP::`anonymous namespace'::`dynamic initializer for 's_zero''+0x24 [g:\cryptopp\integer.cpp @ 3031]
0007e0e4 1011ea13 1018b264 1018b390 0007e0d8 MSVCR120D!_initterm+0x1a [f:\dd\vctools\crt\crtw32\startup\crt0dat.c @ 955]
0007e128 1011ed0c 10000000 00000001 00000000 my_dll!_CRT_INIT+0xc3 [f:\dd\vctools\crt\crtw32\dllstuff\crtdll.c @ 295]
0007e16c 1011ec4f 10000000 00000001 00000000 my_dll!__DllMainCRTStartup+0xac [f:\dd\vctools\crt\crtw32\dllstuff\crtdll.c @ 502]
0007e180 7c92118a 10000000 00000001 00000000 my_dll!_DllMainCRTStartup+0x1f [f:\dd\vctools\crt\crtw32\dllstuff\crtdll.c @ 472]
0007e1a0 7c93c4da 1011ec30 10000000 00000001 ntdll!LdrpCallInitRoutine+0x14
0007e2a8 7c936351 00000000 c0150008 00000000 ntdll!LdrpRunInitializeRoutines+0x344
0007e554 7c9364b3 00000000 000947f8 0007e848 ntdll!LdrpLoadDll+0x3e5
0007e7fc 7c801bbd 000947f8 0007e848 0007e828 ntdll!LdrLoadDll+0x230
0007e864 01001dbe 000341a6 00000000 00000008 kernel32!LoadLibraryExW+0x18e
0007ff1c 010024bf 01000000 00000000 000205ee regsvr32!wWinMain+0x741
0007ffc0 7c817067 00000018 00000000 7ffda000 regsvr32!wWinMainCRTStartup+0x198
0007fff0 00000000 01002327 00000000 78746341 kernel32!BaseProcessStart+0x23
Seems these two line causes the problem but I don't see why.
g:\cryptopp\misc.h @ 296
g:\cryptopp\integer.cpp @ 3031
This dll works fine on **Win10**, but hangs on **WinXP**.
Development environment: Win10-pro-64bit, VisualStudio2013-Update5, CryptoPP-5.6.5(**/MDd**)
Testing environment: WinXP-pro-sp3 | Hang and loader lock on WinXP | https://api.github.com/repos/weidai11/cryptopp/issues/373/comments | 6 | 2017-02-08T14:07:37Z | 2018-01-19T21:35:29Z | https://github.com/weidai11/cryptopp/issues/373 | 206,207,571 | 373 |
[
"weidai11",
"cryptopp"
] | CryptoPP::Singleton::Ref() in misc.h assumes thread-safe local statics. MSVC 11 (2012) and 12 (2013) do not support them, so locking the static mutex sometimes crashes.
I was not sure if thread-safe initialization of local static variables should be included in CRYPTOPP_CXX11_SYNCHRONIZATION or if it was only meant for library features, so I've created an issue instad of a pull request. | Singleton::Ref() crashes on VS2012/VS2013 | https://api.github.com/repos/weidai11/cryptopp/issues/372/comments | 12 | 2017-02-01T09:46:23Z | 2018-01-19T21:35:06Z | https://github.com/weidai11/cryptopp/issues/372 | 204,537,343 | 372 |
[
"weidai11",
"cryptopp"
] | We've been following a thread from [Ethereum](https://github.com/ethereum/cpp-ethereum/issues/3493#issuecomment-275585995). One of the side/related issues appears to be determining the Crypto++ version.
The problem is, `CRYPTOPP_VERSION` is a macro in [`config.h`, around line 65](https://github.com/weidai11/cryptopp/blob/master/config.h#L65), and it can be a bit misleading. Someonecould be runtime linking against a shared object version 5.5, but if library versions are mixed/matched, then they could get 5.6.5 from the header.
I think we need two functions in the `CryptoPP` namespace:
* `int HeaderVersion()`
* `int LibraryVersion()`
`HeaderVersion` would return `CRYPTOPP_VERSION` from `config.h`. Its the version of the library the app was built against. The function should be declared in a header, and the definition should be in the header, too.
`LibraryVersion` would return `CRYPTOPP_VERSION` used to build the library. The function should be declared in a header, and the definition should be in a source file to ensure it records what a distro builds and distributes the library, and it does not change when an app builds against it.
Both `LibraryVersion` and `HeaderVersion` should reside int he `CryptoPP` namespace. Both `LibraryVersion` and `HeaderVersion` should use C linkage (`extern "C"`) so that those who `dlsym` for it don't have to contend with name mangling.
Later, if users mix and match library versions, then they will be able to detect the condition. For app code, it could be as simple as:
```
if (LibraryVersion() != HeaderVersion())
{
cout << "Potential library version mismatch << endl;
const int bmaj = (LibraryVersion() / 100U) % 10;
const int bmin = (LibraryVersion() / 10U) % 10;
const int rmaj = (HeaderVersion() / 100U) % 10;
const int rmin = (HeaderVersion() / 10U) % 10;
if(bmaj ^ rmaj)
{
cout << "Major version mismatch" << endl;
}
else if(bmin ^ rmin )
{
cout << "Minor version mismatch" << endl;
}
}
```
OpenSSL and other projects have the same problem and similar mechanisms. For example, here is OpenSSL's [`SSLeay_version` man page](https://www.openssl.org/docs/man1.0.2/crypto/SSLeay_version.html), which returns build-time version information. And here is the [`OPENSSL_VERSION_NUMBER` macro man page](https://www.openssl.org/docs/man1.0.2/crypto/OPENSSL_VERSION_NUMBER.html), which provides the app's runtime version. | Add HeaderVersion() and LibraryVersion() functions | https://api.github.com/repos/weidai11/cryptopp/issues/371/comments | 2 | 2017-01-28T05:25:04Z | 2017-01-29T20:00:30Z | https://github.com/weidai11/cryptopp/issues/371 | 203,788,960 | 371 |
[
"weidai11",
"cryptopp"
] | I've tried installing cryptopp using "brew install cryptopp" on two Macs already, one of them was newly setup, so there's nothing strange going on in the system.
On both computers, the install just stalls in the make step and doesn't continue from there. I've kept it running for hours, and there was no CPU usage.
me-mbp:~$ brew install cryptopp
==> Using the sandbox
==> Downloading https://github.com/weidai11/cryptopp/archive/CRYPTOPP_5_6_5.tar.gz
Already downloaded: /Users/me/Library/Caches/Homebrew/cryptopp-5.6.5.tar.gz
==> make shared all CXX=clang++
I have MacOS Sierra 10.12.3.
I also tried to get into interactive homebrew and call `make --help` from the shell, but even `make --help` hangs the same way. I'm not sure whether this is an issue with homebrew or with cryptopp, but since this only happens with the cryptopp package (other homebrew packages install fine), I report it here. | Homebrew package broken | https://api.github.com/repos/weidai11/cryptopp/issues/370/comments | 14 | 2017-01-27T19:06:53Z | 2023-03-22T23:21:07Z | https://github.com/weidai11/cryptopp/issues/370 | 203,714,482 | 370 |
[
"weidai11",
"cryptopp"
] | Since the library is preparing for a version bump that breaks compatibility, we should remove `MAINTAIN_BACKWARDS_COMPATIBILITY` macro and code previously guarded by it. Some of the code is really old, dating back to the Crypto++ 5.5 days if research is correct. It probably predates 5.5 in some instances.
Functions guarded with the macro have been commented out for several months. We have not received reports of breaking users.
When we ask for testers for the upcoming Crypto++ 5.7.0, we will learn if there's code that needs to be guarded by it in the current library. | Remove MAINTAIN_BACKWARDS_COMPATIBILITY | https://api.github.com/repos/weidai11/cryptopp/issues/369/comments | 1 | 2017-01-27T11:02:41Z | 2017-05-02T12:21:32Z | https://github.com/weidai11/cryptopp/issues/369 | 203,608,495 | 369 |
[
"weidai11",
"cryptopp"
] | Here's an ugly result for Blake2 testing with Crypto++ and [Botan](http://github.com/randombit/botan/issues/845) on ARMv8/Aarch64 with Cortex-A57. Cortex-A53 is OK, meaning it does not slow down. A53 runs at about the same speed for both CXX and NEON.
A57, Crypto++ (3 second benchmark):
* CXX implementation: 5.7 cpb
* NEON implementation: 12.6 cpb
A57, Botan (speed test, 3000 ms):
* CXX implementation: 315.197 MiB/sec (945.594 MiB in 3000.008 ms)
* NEON implementation: 148.028 MiB/sec (444.086 MiB in 3000.014 ms)
The astute reader will realize those numbers should be inverted :( | BLAKE2b NEON suffers poor performance on ARMv8/Aarch64 with Cortex-A57 | https://api.github.com/repos/weidai11/cryptopp/issues/367/comments | 2 | 2017-01-22T07:45:47Z | 2017-11-23T09:03:43Z | https://github.com/weidai11/cryptopp/issues/367 | 202,367,277 | 367 |
[
"weidai11",
"cryptopp"
] | `cryptest.sh` reveals the changes for [Add GCC inline ASM for PMULL and PMULL2 , Commit b129818c35a0eceb](https://github.com/weidai11/cryptopp/commit/b129818c35a0eceb0db8b1613fdca17a5a96173c) are giving some of the builds trouble. The failures only show up under Debug builds.
```
/opt/cfarm/gcc-latest/bin/g++ -DDEBUG -g3 -O0 -march=armv8-a+crc+crypto -fPIC -pipe -D_GLIBCXX_DEBUG -c gcm.cpp
gcm.cpp: In function 'uint64x2_t CryptoPP::VEXT_8(uint64x2_t, uint64x2_t, unsigned int)':
gcm.cpp:90:48: warning: asm operand 3 probably doesn't match constraints
:"=w" (r) : "w" (a), "w" (b), "I" (c) );
^
gcm.cpp:90:48: error: impossible constraint in 'asm'
make: *** [gcm.o] Error 1
GNUmakefile:795: recipe for target 'gcm.o' failed
make: *** Waiting for unfinished jobs....
ERROR: failed to make cryptest.exe
```
---
Here's the function in question. The third argument is a `count`:
```
inline uint64x2_t VEXT_8(uint64x2_t a, uint64x2_t b, unsigned int c)
{
uint64x2_t r;
__asm __volatile("ext %0.16b, %1.16b, %2.16b, %3 \n\t"
:"=w" (r) : "w" (a), "w" (b), "I" (c) );
return r;
}
``` | gcm.cpp and "warning: asm operand 3 probably doesn't match constraints" | https://api.github.com/repos/weidai11/cryptopp/issues/366/comments | 1 | 2017-01-20T20:01:33Z | 2017-01-20T23:50:10Z | https://github.com/weidai11/cryptopp/issues/366 | 202,229,299 | 366 |
[
"weidai11",
"cryptopp"
] | The [sha.cpp whitespace checkin, commit fc306b6474a32cfb](https://github.com/weidai11/cryptopp/commit/fc306b6474a32cfb169fcff50e4db9d4a29b97cb), broke 32-bit SHA-384 and SHA-512. It was made prior to checking in the ARM SHA extensions.
It slipped through immediate testing because "smoke testing" occurs on x86_64 machines. It surfaced under the `cryptest.sh` test script, where more thorough testing occurs on a number of platforms, including i686. | Whitespace check-in for sha.cpp broke 32-bit SHA-384 and SHA-512 | https://api.github.com/repos/weidai11/cryptopp/issues/365/comments | 1 | 2017-01-17T05:45:50Z | 2017-01-18T00:27:04Z | https://github.com/weidai11/cryptopp/issues/365 | 201,181,632 | 365 |
[
"weidai11",
"cryptopp"
] | Testing on OS X 10.9 using Apple Clang 6.0. `cryptest.sh` reveals `TestRounding()` is failing one test case:
```
try
{
const word128 h = ((word128)W64LIT(0xffffffffffffffff)) << 64U;
const word128 v = h | (word128)W64LIT(0xfffffffffffffff9), b=0x08;
word128 r=RoundUpToMultipleOf(v, b);
fail = true;
}
catch(const Exception&)
{
fail = false;
}
```
Here's the debug session with `const word128 m = std::numeric_limits<word128>::max();` added for instrumentation.
```
Breakpoint 1, TestRounding () at validat0.cpp:456
456 const word128 h = ((word128)W64LIT(0xffffffffffffffff)) << 64U;
(gdb) n
457 const word128 v = h | (word128)W64LIT(0xfffffffffffffff9), b=0x08;
(gdb)
458 const word128 m = std::numeric_limits<word128>::max();
(gdb)
459 word128 r=RoundUpToMultipleOf(v, b);
(gdb) p v
$1 = 0xfffffffffffffffffffffffffffffff9
(gdb) p m
$2 = 0x00000000000000000000000000000000
```
The tests were put in place after [Issue 360](https://github.com/weidai11/cryptopp/issues/360). | Apple Clang 6.0 and numeric_limits<word128>::max() returns 0 | https://api.github.com/repos/weidai11/cryptopp/issues/364/comments | 7 | 2017-01-15T20:19:36Z | 2017-01-16T04:05:03Z | https://github.com/weidai11/cryptopp/issues/364 | 200,891,645 | 364 |
[
"weidai11",
"cryptopp"
] | We have specialized ARM implementations for a few algorithms, including CRC32, Carryless Multiply and SHA-1 ans SHA-256. Its now showing some cracks under Apple Clang.
It appears Apple Clang does not provide `<arm_acle.h>` (we knew that), and it also disgorges `PMULL` and `PMULL2` from the Crypto gear (that's news to us). Its also missing some types, like `poly16x4x2_t`.
From the comment for [Commit d3bb0e13def80a4b](https://github.com/weidai11/cryptopp/commit/d3bb0e13def80a4bf59ea324eed80becdf0045ce):
> It looks like we still have some work to get `cpu.h` in order due to Clang...
>
> Testing under iOS for ARM64/Aarch64. This is the ARM cpu feature detection code in `cpu.cpp`. Its testing for carryless multiply instructions.
>
> ```
> clang++ -DNDEBUG -g2 -Os -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk -stdlib=libc++ -c cpu.cpp
> cpu.cpp:486:9: error: unknown type name 'poly64_t'
> const poly64_t a1={2}, b1={3};
> ^
> cpu.cpp:486:28: error: expected ';' at end of declaration
> const poly64_t a1={2}, b1={3};
> ^
> ;
> cpu.cpp:487:9: error: unknown type name 'poly64x2_t'; did you mean
> 'poly16x4x2_t'?
> const poly64x2_t a2={4,5}, b2={6,7};
> ^~~~~~~~~~
> poly16x4x2_t
> ``` | Fix include logic for ARM headers under Apple and LLVM Clang | https://api.github.com/repos/weidai11/cryptopp/issues/362/comments | 1 | 2017-01-13T11:43:52Z | 2017-01-29T08:11:19Z | https://github.com/weidai11/cryptopp/issues/362 | 200,611,196 | 362 |
[
"weidai11",
"cryptopp"
] | I packaged lates master branch for cpp-ethereum project and received this crash report: https://github.com/ethereum/cpp-ethereum/issues/3490. I would more than happy is someone can take a look on the stack trace. | Crash on Windows 10 in dependent project | https://api.github.com/repos/weidai11/cryptopp/issues/361/comments | 7 | 2017-01-10T22:15:24Z | 2017-01-11T22:50:33Z | https://github.com/weidai11/cryptopp/issues/361 | 199,948,643 | 361 |
[
"weidai11",
"cryptopp"
] | Boldizsár Lipka reported the following in a private email. The email was forwarded to the mailing list at [Crypto++ RoundUpToMultipleOf bug](https://groups.google.com/forum/#!topic/cryptopp-users/4uDekpzXnNo).
> I found an issue in the implementation of the Crypto++ function
> RoundUpToMultipleOf (misc.h:745). The function is used at multiple places
> throughout the code, so the bug *might* have security implications, hence
> I'm reporting via email.
>
> misc.h:748 incorrectly assumes that the maximal value of type T1 is
> SIZE_MAX/sizeof(T1), which causes RoundUpToMultipleOf to detect integer
> overflows incorrectly. The branch condition gives false positives for large
> 64-bit integers and false negatives for smaller types. See the attached
> source code for examples. Additionally, the documentation states that
> RoundUpToMultipleOf returns n + n%m, while in fact it returns (as it should)
> n + (m-n%m)%m.
-----
Here is the attachment `round.cpp` that was included with the email.
[round.zip](https://github.com/weidai11/cryptopp/files/697127/round.zip)
| Crypto++ RoundUpToMultipleOf bug | https://api.github.com/repos/weidai11/cryptopp/issues/360/comments | 1 | 2017-01-10T19:22:52Z | 2017-01-15T20:23:22Z | https://github.com/weidai11/cryptopp/issues/360 | 199,910,521 | 360 |
[
"weidai11",
"cryptopp"
] | Hi,
I'm trying to build cryptopp with cmake (win10, msvc14 upd.3 (2015), 32 bit, cmake 3.7.1) in shared config.
But cryptopp-shared target (cryptopp-shared.dll) does not have any exports.
When I'm adding CRYPTOPP_EXPORTS definition I see the following error:
```
1>ttmac.obj : error LNK2019: unresolved external symbol "protected:
void __thiscall CryptoPP::IteratedHashBase
<unsigned int,class CryptoPP::MessageAuthenticationCode>::PadLastBlock(unsigned int,unsigned char)"
(?PadLastBlock@?$IteratedHashBase@IVMessageAuthenticationCode@CryptoPP@@@CryptoPP@@IAEXIE@Z)
referenced in function "public: virtual void __thiscall CryptoPP::TTMAC_Base::TruncatedFinal(unsigned char *,unsigned int)"
(?TruncatedFinal@TTMAC_Base@CryptoPP@@UAEXPAEI@Z)
```
Could you try to check it yourself or maybe you have a solution?
I've investigated it a bit and it seems the issue is somewhere in `iterhash.h`.
https://github.com/weidai11/cryptopp/blob/master/iterhash.h#L177
Maybe issue with definitions. | CMake does not set CRYPTOPP_EXPORTS for shared build (and errors during building) | https://api.github.com/repos/weidai11/cryptopp/issues/358/comments | 13 | 2017-01-07T23:12:54Z | 2017-07-20T18:42:00Z | https://github.com/weidai11/cryptopp/issues/358 | 199,390,947 | 358 |
[
"weidai11",
"cryptopp"
] | I'm using CMake 3.6.1 and Xcode 8. I'm attempting to build cryptopp 5.6.5.
When attempting to build the static or shared library using cmake with the Xcode generator, the library itself is never created. The shared target fails due to the missing output file at some point while the static target claims to succeed despite the same lack of output.
It appears to be caused by (at least for CMake >= 2.8.8) the shared and static library targets having only object files as input. According to [the documentation for cmake's add_library](https://cmake.org/cmake/help/latest/command/add_library.html#id4):
> Some native build systems may not like targets that have only object files, so consider adding at least one real source file to any target that references $<TARGET_OBJECTS:objlib>.
It would seem this is the case for Xcode. I see several options:
1. You tell me you don't care about Xcode (or any other affected generators), in which case I'll maintain a patch locally.
1. Applying the workaround suggested in the documentation. This could be done by creating an empty source file in the build directory and adding it to the target. A small and fairly local fix but hacky and perhaps even fragile.
1. The use of an intermediate objects target is made optional (rather than defined purely by the CMake version used) so it can be disabled manually in case of issues. This is my personal favorite. I would attach a patch for it but I'm having too much fun with the line endings. I'll try again tomorrow. | CMake-based Xcode build fails to build any library | https://api.github.com/repos/weidai11/cryptopp/issues/355/comments | 9 | 2017-01-04T16:52:02Z | 2017-08-26T23:20:31Z | https://github.com/weidai11/cryptopp/issues/355 | 198,755,477 | 355 |
[
"weidai11",
"cryptopp"
] | https://sourceforge.net/projects/cryptopp/files/cryptopp/ has no 5.6.5 release whereas https://cryptopp.com/release565.html links to it. | Sourceforge link to 5.6.5 is bad: no 5.6.5 release file on sourceforge. | https://api.github.com/repos/weidai11/cryptopp/issues/353/comments | 3 | 2016-12-29T01:46:54Z | 2017-01-29T22:44:17Z | https://github.com/weidai11/cryptopp/issues/353 | 197,941,219 | 353 |
[
"weidai11",
"cryptopp"
] | Google has recently published [project wycheproof](https://github.com/google/wycheproof), which is a tool / library for testing implementations for common cryptographic attacks (it's in Java though). We at least should think about hacking together a thin wrapper and applying this tool on Crypto++.
Additionally there are a bunch of tools for verification of constant-timedness of code which we maybe should also evaluate to use.
- https://github.com/oreparaz/dudect which is a tool that basically fuzzy-tests the code and checks if it runs in constant time (by literally measuring the execution time), the effort needed for integration should be quite low (the relevant paper is: https://eprint.iacr.org/2016/1123 )
- https://github.com/agl/ctgrind which is a patch to valgrind that changes the uninitialised-memory-access-detection-engine to detect control decisions made upon secret data, the integration effort is probably quite high here because the patches are several years old
- https://github.com/imdea-software/verifying-constant-time which is a modified version of Clang LLVM (AFAICT) that runs through "test-cases" and verifies constant-timeness on an assembly level (AFAICT), the relevant paper should be https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_almeida.pdf | Evaluate advanced tool-assisted security checking | https://api.github.com/repos/weidai11/cryptopp/issues/350/comments | 2 | 2016-12-20T20:07:39Z | 2016-12-24T05:15:27Z | https://github.com/weidai11/cryptopp/issues/350 | 196,767,998 | 350 |
[
"weidai11",
"cryptopp"
] | The default Socket::Listen backlog value is 5, most likely because this was the maximum supported 20 years ago in Windows Sockets 1:
https://github.com/weidai11/cryptopp/blob/master/socketft.h#L75
This should be SOMAXCONN on Windows. Not sure about similar magic values on other platforms.
A value as low as 5 will cause connections to be dropped if an application needs to handle many incoming connections at the same time, and users will complain about these dropped connections. | Default Socket::Listen backlog value is ancient and much too low | https://api.github.com/repos/weidai11/cryptopp/issues/349/comments | 3 | 2016-12-18T00:43:20Z | 2016-12-24T05:17:44Z | https://github.com/weidai11/cryptopp/issues/349 | 196,251,186 | 349 |
[
"weidai11",
"cryptopp"
] | Add Aumasson and Bernstein's [SipHash: a fast short-input PRF](http://131002.net/siphash/siphash.pdf). SipHash has some unique use cases that some users will find valuable.
The test vector generator is available at [SipHash GitHub](https://github.com/veorq/SipHash/tree/master). Check the `halfsiphash` branch for `test.c`. Below is our hacked version that prints the parameters. We changed `MAXLEN` to 320 to ensure we would get into mod'ed length values. `C` and `D` get changed in `siphash.c`.
-----
```
/*
SipHash reference C implementation
Copyright (c) 2012 Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
Copyright (c) 2012 Daniel J. Bernstein <djb@cr.yp.to>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#define MAXLEN 320
int siphash(const uint8_t *in, const size_t inlen, const uint8_t *k, \
uint8_t *out, const size_t outlen);
int halfsiphash(const uint8_t *in, const size_t inlen, const uint8_t *k,\
uint8_t *out, const size_t outlen);
/*
SipHash-2-4 output with
k = 00 01 02 ...
and
in = (empty string)
in = 00 (1 byte)
in = 00 01 (2 bytes)
in = 00 01 02 (3 bytes)
...
in = 00 01 02 ... 3e (63 bytes)
*/
const uint8_t vectors_sip64[MAXLEN][8] =
{
{ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72 },
{ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74 },
{ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d },
{ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85 },
{ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf },
{ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18 },
{ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb },
{ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab },
{ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93 },
{ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e },
{ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a },
{ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4 },
{ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75 },
{ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14 },
{ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7 },
{ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1 },
{ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f },
{ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69 },
{ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b },
{ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb },
{ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe },
{ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0 },
{ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93 },
{ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8 },
{ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8 },
{ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc },
{ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17 },
{ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f },
{ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde },
{ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6 },
{ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad },
{ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32 },
{ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71 },
{ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7 },
{ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12 },
{ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15 },
{ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31 },
{ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02 },
{ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca },
{ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a },
{ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e },
{ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad },
{ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18 },
{ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4 },
{ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9 },
{ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9 },
{ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb },
{ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0 },
{ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6 },
{ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7 },
{ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee },
{ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1 },
{ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a },
{ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81 },
{ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f },
{ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24 },
{ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7 },
{ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea },
{ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60 },
{ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66 },
{ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c },
{ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f },
{ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5 },
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95 }
};
const uint8_t vectors_sip128[MAXLEN][16] =
{
{ 0xa3, 0x81, 0x7f, 0x04, 0xba, 0x25, 0xa8, 0xe6, 0x6d, 0xf6, 0x72, 0x14, 0xc7, 0x55, 0x02, 0x93 },
{ 0xda, 0x87, 0xc1, 0xd8, 0x6b, 0x99, 0xaf, 0x44, 0x34, 0x76, 0x59, 0x11, 0x9b, 0x22, 0xfc, 0x45 },
{ 0x81, 0x77, 0x22, 0x8d, 0xa4, 0xa4, 0x5d, 0xc7, 0xfc, 0xa3, 0x8b, 0xde, 0xf6, 0x0a, 0xff, 0xe4 },
{ 0x9c, 0x70, 0xb6, 0x0c, 0x52, 0x67, 0xa9, 0x4e, 0x5f, 0x33, 0xb6, 0xb0, 0x29, 0x85, 0xed, 0x51 },
{ 0xf8, 0x81, 0x64, 0xc1, 0x2d, 0x9c, 0x8f, 0xaf, 0x7d, 0x0f, 0x6e, 0x7c, 0x7b, 0xcd, 0x55, 0x79 },
{ 0x13, 0x68, 0x87, 0x59, 0x80, 0x77, 0x6f, 0x88, 0x54, 0x52, 0x7a, 0x07, 0x69, 0x0e, 0x96, 0x27 },
{ 0x14, 0xee, 0xca, 0x33, 0x8b, 0x20, 0x86, 0x13, 0x48, 0x5e, 0xa0, 0x30, 0x8f, 0xd7, 0xa1, 0x5e },
{ 0xa1, 0xf1, 0xeb, 0xbe, 0xd8, 0xdb, 0xc1, 0x53, 0xc0, 0xb8, 0x4a, 0xa6, 0x1f, 0xf0, 0x82, 0x39 },
{ 0x3b, 0x62, 0xa9, 0xba, 0x62, 0x58, 0xf5, 0x61, 0x0f, 0x83, 0xe2, 0x64, 0xf3, 0x14, 0x97, 0xb4 },
{ 0x26, 0x44, 0x99, 0x06, 0x0a, 0xd9, 0xba, 0xab, 0xc4, 0x7f, 0x8b, 0x02, 0xbb, 0x6d, 0x71, 0xed },
{ 0x00, 0x11, 0x0d, 0xc3, 0x78, 0x14, 0x69, 0x56, 0xc9, 0x54, 0x47, 0xd3, 0xf3, 0xd0, 0xfb, 0xba },
{ 0x01, 0x51, 0xc5, 0x68, 0x38, 0x6b, 0x66, 0x77, 0xa2, 0xb4, 0xdc, 0x6f, 0x81, 0xe5, 0xdc, 0x18 },
{ 0xd6, 0x26, 0xb2, 0x66, 0x90, 0x5e, 0xf3, 0x58, 0x82, 0x63, 0x4d, 0xf6, 0x85, 0x32, 0xc1, 0x25 },
{ 0x98, 0x69, 0xe2, 0x47, 0xe9, 0xc0, 0x8b, 0x10, 0xd0, 0x29, 0x93, 0x4f, 0xc4, 0xb9, 0x52, 0xf7 },
{ 0x31, 0xfc, 0xef, 0xac, 0x66, 0xd7, 0xde, 0x9c, 0x7e, 0xc7, 0x48, 0x5f, 0xe4, 0x49, 0x49, 0x02 },
{ 0x54, 0x93, 0xe9, 0x99, 0x33, 0xb0, 0xa8, 0x11, 0x7e, 0x08, 0xec, 0x0f, 0x97, 0xcf, 0xc3, 0xd9 },
{ 0x6e, 0xe2, 0xa4, 0xca, 0x67, 0xb0, 0x54, 0xbb, 0xfd, 0x33, 0x15, 0xbf, 0x85, 0x23, 0x05, 0x77 },
{ 0x47, 0x3d, 0x06, 0xe8, 0x73, 0x8d, 0xb8, 0x98, 0x54, 0xc0, 0x66, 0xc4, 0x7a, 0xe4, 0x77, 0x40 },
{ 0xa4, 0x26, 0xe5, 0xe4, 0x23, 0xbf, 0x48, 0x85, 0x29, 0x4d, 0xa4, 0x81, 0xfe, 0xae, 0xf7, 0x23 },
{ 0x78, 0x01, 0x77, 0x31, 0xcf, 0x65, 0xfa, 0xb0, 0x74, 0xd5, 0x20, 0x89, 0x52, 0x51, 0x2e, 0xb1 },
{ 0x9e, 0x25, 0xfc, 0x83, 0x3f, 0x22, 0x90, 0x73, 0x3e, 0x93, 0x44, 0xa5, 0xe8, 0x38, 0x39, 0xeb },
{ 0x56, 0x8e, 0x49, 0x5a, 0xbe, 0x52, 0x5a, 0x21, 0x8a, 0x22, 0x14, 0xcd, 0x3e, 0x07, 0x1d, 0x12 },
{ 0x4a, 0x29, 0xb5, 0x45, 0x52, 0xd1, 0x6b, 0x9a, 0x46, 0x9c, 0x10, 0x52, 0x8e, 0xff, 0x0a, 0xae },
{ 0xc9, 0xd1, 0x84, 0xdd, 0xd5, 0xa9, 0xf5, 0xe0, 0xcf, 0x8c, 0xe2, 0x9a, 0x9a, 0xbf, 0x69, 0x1c },
{ 0x2d, 0xb4, 0x79, 0xae, 0x78, 0xbd, 0x50, 0xd8, 0x88, 0x2a, 0x8a, 0x17, 0x8a, 0x61, 0x32, 0xad },
{ 0x8e, 0xce, 0x5f, 0x04, 0x2d, 0x5e, 0x44, 0x7b, 0x50, 0x51, 0xb9, 0xea, 0xcb, 0x8d, 0x8f, 0x6f },
{ 0x9c, 0x0b, 0x53, 0xb4, 0xb3, 0xc3, 0x07, 0xe8, 0x7e, 0xae, 0xe0, 0x86, 0x78, 0x14, 0x1f, 0x66 },
{ 0xab, 0xf2, 0x48, 0xaf, 0x69, 0xa6, 0xea, 0xe4, 0xbf, 0xd3, 0xeb, 0x2f, 0x12, 0x9e, 0xeb, 0x94 },
{ 0x06, 0x64, 0xda, 0x16, 0x68, 0x57, 0x4b, 0x88, 0xb9, 0x35, 0xf3, 0x02, 0x73, 0x58, 0xae, 0xf4 },
{ 0xaa, 0x4b, 0x9d, 0xc4, 0xbf, 0x33, 0x7d, 0xe9, 0x0c, 0xd4, 0xfd, 0x3c, 0x46, 0x7c, 0x6a, 0xb7 },
{ 0xea, 0x5c, 0x7f, 0x47, 0x1f, 0xaf, 0x6b, 0xde, 0x2b, 0x1a, 0xd7, 0xd4, 0x68, 0x6d, 0x22, 0x87 },
{ 0x29, 0x39, 0xb0, 0x18, 0x32, 0x23, 0xfa, 0xfc, 0x17, 0x23, 0xde, 0x4f, 0x52, 0xc4, 0x3d, 0x35 },
{ 0x7c, 0x39, 0x56, 0xca, 0x5e, 0xea, 0xfc, 0x3e, 0x36, 0x3e, 0x9d, 0x55, 0x65, 0x46, 0xeb, 0x68 },
{ 0x77, 0xc6, 0x07, 0x71, 0x46, 0xf0, 0x1c, 0x32, 0xb6, 0xb6, 0x9d, 0x5f, 0x4e, 0xa9, 0xff, 0xcf },
{ 0x37, 0xa6, 0x98, 0x6c, 0xb8, 0x84, 0x7e, 0xdf, 0x09, 0x25, 0xf0, 0xf1, 0x30, 0x9b, 0x54, 0xde },
{ 0xa7, 0x05, 0xf0, 0xe6, 0x9d, 0xa9, 0xa8, 0xf9, 0x07, 0x24, 0x1a, 0x2e, 0x92, 0x3c, 0x8c, 0xc8 },
{ 0x3d, 0xc4, 0x7d, 0x1f, 0x29, 0xc4, 0x48, 0x46, 0x1e, 0x9e, 0x76, 0xed, 0x90, 0x4f, 0x67, 0x11 },
{ 0x0d, 0x62, 0xbf, 0x01, 0xe6, 0xfc, 0x0e, 0x1a, 0x0d, 0x3c, 0x47, 0x51, 0xc5, 0xd3, 0x69, 0x2b },
{ 0x8c, 0x03, 0x46, 0x8b, 0xca, 0x7c, 0x66, 0x9e, 0xe4, 0xfd, 0x5e, 0x08, 0x4b, 0xbe, 0xe7, 0xb5 },
{ 0x52, 0x8a, 0x5b, 0xb9, 0x3b, 0xaf, 0x2c, 0x9c, 0x44, 0x73, 0xcc, 0xe5, 0xd0, 0xd2, 0x2b, 0xd9 },
{ 0xdf, 0x6a, 0x30, 0x1e, 0x95, 0xc9, 0x5d, 0xad, 0x97, 0xae, 0x0c, 0xc8, 0xc6, 0x91, 0x3b, 0xd8 },
{ 0x80, 0x11, 0x89, 0x90, 0x2c, 0x85, 0x7f, 0x39, 0xe7, 0x35, 0x91, 0x28, 0x5e, 0x70, 0xb6, 0xdb },
{ 0xe6, 0x17, 0x34, 0x6a, 0xc9, 0xc2, 0x31, 0xbb, 0x36, 0x50, 0xae, 0x34, 0xcc, 0xca, 0x0c, 0x5b },
{ 0x27, 0xd9, 0x34, 0x37, 0xef, 0xb7, 0x21, 0xaa, 0x40, 0x18, 0x21, 0xdc, 0xec, 0x5a, 0xdf, 0x89 },
{ 0x89, 0x23, 0x7d, 0x9d, 0xed, 0x9c, 0x5e, 0x78, 0xd8, 0xb1, 0xc9, 0xb1, 0x66, 0xcc, 0x73, 0x42 },
{ 0x4a, 0x6d, 0x80, 0x91, 0xbf, 0x5e, 0x7d, 0x65, 0x11, 0x89, 0xfa, 0x94, 0xa2, 0x50, 0xb1, 0x4c },
{ 0x0e, 0x33, 0xf9, 0x60, 0x55, 0xe7, 0xae, 0x89, 0x3f, 0xfc, 0x0e, 0x3d, 0xcf, 0x49, 0x29, 0x02 },
{ 0xe6, 0x1c, 0x43, 0x2b, 0x72, 0x0b, 0x19, 0xd1, 0x8e, 0xc8, 0xd8, 0x4b, 0xdc, 0x63, 0x15, 0x1b },
{ 0xf7, 0xe5, 0xae, 0xf5, 0x49, 0xf7, 0x82, 0xcf, 0x37, 0x90, 0x55, 0xa6, 0x08, 0x26, 0x9b, 0x16 },
{ 0x43, 0x8d, 0x03, 0x0f, 0xd0, 0xb7, 0xa5, 0x4f, 0xa8, 0x37, 0xf2, 0xad, 0x20, 0x1a, 0x64, 0x03 },
{ 0xa5, 0x90, 0xd3, 0xee, 0x4f, 0xbf, 0x04, 0xe3, 0x24, 0x7e, 0x0d, 0x27, 0xf2, 0x86, 0x42, 0x3f },
{ 0x5f, 0xe2, 0xc1, 0xa1, 0x72, 0xfe, 0x93, 0xc4, 0xb1, 0x5c, 0xd3, 0x7c, 0xae, 0xf9, 0xf5, 0x38 },
{ 0x2c, 0x97, 0x32, 0x5c, 0xbd, 0x06, 0xb3, 0x6e, 0xb2, 0x13, 0x3d, 0xd0, 0x8b, 0x3a, 0x01, 0x7c },
{ 0x92, 0xc8, 0x14, 0x22, 0x7a, 0x6b, 0xca, 0x94, 0x9f, 0xf0, 0x65, 0x9f, 0x00, 0x2a, 0xd3, 0x9e },
{ 0xdc, 0xe8, 0x50, 0x11, 0x0b, 0xd8, 0x32, 0x8c, 0xfb, 0xd5, 0x08, 0x41, 0xd6, 0x91, 0x1d, 0x87 },
{ 0x67, 0xf1, 0x49, 0x84, 0xc7, 0xda, 0x79, 0x12, 0x48, 0xe3, 0x2b, 0xb5, 0x92, 0x25, 0x83, 0xda },
{ 0x19, 0x38, 0xf2, 0xcf, 0x72, 0xd5, 0x4e, 0xe9, 0x7e, 0x94, 0x16, 0x6f, 0xa9, 0x1d, 0x2a, 0x36 },
{ 0x74, 0x48, 0x1e, 0x96, 0x46, 0xed, 0x49, 0xfe, 0x0f, 0x62, 0x24, 0x30, 0x16, 0x04, 0x69, 0x8e },
{ 0x57, 0xfc, 0xa5, 0xde, 0x98, 0xa9, 0xd6, 0xd8, 0x00, 0x64, 0x38, 0xd0, 0x58, 0x3d, 0x8a, 0x1d },
{ 0x9f, 0xec, 0xde, 0x1c, 0xef, 0xdc, 0x1c, 0xbe, 0xd4, 0x76, 0x36, 0x74, 0xd9, 0x57, 0x53, 0x59 },
{ 0xe3, 0x04, 0x0c, 0x00, 0xeb, 0x28, 0xf1, 0x53, 0x66, 0xca, 0x73, 0xcb, 0xd8, 0x72, 0xe7, 0x40 },
{ 0x76, 0x97, 0x00, 0x9a, 0x6a, 0x83, 0x1d, 0xfe, 0xcc, 0xa9, 0x1c, 0x59, 0x93, 0x67, 0x0f, 0x7a },
{ 0x58, 0x53, 0x54, 0x23, 0x21, 0xf5, 0x67, 0xa0, 0x05, 0xd5, 0x47, 0xa4, 0xf0, 0x47, 0x59, 0xbd },
{ 0x51, 0x50, 0xd1, 0x77, 0x2f, 0x50, 0x83, 0x4a, 0x50, 0x3e, 0x06, 0x9a, 0x97, 0x3f, 0xbd, 0x7c }
};
const uint8_t vectors_halfsip32[MAXLEN][4] =
{
{0x08, 0x99, 0xcb, 0xf6 },
{0xbc, 0xc9, 0x99, 0xe4 },
{0x48, 0x62, 0x08, 0xc5 },
{0x1b, 0x1c, 0x06, 0x8c },
{0xe7, 0x60, 0x30, 0xfd },
{0xe9, 0x73, 0xbb, 0xba },
{0xf1, 0xeb, 0xa4, 0x9c },
{0x92, 0x52, 0xa9, 0x2c },
{0xeb, 0x00, 0xf4, 0xa7 },
{0x39, 0xf4, 0xcd, 0xf6 },
{0x28, 0xaa, 0x20, 0x71 },
{0x76, 0xcc, 0x30, 0x5d },
{0x5e, 0x7c, 0xff, 0x01 },
{0x2b, 0x53, 0x2e, 0xb4 },
{0x7d, 0x35, 0x77, 0xe9 },
{0xe2, 0x7d, 0xbe, 0xe7 },
{0x8c, 0x1b, 0xe7, 0x97 },
{0x0e, 0x01, 0xba, 0xee },
{0xe7, 0x1a, 0x84, 0x27 },
{0xf8, 0xc3, 0x76, 0xf9 },
{0xf4, 0xbb, 0x68, 0x3c },
{0x6f, 0x9e, 0x29, 0xc7 },
{0xbc, 0xa0, 0xfa, 0x94 },
{0xd1, 0x6a, 0x55, 0xbc },
{0xf4, 0xd6, 0x08, 0x96 },
{0x50, 0xf1, 0xff, 0xa5 },
{0xca, 0x30, 0x6b, 0x0d },
{0x3d, 0xad, 0x3c, 0xdc },
{0x7b, 0x4b, 0xbb, 0x5d },
{0x29, 0x97, 0xbf, 0x8d },
{0x56, 0xb9, 0x50, 0x90 },
{0xe8, 0x54, 0x7d, 0xc0 },
{0x34, 0xd0, 0x3a, 0xc4 },
{0xfb, 0x6f, 0x04, 0x6d },
{0x86, 0x11, 0x8a, 0x54 },
{0x76, 0x21, 0x02, 0x7c },
{0x25, 0xc3, 0x55, 0x46 },
{0x7a, 0xe5, 0x19, 0x61 },
{0xef, 0x77, 0x52, 0xe2 },
{0xb5, 0x8a, 0x16, 0x95 },
{0x48, 0x40, 0x47, 0x41 },
{0x5e, 0xa9, 0x09, 0xde },
{0xb3, 0x83, 0xd0, 0x08 },
{0xb3, 0x81, 0x5b, 0x1f },
{0x20, 0x7a, 0xdb, 0x50 },
{0x91, 0x6a, 0x77, 0x0e },
{0xfb, 0x7d, 0x5f, 0x65 },
{0xd8, 0x91, 0x36, 0xef },
{0xc0, 0xa2, 0x25, 0x7f },
{0x68, 0x82, 0xb2, 0x08 },
{0x01, 0xd1, 0x1b, 0xb5 },
{0x2a, 0x7c, 0x73, 0x7d },
{0xa0, 0xf2, 0xde, 0x0e },
{0x59, 0xc4, 0x8d, 0x4a },
{0x43, 0xc4, 0x38, 0x73 },
{0xd9, 0x02, 0xc3, 0x33 },
{0xb9, 0xd2, 0xfb, 0x16 },
{0x98, 0x3c, 0xdc, 0x43 },
{0x34, 0xbf, 0x29, 0x3c },
{0x17, 0x32, 0x39, 0x01 },
{0xc1, 0xa8, 0x89, 0x02 },
{0xed, 0xa5, 0x8d, 0x32 },
{0xea, 0x75, 0xa7, 0xf6 },
{0xd0, 0x51, 0x73, 0x5c }
};
const uint8_t vectors_halfsip64[MAXLEN][8] =
{
{0x2b, 0x21, 0x70, 0xca, 0x52, 0x14, 0xce, 0x7c },
{0x2f, 0x7b, 0x14, 0x5b, 0xf0, 0xc0, 0x35, 0xbe },
{0xd9, 0x65, 0x05, 0x6f, 0x38, 0x69, 0xd1, 0xe4 },
{0x97, 0xa6, 0x3d, 0x56, 0x45, 0xba, 0xee, 0x3e },
{0x63, 0xe8, 0x92, 0x6f, 0xbe, 0xfd, 0xe2, 0x2a },
{0x34, 0xb9, 0xd8, 0x9b, 0xda, 0x60, 0x3c, 0x60 },
{0xb5, 0xcb, 0xbf, 0xdc, 0x11, 0x88, 0xe6, 0xc5 },
{0x24, 0x5e, 0x4b, 0x2e, 0xea, 0xf8, 0x66, 0xa3 },
{0x1e, 0x25, 0x8f, 0x31, 0x01, 0x51, 0x6a, 0x55 },
{0x72, 0x86, 0x52, 0xc3, 0xe7, 0x10, 0x37, 0x02 },
{0xbc, 0xdd, 0x32, 0x5f, 0xa3, 0x02, 0xef, 0x68 },
{0xf1, 0x89, 0x0d, 0xe5, 0xd6, 0xf3, 0xc6, 0x27 },
{0x9c, 0x09, 0x37, 0x57, 0xa5, 0x06, 0xc5, 0x3e },
{0x2a, 0x32, 0x80, 0xb8, 0xee, 0x44, 0x8a, 0xa4 },
{0xca, 0xb9, 0xdf, 0xa2, 0x03, 0xae, 0x92, 0x9d },
{0xae, 0x36, 0x26, 0x08, 0x32, 0xa6, 0x31, 0xb2 },
{0x7b, 0x32, 0x86, 0xb0, 0x17, 0x5e, 0x26, 0x01 },
{0x9e, 0xba, 0xb3, 0xa1, 0xe8, 0xd4, 0x32, 0xb1 },
{0x00, 0xe1, 0x7d, 0xe3, 0x1d, 0x04, 0xda, 0xe2 },
{0x39, 0x27, 0x3f, 0xef, 0xa7, 0x36, 0xbc, 0xdf },
{0xd8, 0xe7, 0x0a, 0xfb, 0x9c, 0x12, 0x55, 0xcc },
{0x4c, 0x40, 0xd5, 0x8c, 0x3d, 0x86, 0xb0, 0x10 },
{0x34, 0x95, 0xc1, 0xc4, 0x62, 0x5c, 0x42, 0x09 },
{0xe5, 0xed, 0x01, 0xa7, 0x3a, 0xf2, 0xea, 0x26 },
{0x94, 0x78, 0x8c, 0x8a, 0xb1, 0xa2, 0xd7, 0xfb },
{0x33, 0x4e, 0x46, 0x2c, 0x0e, 0xb7, 0x56, 0x67 },
{0x14, 0xa5, 0x34, 0x0f, 0x48, 0x61, 0x90, 0xea },
{0xcf, 0x0b, 0xd7, 0x27, 0xc0, 0x79, 0x7c, 0x25 },
{0x2c, 0x6b, 0x19, 0xbd, 0xc2, 0x22, 0x17, 0x11 },
{0x5a, 0xb2, 0xb1, 0x6a, 0x92, 0x52, 0xe3, 0x44 },
{0x7c, 0xa7, 0xf3, 0xc4, 0x45, 0xa2, 0x33, 0xc1 },
{0x8e, 0x36, 0xe0, 0x0c, 0x93, 0x59, 0xf7, 0x61 },
{0x58, 0x90, 0xd3, 0xdb, 0x17, 0xc6, 0x90, 0x4a },
{0x88, 0x48, 0x7b, 0x94, 0x18, 0x12, 0x7c, 0xa1 },
{0x15, 0x9e, 0xb3, 0x70, 0x3f, 0x81, 0x7d, 0x55 },
{0x2a, 0xec, 0x9c, 0x81, 0xee, 0xa8, 0x92, 0xac },
{0xac, 0x5b, 0x79, 0x0e, 0x61, 0x8b, 0xf3, 0xa8 },
{0x8f, 0xc5, 0xeb, 0x57, 0xee, 0xe4, 0x81, 0x63 },
{0x0e, 0xd0, 0xab, 0xbc, 0x9d, 0x94, 0xe2, 0xd9 },
{0x5d, 0xa3, 0xe5, 0x39, 0x9d, 0xae, 0x66, 0xa5 },
{0x34, 0x13, 0xf9, 0x4c, 0x8c, 0xe9, 0x93, 0x9a },
{0x27, 0x0f, 0xc4, 0xd0, 0x1e, 0x7a, 0x71, 0xb4 },
{0xcd, 0x6a, 0xd8, 0x07, 0x04, 0x3c, 0x84, 0xad },
{0xb7, 0x51, 0x18, 0x64, 0x22, 0xf4, 0x0c, 0x5d },
{0x90, 0xcf, 0x8d, 0xc2, 0x1a, 0x75, 0x82, 0xe2 },
{0x22, 0x96, 0x4a, 0x10, 0xaf, 0xa3, 0x0c, 0x3f },
{0x9c, 0x38, 0x2e, 0x80, 0x14, 0x37, 0x7b, 0xa0 },
{0x98, 0x1c, 0x11, 0x08, 0xe6, 0x4a, 0x36, 0xbb },
{0xc4, 0x51, 0xbb, 0x39, 0x4b, 0xdc, 0x43, 0x55 },
{0x27, 0xb8, 0x2e, 0x1c, 0x92, 0x2c, 0xf2, 0x7c },
{0xbb, 0x4b, 0x27, 0xf0, 0xa6, 0xbb, 0xac, 0x85 },
{0x6c, 0x46, 0xa4, 0xc6, 0x1c, 0xba, 0x82, 0xa4 },
{0x1c, 0xa4, 0xe0, 0x6f, 0xb6, 0x00, 0x5a, 0xe5 },
{0x1f, 0xd2, 0x33, 0x97, 0x70, 0x88, 0x2b, 0x03 },
{0x18, 0xce, 0xa4, 0x4c, 0xea, 0xcb, 0x69, 0x69 },
{0x77, 0x9d, 0x2b, 0xe4, 0xec, 0xd5, 0xd7, 0xe9 },
{0xac, 0x5f, 0x9f, 0xa2, 0x67, 0xc9, 0xae, 0xd1 },
{0x55, 0x86, 0x68, 0x08, 0xea, 0x1f, 0x47, 0xa4 },
{0x23, 0x03, 0x88, 0x1d, 0x4a, 0xea, 0x59, 0xa0 },
{0x4b, 0x06, 0xd7, 0x7d, 0x19, 0x57, 0xfe, 0xee },
{0x87, 0xa8, 0x08, 0x1a, 0xd9, 0x08, 0xac, 0xaa },
{0x4f, 0xb6, 0xce, 0x59, 0xfd, 0xc4, 0xf5, 0x81 },
{0xd5, 0xd2, 0x74, 0xfc, 0xa0, 0x01, 0x91, 0x60 },
{0xd2, 0x6c, 0xed, 0x5b, 0x43, 0x65, 0x36, 0xea },
};
int main()
{
uint8_t in[MAXLEN], out[16], k[16];
int i, j;
int fails = 0;
for( i = 0; i < 16; ++i ) k[i] = i;
for( i = 0; i < MAXLEN; ++i ) in[i] = (uint8_t)i;
printf("AlgorithmType: MAC\n");
printf("Name: SipHash-2-4\n");
printf("Source: SipHash GitHub test vector generator (http://github.com/veorq/SipHash/blob/halfsiphash/test.c)\n");
printf("Key: ");
for( i = 0; i < 16; i++)
printf("%02X", k[i]);
printf("\n");
#define TAG 16
for( i = 0; i < MAXLEN; ++i )
{
siphash( in, i, k, out, TAG );
/* Positive */
if (!i)
{
printf("Message: \"\"\n");
}
else
{
printf("Message: ");
for( j = 0; j < i; j++)
printf("%02X", in[j]);
printf("\n");
}
printf("MAC: ");
for( j = 0; j < TAG; j++)
printf("\\x%02X", out[j]);
printf("\n");
printf("Test: Verify\n");
/* Negative */
#if 0
if (!i)
{
printf("Message: \"\"\n");
}
else
{
printf("Message: ");
for( j = 0; j < i; j++)
printf("%02X", in[j]);
printf("\n");
}
printf("MAC: ");
for( j = 0; j < 8; j++)
printf("%02X", out[j]^0x01);
printf("\n");
printf("Test: NotVerify\n");
#endif
//if ( memcmp( out, vectors_sip64[i], 8 ) )
//{
// printf( "fail for %d bytes\n", i );
// fails++;
//}
}
//if (!fails) printf("OK\n");
fails = 0;
//printf( "SipHash 128-bit tag:\n");
//for( i = 0; i < MAXLEN; ++i )
//{
// siphash( in, i, k, out, 16 );
//if ( memcmp( out, vectors_sip128[i], 16 ) )
//{
// printf( "fail for %d bytes\n", i );
// fails++;
//}
//}
//if (!fails) printf("OK\n");
#if 0
fails = 0;
printf( "HalfSipHash 32-bit tag:\n");
for( i = 0; i < MAXLEN; ++i )
{
in[i] = i;
halfsiphash( in, i, k, out, 4 );
if ( memcmp( out, vectors_halfsip32[i], 4 ) )
{
printf( "fail for %d bytes\n", i );
fails++;
}
}
if (!fails) printf("OK\n");
fails = 0;
printf( "HalfSipHash 64-bit tag:\n");
for( i = 0; i < MAXLEN; ++i )
{
in[i] = i;
halfsiphash( in, i, k, out, 8 );
if ( memcmp( out, vectors_halfsip64[i], 8 ) )
{
printf( "fail for %d bytes\n", i );
fails++;
}
}
if (!fails) printf("OK\n");
#endif
return 0;
}
```
| Add SipHash | https://api.github.com/repos/weidai11/cryptopp/issues/348/comments | 1 | 2016-12-17T08:23:47Z | 2016-12-18T01:26:01Z | https://github.com/weidai11/cryptopp/issues/348 | 196,210,207 | 348 |
[
"weidai11",
"cryptopp"
] | We sent a copy to the mailing list at [Security issue (DoS) in Crypto++ ASN1 decoder](https://groups.google.com/d/msg/cryptopp-users/fEQ8jWg_K8g/qOLHGIDICwAJ).
<strike>We asked for a CVE to be assigned on oss-security.</strike> CVE-2016-9939 was assigned to the issue.
On Mon, Dec 12, 2016 at 8:45 AM, Gergely Nagy <ngg@tresorit.com> wrote:
> Hi!
>
> I have found a bug in several BERDecode* functions which could be used for a
> DoS attack.
>
> The issue is similar to CVE-2016-2109 in OpenSSL which was disclosed in
> https://www.openssl.org/news/secadv/20160503.txt
>
> Basically after the ASN1 decoder reads the length, it allocates a
> SecByteBlock of that size before checking that there is enough data
> available.
>
> This can cause memory exhaustion on most platforms, but it has (in my
> opinion) the worst effect on 64-bit Linux systems where the allocation
> will succeed for huge sizes and then a BERDecodeError exception will be
> thrown that causes the destructor of the SecByteBlock to be called,
> which can hang the CPU for a really long time zeroing out memory.
>
> I have attached a patch (for the current master branch) that fixes this
> behavior in both versions of BERDecodeOctetString, BERDecodeTextString,
> BERDecodeBitString and BERDecodeUnsigned. I am not 100% sure that there are
> no other places in the code with the same issue.
>
> I don't know how you want to disclose this issue, but if you want to assign
> a CVE number and release a new version before publicly disclosing it
> then we won't deploy our fix until then.
>
> We will binary patch our software which includes a statically linked
> Crypto++ after 30 days if we don't get a proper response.
>
> When you disclose the issue please refer to me as "Gergely Nagy (Tresorit)",
> and say that the bug was found using "honggfuzz".
>
> Thanks,
>
> Gergely Nagy (Tresorit)
-----
Here is the patch that was attached to the email.
```
diff --git a/asn.cpp b/asn.cpp
index 5708a2c..3e3ae81 100644
--- a/asn.cpp
+++ b/asn.cpp
@@ -124,6 +124,9 @@ size_t BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str)
if (!BERLengthDecode(bt, bc))
BERDecodeError();
+ if (bc > bt.MaxRetrievable())
+ BERDecodeError();
+
str.New(bc);
if (bc != bt.Get(str, bc))
BERDecodeError();
@@ -140,6 +143,9 @@ size_t BERDecodeOctetString(BufferedTransformation &bt, BufferedTransformation &
if (!BERLengthDecode(bt, bc))
BERDecodeError();
+ if (bc > bt.MaxRetrievable())
+ BERDecodeError();
+
bt.TransferTo(str, bc);
return bc;
}
@@ -162,10 +168,12 @@ size_t BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte as
if (!BERLengthDecode(bt, bc))
BERDecodeError();
- SecByteBlock temp(bc);
- if (bc != bt.Get(temp, bc))
+ if (bc > bt.MaxRetrievable())
+ BERDecodeError();
+
+ str.resize(bc);
+ if (bc != bt.Get((byte *)str.data(), bc))
BERDecodeError();
- str.assign((char *)temp.begin(), bc);
return bc;
}
@@ -189,6 +197,9 @@ size_t BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigne
if (!BERLengthDecode(bt, bc))
BERDecodeError();
+ if (bc > bt.MaxRetrievable())
+ BERDecodeError();
+
byte unused;
if (!bt.Get(unused))
BERDecodeError();
diff --git a/asn.h b/asn.h
index e8283f7..aff1c31 100644
--- a/asn.h
+++ b/asn.h
@@ -499,6 +499,9 @@ void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag = INTEGER,
if (!definite)
BERDecodeError();
+ if (bc > in.MaxRetrievable())
+ BERDecodeError();
+
SecByteBlock buf(bc);
if (bc != in.Get(buf, bc))
```
| Security issue (DoS) in Crypto++ ASN1 decoder | https://api.github.com/repos/weidai11/cryptopp/issues/346/comments | 15 | 2016-12-12T20:42:57Z | 2018-01-22T21:57:30Z | https://github.com/weidai11/cryptopp/issues/346 | 195,080,315 | 346 |
[
"weidai11",
"cryptopp"
] | `default.h` and `default.cpp` use some rusty algorithms. Below is from `default.h`. `DES_EDE2` is 2-key TripleDES, and it provides about 80 bits of security.
```
typedef DES_EDE2 DefaultBlockCipher;
typedef SHA DefaultHashModule;
typedef HMAC<DefaultHashModule> DefaultMAC;
```
We need to provide the legacy stuff for those who need the upgrade path. The best fit appears to lie somewhere around a common, templated `DataEncryptor`, `DataEncryptorWithMAC`, etc. Then we provide `DefaultEncryptor`, `DefaultEncryptorWithMAC` and friends with new algorithms; and `LegacyEncryptor`, `LegacyEncryptorWithMAC` and friends with the old gear for those who need it.
Attached is a tentative patch. It includes the new `default.h` and `default.cpp`, and a diff of the changes.
Tentative patch: [default.zip](https://github.com/weidai11/cryptopp/files/635497/default.zip) | Update DefaultEncryptor, DefaultEncryptorWithMAC and friends | https://api.github.com/repos/weidai11/cryptopp/issues/345/comments | 1 | 2016-12-07T02:19:44Z | 2016-12-11T10:11:50Z | https://github.com/weidai11/cryptopp/issues/345 | 193,940,633 | 345 |
[
"weidai11",
"cryptopp"
] | `validat1.cpp` has three tests that were added over time in response to bug reports. The three tests are `TestSecBlock`, `TestPolynomialMod2` and `TestHuffmanCodes`. The tests are exercised in debug builds because they are more comprehensive. They are sanity checks that provide extra attention when running under Valgrind, the Sanitizers, etc.
We have an additional 2000 or 3000 lines to add for `TestIntegerBitops`. `TestIntegerBitops` are the tsts for [Issue 336: Add AND, OR and XOR bitops to Integer class](https://github.com/weidai11/cryptopp/issues/336). They were created with Java (see the 336 bug report for the Java program).
`validate1.cpp` has become a dumping ground for these sort of debug tests. There will be four tests guarded with:
```
#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_IMPORTS)
bool PerformDebugTest()
{
...
}
#endif
```
This issue tracks (1) adding the self tests for Integer bitops, and (2) adding a `validate0.cpp` to cleanup `validate1.cpp`. | Add additional validate source file with additional tests | https://api.github.com/repos/weidai11/cryptopp/issues/344/comments | 1 | 2016-12-07T01:38:56Z | 2016-12-07T01:58:17Z | https://github.com/weidai11/cryptopp/issues/344 | 193,935,246 | 344 |
[
"weidai11",
"cryptopp"
] | It looks like Doxygen is having trouble documenting constants when a constant is declared as an anonymous `enum`:

The `enum` is selected in `config.h`:
```
// How to declare class constants
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
# define CRYPTOPP_CONSTANT(x) enum {x};
#else
# define CRYPTOPP_CONSTANT(x) static const int x;
#endif
```
It looks like we are going to have to switch back to `static const int` for documentation. The difference between them is `static const int` has an allocation and takes up space. You can also take the address of `static const int`. An enumeration does not take up space, and you cannot take the address of it. | Crypto++ manual and empty enum values | https://api.github.com/repos/weidai11/cryptopp/issues/343/comments | 1 | 2016-12-04T20:17:22Z | 2016-12-04T21:08:58Z | https://github.com/weidai11/cryptopp/issues/343 | 193,372,642 | 343 |
[
"weidai11",
"cryptopp"
] | Crypto++ currently supports VC++ 5.0/6.0 support from the mid 1990's. Its caused us to keep code like the following from `sha.cpp`:
```
static void X86_SHA256_HashBlocks(word32 *state, const word32 *data, size_t len
#if defined(_MSC_VER) && (_MSC_VER == 1200)
, ... // VC60 workaround: prevent VC 6 from inlining this function
#endif
)
```
We would like to remove VC++ 5.0/6.0 support for the upcoming Crypto++ 5.7 release. Its part of a general cleanup to help with long term maintenance. Crypto++ will continue to support the early .Net compilers (VS.Net 2002 (7.0) and VS.Net 2003 (7.1)). The .Net compilers are a good choice because they are mostly conforming.
WD has no preference on the move.
| Remove VC++ 5.0/6.0 support | https://api.github.com/repos/weidai11/cryptopp/issues/342/comments | 2 | 2016-12-03T02:30:14Z | 2017-07-20T18:42:23Z | https://github.com/weidai11/cryptopp/issues/342 | 193,259,665 | 342 |
[
"weidai11",
"cryptopp"
] | ```
Do you think we can take care of these warning?
=20
In file included from /opt/local/include/cryptopp/simple.h:17:
/opt/local/include/cryptopp/misc.h:1953:14: warning: implicit conversion lo=
ses integer precision: 'int' to 'word16' (aka 'unsigned short') [-Wconversi=
on]
? block[1] | (block[0] << 8)
~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/local/include/cryptopp/misc.h:1954:14: warning: implicit conversion lo=
ses integer precision: 'int' to 'word16' (aka 'unsigned short') [-Wconversi=
on]
: block[0] | (block[1] << 8);
~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from ../src/timing.cpp:19:
In file included from /opt/local/include/cryptopp/oids.h:9:
/opt/local/include/cryptopp/asn.h:344:71: warning: implicit conversion chan=
ges signedness: 'int' to 'byte' (aka 'unsigned char') [-Wsign-conversion]
void BERDecode(BERSequenceDecoder &seqDecoder, byte tag, byte mask =
=3D ~CONSTRUCTED)
=
~ ^~~~~~~~~~~~
/opt/local/include/cryptopp/asn.h:541:32: warning: implicit conversion lose=
s integer precision: 'unsigned long' to 'word32' (aka 'unsigned int') [-Wsh=
orten-64-to-32]
{return ::CryptoPP::OID(lhs)+=3Drhs;}
~~^~~
In file included from ../src/timing.cpp:20:
In file included from /opt/local/include/cryptopp/osrng.h:14:
In file included from /opt/local/include/cryptopp/randpool.h:35:
In file included from /opt/local/include/cryptopp/aes.h:9:
In file included from /opt/local/include/cryptopp/rijndael.h:11:
/opt/local/include/cryptopp/seckey.h:89:85: warning: implicit conversion ch=
anges signedness: 'int' to 'unsigned int' [-Wsign-conversion]
throw InvalidRounds(alg ? alg->AlgorithmNam=
e() : std::string("VariableRounds"), rounds);
~~~~~~~~~~~~~ =
^~~~~~
/opt/local/include/cryptopp/seckey.h:94:85: warning: implicit conversion ch=
anges signedness: 'int' to 'unsigned int' [-Wsign-conversion]
throw InvalidRounds(alg ? alg->AlgorithmNam=
e() : std::string("VariableRounds"), rounds);
~~~~~~~~~~~~~ =
^~~~~~
In file included from ../src/timing.cpp:18:
In file included from /opt/local/include/cryptopp/hex.h:10:
In file included from /opt/local/include/cryptopp/basecode.h:10:
In file included from /opt/local/include/cryptopp/filters.h:17:
In file included from /opt/local/include/cryptopp/simple.h:17:
/opt/local/include/cryptopp/misc.h:554:41: warning: operand of ? changes si=
gnedness: 'int' to 'unsigned int' [-Wsign-conversion]
result =3D char((digit < 10 ? '0' : (CH - 10)) + digit) + r=
esult;
~~~^~~~ ~
/opt/local/include/cryptopp/simple.h:58:113: note: in instantiation of func=
tion template specialization 'CryptoPP::IntToString<unsigned int>' requeste=
d here
explicit InvalidRounds(const std::string &algorithm, unsigned int r=
ounds) : InvalidArgument(algorithm + ": " + IntToString(rounds) + " is not =
a valid number of rounds") {}
=
^
7 warnings generated.
``` | Compiler conversion warnings | https://api.github.com/repos/weidai11/cryptopp/issues/340/comments | 1 | 2016-12-02T19:18:10Z | 2016-12-02T19:50:23Z | https://github.com/weidai11/cryptopp/issues/340 | 193,195,398 | 340 |
[
"weidai11",
"cryptopp"
] | Add Poly1305 class | Add Poly1305 class | https://api.github.com/repos/weidai11/cryptopp/issues/338/comments | 1 | 2016-11-27T20:31:43Z | 2016-11-27T22:09:45Z | https://github.com/weidai11/cryptopp/issues/338 | 191,883,621 | 338 |
[
"weidai11",
"cryptopp"
] | The 5.6.4 release added a new argument of type CryptoPP::ByteOrder to several constructors of type CryptoPP::Integer. This broke the ABI of the class because adding an argument to a function, even with a defualt value, changes the function signature. See https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B for a list of what you can and what you cannot do to keep the ABI. | 5.6.4 broke ABI of Integer::Integer() | https://api.github.com/repos/weidai11/cryptopp/issues/337/comments | 7 | 2016-11-23T16:44:42Z | 2018-01-22T21:57:43Z | https://github.com/weidai11/cryptopp/issues/337 | 191,324,937 | 337 |
[
"weidai11",
"cryptopp"
] | Add AND, OR and XOR bitops to Integer class.
This will help support some ciphers, like Poly1305. Users may also find it useful, so an external interface should be made available.
The primitive operations are already available in `<words.h>`: `AndWords`, `OrWords` and `XorWords`. | Add AND, OR and XOR bitops to Integer class | https://api.github.com/repos/weidai11/cryptopp/issues/336/comments | 2 | 2016-11-23T13:00:12Z | 2016-11-26T15:42:20Z | https://github.com/weidai11/cryptopp/issues/336 | 191,264,458 | 336 |
[
"weidai11",
"cryptopp"
] | Hello,
I've got pretty low performance on transfers with AES-256-CBC on Marvell Armada 375 (Dual-core Cortex A9) using Tahoe-LAFS, which in turn uses pycryptopp, which in turn uses cryptopp.
There is a hardware crypto module available, and there is a kernel driver for it. The device is exposed as /dev/crypto (known as crypto-dev).
I've tested openSSL and its performance is greater while using crypto-dev. Is it possible to add crypto-dev support to cryptopp?
Thank you. | crypto-dev support | https://api.github.com/repos/weidai11/cryptopp/issues/335/comments | 4 | 2016-11-12T18:52:57Z | 2023-06-26T10:06:26Z | https://github.com/weidai11/cryptopp/issues/335 | 188,927,897 | 335 |
[
"weidai11",
"cryptopp"
] | When trying to activate spotify support in Clementine player, the application crash with the following error: `clementine: symbol lookup error: clementine: undefined symbol: _ZN8CryptoPP6SHA5129InitStateEPy`
Tried downgrading to 5.6.4 and everything works just fine, so there is something with the 5.6.5 release in particular.
Some extra info in the original issue clementine-player/Clementine#5521
Hope this helps ;) | Undefined symbol in 5.6.5 | https://api.github.com/repos/weidai11/cryptopp/issues/333/comments | 2 | 2016-11-06T09:40:18Z | 2016-11-06T20:01:57Z | https://github.com/weidai11/cryptopp/issues/333 | 187,549,053 | 333 |
[
"weidai11",
"cryptopp"
] | Testing a Fedora [RPM build](https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Packagers_Guide/chap-Packagers_Guide-Creating_and_Building_Packages.html) reveals the following.
```
libtool: link: g++ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOU
RCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
cc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -
DCRYPTOPP_DATA_DIR=\"\" -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIF
Y_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grec
ord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=gene
ric -Wl,-z -Wl,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o cryptestcw
d cryptestcwd-test.o cryptestcwd-bench1.o cryptestcwd-bench2.o cryptestcwd-valid
at1.o cryptestcwd-validat2.o cryptestcwd-validat3.o cryptestcwd-datatest.o crypt
estcwd-fipstest.o cryptestcwd-regtest.o cryptestcwd-fipsalgt.o cryptestcwd-dllte
st.o
cryptestcwd-test.o: In function `CryptoPP::BufferedTransformation::BufferedTrans
formation()':
/home/jwalton/rpmbuild/BUILD/cryptopp-5.6.5/cryptlib.h:1370: undefined reference
to `CryptoPP::Algorithm::Algorithm(bool)'
cryptestcwd-test.o: In function `CryptoPP::StringSinkTemplate<std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char> > >::StringSinkTempl
ate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char
> >&)':
/home/jwalton/rpmbuild/BUILD/cryptopp-5.6.5/filters.h:977: undefined reference t
o `vtable for CryptoPP::StringSinkTemplate<std::__cxx11::basic_string<char, std:
:char_traits<char>, std::allocator<char> > >'
/bin/ld: cryptestcwd-test.o: relocation R_X86_64_PC32 against undefined symbol `
_ZTVN8CryptoPP18StringSinkTemplateINSt7__cxx1112basic_stringIcSt11char_traitsIcE
SaIcEEEEE' can not be used when making a shared object; recompile with -fPIC
/bin/ld: final link failed: Bad value
```
It looks like a documentation could have introduced some of this break: [Commit b5f04e5ed5738b76](https://github.com/weidai11/cryptopp/commit/b5f04e5ed5738b764e1a56e50326b5d667439bb1#diff-d2db349ae9147080146ad7fd030eb851). | Shared object and "undefined reference to Algorithm::Algorithm(bool)" | https://api.github.com/repos/weidai11/cryptopp/issues/332/comments | 1 | 2016-11-01T05:41:42Z | 2016-11-05T01:23:40Z | https://github.com/weidai11/cryptopp/issues/332 | 186,463,551 | 332 |
[
"weidai11",
"cryptopp"
] | Zhaomo Yang, Kirill Levchenko, Sorin Lerner and Brian Johannesmeyer reports the following.
```
On Mon, Oct 31, 2016 at 8:40 PM, Zhaomo Yang <zhy001@cs.ucsd.edu> wrote:
> Hi folks,
>
> I am a Ph.D. student in Computer Science and Engineering from the University
> of California, San Diego. My colleagues and I are studying cases where
> optimizing compilers remove code that scrubs sensitive data. Specifically,
> developers clear sensitive objects after the last use. However, because the
> value set by the clearing operation is not used, the compiler (optimizer)
> may consider it dead code and thus remove it. This is a known issue and
> people have developed various ways to deal with it. See, for example the
> CERT C Secure Coding Standard recommendation MSC06-C
> (https://www.securecoding.cert.org/confluence/display/c/MSC06-C.+Beware+of+compiler+optimizations).
>
> We have modified the Clang compiler that reports cases where a store
> operation may be removed by the optimizer, allowing us to identify cases
> where sensitive data scrubbing operations are optimized out. We compiled
> Crypto++ 5.6.4 (the release version on Sept 11, 2016) using our instrumented
> Clang compiler using your project's default flags. We found that there may
> be some removed sensitive data clearing operations in your program. The
> report is attached. Here is how to read our report.
>
> ======= possible scrubbing removal =======
> Location: cryptopp564/cast.cpp:293:2
> Removed IR Instruction: call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64
> 32, i32 16, i1 false), !dbg !1382
> Comment: potentially security critical because the user key on the stack is
> not scrubbed
>
> Location: where the removed memory clearing operation is in the source code.
> In this example, it is in line 293, column 2 of cryptopp564/cast.cpp.
> Removed IR instruction: the removed LLVM IR instruction.
> Additional Info: provides additional information in case of inlining. In
> this example there is none. However, typically the enclosing function of the
> removed operation is inlined at the location given in brackets.
> Comment: our comment on the removal case.
>
> Here is the code snippet around line 293 in cryptopp564/cast.cpp:
>
> 287: std::swap(K[i1],K[i2]);
> 288: std::swap(K[i1+4],K[i2+4]);
> 289: }
> 290: }
> 291: }
> 292:
> 293: memset(kappa, 0, sizeof(kappa)); // *** THIS STATEMENT IS REMOVED BY
> THE COMPILER
> 294: }
>
> The removed IR instruction comes from line 293, where the memset tries to
> scrub the user key on the stack.
>
> - How to fix the program
> One way to fix the issue is to use Crypto++'s SecureWipeArray (defined in
> cryptopp564/misc.h) to clear memory. In case that you want to look at other
> implementations, we're attaching an implementation of a secure scrubbing
> function, secure_memzero(), that ensures that memory is cleared even if it
> is not accessed again. We are releasing this code into the public domain.
> You may use it in your code without altering the terms of your license.
>
> Thanks,
> Zhaomo Yang and Brian Johannesmeyer
```
| CAST and zeroizer removal by the optimizer | https://api.github.com/repos/weidai11/cryptopp/issues/331/comments | 1 | 2016-11-01T02:20:20Z | 2016-11-01T09:53:40Z | https://github.com/weidai11/cryptopp/issues/331 | 186,447,793 | 331 |
[
"weidai11",
"cryptopp"
] | László Böszörményi reports the following. Crypto++ 5.6.3 was compiled eight times on Hurd without any problem. Crypto++ 5.6.4 (maybe something else meanwhile) broke Hurd support. During the compilation of cpu.cpp, the following error arises:
```
/tmp/ccOaIF5V.s: Assembler messages:
/tmp/ccOaIF5V.s:820: Error: character following name is not '#'
```
| Debian Hurd, cpu.cpp and "Error: character following name is not '#'" | https://api.github.com/repos/weidai11/cryptopp/issues/330/comments | 3 | 2016-10-28T18:21:06Z | 2016-10-29T09:51:58Z | https://github.com/weidai11/cryptopp/issues/330 | 185,988,428 | 330 |
[
"weidai11",
"cryptopp"
] | Andrew Marlow reports the following on Solaris 11. I believe its Sparc, but I'm not certain.
> But on solaris 11 where I have g++ version 4.8.2 I get a compilation error:
>
> ```
> In file included from apmtest.cpp:6:0:
> config.h:582:34: error: operator '>=' has no left operand
> #if ((__ILP32__ >= 1) || (_ILP32 >= 1)) && defined(__x86_64__)
> ```
| Solaris 11 and "error: operator '>=' has no left operand" | https://api.github.com/repos/weidai11/cryptopp/issues/329/comments | 1 | 2016-10-27T18:15:00Z | 2016-10-27T18:23:53Z | https://github.com/weidai11/cryptopp/issues/329 | 185,742,262 | 329 |
[
"weidai11",
"cryptopp"
] | On the diffie hellman page, in section 9.1, the following code has a problem:
```
// Initialize the Diffie-Hellman class with a random prime and base
AutoSeededRandomPool rngA;
DH dhA(rngA, 128);
```
Since there are no other examples of initializing the DH class with a RNG, using the DH code from this library presents a higher than necessary barrier.
```
gcc v5.4.0
compile command: g++ -c dh.cpp -std=gnu++11 -I/usr/local/include/cryptopp
```
---
Further bug info:
The next morning, I had another run at it, and by combining code from two examples, I got the 9.1 example to work. The key is that initializing a **DH** class with a random number generator, and key size, doesn't work, however, if you use the longer form from one of the previous examples:
`dh.AccessGroupParameters().GenerateRandomWithKeySize(rng, 128);`
you can get it to work. Not as nice looking, but it only adds an extra line of code.
| Diffie-Hellman example code not compiling | https://api.github.com/repos/weidai11/cryptopp/issues/328/comments | 6 | 2016-10-23T03:40:37Z | 2016-12-04T20:22:18Z | https://github.com/weidai11/cryptopp/issues/328 | 184,669,422 | 328 |
[
"weidai11",
"cryptopp"
] | Hi,
This applies to both the cmake and proprietary build systems.
When enabling tests the tests are both built and installed.
When enabling tests but disabling static library build fails.
When enabling tests and shared, which derived enabling static, installation install all while in many cases only the shared library is required.
The proprietary build system takes one step farther by auto detecting the file during installation, so if once built and not cleaned files are installed regardless of the options.
I suggest to have the following logic explicitly to what we want to be installed:
1. INSTALL_SHARED triggers BUILD_SHARED
2. INSTALL_STATIC triggers BUILD_STATIC
3. INSTALL_TESTS triggers BUILD_TESTS
4. BUILD_TESTS triggers BUILD_STATIC
This will allow installing only shared library but be able to execute make check, or install only shared and static and able to execute make check.
What do you think? I can probably arrange a patch if this is acceptable.
| Support split of build optional components and install optional components | https://api.github.com/repos/weidai11/cryptopp/issues/327/comments | 12 | 2016-10-21T21:04:20Z | 2017-09-16T22:40:40Z | https://github.com/weidai11/cryptopp/issues/327 | 184,569,270 | 327 |
[
"weidai11",
"cryptopp"
] | Hi,
Any reason why 5.6.4 contained cmake buildsystem and the 5.6.5 excluded it?
Isn't cmake should be used over the proprietary build?
Thanks!
Alon
[1] https://www.cryptopp.com/cryptopp565.zip
| CMake build system is missing from 5.6.5 zip (cryptopp565.zip) | https://api.github.com/repos/weidai11/cryptopp/issues/325/comments | 4 | 2016-10-21T14:59:00Z | 2017-09-16T22:40:53Z | https://github.com/weidai11/cryptopp/issues/325 | 184,506,919 | 325 |
[
"weidai11",
"cryptopp"
] | I have problems using Crypto++ to save a RSA public key string. When decoding the key, I always get a BERDecodeErr exception.
Here is the code I am using:
```
string RsaEncryptor::encryptor(string plaintext, string publicKey) {
std::string cipher;
AutoSeededRandomPool prng;
try {
ByteQueue queue;
Base64Decoder decoder(new Redirector(queue));
decoder.Put((const byte *) publicKey.data(), publicKey.size());
decoder.MessageEnd();
RSA::PublicKey rsaPublick;
rsaPublick.BERDecodePublicKey(queue, false, (size_t) queue.MaxRetrievable());
// BERDecodePrivateKey is a void function. Here's the only check
// we have regarding the DER bytes consumed.
CRYPTOPP_ASSERT(queue.IsEmpty());
bool valid = rsaPublick.Validate(prng, 3);
if (!valid)
cipher = "RSA private key is not valid";
RSAES_OAEP_SHA_Encryptor e(rsaPublick);
StringSource ss(plaintext, true,
new PK_EncryptorFilter(prng, e,
new StringSink(cipher)
) // PK_EncryptorFilter
); // StringSource
}
catch (CryptoPP::Exception &e) {
cipher = e.what();
}
return cipher;
}
```
| Can't BER decode RSA public key with NDK Android | https://api.github.com/repos/weidai11/cryptopp/issues/324/comments | 2 | 2016-10-19T02:13:18Z | 2016-11-03T10:05:05Z | https://github.com/weidai11/cryptopp/issues/324 | 183,848,969 | 324 |
[
"weidai11",
"cryptopp"
] | `oids.h` uses OIDs from an older IETF draft which has expired. We should now be using [Algorithm Identifiers for Ed25519, Ed25519ph, Ed448, Ed448ph, X25519 and X448 for use in the Internet X.509 Public Key Infrastructure](http://tools.ietf.org/id/draft-ietf-curdle-pkix) instead.
| curve25519 using old OID | https://api.github.com/repos/weidai11/cryptopp/issues/323/comments | 2 | 2016-10-18T20:26:30Z | 2018-01-18T03:29:23Z | https://github.com/weidai11/cryptopp/issues/323 | 183,793,759 | 323 |
[
"weidai11",
"cryptopp"
] | [cryptest.sh](http://github.com/weidai11/cryptopp/blob/master/cryptest.sh) reveals the following on Cygwin.
```
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c socketft.cpp
socketft.cpp: In function ‘int CryptoPP::inet_pton(int, const char*, void*)’:
socketft.cpp:89:70: error: ‘WSAStringToAddress’ was not declared in this scope
if (WSAStringToAddress(temp, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
^
make: *** [GNUmakefile:784: socketft.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: failed to make cryptest.exe
```
This was a recent change to avoid Microsoft deprecated warnings under MSC compilers. Also see [Commit 4630a5dab66a0e18: Remove reliance on _WINSOCK_DEPRECATED_NO_WARNINGS (Issue 19)](http://github.com/weidai11/cryptopp/commit/4630a5dab66a0e18ec8dfc0998ac223e40b3dc13).
| Cygwin and "WSAStringToAddress was not declared in this scope" | https://api.github.com/repos/weidai11/cryptopp/issues/322/comments | 1 | 2016-10-14T07:31:48Z | 2016-10-14T07:50:39Z | https://github.com/weidai11/cryptopp/issues/322 | 182,981,932 | 322 |
[
"weidai11",
"cryptopp"
] | This was originally reported at [VS2015 and MinGW testing of constexpr dev-branch](http://groups.google.com/d/msg/cryptopp-users/qeZVbY9cHJc/ZoMO1X05FAAJ). <strike>Someone else reported this issue in a comment on the mailing list, but I can't find it at the moment.</strike>
Here's the exception message:
```
Unhandled exception at 0x0018E435 in cryptest.exe: 0xC0000005:
Access violation writing location 0x0092C000.
```
The code responsible is Line 132, `mov DWORD PTR [buffer], eax`.
```
Full_Machine_Word:
mov DWORD PTR [buffer], eax
add buffer, MWSIZE ;; No need for Intel Core 2 slow workarounds, like
sub bsize, MWSIZE ;; `lea buffer,[buffer+MWSIZE]` for faster adds
```
| MASM, x86 and RDRAND and Access Violation under VS2013 | https://api.github.com/repos/weidai11/cryptopp/issues/321/comments | 1 | 2016-10-12T04:57:24Z | 2016-10-14T19:41:41Z | https://github.com/weidai11/cryptopp/issues/321 | 182,435,263 | 321 |
[
"weidai11",
"cryptopp"
] | Built against tag `CRYPTOPP_5_6_4`, only confirmed on FreeBSD (haven't tested elsewhere).
Log (cryptopp at the bottom):
https://build.getmonero.org/builders/kovri-all-freebsd64/builds/10/steps/compile/logs/stdio
I wanted to get this issue submitted before I left. I'll be back (Tuesday) to test any patches.
https://github.com/weidai11/cryptopp/blob/CRYPTOPP_5_6_4/cpu.h#L112 ?
| Clang 3.6.2: gcm.cpp:143:25: error: use of undeclared identifier '_mm_clmulepi64_si128' | https://api.github.com/repos/weidai11/cryptopp/issues/320/comments | 3 | 2016-10-11T05:52:22Z | 2016-10-11T17:22:15Z | https://github.com/weidai11/cryptopp/issues/320 | 182,179,632 | 320 |
[
"weidai11",
"cryptopp"
] | Hello! I'm get last version from git. When compile (Qt 5.5.1 (mingw492_32)) there is next error
file: validat1.cpp CryptoPP::memcpy_s has not been declared.
When i change to (coment // using CryptoPP::memcpy_s;) ALL COMPILED OK!! ALL TESTES PASSED!!
my changes in file: validat1.cpp is
```
//#if defined(__MINGW32__)
// using CryptoPP::memcpy_s;
//#endif
```
See issue http://github.com/weidai11/cryptopp/issues/28
| CryptoPP::memcpy_s has not been declared | https://api.github.com/repos/weidai11/cryptopp/issues/319/comments | 8 | 2016-10-10T11:09:07Z | 2016-10-18T06:17:11Z | https://github.com/weidai11/cryptopp/issues/319 | 181,988,526 | 319 |
[
"weidai11",
"cryptopp"
] | Andreas Mohr left a comment at [Issue 178](http://github.com/weidai11/cryptopp/issues/178#issuecomment-233405697). Its a large comment so please visit it.
If I am digesting it properly, it discussed potential issues with supporting multiple versions of Windows, and dependencies on macros `WINVER` and `_WIN32_WINNT`. It also went into some detail on higher level engineering concepts, and some of the problems we face because we don't enforce any particular policy. That is, we attempt to be agnostic to Windows Vista vs Windows 7 vs Windows 8 vs Windows 10 vs Windows Phone, etc.
I think we can side step the `WINVER` and `_WIN32_WINNT` macros using the following code. However, it comes at a cost: we have to (1) locate symbols dynamically, and (2) use implicit library linking to avoid `LoadLibrary`. A third (3) cost is we to move towards an initializer, which may be a can of worms in C++. For details on why we want to avoid `LoadLibrary` see [Implicit library linking and GetModuleHandle/GetProcAdress](http://stackoverflow.com/q/39941690) on Stack Overflow.
I also believe it addressed DB's affirmation for https://github.com/weidai11/cryptopp/issues/178#issuecomment-233505619:
> ... I especially agree with this:
>
> > individual source code areas are to never, ever custom-bend values of any defines which indicate the target baseline platform value to be implementing for
>
> And with this:
>
> > (one could say that instead one should be doing code such as
> >
> > ```
> > #ifdef WIN32
> > #ifndef WINVER
> > #pragma message("You failed to consistently indicate a minimum platform
> > baseline version config to this place here, aborting!! " __FILE_)
> > ERROR_missing_platform_config;
> > #endif
> > #endif
> > ```
The floor is now open for discussion.
---
```
$ git diff > socketft.cpp.diff
$ cat socketft.cpp.diff
diff --git a/socketft.cpp b/socketft.cpp
index 97f370b..658315c 100644
--- a/socketft.cpp
+++ b/socketft.cpp
@@ -10,14 +10,41 @@
#include "socketft.h"
#include "wait.h"
-// Windows 8, Windows Server 2012, and Windows Phone 8.1 need <synchapi.h> and <ioapiset.h>
+// These gyrations attempt to find CancelIo{Ex} and GetOverlappedResult{Ex}
+// without introducing:
+// * Dependencies on Windows version numbers
+// * Dependencies on LoadLibrary
#if defined(CRYPTOPP_WIN32_AVAILABLE)
-# if ((WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) || (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/))
-# include <synchapi.h>
-# include <ioapiset.h>
-# define USE_WINDOWS8_API
-# endif
-#endif
+namespace
+{
+ extern "C" {
+ typedef BOOL (WINAPI * PFN_CANCELIO)(HANDLE);
+ typedef BOOL (WINAPI * PFN_CANCELIOEX)(HANDLE, LPOVERLAPPED);
+ typedef BOOL (WINAPI * PFN_GETOVERLAPPEDRESULT)(HANDLE, LPOVERLAPPED, LPDWORD, BOOL);
+ typedef BOOL (WINAPI * PFN_GETOVERLAPPEDRESULTEX)(HANDLE, LPOVERLAPPED, LPDWORD, DWORD, BOOL);
+ }
+ PFN_CANCELIO InitializeCancelIo() {
+ const HINSTANCE hInst = GetModuleHandle("kernel32");
+ return (PFN_CANCELIO)(hInst ? (PVOID)GetProcAddress(hInst, "CancelIo") : NULL);
+ }
+ PFN_CANCELIOEX InitializeCancelIoEx() {
+ const HINSTANCE hInst = GetModuleHandle("kernel32");
+ return (PFN_CANCELIOEX)(hInst ? (PVOID)GetProcAddress(hInst, "CancelIoEx") : NULL);
+ }
+ PFN_GETOVERLAPPEDRESULT InitializeGetOverlappedResult() {
+ const HINSTANCE hInst = GetModuleHandle("kernel32");
+ return (PFN_GETOVERLAPPEDRESULT)(hInst ? (PVOID)GetProcAddress(hInst, "GetOverlappedResult") : NULL);
+ }
+ PFN_GETOVERLAPPEDRESULTEX InitializeGetOverlappedResultEx() {
+ const HINSTANCE hInst = GetModuleHandle("kernel32");
+ return (PFN_GETOVERLAPPEDRESULTEX)(hInst ? (PVOID)GetProcAddress(hInst, "GetOverlappedResultEx") : NULL);
+ }
+ const PFN_CANCELIO pfnCancelIo = InitializeCancelIo();
+ const PFN_CANCELIOEX pfnCancelIoEx = InitializeCancelIoEx();
+ const PFN_GETOVERLAPPEDRESULT pfnGetOverlappedResult = InitializeGetOverlappedResult();
+ const PFN_GETOVERLAPPEDRESULTEX pfnGetOverlappedResultEx = InitializeGetOverlappedResultEx();
+}
+#endif // CRYPTOPP_WIN32_AVAILABLE
#ifdef USE_BERKELEY_STYLE_SOCKETS
#include <errno.h>
@@ -105,17 +132,25 @@ void Socket::CloseSocket()
if (m_s != INVALID_SOCKET)
{
#ifdef USE_WINDOWS_STYLE_SOCKETS
-# if defined(USE_WINDOWS8_API)
- BOOL result = CancelIoEx((HANDLE) m_s, NULL);
- CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
- CheckAndHandleError_int("closesocket", closesocket(m_s));
- CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds
-# else
- BOOL result = CancelIo((HANDLE) m_s);
- CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
- CheckAndHandleError_int("closesocket", closesocket(m_s));
- CRYPTOPP_UNUSED(result);
-# endif
+ if(pfnCancelIo)
+ {
+ BOOL result = pfnCancelIo((HANDLE) m_s);
+ CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
+ CheckAndHandleError_int("closesocket", closesocket(m_s));
+ CRYPTOPP_UNUSED(result);
+ }
+ else if(pfnCancelIoEx)
+ {
+ BOOL result = pfnCancelIoEx((HANDLE) m_s, NULL);
+ CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
+ CheckAndHandleError_int("closesocket", closesocket(m_s));
+ CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds
+ }
+ else
+ {
+ CRYPTOPP_ASSERT(0);
+ throw Socket::Err(m_s, "CloseSocket (CancelIo{Ex} not found)", E_FAIL);
+ }
#else
CheckAndHandleError_int("close", close(m_s));
#endif
@@ -367,15 +402,23 @@ SocketReceiver::SocketReceiver(Socket &s)
SocketReceiver::~SocketReceiver()
{
#ifdef USE_WINDOWS_STYLE_SOCKETS
-# if defined(USE_WINDOWS8_API)
- BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULL);
- CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
- CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds
-# else
- BOOL result = CancelIo((HANDLE) m_s.GetSocket());
- CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
- CRYPTOPP_UNUSED(result);
-# endif
+ if(pfnCancelIo)
+ {
+ BOOL result = pfnCancelIo((HANDLE) m_s.GetSocket());
+ CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
+ CRYPTOPP_UNUSED(result);
+ }
+ else if(pfnCancelIoEx)
+ {
+ BOOL result = pfnCancelIoEx((HANDLE) m_s.GetSocket(), NULL);
+ CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
+ CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds
+ }
+ else
+ {
+ CRYPTOPP_ASSERT(0);
+ throw Socket::Err(m_s, "CloseSocket (CancelIo{Ex} not found)", E_FAIL);
+ }
#endif
}
@@ -459,15 +502,23 @@ SocketSender::SocketSender(Socket &s)
SocketSender::~SocketSender()
{
#ifdef USE_WINDOWS_STYLE_SOCKETS
-# if defined(USE_WINDOWS8_API)
- BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULL);
- CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
- CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds
-# else
- BOOL result = CancelIo((HANDLE) m_s.GetSocket());
- CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
- CRYPTOPP_UNUSED(result);
-# endif
+ if(pfnCancelIo)
+ {
+ BOOL result = pfnCancelIo((HANDLE) m_s.GetSocket());
+ CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
+ CRYPTOPP_UNUSED(result);
+ }
+ else if(pfnCancelIoEx)
+ {
+ BOOL result = pfnCancelIoEx((HANDLE) m_s.GetSocket(), NULL);
+ CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND));
+ CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds
+ }
+ else
+ {
+ CRYPTOPP_ASSERT(0);
+ throw Socket::Err(m_s, "CloseSocket (CancelIo{Ex} not found)", E_FAIL);
+ }
#endif
}
```
---
Notify folks who usually take interest: @denisbider, @DevJPM, @zabulus, @MarcelRaad, @andim2.
| Remove dependencies on WINVER and _WIN32_WINNT | https://api.github.com/repos/weidai11/cryptopp/issues/318/comments | 7 | 2016-10-09T19:38:46Z | 2018-05-02T01:46:06Z | https://github.com/weidai11/cryptopp/issues/318 | 181,906,222 | 318 |
[
"weidai11",
"cryptopp"
] | From https://github.com/weidai11/cryptopp/issues/178#issuecomment-227894209
> By the way, Crypto++ violates separation of concerns because it lacks a good separation between development, testing and release. We need more volunteers with more spare cycles.
I don't see anything in the readme nor in any open issue for a "community request" for testers or spare cycles. I also don't see any details noted in a contributing guide for any curious visitors wishing to contribute.
Is there a way to formalize a community request? Is there already such a request in place? As an open source project, is such a request inherently implied (if so, should this issue be closed)?
| Call for testers and spare cycles? | https://api.github.com/repos/weidai11/cryptopp/issues/317/comments | 9 | 2016-10-08T21:08:43Z | 2016-10-11T21:52:50Z | https://github.com/weidai11/cryptopp/issues/317 | 181,848,894 | 317 |
[
"weidai11",
"cryptopp"
] | We have code in a few places which guards like so:
```
<CustomBuild Include="x64dll.asm">
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
...
</CustomBuild>
```
The guard works well when X86 and X64 are the only platforms. However, it will fail if the configuration includes an ARM platform.
| Visual Studio projects include X86/X64 ASM for ARM-based MSBuilds | https://api.github.com/repos/weidai11/cryptopp/issues/316/comments | 1 | 2016-10-06T19:58:18Z | 2016-10-11T06:44:46Z | https://github.com/weidai11/cryptopp/issues/316 | 181,510,778 | 316 |
[
"weidai11",
"cryptopp"
] | [`cryptest.sh`](http://github.com/weidai11/cryptopp/blob/master/cryptest.sh) uncovered a compile failure under Cygwin-i686 after we added `<ossign.h>` to help with [Issue 277 and CVE-2016-7420](http://github.com/weidai11/cryptopp/issues/277). `g++` alone is OK; the failure occurs with `-std=c++XX` and `-std=gnu++XX`.
The following is from [Issue 20665 - Cannot compile program with <signal.h> and C++ when using -std=XXX](http://sourceware.org/bugzilla/show_bug.cgi?id=20665) reported to Cygwin.
```
$ cat ~/test.cxx
#include <signal.h>
int main(int argc, char* argv[])
{
struct sigaction new_handler;
int ret = sigemptyset(&new_handler.sa_mask);
return 0;
}
Without a -atd=XXX, it results in:
$ g++ -c test.cxx
$
With a -atd=XXX, it results in:
$ g++ -std=c++03 -c test.cxx
test.cxx: In function ?int main(int, char**)?:
test.cxx:6:44: error: ?sigemptyset? was not declared in this scope
int ret = sigemptyset(&new_handler.sa_mask);
^
$ g++ -std=c++11 -c test.cxx
test.cxx: In function ?int main(int, char**)?:
test.cxx:6:44: error: ?sigemptyset? was not declared in this scope
int ret = sigemptyset(&new_handler.sa_mask);
^
$ g++ -std=c++14 -c test.cxx
test.cxx: In function ?int main(int, char**)?:
test.cxx:6:44: error: ?sigemptyset? was not declared in this scope
int ret = sigemptyset(&new_handler.sa_mask);
^
$ g++ -std=c++17 -c test.cxx
test.cxx: In function ?int main(int, char**)?:
test.cxx:6:44: error: ?sigemptyset? was not declared in this scope
int ret = sigemptyset(&new_handler.sa_mask);
```
| Cygwin cannot compile library with <ossig.h> with option -std=XXX | https://api.github.com/repos/weidai11/cryptopp/issues/315/comments | 1 | 2016-10-04T01:16:49Z | 2016-10-06T00:31:30Z | https://github.com/weidai11/cryptopp/issues/315 | 180,785,389 | 315 |
[
"weidai11",
"cryptopp"
] | While investigating the memory leaks after a debug run, we learned the leaks disappear when building using the [`cryptest.nmake`](http://github.com/weidai11/cryptopp/blob/master/cryptest.nmake) using nearly the same compiler and linker flags.
This report provides authority for cleanup so we can zero-in on the memory leak culprit under Visual Studio. The list below represents some of the cleanup.
- Remove `_ProjectFileVersion` and `10.0.40219.1`. This appears to be an artifact after opening in Visual Studio 2010
- Remove Microsoft platform defines, like `_WINDOWS`, `_CONSOLE` and `_DEBUG`. These are set by the IDE and Compiler. For example, `_DEBUG` is set when using `/LDd`, `/MTd` and `/MDd`
- Fold XML Configuration rules (see below)
- _"Crypto++ DLL"_ prefix for `OutputDebugString` calls
- Opt-out of ASLR for FIPS DLL due to VS2012 policy change
- New UUIDs for solution and projects
---
Folding configuration rules is as easy as identifying duplicate conditions that result in the same setting. Below, all `dll.cpp` configurations forgo precompiled headers, so a single `<PrecompiledHeader />` will suffice.
```
<ClCompile Include="dll.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DLL-Import Debug|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DLL-Import Debug|x64'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DLL-Import Release|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DLL-Import Release|x64'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- </PrecompiledHeader>
+ <PrecompiledHeader />
</ClCompile>
```
| Visual Studio 2010 project file cleanup | https://api.github.com/repos/weidai11/cryptopp/issues/314/comments | 1 | 2016-10-02T18:18:30Z | 2016-10-06T00:11:03Z | https://github.com/weidai11/cryptopp/issues/314 | 180,526,032 | 314 |
[
"weidai11",
"cryptopp"
] | Hi every one.
When i want to import Crypto++ folder(or zip file), i found the Omnet++ wizard :

Please help me to choose the right choice.
| Crypto++ on omnet++ | https://api.github.com/repos/weidai11/cryptopp/issues/313/comments | 2 | 2016-10-01T18:29:00Z | 2016-10-02T11:08:13Z | https://github.com/weidai11/cryptopp/issues/313 | 180,471,917 | 313 |
[
"weidai11",
"cryptopp"
] | Coverity Scan reports the following:
```
91 WindowsPipeReceiver::WindowsPipeReceiver()
92 : m_resultPending(false), m_eofReceived(false)
CID 148138 (1 of 1): Uninitialized scalar field (UNINIT_CTOR)
2. uninit_member: Non-static class member m_lastResult is not initialized
in this constructor nor in any functions that it calls.
```
| Coverity finding CID 148134, 148138: Uninitialized scalar field (UNINIT_CTOR) | https://api.github.com/repos/weidai11/cryptopp/issues/312/comments | 1 | 2016-09-30T02:14:12Z | 2016-09-30T04:57:28Z | https://github.com/weidai11/cryptopp/issues/312 | 180,205,070 | 312 |
[
"weidai11",
"cryptopp"
] | ```
159 DWORD dwResult = ::WaitForMultipleObjectsEx((DWORD)m_threads.size(), threadHandles, TRUE, INFINITE, FALSE);
CID 171230 (1 of 1): Macro compares unsigned to 0 (NO_EFFECT)
unsigned_compare: This greater-than-or-equal-to-zero comparison of an unsigned value is always true. dwResult >= 0UL.
160 CRYPTOPP_ASSERT((dwResult >= WAIT_OBJECT_0) && (dwResult < (DWORD)m_threads.size()));
```
| Coverity finding CID 171230: Macro compares unsigned to 0 (NO_EFFECT) | https://api.github.com/repos/weidai11/cryptopp/issues/311/comments | 1 | 2016-09-29T19:11:43Z | 2016-09-30T19:42:58Z | https://github.com/weidai11/cryptopp/issues/311 | 180,136,470 | 311 |
[
"weidai11",
"cryptopp"
] | Coverity Scan under Windows reports the following. There are approximately 80 similar findings. It appears the pattern is causing problems under Windows. Unix, Linux and OS X did not produce a finding.
```
2. Condition this->IsNegative(), taking true branch.
3. Condition this->WordCount() == 0, taking true branch.
3921 if (IsNegative() && WordCount()==0) // avoid -0
4. alloc_fn: Storage is returned from allocation function Zero. [show details]
5. noescape: Resource CryptoPP::Integer::Zero() is not freed or pointed-to in operator =.
CID 171218 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_storage: Failing to save or free storage allocated by CryptoPP::Integer::Zero() leaks it.
3922 *this = Zero();
3923 return *this;
```
Drilling into `(5) noescape`:
```
1. noescape: CryptoPP::Integer::operator =(CryptoPP::Integer const &) does not free or save its parameter t.
3049 Integer& Integer::operator=(const Integer& t)
3050 {
3051 if (this != &t)
3052 {
3053 if (reg.size() != t.reg.size() || t.reg[t.reg.size()/2] == 0)
3054 reg.New(RoundupSize(t.WordCount()));
3055 CopyWords(reg, t.reg, reg.size());
3056 sign = t.sign;
3057 }
3058 return *this;
3059 }
```
| Coverity findings CID 171217-171280: Resource leak (RESOURCE_LEAK) | https://api.github.com/repos/weidai11/cryptopp/issues/310/comments | 5 | 2016-09-29T18:30:18Z | 2016-10-03T08:02:10Z | https://github.com/weidai11/cryptopp/issues/310 | 180,126,536 | 310 |
[
"weidai11",
"cryptopp"
] | We are attempting to add self tests to ensure we don't inadvertently break DLIES and ECIES. Under Crypto++ 5.6.2, we generated a known answer with the key provided in `TestData`. We then tried to verify the known answer under Crypto++ 5.6.2 and Crypto++ 5.6.5.
```
// Crypto++ 5.6.2
DLIES<NoCofactorMultiplication,true>::Decryptor dec;
FileSource fs("TestData/dlie1024.dat", true, new HexDecoder);
dec.AccessKey().Load(fs);
```
We then encrypted the string **_`abc`**_ under it:
```
HexEncoder hex(new FileSink (cout), true, 2, "\\x");
DLIES<NoCofactorMultiplication,true>::Encryptor enc(dec);
StringSource ss (plain, true, new PK_EncryptorFilter(prng, enc, new Redirector(hex)));
```
The output is a C++-string compatible ciphertext: **_`"\x06\x50\x83\xF2 ... \x89\x9F\x89\xB2"`**_
Finally, Crypto++ 5.6.5 `validat2.cpp` attempts to decrypt it and verify the original message:
```
// Crypto++ 5.6.5
static const char plain[] = "abc";
static const size_t size = 620;
static const byte cipher[size+1] =
"\x06\x50\x83\xF2\x70\xCC\x22\x34\x99\x24\xE2\xCC\xB3\x64\x4F\x91\x24\x7E\x8C\xB2"
"\xE3\x79\x65\x79\x5B\x64\x62\x12\x56\xF8\x2E\x68\x8D\x50\x5A\xC0\x7D\x87\x5D\x00"
"\x09\x92\x47\x5C\x31\xBC\x21\xB9\x42\x30\x47\xD6\xF3\xD7\x36\x19\xB7\x02\xE5\x96"
"\xBE\xF6\x99\x8C\xE1\xAB\xC1\x1D\xE2\x95\x1A\x1D\x72\x62\xEA\x7F\x2E\xF6\xD9\x01"
"\x63\x81\x05\xA0\xFB\x15\x66\x6F\x2B\xF6\x93\xE7\x24\x1F\x92\x54\x29\x38\x53\xCC"
"\x25\x39\x01\x80\xF1\xCA\x4A\xF6\x7F\xFA\xCD\xD9\x6A\x62\xC8\x06\xFD\x5D\x38\x74"
"\x16\x0A\x96\xA3\x32\x91\x60\x80\x79\x01\x8E\x20\xCF\xEB\xA1\x4E\x92\xE5\x6B\xBB"
"\x58\xA0\xA3\x04\x3E\x0D\xC4\x89\x9F\x89\xB2";
FileSource keys(CRYPTOPP_DATA_DIR "TestData/dlies1024.dat", true, new HexDecoder);
DLIES<SHA1,NoCofactorMultiplication,true,true>::Decryptor decryptor(keys);
DLIES<SHA1,NoCofactorMultiplication,true,true>::Encryptor encryptor(decryptor);
SecByteBlock recovered(decryptor.MaxPlaintextLength(size));
fail = decryptor.Decrypt(GlobalRNG(), cipher, size, recovered) != DecodingResult(3);
fail = fail || memcmp(plain, recovered, 3);
cout << (fail ? "FAILED " : "passed ") << "1024-bit, NoCofactorMultiplication,DHAES_MODE=true,LABEL_OCTET=true\n";
```
While not readily apparent, Crypto++ 5.6.2 file `dlie1024.dat` is Crypto++ 5.6.5 file `dlies1024.dat`. It was changed at [Commit 7f401a2333d0a1e5](http://github.com/weidai11/cryptopp/commit/7f401a2333d0a1e5d109f9cf746b03eefba60a2d).
| DLIES cannot decrypt message in new context | https://api.github.com/repos/weidai11/cryptopp/issues/307/comments | 1 | 2016-09-25T19:05:25Z | 2018-01-12T22:27:16Z | https://github.com/weidai11/cryptopp/issues/307 | 179,102,575 | 307 |
[
"weidai11",
"cryptopp"
] | As you can see a 20 is added to the hex encoded result.. 20 in hexidecimal is a whitespace.
```
// encode hex to string
string hexEncode(string v)
{
string out;
CryptoPP::StringSource s(v,true,new CryptoPP::HexEncoder(new CryptoPP::StringSink(out)));
return(out);
}
void pbkdf2()
{
std::string pin ="d4ee37e2fe975179f1513e79c40baca9";
CryptoPP::SecByteBlock key(16);
// Send it through 1024 iterations of PBKDF2
PKCS5_PBKDF2_HMAC<SHA256> pbkdf;
pbkdf.DeriveKey(key, key.size(),0x00,(unsigned char*)pin.c_str(), pin.size(),NULL, 0,1024);
cout<<"Expected: e35373499d347cfd8aa27221ffbfb4ac - Got: "<<hexEncode(string((char*)key.data()))<<endl;
}
```
Expected: e35373499d347cfd8aa27221ffbfb4ac - Got: e35373499d347cfd8aa27221ffbfb4ac20
| PKCS5_PBKDF2_HMAC::DeriveKey adds a whitespace | https://api.github.com/repos/weidai11/cryptopp/issues/305/comments | 6 | 2016-09-23T22:51:15Z | 2016-09-24T01:42:09Z | https://github.com/weidai11/cryptopp/issues/305 | 178,989,596 | 305 |
[
"weidai11",
"cryptopp"
] | `cryptest.sh` reports the following using g++ 4.9.2-10 on Debian 8.6/i686. It occurs with and without `-std=c++03`. Its also duplicates under g++5.3 on Fedora 23/i686. Finally, it duplicates with `vmac.cpp` from Crypto++ 5.6.2.
```
make CXXFLAGS="-DDEBUG -g3 -O0 -std=c++03 -march=native -pipe -fsanitize=address -fno-omit-frame-pointer -D_GLIBCXX_DEBUG"
...
./cryptest.exe v
...
Testing MAC algorithm VMAC(AES)-64.
.ASAN:SIGSEGV
=================================================================
==27062==ERROR: AddressSanitizer: SEGV on unknown address 0xfffffef0 (pc 0x08355529 sp 0xbf9830f0 bp 0xbf9832c8 T0)
#0 0x8355528 in CryptoPP::VMAC_Base::VHASH_Update_SSE2(unsigned long long const*, unsigned int, int) /home/jwalton/cryptopp/vmac.cpp:477
#1 0x8357094 in CryptoPP::VMAC_Base::VHASH_Update(unsigned long long const*, unsigned int) /home/jwalton/cryptopp/vmac.cpp:811
#2 0x8356289 in CryptoPP::VMAC_Base::TruncatedFinal(unsigned char*, unsigned int) /home/jwalton/cryptopp/vmac.cpp:887
#3 0x824a95c in CryptoPP::HashTransformation::TruncatedVerify(unsigned char const*, unsigned int) /home/jwalton/cryptopp/cryptlib.cpp:412
#4 0x856705b in CryptoPP::HashVerificationFilter::LastPut(unsigned char const*, unsigned int) /home/jwalton/cryptopp/filters.cpp:840
#5 0x8560503 in CryptoPP::FilterWithBufferedInput::PutMaybeModifiable(unsigned char*, unsigned int, int, bool, bool) /home/jwalton/cryptopp/filters.cpp:437
#6 0x806278f in CryptoPP::FilterWithBufferedInput::Put2(unsigned char const*, unsigned int, int, bool) /home/jwalton/cryptopp/filters.h:339
#7 0x805c21e in CryptoPP::BufferedTransformation::MessageEnd(int, bool) /home/jwalton/cryptopp/cryptlib.h:1444
#8 0x81da800 in TestDigestOrMAC(std::__debug::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&, bool) /home/jwalton/cryptopp/datatest.cpp:604
#9 0x81dc982 in TestDataFile(std::string, CryptoPP::NameValuePairs const&, unsigned int&, unsigned int&) /home/jwalton/cryptopp/datatest.cpp:804
#10 0x81dd117 in RunTestDataFile(char const*, CryptoPP::NameValuePairs const&, bool) /home/jwalton/cryptopp/datatest.cpp:843
#11 0x813d0d9 in ValidateVMAC() /home/jwalton/cryptopp/validat1.cpp:3039
#12 0x8125119 in ValidateAll(bool) /home/jwalton/cryptopp/validat1.cpp:141
#13 0x80588c0 in Validate(int, bool, char const*) /home/jwalton/cryptopp/test.cpp:894
#14 0x804ffdd in main /home/jwalton/cryptopp/test.cpp:360
#15 0xb6f4aa62 in __libc_start_main (/lib/i386-linux-gnu/i686/cmov/libc.so.6+0x19a62)
#16 0x804d7e0 (/home/jwalton/cryptopp/cryptest.exe+0x804d7e0)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/jwalton/cryptopp/vmac.cpp:477 CryptoPP::VMAC_Base::VHASH_Update_SSE2(unsigned long long const*, unsigned int, int)
==27062==ABORTING
```
---
In contrast, Valgrind reports no problems:
```
$ valgrind ./cryptest.exe tv vmac
==9343== Memcheck, a memory error detector
==9343== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==9343== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==9343== Command: ./cryptest.exe tv vmac
==9343==
Using seed: 1474675008
Testing MAC algorithm VMAC(AES)-64.
...........
Testing MAC algorithm VMAC(AES)-128.
...........
Tests complete. Total tests = 22. Failed tests = 0.
==9343==
==9343== HEAP SUMMARY:
==9343== in use at exit: 18,944 bytes in 1 blocks
==9343== total heap usage: 2,997 allocs, 2,996 frees, 6,197,441 bytes allocated
==9343==
==9343== LEAK SUMMARY:
==9343== definitely lost: 0 bytes in 0 blocks
==9343== indirectly lost: 0 bytes in 0 blocks
==9343== possibly lost: 0 bytes in 0 blocks
==9343== still reachable: 18,944 bytes in 1 blocks
==9343== suppressed: 0 bytes in 0 blocks
==9343== Rerun with --leak-check=full to see details of leaked memory
==9343==
==9343== For counts of detected and suppressed errors, rerun with: -v
==9343== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```
| Asan and "AddressSanitizer: SEGV on unknown address 0xfffffef0" in VMAC | https://api.github.com/repos/weidai11/cryptopp/issues/304/comments | 3 | 2016-09-23T20:36:11Z | 2019-07-05T21:39:27Z | https://github.com/weidai11/cryptopp/issues/304 | 178,968,047 | 304 |
[
"weidai11",
"cryptopp"
] | I'm getting ready to dump some additional test scripts into the library. I'm concerned the scripts are moving beyond _"reasonable and tidy"_ and into the _"unreasonable and messy"_ area. A dozen or so different scripts kind of pollutes the root directory.
| Add TestScripts directory; move test fodder into it | https://api.github.com/repos/weidai11/cryptopp/issues/303/comments | 1 | 2016-09-23T15:15:09Z | 2016-10-08T05:35:27Z | https://github.com/weidai11/cryptopp/issues/303 | 178,903,282 | 303 |
[
"weidai11",
"cryptopp"
] | John Byrd privately reported a crash in AES under Microsoft compilers due to use of `_malloca`, `AliasedWithTables` and `_freea`. `_malloca` and `_freea` are Microsoft SDLC functions (`alloca` is on Microsoft's [SDLC banned function list](http://msdn.microsoft.com/en-us/library/bb288454.aspx)). Microsoft sometimes uses the heap rather than the stack for `_malloca`, and that's the reason `_freea` is needed.
The bug is specific to Windows and Microsoft compilers because its guarded by `_MSC_VER`. The bug does not affect Unix and Linux; and does not affect non-Microsoft compilers, like ICC and Borland. The bug was introduced at [Commit 823bc93357da32a3](http://github.com/weidai11/cryptopp/commit/823bc93357da32a3a4a2b71b9915a4e124839d18) and only affects Crypto++ 5.6.4.
The code in question asks `_malloca` for a block of memory. The code also over-commits the size and adjust the pointer to a 256-byte boundary. The pointer is sent `AliasedWithTables` to flush cache lines. If `AliasedWithTables` cannot perform the flush, then it returns false. Upon the false return, the code reallocates, adjusts the pointer and calls `AliasedWithTables` again. Eventually the call succeeds. After the code in question completes, it frees the adjusted pointer and not the original pointer using `_freea`.
We believe we failed to detect the issue during testing because the pointer did not require adjustment. We got [un]lucky, but Byrd's testing revealed it.
Fortune favored us, and we picked up Byrd's suggestion of avoiding unaligned data access last week at at [Commit f57c4dced5bfbcd1](http://github.com/weidai11/cryptopp/commit/f57c4dced5bfbcd10d0883ae7161833a70eff268). The issue is side stepped "out of the box" in Master. However, an unsuspecting user could wander back into the configuration.
We immediately disclosed the memory bug so decision makers could assess the risk, provide feedback, and select a remediation commensurate with the security posture and comfort level:
- [Issue 302: AES and incorrect argument to _freea() under Microsoft compilers](http://groups.google.com/forum/#!topic/cryptopp-users/jiFMHBlaUsE) on the mailing list
- []() on oss-security
| AES and incorrect use or _malloca() and _freea() under Microsoft compilers | https://api.github.com/repos/weidai11/cryptopp/issues/302/comments | 10 | 2016-09-23T01:16:51Z | 2017-09-17T00:40:07Z | https://github.com/weidai11/cryptopp/issues/302 | 178,760,379 | 302 |
[
"weidai11",
"cryptopp"
] | Clang 3.9 on OS X is complaining about the following.
We tried to fix with a [simple extern declaration guarded to avoid duplicate definitions in the DLL](http://github.com/weidai11/cryptopp/pull/270), but we had to [back it out because it broke GCC and Windows](http://github.com/weidai11/cryptopp/pull/294).
I'm beginning to wonder if this is a Clang diagnostic bug or real a problem. I can't get another compiler to produce it. And when we appease Clang with a definition, it results in multiple definitions during link. Finally, Clang 3.9 only complains about `PKCS_DigestDecoration<H>::decoration` (an array), and not `PKCS_DigestDecoration<H>::length` (a scalar).
```
/opt/local/bin/clang++-mp-3.9 -DNDEBUG -g2 -O3 -fPIC -march=native -pipe -c dlltest.cpp
In file included from regtest.cpp:13:
In file included from ./rsa.h:14:
./pkcspad.h:79:53: warning: instantiation of variable
'CryptoPP::PKCS_DigestDecoration<CryptoPP::Weak1::MD2>::decoration'
required here, but no definition is available [-Wundefined-var-template]
...return HashIdentifier(PKCS_DigestDecoration<H>::decoration, (size_t)PKCS...
^
./pubkey.h:614:19: note: in instantiation of member function
'CryptoPP::PKCS1v15_SignatureMessageEncodingMethod::HashIdentifierLookup::HashIdentifierLookup2<CryptoPP::Weak1::MD2>::Lookup'
requested here
return L::Lookup();
^
./pubkey.h:644:26: note: in instantiation of member function
'CryptoPP::TF_ObjectImplBase<CryptoPP::TF_SignerBase,
CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::Weak1::MD2, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::Weak1::MD2>,
CryptoPP::InvertibleRSAFunction>::GetHashIdentifier' requested here
class CRYPTOPP_NO_VTABLE TF_ObjectImpl : public TF_ObjectImplBase<BASE, ...
^
./factory.h:26:14: note: in instantiation of member function
'CryptoPP::PK_FinalTemplate<CryptoPP::TF_SignerImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::Weak1::MD2, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::Weak1::MD2> >
>::PK_FinalTemplate' requested here
return new ConcreteClass;
^
./factory.h:102:26: note: in instantiation of member function
'CryptoPP::DefaultObjectFactory<CryptoPP::PK_Signer,
CryptoPP::PK_FinalTemplate<CryptoPP::TF_SignerImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::Weak1::MD2, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::Weak1::MD2> >
> >::CreateObject' requested here
RegisterFactory(n, new DefaultObjectFactory<AbstractClas...
^
./factory.h:117:2: note: in instantiation of member function
'CryptoPP::RegisterDefaultFactoryFor<CryptoPP::PK_Signer,
CryptoPP::PK_FinalTemplate<CryptoPP::TF_SignerImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::Weak1::MD2, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::Weak1::MD2> >
>, 0>::RegisterDefaultFactoryFor' requested here
RegisterDefaultFactoryFor<PK_Signer, CPP_TYPENAME SchemeClass::S...
^
regtest.cpp:134:2: note: in instantiation of function template specialization
'CryptoPP::RegisterSignatureSchemeDefaultFactories<CryptoPP::RSASS<CryptoPP::PKCS1v15,
CryptoPP::Weak1::MD2> >' requested here
RegisterSignatureSchemeDefaultFactories<RSASS<PKCS1v15, Weak::MD...
^
./pkcspad.h:32:20: note: forward declaration of template entity is here
static const byte decoration[];
^
./pkcspad.h:79:53: warning: instantiation of variable
'CryptoPP::PKCS_DigestDecoration<CryptoPP::SHA1>::decoration' required
here, but no definition is available [-Wundefined-var-template]
...return HashIdentifier(PKCS_DigestDecoration<H>::decoration, (size_t)PKCS...
^
./pubkey.h:614:19: note: in instantiation of member function
'CryptoPP::PKCS1v15_SignatureMessageEncodingMethod::HashIdentifierLookup::HashIdentifierLookup2<CryptoPP::SHA1>::Lookup'
requested here
return L::Lookup();
^
./pubkey.h:644:26: note: in instantiation of member function
'CryptoPP::TF_ObjectImplBase<CryptoPP::TF_SignerBase,
CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::SHA1, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::SHA1>,
CryptoPP::InvertibleRSAFunction>::GetHashIdentifier' requested here
class CRYPTOPP_NO_VTABLE TF_ObjectImpl : public TF_ObjectImplBase<BASE, ...
^
./factory.h:26:14: note: in instantiation of member function
'CryptoPP::PK_FinalTemplate<CryptoPP::TF_SignerImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::SHA1, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::SHA1> >
>::PK_FinalTemplate' requested here
return new ConcreteClass;
^
./factory.h:102:26: note: in instantiation of member function
'CryptoPP::DefaultObjectFactory<CryptoPP::PK_Signer,
CryptoPP::PK_FinalTemplate<CryptoPP::TF_SignerImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::SHA1, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::SHA1> > >
>::CreateObject' requested here
RegisterFactory(n, new DefaultObjectFactory<AbstractClas...
^
./factory.h:117:2: note: in instantiation of member function
'CryptoPP::RegisterDefaultFactoryFor<CryptoPP::PK_Signer,
CryptoPP::PK_FinalTemplate<CryptoPP::TF_SignerImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,
CryptoPP::SHA1, CryptoPP::RSA, int>, CryptoPP::RSA,
CryptoPP::PKCS1v15_SignatureMessageEncodingMethod, CryptoPP::SHA1> > >,
0>::RegisterDefaultFactoryFor' requested here
RegisterDefaultFactoryFor<PK_Signer, CPP_TYPENAME SchemeClass::S...
^
regtest.cpp:135:2: note: in instantiation of function template specialization
'CryptoPP::RegisterSignatureSchemeDefaultFactories<CryptoPP::RSASS<CryptoPP::PKCS1v15,
CryptoPP::SHA1> >' requested here
RegisterSignatureSchemeDefaultFactories<RSASS<PKCS1v15, SHA1> >(...
^
./pkcspad.h:32:20: note: forward declaration of template entity is here
static const byte decoration[];
^
```
| Clang 3.9 and missing member definitions for template classes | https://api.github.com/repos/weidai11/cryptopp/issues/300/comments | 3 | 2016-09-22T16:38:15Z | 2016-09-23T04:01:01Z | https://github.com/weidai11/cryptopp/issues/300 | 178,660,799 | 300 |
[
"weidai11",
"cryptopp"
] | CID 12086 (3-4 of 4): Use of untrusted scalar value (TAINTED_SCALAR) (Ubuntu 12 i686)
```
363 else if (command == "b2")
27. tainted_data_transitive: Call to function basic_string with tainted argument argv[3] transitively taints <temporary>.
28. tainted_data: Passing tainted variable std::string const(argv[3], std::allocator<char>()) to a tainted sink. [show details]
364 BenchmarkAll2(argc<3 ? 1 : StringToValue<float, true>(argv[2]), argc<4 ? 0 : StringToValue<float, true>(argv[3])*1e9);
```
| Coverity finding CID 12086: Use of untrusted scalar value (TAINTED_SCALAR) | https://api.github.com/repos/weidai11/cryptopp/issues/299/comments | 2 | 2016-09-22T04:10:08Z | 2016-09-23T14:39:06Z | https://github.com/weidai11/cryptopp/issues/299 | 178,517,776 | 299 |
[
"weidai11",
"cryptopp"
] | CID 170382 (1 of 1): Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
```
114static IDEA::Word MulInv(IDEA::Word x)
115{
116 IDEA::Word y=x;
117 for (unsigned i=0; i<15; i++)
118 {
CID 170382 (1 of 1): Operands don't affect result
result_independent_of_operands: (y & 65535) <= 65535 is always true regardless of the values of its operands. This occurs as a value.
119 DirectMUL(y,low16(y));
120 DirectMUL(y,x);
121 }
122 return low16(y);
123}
```
We added an assert to ensure `y<=65535`. We are going to remove it.
| Coverity finding CID 170382: Operands don't affect result (CONSTANT_EXPRESSION_RESULT) | https://api.github.com/repos/weidai11/cryptopp/issues/298/comments | 1 | 2016-09-22T01:13:58Z | 2016-09-22T01:18:27Z | https://github.com/weidai11/cryptopp/issues/298 | 178,498,816 | 298 |
[
"weidai11",
"cryptopp"
] | For the purpose of supporting Rijndael features not included in AES, specifically 192- and 256-bit block sizes.
In case it matters, AESNI instruction set allows hardware-optimized RIjndael implementation, not only AES.
| Separate AES from Rijndael; Support Rijndael 192-bit and 256-bit block sizes | https://api.github.com/repos/weidai11/cryptopp/issues/297/comments | 10 | 2016-09-21T14:21:53Z | 2019-07-11T21:47:13Z | https://github.com/weidai11/cryptopp/issues/297 | 178,361,613 | 297 |
[
"weidai11",
"cryptopp"
] | CID 170383 (4 of 4): Overflowed return value (INTEGER_OVERFLOW)
```
836template <class T1, class T2>
837inline T2 ModPowerOf2(const T1 &a, const T2 &b)
838{
839 CRYPTOPP_ASSERT(IsPowerOf2(b));
1. overflow: Subtract operation overflows on operands b and 1U.
CID 170383 (4 of 4): Overflowed return value (INTEGER_OVERFLOW)
2. overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or
truncated value) (unsigned int)a & b - 1U used as return value.
840 return T2(a) & (b-1);
841}
```
The issue is `b - 1` and its ability to underflow if `b=0`. I think we should be able to do a saturating subtract. Need to test it....
| Coverity finding CID 170383 Overflowed return value (INTEGER_OVERFLOW) | https://api.github.com/repos/weidai11/cryptopp/issues/295/comments | 1 | 2016-09-21T07:02:10Z | 2016-09-22T02:11:23Z | https://github.com/weidai11/cryptopp/issues/295 | 178,263,336 | 295 |
[
"weidai11",
"cryptopp"
] | Coverity finding CID 170385 (1 of 1): Uninitialized scalar field (UNINIT_CTOR) in `integer.cpp`:
```
342 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
1. member_decl: Class member declaration for m_whole.
343 dword m_whole;
344 #else
```
1. uninit_member: Non-static class member m_whole is not initialized in this constructor nor in any functions that it calls.***
```
235 DWord(word low, word high)
236 {
237 m_halfs.low = low;
238 m_halfs.high = high;
239 }
```
In the call ctor above, `m_whole` and `m_halfs` are different members of the same union. While Coverity is complaining we did not initialize `m_whole` because `NATIVE_DWORD` is in effect, there's a bigger problem lurking: [undefined behavior when accessing the inactive union members](http://stackoverflow.com/q/11373203) (`m_halves.low` and `m_halves.high`).
The fix for `UNINIT_CTOR` finding below makes the undefined behavior more apparent.
| Coverity finding CID 170385, Uninitialized scalar field (UNINIT_CTOR) | https://api.github.com/repos/weidai11/cryptopp/issues/293/comments | 2 | 2016-09-21T00:32:19Z | 2016-09-21T13:21:12Z | https://github.com/weidai11/cryptopp/issues/293 | 178,215,520 | 293 |
[
"weidai11",
"cryptopp"
] | Current master fails to compile. Keccak got broken by commit ccd59710 (was it tested before merging?):
```
. . . . .
clang++ -maes -mpclmul -mrdrnd -msse2 -mssse3 -msse4.2 -mtune=native -Os -Ofast -std=c++11 -fPIC -march=native -pipe -c keccak.cpp
In file included from keccak.cpp:18:
./keccak.h:81:40: error: constexpr function's return type 'std::string' (aka 'basic_string<char,
char_traits<char>, allocator<char> >') is not a literal type
CRYPTOPP_CONSTEXPR static std::string StaticAlgorithmName() { return "Keccak-" + IntToStri...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:4271:48: note:
'basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >' is not literal because
it is not an aggregate and has no constexpr constructors other than copy or move constructors
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<char>)
^
In file included from keccak.cpp:18:
./keccak.h:82:34: error: virtual function cannot be constexpr
CRYPTOPP_CONSTEXPR unsigned int BlockSize() const { return BLOCKSIZE; }
^
./cryptlib.h:984:23: note: overridden virtual function is here
virtual unsigned int BlockSize() const {return 0;}
^
2 errors generated.
make: *** [keccak.o] Error 1
```
```
$ git blame keccak.h
. . . . .
cd59710 (DevJPM 2016-09-20 11:27:25 +0200 80) Keccak_Final() : Keccak(DIGESTSIZE) {}
ccd59710 (DevJPM 2016-09-20 11:27:25 +0200 81) CRYPTOPP_CONSTEXPR static std::string StaticAlgorithmName() { return "Keccak-" + IntToString(DIGESTSIZE * 8); }
. . . . .
```
Mac OS X 10.11.6, Xcode-8.0.
| Commit ccd59710 broke Keccak | https://api.github.com/repos/weidai11/cryptopp/issues/292/comments | 2 | 2016-09-20T22:30:56Z | 2016-09-21T00:41:32Z | https://github.com/weidai11/cryptopp/issues/292 | 178,197,393 | 292 |
[
"weidai11",
"cryptopp"
] | In addition to #272, I think the project would benefit from having regular commit signing. I'd be happy to argue the benefits but I think that they're self-evident (especially within this community). Maybe also include a small contributing guide so others can start signing too (or is that asking for too much)?
| Crypto++ and Commit Signing | https://api.github.com/repos/weidai11/cryptopp/issues/290/comments | 20 | 2016-09-20T08:31:44Z | 2016-09-28T02:47:18Z | https://github.com/weidai11/cryptopp/issues/290 | 177,997,974 | 290 |
[
"weidai11",
"cryptopp"
] | ```
cpu.cpp:228:84: error: constructor priorities are not supported
void __attribute__ ((constructor (CRYPTOPP_INIT_PRIORITY + 50))) DetectX86Features()
^
gmake: *** [cpu.o] Error 1
gmake: *** Waiting for unfinished jobs....
```
| Solaris GCC and "error: constructor priorities are not supported" | https://api.github.com/repos/weidai11/cryptopp/issues/289/comments | 1 | 2016-09-20T00:05:21Z | 2016-09-20T01:44:39Z | https://github.com/weidai11/cryptopp/issues/289 | 177,929,900 | 289 |
[
"weidai11",
"cryptopp"
] | While working on Skein I used the idea that the final, main instances only differentiate in digest-size.
So I wrote a template class, with the digest-size as a template and generalized everything digest-size dependent (e.g. the constants, the algorithmName(),...).
Should we also consider this for Keccak / SHA3?
The benefit would be that adding a new compile-time digest Keccak instance would come down to `typedef Keccak<16> Keccak_128;` instead of the 10-20 lines construct we have now, which would greatly increase maintainability and would probably save us about 100 lines or so of code.
Note: I consider this to be a really low priority issue.
| Making the derived SHA3 and Keccak classes templates with typedefs instead of their own classes? | https://api.github.com/repos/weidai11/cryptopp/issues/288/comments | 1 | 2016-09-19T22:22:21Z | 2016-09-20T14:32:30Z | https://github.com/weidai11/cryptopp/issues/288 | 177,913,901 | 288 |
[
"weidai11",
"cryptopp"
] | Also see [Pull Request 286: Trivial VC10 project fixes](https://github.com/weidai11/cryptopp/pull/286): The digested version is:
Take this:
```
- <ClCompile Include="zlib.cpp">
- <Optimization Condition="'$(Configuration)|$(Platform)'=='DLL-Import Debug|Win32'">Disabled</Optimization>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DLL-Import Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <Optimization Condition="'$(Configuration)|$(Platform)'=='DLL-Import Debug|x64'">Disabled</Optimization>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DLL-Import Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <Optimization Condition="'$(Configuration)|$(Platform)'=='DLL-Import Release|Win32'">MaxSpeed</Optimization>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DLL-Import Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <Optimization Condition="'$(Configuration)|$(Platform)'=='DLL-Import Release|x64'">MaxSpeed</Optimization>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DLL-Import Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
```
And turn it into this:
```
+ <ClCompile Include="zlib.cpp" />
```
| Cleanup VS2010 Project Files by inheriting Optimizations and PreprocessorDefinitions | https://api.github.com/repos/weidai11/cryptopp/issues/287/comments | 1 | 2016-09-19T21:49:03Z | 2016-09-19T21:53:26Z | https://github.com/weidai11/cryptopp/issues/287 | 177,907,376 | 287 |
[
"weidai11",
"cryptopp"
] | We are experiencing the following on Sun Studio 12.2 (SunCC 5.11) through Sun Studio 12.4 (SunCC 5.13). The machine the initial cut-in was tested used Sun Studio 12.5 and it worked fine.
The error below is due to `DebugTraphandler`.
```
/opt/solstudio12.2/bin/CC -DDEBUG -g -xO0 -D__SSE2__ -D__SSE3__ -D__SSSE3__
-xarch=ssse3 -m64 -KPIC -template=no%extdef -c test.cpp
"wait.h", line 162: Warning: Identifier expected instead of "}".
"ossig.h", line 75: Error: Different types for "?:" (extern "C" void(*)(int) and void(*)(int)).
1 Error(s) and 1 Warning(s) detected.
gmake: *** [test.o] Error 2
gmake: *** Waiting for unfinished jobs....
ERROR: failed to make cryptest.exe
```
Ironically, we followed Oracle's recommendation to [declare the function pointer `extern "C"`](http://www.oracle.com/technetwork/articles/servers-storage-dev/mixingcandcpluspluscode-305840.html). No good deed goes unpunished.
Here's what we get wen we avoid the `extern "C"`.
```
$ /opt/solarisstudio12.2/bin/CC -DDEBUG -g3 -xO0 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -xarch=ssse3 -m64 -native -KPIC -template=no%extdef -c test.cpp
"wait.h", line 162: Warning: Identifier expected instead of "}".
"ossig.h", line 73: Warning (Anachronism): Using void(*)(int) to initialize extern "C" void(*)(int).
"test.cpp", line 135: Where: While instantiating "CryptoPP::SignalHandler<5, 0>::SignalHandler(void(*)(int), int)".
"test.cpp", line 135: Where: Instantiated from non-template code.
2 Warning(s) detected.
```
| Sun Studio 12.2-12.4 and failed debug compile for ossig.h | https://api.github.com/repos/weidai11/cryptopp/issues/285/comments | 1 | 2016-09-18T18:45:21Z | 2016-09-18T21:36:55Z | https://github.com/weidai11/cryptopp/issues/285 | 177,668,642 | 285 |
[
"weidai11",
"cryptopp"
] | ```
$ CXX=/opt/developerstudio12.5/bin/CC CXXFLAGS="-DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -xarch=ssse3" gmake -j 4
...
$ ./cryptest.exe tv gcm
Testing AuthenticatedSymmetricCipher algorithm AES/GCM.
..incorrectly encrypted: 0388DACE60B6A392F328C2B971B2FE78B5E404DE87C2BDA835F5026D5E251EBC
AlgorithmType: AuthenticatedSymmetricCipher
Ciphertext: 0388dace60b6a392f328c2b971b2fe78
IV: 000000000000000000000000
Key: 00000000000000000000000000000000
MAC: ab6e47d42cec13bdf53a67b21257bddf
Name: AES/GCM
Plaintext: 00000000000000000000000000000000
Source: aes-modes-src-07-10-08/Testvals/gcm.1, Basic Tests for GCM (compiled by B. R. Gladman)
Test: Encrypt
...
```
| SunCC 12.2 - 12.5 and incorrect results for GCM when using SSE2 ASM | https://api.github.com/repos/weidai11/cryptopp/issues/284/comments | 1 | 2016-09-18T15:03:16Z | 2016-09-18T15:52:14Z | https://github.com/weidai11/cryptopp/issues/284 | 177,656,701 | 284 |
[
"weidai11",
"cryptopp"
] | [`cryptest.sh`](http://github.com/weidai11/cryptopp/blob/master/cryptest.sh) has a test to build the _library_ (`libcryptopp.a`) and the test _program_ (`cryptest.exe`) with different capabilities. In this setup, `libcryptopp.a` is built with SSE2 via `-march=x86-64`, while `cryptest.exe` is built with AES and above using `-march=native`.
The test attempts to simulate a distro like Debian. In this case, Debian builds the library for a _"minimally capable"_ machine so it can be distributed by their package system. Later, a user with a shinny new Core i5 or i7, uses the library.
```
************************************
Testing: Debug, mismatched arch capabilities
# Build libcryptopp
c++ -DDEBUG -g3 -O0 -march=x86-64 -fPIC -pipe -c cryptlib.cpp
c++ -DDEBUG -g3 -O0 -march=x86-64 -fPIC -pipe -c cpu.cpp
...
# Build cryptest.exe
c++ -DDEBUG -g3 -O0 -march=native -fPIC -pipe -c test.cpp
c++ -DDEBUG -g3 -O0 -march=native -fPIC -pipe -c bench1.cpp
...
# And link
c++ -o cryptest.exe -DDEBUG -g3 -O0 -march=native -fPIC -pipe test.o bench1.o bench2.o
validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o ./libcryptopp.a
Undefined symbols for architecture x86_64:
"CryptoPP::Rijndael::Dec::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const", referenced from:
vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec> in validat1.o
vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>, CryptoPP::Rijndael::Dec> in validat1.o
vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec> in regtest.o
vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>, CryptoPP::Rijndael::Dec> in regtest.o
"non-virtual thunk to CryptoPP::Rijndael::Dec::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const", referenced from:
vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec> in validat1.o
vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>, CryptoPP::Rijndael::Dec> in validat1.o
vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec> in regtest.o
vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>, CryptoPP::Rijndael::Dec> in regtest.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
GNUmakefile:644: recipe for target 'cryptest.exe' failed
make: *** [cryptest.exe] Error 1
ERROR: failed to make cryptest.exe
```
---
The reason for the failure is different defines guard `AdvancedProcessBlocks` for the encryption and decryption transformations. When `-march=x86-64`, `CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE` is _not_ available.
```
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
{
public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
#endif
};
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
{
public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
#endif
};
```
| Link failure with mismatched library and program capabilities | https://api.github.com/repos/weidai11/cryptopp/issues/283/comments | 2 | 2016-09-18T13:18:07Z | 2016-11-23T21:50:47Z | https://github.com/weidai11/cryptopp/issues/283 | 177,651,320 | 283 |
[
"weidai11",
"cryptopp"
] | Skein is the hash function from Schneier, Fergueson and Lucks from the final round of the SHA-3 competition.
This issue is here to track the progress of the implementation of Skein and its underlying mode UBI and the underlying tweakable block cipher Threefish.
With the implementation I largely orientated at the BLAKE2 implementation for Skein and at Serpent with Threefish. The new interfaces add a fixed-size tweak-value (including new instances of a bunch of helper classes) which defaults to all-zero if the overloaded function isn't used.
Note: All the additional inputs and features of Skein are supported (excluding crazy modes like PRNG and PBKDF) but tree-hashing is unsupported, because I couldn't come up with a nice interface yet and the library traditionally didn't support tree-hashing.
Status:
- **UBI**: Straight hashing passes all test vectors, MAC-mode still needs verification, as test vector implementation into cryptest and addition to the benchmark suite are to-be-done. **Note:** Skein itself is just a "simple" instance of UBI.
- **Threefish**: Passes all provided test vectors, testing is part of `cryptest.exe v` and working, implementation (for now) is taken from the Skein3Fish project using the fully unrolled version. Reduction in code size (to not have a 150kB source file) and addition of XMM (for better perfomance on 32-bit platforms) implementation to follow
| Add tweakable block ciphers, Threefish and Skein to Crypto++ | https://api.github.com/repos/weidai11/cryptopp/issues/279/comments | 6 | 2016-09-16T14:10:32Z | 2018-01-12T22:25:34Z | https://github.com/weidai11/cryptopp/issues/279 | 177,435,276 | 279 |
[
"weidai11",
"cryptopp"
] | Some products (like https://github.com/cryfs/cryfs.git) want to utilize keys longer than 256 bits. However `mars.h` sets the cap at 32 bytes, even though the original algorithm sets it at 56 bytes.
There is no reason for us to set that limitation (we aren't NIST, after all), so I request that it is removed.
| MARS max keysize is limited at 32 bytes - breaks CryFS | https://api.github.com/repos/weidai11/cryptopp/issues/278/comments | 6 | 2016-09-16T12:36:00Z | 2016-09-16T17:16:03Z | https://github.com/weidai11/cryptopp/issues/278 | 177,414,961 | 278 |
[
"weidai11",
"cryptopp"
] | From a recent discussion with the Debian Security Team:
> On Thu, Sep 15, 2016 at 3:21 PM, Jeffrey Walton noloader@gmail.com wrote:
>
> > Thanks Florian.
> >
> > > this matter does not seem to be something for the Debian security
> > > team. Debian doesn't enable coredumps by default, and crypto++
> > > upstream doesn't document that builds without -DNDEBUG are unsafe
> > > (say, due to denial-of-service issues caused by broken asserts).
> >
> > Fair enough, done. We added information to both Readme.txt and
> > Install.txt; see
> > http://github.com/weidai11/cryptopp/commit/553049ba297d89d9e8fbf2204acb40a8a53f5cd6
> >
> > Are there other places we should disseminate the information? I want
> > to ensure you are looking in places I expect you to look (i.e., we are
> > not suffering a disconnect).
For completeness, the asserts are working as expected; they are not broken. The library's build system, [GNU] Make, adds the define. The define is also added by Visual Studio without user intervention. The library is well configured in its default state.
The problem is many distros and developers fail to add `-DNDEBUG` for release/production when using alternate build systems, like Autotools, CMake and Eclipse. Effectively the library receives an alternate set of flags and options, and it is placed in a debug configuration. Sometimes the lack of `-DNDEBUG` is due to policy (Debian and Autotools), and sometimes its due to omission (regular developers under CMake, Eclipse, etc).
Mitre assigned [CVE-2016-7420](http://seclists.org/oss-sec/2016/q3/520) for the issue.
Also see [CRYPTOPP_ASSERT](https://groups.google.com/d/msg/cryptopp-users/ixwCeessWZ8/gv26MxLxNysJ) on the user mailing list. We discussed a library assert over a year ago. We already have it and have been waiting for a good time to cut-over to it.
---
There are 590 asserts in effect when the library is in a debug configuration. [Debug builds are tested](http://github.com/weidai11/cryptopp/blob/master/cryptest.sh) with out test suite, and none of them trigger when asserts are in effect. The caveat is its not attacker controlled data.
Here's a list of files which could assert in the library when using a debug configuration.
```
$ grep assert *.h *.cpp | cut -f 1 -d ':' | sort | uniq | tr '\n' ' '
adler32.cpp algebra.cpp algparam.cpp algparam.h asn.cpp asn.h authenc.cpp authenc.h
basecode.cpp bench1.cpp blake2.cpp blake2.h camellia.cpp cast.cpp ccm.cpp chacha.cpp
cmac.cpp cryptlib.cpp cryptlib.h datatest.cpp dlltest.cpp eax.cpp ec2n.cpp eccrypto.cpp
ecp.cpp emsa2.cpp eprecomp.cpp esign.cpp fhmqv.h files.cpp filters.cpp filters.h fips140.cpp
fipsalgt.cpp fltrimpl.h gcm.cpp gf2_32.cpp gf2n.cpp gf2n.h gfpcrypt.cpp gfpcrypt.h hkdf.h
hmac.cpp hmqv.h hrtimer.cpp ida.cpp idea.cpp integer.cpp iterhash.cpp keccak.cpp luc.h
mersenne.h misc.cpp misc.h modes.cpp modes.h nbtheory.cpp network.cpp oaep.cpp
panama.cpp pkcspad.cpp polynomi.cpp pssr.cpp pubkey.h pwdbased.h queue.cpp queue.h
rdrand.cpp rdrand.h rijndael.cpp rsa.cpp rw.cpp salsa.cpp seal.cpp secblock.h sha.cpp
sha3.cpp shark.cpp simple.h smartptr.h socketft.cpp socketft.h sosemanuk.cpp stdcpp.h
strciphr.cpp strciphr.h tea.cpp test.cpp trap.h trdlocal.cpp validat1.cpp validat2.cpp vmac.cpp
wait.cpp winpipes.cpp winpipes.h words.h xtr.cpp xtr.h zdeflate.cpp zinflate.cpp zlib.cpp
```
| Cut-over to CRYPTOPP_ASSERT due to CVE-2016-7420 | https://api.github.com/repos/weidai11/cryptopp/issues/277/comments | 2 | 2016-09-15T21:07:01Z | 2017-09-17T00:40:20Z | https://github.com/weidai11/cryptopp/issues/277 | 177,290,162 | 277 |
[
"weidai11",
"cryptopp"
] | Sigh...
```
cryptopp-build$ rm -rf * && CXX=/opt/solstudio12.2/bin/CC cmake ../cryptopp
cryptopp-build$ make
Scanning dependencies of target cryptopp-object
[ 1%] Building CXX object CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
[ 2%] Building CXX object CMakeFiles/cryptopp-object.dir/cpu.cpp.o
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
...
```
And then
```
(dbx) where
=>[1] CryptoPP::Baseline_Multiply2(0x23e64d0, 0x240b6f0, 0x240b7b0, 0x240b7b0, 0xa, 0x23dcbc8), at 0x182fac7
[2] CryptoPP::RecursiveMultiply(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x1846067
[3] CryptoPP::AsymmetricMultiply(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x18473a0
[4] CryptoPP::PositiveMultiply(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x1855167
[5] CryptoPP::Multiply(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x18551da
[6] CryptoPP::Integer::Times(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x18552c3
[7] CryptoPP::StringToInteger<char>(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x1862e12
[8] CryptoPP::Integer::Integer(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x184c9f5
[9] ValidateBBS(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x11b6dcb
[10] ValidateAll(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0x108bf07
[11] Validate(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xcdb7fe
[12] main(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xca2e7a
(dbx)
```
| CMake produces artifacts without debugging information | https://api.github.com/repos/weidai11/cryptopp/issues/276/comments | 5 | 2016-09-15T16:03:43Z | 2017-09-16T22:41:06Z | https://github.com/weidai11/cryptopp/issues/276 | 177,218,257 | 276 |
[
"weidai11",
"cryptopp"
] | CMake does not configure the library to the project's specifications.
The Cmake related files will no longer be distributed in the ZIP. The CMake related files will be available in Master.
The decision could change in the future if someone steps up to maintain it. CMake has too many open issues, and neither UB and JW have the time or expertise to maintain it.
---
Here's more of the back story... CMake does not build the library to our specs. We know the specs, but we don't know how to instruct CMake. Sometimes its easy to learn the CMake procedure, other times its not. For example, it was relatively pain free to instruct CMake to [stop hiding its output so we could see the build results](http://github.com/weidai11/cryptopp/commit/9280850b2609153b60c072378acbbf4ccc75b359). The same cannot be said about instructing CMake to [use `CXXFLAGS` when linking](http://stackoverflow.com/q/39497813/608639).
| Remove CMake from Release ZIP | https://api.github.com/repos/weidai11/cryptopp/issues/275/comments | 1 | 2016-09-15T15:45:32Z | 2016-09-15T15:46:21Z | https://github.com/weidai11/cryptopp/issues/275 | 177,213,595 | 275 |
[
"weidai11",
"cryptopp"
] | Testing under Solaris 11.3 is revealing:
```
[ 3%] Building CXX object CMakeFiles/cryptopp-object.dir/integer.cpp.o
/opt/solarisstudio12.3/bin/CC -fPIC -native -m64 -template=no%extdef -o CMakeFiles/cryptopp-object.dir/integer.cpp.o
-c /export/home/jwalton/cryptopp/integer.cpp
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
"/export/home/jwalton/cryptopp/integer.cpp", line 335: Warning: Types cannot be declared in anonymous union.
1 Warning(s) detected.
```
According to the Microsoft docs at [Anonymous Unions](http://msdn.microsoft.com/en-us/library/35ect93t%28v=vs.80%29.aspx):
> Simply omitting the class-name portion of the syntax does not make a union an anonymous union. For a union to qualify as an anonymous union, the declaration must not declare an object.
I _think_ we are getting into trouble because we are declaring class objects (i.e., objects of type `m_halfs`). That's what the SunCC compiler is complaining about.
Also see [SunCC 5.12 through 5.14 and “Types cannot be declared in anonymous union”](http://stackoverflow.com/q/39505525). Its our question for this issue. A related question is [Why does C++ disallow anonymous structs and unions?](http://stackoverflow.com/a/12785369/608639) on Stack Overflow, but its not our question.
---
I'm guessing the cod below is very old with a MSVC pedigree. It probably dates back to the late 1990s.
```
union
{
#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
dword m_whole;
#endif
struct
{
#ifdef IS_LITTLE_ENDIAN
word low;
word high;
#else
word high;
word low;
#endif
} m_halfs;
};
```
| Solaris, integer.cpp and "Types cannot be declared in anonymous union" | https://api.github.com/repos/weidai11/cryptopp/issues/274/comments | 1 | 2016-09-15T00:43:33Z | 2016-09-15T16:25:24Z | https://github.com/weidai11/cryptopp/issues/274 | 177,059,606 | 274 |
[
"weidai11",
"cryptopp"
] | At [Commit 9280850b2609153b](http://github.com/weidai11/cryptopp/commit/9280850b2609153b60c072378acbbf4ccc75b359) we enabled `VERBOSE=1` by default. Its revealing less than ideal `CXXFLAGS` with a basic or default configuration information:
```
Scanning dependencies of target cryptopp-object
...
[ 0%] [ 1%] Building CXX object CMakeFiles/cryptopp-object.dir/cpu.cpp.o
/usr/bin/c++ -fPIC -o CMakeFiles/cryptopp-object.dir/cpu.cpp.o -c /home/jwalton/cryptopp/cpu.cpp
Building CXX object CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o
/usr/bin/c++ -fPIC -o CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o -c /home/jwalton/cryptopp/cryptlib.cpp
...
```
| Cmake lacks -march=native for compilers which support it | https://api.github.com/repos/weidai11/cryptopp/issues/273/comments | 4 | 2016-09-14T15:54:32Z | 2016-09-27T01:14:17Z | https://github.com/weidai11/cryptopp/issues/273 | 176,946,357 | 273 |
[
"weidai11",
"cryptopp"
] | A few of our responsibilities include coordinating with the distributions on security issues, coordinating with the distributions releases, and support distros in packaging the library to ensure the best deliverable. When we release, we coordinate with our package maintainers to give them a "heads up".
We received some feedback from the openSUSE folks. It reiterates some sentiments of Debian and Fedora:
> # 3. you could create and publish a PGP signature for the .zip file
>
> so that we know that it is really the version you made
> and not the one some hacker uploaded to your server (and updated
> the hashes next to it)
> https://www.cryptopp.com/cryptopp564.zip.asc
> would be a nice URL for that.
> # 3 is especially nice for openSUSE because we have mechanisms to
>
> automatically fetch and verify such sigs, reducing the work of
> verifying the authenticity to zero.
This report tracks the initiative of signing releases.
I believe this would benefit both distros and users, so it has larger scope than maintaining relationships with distros. There's also an intersection with repackagers who have been known to insert additional cruft into archives and installers.
Try not to wander too far into policy and procedure at this point in time. Policy and procedure would include things like who has access to the private key, how the private key is distributed, and how the private key is stored. Let's focus on whether its a good idea to sign releases; and if so, then should this project do it.
| Crypto++ and Release Signing | https://api.github.com/repos/weidai11/cryptopp/issues/272/comments | 9 | 2016-09-14T11:05:53Z | 2018-12-27T19:05:53Z | https://github.com/weidai11/cryptopp/issues/272 | 176,878,431 | 272 |
[
"weidai11",
"cryptopp"
] | Cmake is producing output artifacts that can't be linked.
**_ARM BananaPi dev-board**_:
```
Scanning dependencies of target cryptest
/usr/bin/ld: CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o: relocation R_ARM_THM_MOVW_ABS_NC against
`__pthread_key_create' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o:
error adding symbols: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/cryptopp-shared.dir/build.make:307: recipe for target 'libcryptopp.so.5.6' failed
```
**_MIPS ci20 dev-board**_:
```
...
[ 92%] Built target cryptopp-object
Scanning dependencies of target cryptopp-shared
Scanning dependencies of target cryptopp-static
Linking CXX static library libcryptopp.a
Linking CXX shared library libcryptopp.so
/usr/bin/ld: CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o: relocation R_MIPS_HI16 against
`a local symbol' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
```
| Cmake and output artifacts that can't be linked due to missing PIC | https://api.github.com/repos/weidai11/cryptopp/issues/271/comments | 1 | 2016-09-14T09:32:54Z | 2016-09-14T13:30:39Z | https://github.com/weidai11/cryptopp/issues/271 | 176,859,503 | 271 |
[
"weidai11",
"cryptopp"
] | Using Cmake with the SunCC compiler results in link errors:
```
$ gamke -j 4
...
/opt/developerstudio12.5/bin/CC -DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__
-D__SSE4_2__ -D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__ -D__AVX2__
-D__BMI__ -D__BMI2__ -D__ADX__ -xarch=avx2_i
CMakeFiles/cryptest.dir/bench1.cpp.o CMakeFiles/cryptest.dir/bench2.cpp.o
CMakeFiles/cryptest.dir/test.cpp.o CMakeFiles/cryptest.dir/validat1.cpp.o
CMakeFiles/cryptest.dir/validat2.cpp.o CMakeFiles/cryptest.dir/validat3.cpp.o
CMakeFiles/cryptest.dir/datatest.cpp.o CMakeFiles/cryptest.dir/regtest.cpp.o
CMakeFiles/cryptest.dir/fipsalgt.cpp.o CMakeFiles/cryptest.dir/dlltest.cpp.o
CMakeFiles/cryptest.dir/fipstest.cpp.o -o cryptest.exe libcryptopp.a
Undefined first referenced
symbol in file
bind libcryptopp.a(socketft.cpp.o)
recv libcryptopp.a(socketft.cpp.o)
send libcryptopp.a(socketft.cpp.o)
getservbyname libcryptopp.a(socketft.cpp.o)
getsockname libcryptopp.a(socketft.cpp.o)
accept libcryptopp.a(socketft.cpp.o)
listen libcryptopp.a(socketft.cpp.o)
gethostbyname libcryptopp.a(socketft.cpp.o)
socket libcryptopp.a(socketft.cpp.o)
setsockopt CMakeFiles/cryptest.dir/test.cpp.o
connect libcryptopp.a(socketft.cpp.o)
getpeername libcryptopp.a(socketft.cpp.o)
inet_addr libcryptopp.a(socketft.cpp.o)
shutdown libcryptopp.a(socketft.cpp.o)
ld: fatal: symbol referencing errors
gmake[2]: *** [cryptest.exe] Error 2
gmake[2]: Leaving directory `/export/home/jwalton/cryptopp-build'
gmake[1]: *** [CMakeFiles/cryptest.dir/all] Error 2
gmake[1]: Leaving directory `/export/home/jwalton/cryptopp-build'
gmake: *** [all] Error 2
```
Also see [Detect Sun Studio compiler and add platform libraries in CmakeList.txt?](http://stackoverflow.com/q/39474170) on Stack Overflow.
| Cmake and failed link when using SunCC | https://api.github.com/repos/weidai11/cryptopp/issues/269/comments | 1 | 2016-09-13T15:27:54Z | 2016-09-13T16:58:36Z | https://github.com/weidai11/cryptopp/issues/269 | 176,672,275 | 269 |
[
"weidai11",
"cryptopp"
] | Our [`CmakeList.txt`](http://github.com/weidai11/cryptopp/blob/master/CMakeLists.txt) uses [`include(GNUInstallDirs)`](http://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html). According to the Cmake manual on [`GNUInstallDirs`](http://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html):
> Provides install directory variables as defined for GNU software...
>
> ```
> ...
> INCLUDEDIR - C header files (include)
> OLDINCLUDEDIR - C header files for non-gcc (/usr/include)
> ```
We don't install into `/usr`; rather, we install into `/usr/local`. Installing Crypto++ on some platforms, like OpenBSD, breaks the library because the compiler treats all headers in `/usr/include` as C files, and **_not**_ C++ files. OpenBSD handles the library header files as expected when they are installed into `/usr/local/include`.
I don't know if Cmake provides it, but we need similar to a `include(LocalInstallDirs)`.
| CmakeList.txt calls out GNUInstallDirs | https://api.github.com/repos/weidai11/cryptopp/issues/268/comments | 1 | 2016-09-13T13:43:53Z | 2016-10-27T18:05:14Z | https://github.com/weidai11/cryptopp/issues/268 | 176,644,102 | 268 |
[
"weidai11",
"cryptopp"
] | ```
$ export CXX=/opt/developerstudio12.5/bin/CC
$ export CXXFLAGS="-DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__
-D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__ -D__AVX2__ -D__BMI__ -D__BMI2__
-D__ADX__ -xarch=avx2_i"
$ cmake ../cryptopp
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45 (MESSAGE):
The C++ compiler "/bin/c++" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /export/home/test/cryptopp-build/CMakeFiles/CMakeTmp
Run Build Command:/bin/gmake "cmTryCompileExec/fast"
/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make
CMakeFiles/cmTryCompileExec.dir/build
gmake[1]: Entering directory
`/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o
/bin/c++ -DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__
-D__SSE4_2__ -D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__
-D__AVX2__ -D__BMI__ -D__BMI2__ -D__ADX__ -xarch=avx2_i -o
CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -c
/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error: language arch=avx2_i not recognized
c++: error: language arch=avx2_i not recognized
gmake[1]: Leaving directory
`/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp'
gmake[1]: *** [CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o] Error
1
gmake: *** [cmTryCompileExec/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
-- Configuring incomplete, errors occurred!
```
Also see [CMake fails to generate Makefiles with Sun Studio 12.5](http://stackoverflow.com/q/39463746/608639) on Stack Overflow.
| CMake fails to generate Makefiles on Solaris 11 wuth SunCC 5.14 | https://api.github.com/repos/weidai11/cryptopp/issues/267/comments | 1 | 2016-09-13T06:48:04Z | 2016-09-13T15:31:09Z | https://github.com/weidai11/cryptopp/issues/267 | 176,562,997 | 267 |
[
"weidai11",
"cryptopp"
] | This surfaced at [Commit fff2c91b9641dd37](http://github.com/weidai11/cryptopp/commit/fff2c91b9641dd378d853145534f47a3f1a426f1). When attempting to validate TLS-ChaCha test vectors for interop purposes, we used test `Encrypt` because we lacked a `Keystream`:
```
$ ./cryptest.exe tv tls_chacha
Using seed: 1473724933
Testing SymmetricCipher algorithm ChaCha20.
incorrectly encrypted:
AlgorithmType: SymmetricCipher
Ciphertext: 76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669
Comment: Section 7, Test 1
IV: 0000000000000000
Key: 0000000000000000000000000000000000000000000000000000000000000000
Name: ChaCha20
Plaintext:
Source: http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305
Test: Encrypt
```
Test `Keystream` is **_not**_ a one-off case. The upcoming [Keccak changes](http://github.com/weidai11/cryptopp/issues/262) will need it to. I also think the SP 800-108 RNGs will need it too.
| Testing infrastructure lacks a Keystream test | https://api.github.com/repos/weidai11/cryptopp/issues/266/comments | 1 | 2016-09-13T00:08:23Z | 2017-01-02T20:23:36Z | https://github.com/weidai11/cryptopp/issues/266 | 176,516,081 | 266 |
[
"weidai11",
"cryptopp"
] | We added test vectors for TLS-ChaCha at [Commit fff2c91b9641dd37](http://github.com/weidai11/cryptopp/commit/fff2c91b9641dd378d853145534f47a3f1a426f1). The test vectors fail to validate under our implementation.
Our implementation uses Benstein and ECRYPT's implementation with test vectors from http://tools.ietf.org/html/draft-strombergson-chacha-test-vectors. TLS-ChaCha uses a modified ChaCha implementation and test vectors from http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305.
---
```
$ ./cryptest.exe tv tls_chacha
Using seed: 1473724933
Testing SymmetricCipher algorithm ChaCha20.
incorrectly encrypted:
AlgorithmType: SymmetricCipher
Ciphertext: 76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669
Comment: Section 7, Test 1
IV: 0000000000000000
Key: 0000000000000000000000000000000000000000000000000000000000000000
Name: ChaCha20
Plaintext:
Source: http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305
Test: Encrypt
```
| ChaCha fails to validate TLS-ChaCha test vectors | https://api.github.com/repos/weidai11/cryptopp/issues/265/comments | 0 | 2016-09-13T00:02:48Z | 2019-01-24T14:42:49Z | https://github.com/weidai11/cryptopp/issues/265 | 176,515,304 | 265 |
[
"weidai11",
"cryptopp"
] | `cryptest.sh` reports the following on Ubuntu 12 i686 testing (x86_64 is OK).
```
clang++ -DNDEBUG -g2 -O2 -march=native -pipe -c sha.cpp
sha.cpp:731:2: error: Unexpected token!
ASJ( jmp, 0, f)
^
./cpu.h:530:23: note: expanded from macro 'ASJ'
#define ASJ(x, y, z) GNU_ASJ(x, y, z)
^
./cpu.h:524:27: note: expanded from macro 'GNU_ASJ'
#define GNU_ASJ(x, y, z) #x " " #y #z ";" NEW_LINE
^
<scratch space>:80:2: note: expanded from here
"jmp"
^
<inline asm>:20:7: note: instantiated into assembly here
jmp 0f;
^
sha.cpp:731:2: error: unknown use of instruction mnemonic without a size suffix
ASJ( jmp, 0, f)
^
./cpu.h:530:23: note: expanded from macro 'ASJ'
#define ASJ(x, y, z) GNU_ASJ(x, y, z)
^
./cpu.h:524:27: note: expanded from macro 'GNU_ASJ'
#define GNU_ASJ(x, y, z) #x " " #y #z ";" NEW_LINE
^
<scratch space>:80:2: note: expanded from here
"jmp"
^
<inline asm>:20:1: note: instantiated into assembly here
jmp 0f;
^
```
And
```
$ clang++ -v
Ubuntu clang version 3.3-5ubuntu4~precise1 (branches/release_33) (based on LLVM 3.3)
Target: i386-pc-linux-gnu
Thread model: posix
```
| Clang 3.3, i686 and "error: unknown use of instruction mnemonic without a size suffix" | https://api.github.com/repos/weidai11/cryptopp/issues/264/comments | 1 | 2016-09-12T07:40:45Z | 2016-09-21T20:08:55Z | https://github.com/weidai11/cryptopp/issues/264 | 176,312,240 | 264 |
[
"weidai11",
"cryptopp"
] | We recently added Keccak classes to provide generic Keccak behaviors. The behaviors include conforming to SHA's round three selection process and the XOF byte of `0x01`. The existing SHA3 class was also modified to conform to NIST FIPS 202, which provides different results from the round three selection. Also see [Keccak dev-branch](http://groups.google.com/forum/#!topic/cryptopp-users/hhXiNXTQFEI) on the mailing list.
We are now at the point users can use Keccack with F1600 and `0x01`; or SHA3 with F1600 and `0x06`. This was in direct response to @AndrewWPhillips's comment regarding a [runtime choice rather than selecting one behavior at compile time](http://github.com/weidai11/cryptopp/issues/158#issuecomment-240886132) with a `#define`.
Our next hurdles based on use cases are:
1. Other Functions, like F25, F800 and user defined
2. Other XOF values (**_`r`**_, **_`c`**_, **_`d`**_?)
3. Other digest sizes (see [SHA3 with specific length](http://groups.google.com/forum/#!topic/cryptopp-users/q8UsCPSWG58))
4. Use Keccak with "unlimited" digest size (generate a key stream)
5. KMAC (Keccak equivalent of HMAC)
6. RandomNumberGenerator interface (re: item (4))
This bug report will track high level design and implementations decisions as we work our way to something more useful.
---
@DevJPM raised a good point in a private email. He was discussing overloading `Final` or providing a `XOFFinal` function:
> > Do we want XOFFinal() to be stateful (e.g. if you call XOFFinal() twice you
> > get different bytes, namely the next in the XOF stream)?
>
> I would shy away form this. Once Final() is called, the hash is
> restarted. That's how every other Crypto++ hash behaves.
>
> With that said, providing a Restart(KeccakState) sounds like a good
> idea. BLAKE2 did the same thing to support different counter values;
> see http://github.com/weidai11/cryptopp/blob/master/blake2.h#L197 .
---
Regarding the way to combine "Keccak core" + "F-NNN function" + "XOF value", please see [Function passed as template argument](http://stackoverflow.com/q/1174169/608639) on Stack Overflow. I favor the functor as a template argument since it gives us the compile time polymorphism combined with inlining. That's a recipe for speed.
Additionally, AES uses the same method around line 1100:
```
template <typename F1, typename F4>
inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, ...)
{
...
}
```
---
Naively, I think we should be able to get to a point in the design that looks like the following. SHAKE may move around, but I think you get the general idea about sharing code.
```
Keccak Core
|
------------+------------
| | |
Keccak SHA3 SHAKE
```
---
Once we get to a better design and implementation, then I'll perform an SSE and NEON port so we can move towards the theoretical 15 cpb.
| Need better design for Keccak | https://api.github.com/repos/weidai11/cryptopp/issues/262/comments | 4 | 2016-09-09T16:10:02Z | 2018-01-21T16:56:24Z | https://github.com/weidai11/cryptopp/issues/262 | 176,047,578 | 262 |
[
"weidai11",
"cryptopp"
] | We still carry around `cryptdll.dsp`, `cryptest.dsp`, `cryptest.dsw`, `cryptlib.dsp`, `dlltest.dsp` from the VC++ 5.0/6.0 days. I use them for testing on Windows 2000 and Windows XP. Outside of the test cases, I don't believe anyone uses them anymore.
I'd like to move `cryptdll.dsp`, `cryptest.dsp`, `cryptest.dsw`, `cryptlib.dsp`, `dlltest.dsp` into `vc60.zip` and provide `vc60.zip` as part of the distribution.
Please note this does not concern VS2005 or VS2010 project files. It simply seeks disposition for the VC++ 5.0/6.0 project files.
Also see mailing list discussion at [Archive VC++ 6.0 workspace and project files?](https://groups.google.com/forum/#!topic/cryptopp-users/h3h94wWn1Es)
| Archive VC++ 6.0 workspace and project files | https://api.github.com/repos/weidai11/cryptopp/issues/261/comments | 1 | 2016-09-08T21:03:23Z | 2016-09-09T07:37:45Z | https://github.com/weidai11/cryptopp/issues/261 | 175,863,944 | 261 |
[
"weidai11",
"cryptopp"
] | [`integer.cpp`](http://github.com/weidai11/cryptopp/blob/master/integer.cpp) has some ARMEL work around for GCC 7.0 and below. The work around was applied at [Issue 31: BlumBlumShub validation fails under ARMEL (likely others)](http://github.com/weidai11/cryptopp/issues/31):
```
// Debian QEMU/ARMEL issue in MultiplyTop; see http://github.com/weidai11/cryptopp/issues/31.
#if __ARMEL__ && (CRYPTOPP_GCC_VERSION >= 40900) && (CRYPTOPP_GCC_VERSION < 70000) && __OPTIMIZE__
# define WORKAROUND_ARMEL_BUG 1
#endif
#if WORKAROUND_ARMEL_BUG
# pragma GCC push_options
# pragma GCC optimize("O1")
#endif
<thousands of lines of Integer code>
#if WORKAROUND_ARMEL_BUG
# pragma GCC pop_options
#endif
```
I believe the work arounds were a confluence of events, including:
- Privately reported GCC issues
- [Issue 236: word64 compile problems due to SSE2 and NEON interfaces](http://github.com/weidai11/cryptopp/issues/236)
- [Issue 256: error: requested alignment is less than minimum alignment of 16 for type 'unsigned __int128 [8]'](http://github.com/weidai11/cryptopp/issues/256)
I believe we are at the point we can remove the ARMEL work-arounds.
| Remove integer.cpp ARMEL workarounds | https://api.github.com/repos/weidai11/cryptopp/issues/259/comments | 1 | 2016-09-08T07:58:58Z | 2016-09-08T13:44:00Z | https://github.com/weidai11/cryptopp/issues/259 | 175,689,208 | 259 |
[
"weidai11",
"cryptopp"
] | I know the Keccak [site ](http://keccak.noekeon.org/) says HMAC is not necessary for SHA3 MAC construction. However, we have an environment where SHA3 and HMAC may be combined so I hacked in support for an internally maintained fork, something I'm trying to get away from.
Before cleaning this up and submitting a PR I wanted to have a discussion on the desirability of this. I seem to remember some resistance to the idea, but can't find an Issue or a PR for it.
| SHA3 HMAC Support | https://api.github.com/repos/weidai11/cryptopp/issues/257/comments | 10 | 2016-09-07T16:23:21Z | 2018-01-21T16:56:12Z | https://github.com/weidai11/cryptopp/issues/257 | 175,547,243 | 257 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.