Question

I am trying to get hash of password using Botan's function generate_bcrypt().
I read manual http://botan.randombit.net/passhash.html here. Afterwards I have read it yet once. Source code:

#include <botan/botan.h>
#include <botan-1.10/botan/bcrypt.h>
#include <stdio.h>
#include <iostream>

 using namespace Botan;

 int main(int argc, char *argv[])
 {
   LibraryInitializer init;

   std::string passw="12dnblkndlnbfndlknblf";
   AutoSeeded_RNG rng;


    std::string str= generate_bcrypt(passw,rng,12);

   } 


I compiled it successfully, but when I run it I am getting:

     Starting /home/sh/qt/test-build-desktop/test...
      *** stack smashing detected ***: /home/sh/qt/test-build-desktop/test terminated
      ======= Backtrace: =========
  /lib/i386-linux-gnu/libc.so.6(__fortify_fail+0x45)[0x7618d5]
/lib/i386-linux-gnu/libc.so.6(+0xe7887)[0x761887]
/usr/local/lib/libbotan-1.10.so.0(+0x2517a1)[0xd957a1]

/usr/local/lib/libbotan-1.10.so.0(_ZN5Botan8Blowfish16eks_key_scheduleEPKhjS2_j+0x17d)[0xbcb52d]
[0xbfb64f4c]
======= Memory map: ========
00110000-00127000 r-xp 00000000 08:07 17853      /lib/i386-linux-gnu/libpthread-2.13.so
00127000-00128000 r--p 00016000 08:07 17853      /lib/i386-linux-gnu/libpthread-2.13.so
00128000-00129000 rw-p 00017000 08:07 17853      /lib/i386-linux-gnu/libpthread-2.13.so
00129000-0012b000 rw-p 00000000 00:00 0 
0012b000-00147000 r-xp 00000000 08:07 17835      /lib/i386-linux-gnu/libgcc_s.so.1
00147000-00148000 r--p 0001b000 08:07 17835      /lib/i386-linux-gnu/libgcc_s.so.1
00148000-00149000 rw-p 0001c000 08:07 17835      /lib/i386-linux-gnu/libgcc_s.so.1
00149000-00158000 r-xp 00000000 08:07 21570      /lib/libbz2.so.1.0.4
00158000-00159000 r--p 0000e000 08:07 21570      /lib/libbz2.so.1.0.4
00159000-0015a000 rw-p 0000f000 08:07 21570      /lib/libbz2.so.1.0.4
0015a000-001c8000 r-xp 00000000 08:07 212988     /usr/lib/libgmp.so.10.0.1
001c8000-001c9000 r--p 0006d000 08:07 212988     /usr/lib/libgmp.so.10.0.1
001c9000-001d0000 rw-p 0006e000 08:07 212988     /usr/lib/libgmp.so.10.0.1
001d0000-001d7000 r-xp 00000000 08:07 17855      /lib/i386-linux-gnu/librt-2.13.so
001d7000-001d8000 r--p 00006000 08:07 17855      /lib/i386-linux-gnu/librt-2.13.so
001d8000-001d9000 rw-p 00007000 08:07 17855      /lib/i386-linux-gnu/librt-2.13.so
001d9000-001ec000 r-xp 00000000 08:07 17267      /lib/i386-linux-gnu/libz.so.1.2.3.4
001ec000-001ed000 r--p 00012000 08:07 17267      /lib/i386-linux-gnu/libz.so.1.2.3.4
001ed000-001ee000 rw-p 00013000 08:07 17267      /lib/i386-linux-gnu/libz.so.1.2.3.4
001ee000-001f1000 r-xp 00000000 08:07 17842      /lib/i386-linux-gnu/libdl-2.13.so
001f1000-001f2000 r--p 00002000 08:07 17842      /lib/i386-linux-gnu/libdl-2.13.so
001f2000-001f3000 rw-p 00003000 08:07 17842      /lib/i386-linux-gnu/libdl-2.13.so
00214000-00232000 r-xp 00000000 08:07 17836      /lib/i386-linux-gnu/ld-2.13.so
00232000-00233000 r--p 0001d000 08:07 17836      /lib/i386-linux-gnu/ld-2.13.so
00233000-00234000 rw-p 0001e000 08:07 17836      /lib/i386-linux-gnu/ld-2.13.so
00234000-00312000 r-xp 00000000 08:07 666277     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
00312000-00313000 ---p 000de000 08:07 666277     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
00313000-00317000 r--p 000de000 08:07 666277     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
00317000-00318000 rw-p 000e2000 08:07 666277     /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
00318000-0031f000 rw-p 00000000 00:00 0 
0031f000-004ac000 r-xp 00000000 08:07 16477      /lib/i386-linux-gnu/libcrypto.so.1.0.0
004ac000-004ba000 r--p 0018c000 08:07 16477      /lib/i386-linux-gnu/libcrypto.so.1.0.0
004ba000-004c0000 rw-p 0019a000 08:07 16477      /lib/i386-linux-gnu/libcrypto.so.1.0.0
004c0000-004c3000 rw-p 00000000 00:00 0 
004c3000-004eb000 r-xp 00000000 08:07 17843      /lib/i386-linux-gnu/libm-2.13.so
004eb000-004ec000 r--p 00028000 08:07 17843      /lib/i386-linux-gnu/libm-2.13.so
004ec000-004ed000 rw-p 00029000 08:07 17843      /lib/i386-linux-gnu/libm-2.13.so
0067a000-007f0000 r-xp 00000000 08:07 17839      /lib/i386-linux-gnu/libc-2.13.so
007f0000-007f2000 r--p 00176000 08:07 17839      /lib/i386-linux-gnu/libc-2.13.so
007f2000-007f3000 rw-p 00178000 08:07 17839      /lib/i386-linux-gnu/libc-2.13.so
007f3000-007f6000 rw-p 00000000 00:00 0 
0088c000-00b2a000 r-xp 00000000 08:07 214999     /usr/lib/libbotan-1.8.13.so
00b2a000-00b36000 r--p 0029d000 08:07 214999     /usr/lib/libbotan-1.8.13.so
00b36000-00b37000 rw-p 002a9000 08:07 214999     /usr/lib/libbotan-1.8.13.so
00b44000-00e0e000 r-xp 00000000 08:07 287007     /usr/local/lib/libbotan-1.10.so.0.1
00e0e000-00e18000 r--p 002ca000 08:07 287007     /usr/local/lib/libbotan-1.10.so.0.1
00e18000-00e1a000 rw-p 002d4000 08:07 287007     /usr/local/lib/libbotan-1.10.so.0.1
00e3f000-00e40000 r-xp 00000000 00:00 0          [vdso]
08048000-0804a000 r-xp 00000000 08:06 155662     /home/sh/qt/test-build-desktop/test
0804a000-0804b000 r--p 00001000 08:06 155662     /home/sh/qt/test-build-desktop/test
0804b000-0804c000 rw-p 00002000 08:06 155662     /home/sh/qt/test-build-desktop/test
09529000-0954a000 rw-p 00000000 00:00 0          [heap]
b77ee000-b77f4000 rw-p 00000000 00:00 0 
b7812000-b7814000 rw-p 00000000 00:00 0 
bfb45000-bfb66000 rw-p 00000000 00:00 0          [stack]
The program has unexpectedly finished.

