On Wed, 5 May 2021 09:58:11 -0400
Jeffrey Walton <noloa...@gmail.com> wrote:

> On Tue, May 4, 2021 at 2:08 PM Rogier <rogier.b...@gmail.com> wrote:
> >
> > I keep getting segfaults within cryptopp on freebsd for at least PBKDF 
> > DeriveKey(). I used the sample code from the wiki:
> > https://www.cryptopp.com/wiki/PKCS12_PBKDF
> >
> > I used the cryptopp-lib that is available through the binary ports 
> > collection (pkg). The reported version is 8.5.0
> >
> > Any ideas on how I can fix this or at least where to look?
> >
> > Below all the technical info about versions and traces for a first triage.
> 
> Ugh... I can duplicate this, too using FreeBSD's version of the library.
> 
> It looks like the problem is at frame 3:
> 
> #3  0x0000000000207739 in CryptoPP::HashTransformation::CalculateDigest (
>     this=0x7fffffffe820, digest=0x800253000 "", input=<optimized out>,
>     length=192) at /usr/local/include/cryptopp/cryptlib.h:1189
> No locals.
> 
> length=192 is wrong, if I am not mistaken.
> 
> When I look at frame 4, where 192 is passed to frame 3:
> 
> (gdb) f 4
> #4  CryptoPP::PKCS12_PBKDF<CryptoPP::SHA256>::DeriveKey (this=<optimized out>,
>     derived=0x7fffffffe9a0 "\320`\263", derivedLen=32,
>     purpose=<optimized out>, secret=<optimized out>, secretLen=8,
>     salt=0x7fffffffeac0 "salt", saltLen=4, iterations=1024, timeInSeconds=0)
>     at /usr/local/include/cryptopp/pwdbased.h:439
> 439            hash.CalculateDigest(Ai, buffer, buffer.size());
> (gdb) p Ai
> $3 = {
>   m_alloc = {<CryptoPP::AllocatorBase<unsigned char>> = {<No data
> fields>}, <No data fields>}, m_mark = 18446744073709551615, m_size =
> 32,
>   m_ptr = 0x800253000 ""}
> 
> So the size looks OK at frame 4.
> 
> On the upside, building Crypto++ 8.5 from sources is OK and tests OK.
> I can't duplicate when using Crypto++ 8.5 or Master. It is OK with
> both the static lib and shared lib.
> 
> I would be interested to know how FreeBSD builds the library. Like are
> they using LTO, which is known bad. Every distro I have seen that uses
> LTO has problems with it. Also see
> https://cryptopp.com/wiki/Link_Time_Optimization.
> 
> Is there any chance you can avoid FreeBSD's version, and build
> Crypto++ yourself?
> 
> Jeff
> 


Pfiew, I'm glad you can reproduce this issue. I was starting to question my 
sanity.

I'll try to build de library myself to see if it improves. 

Rogier

-- 
-- Insanity: doing the same thing over and over again
-- and expecting different results.

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/20210505185904.61f1b6652e00dfac265d4eea%40gmail.com.

Reply via email to