I have no ideas why I got it(of course, I understand that there is something wrong with stack). But I can't even dare condemn Botan for this. So I expect that I have done somewhere something wrong. Of course, I can leave this library and to try something different. But I have bound myself to this library already(I used decrypt() and ecnrypt()- wealthy), so I don't want to create yet once dependency. I will be really glad and even happy, if somebody gives me tips where my mistake hides.

oops, it's hard to see my screenshots. I reuploaded them:

http://s14.radikal.ru/i187/1203/d1/b1b1a52d051d.png

http://s51.radikal.ru/i131/1203/5f/893fe9f6bbc5.png

I can only guess that there is something wrong in Botan.... But it's unbelievable

Was it helpful?

Solution

Well. I wrote a letter to creator of Botan - Jack Lloyd and he answered!!!uraaa. His personal web page is http://www.randombit.net/ .
He suggested that source of error may be usage of headers that are related to different versions of library. i.e. I had a few version of headers, but one library. I mixed them together. Worked code:

#include <botan-1.10/botan/botan.h>
#include <botan-1.10/botan/bcrypt.h>
#include <iostream>
using namespace std;
using namespace Botan;

 int main(int argc, char* argv[])
  {
    LibraryInitializer init;
    AutoSeeded_RNG rng;
    int a=1;
    string strr="4sdfgnglkjnfkdfdfndfglgndlkgdnlkjj";
    cout<<generate_bcrypt(strr, rng,a);
    return 0;
   }

Also I linked explicitly library:
LIBS += -lbotan \
/home/sh/qt/usb_encrypt/libraries/libbotan-1.10.a

Thank you, Jack Lloyd, for such wonderful library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top