1

For some reason I came up using botan to connect to PKCS11 hardware tokens. I'm new in C++ and want to write the code in with Visual Studio 2019.

I download botan source code and built the source with nmake. After the build completed, there create a folder named build.

I add the directory of botan to VC++ Directories[right click on the application--> properties --> VC++ Directories]

    #include <iostream>
    #include <botan\botan.h>
    #include <botan\alg_id.h>
    #include <external\pkcs11t.h>
    #include <external\pkcs11f.h>
    #include <external\pkcs11.h>


   int main() {

    Botan::Dynamically_Loaded_Library pkcs11_module("C:\\pkcs11-middleware\\library.dll");
    Botan::PKCS11::FunctionListPtr func_list = nullptr;
    Botan::PKCS11::LowLevel::C_GetFunctionList(pkcs11_module, &func_list);
    Botan::PKCS11::LowLevel p11_low_level(func_list);


   }

There are errors in these lines

  • namespace Botan has no member "Dynamically_Loaded_Library"

    Botan::Dynamically_Loaded_Library

  • name followed by '::' must be a class or namespace

All the lines have error, I really mixed up. Help would be appreciated

Hana Bzh
  • 2,212
  • 3
  • 18
  • 38
  • 2
    Did you just create the boton tag based on your misspelling of botan? In any event **Don't type code or error messages: Always copy & paste**. Please edit your question with *copied* errors, not misspelled hand-typed material – President James K. Polk Aug 01 '19 at 14:26
  • I'm not familiar with Botan but it seems `Dynamically_Loaded_Library` is located in [dyn_load.h](https://botan.randombit.net/doxygen/dyn__load_8h_source.html) – t.m.adam Aug 01 '19 at 15:09
  • @James K Polk thanks for the comment. I edit the question. – Hana Bzh Aug 01 '19 at 18:47
  • 1
    Please check using in their own test [examples](https://github.com/randombit/botan/blob/1f134ba1bb9c8fa1f26135561b4301345978f25e/src/tests/test_pkcs11_low_level.cpp#L19). Not related to your error, but as far as I know PKCS#11 headers must be included via `cryptoki.h` file. – Alexander Aug 02 '19 at 12:14

1 Answers1

3
  1. Build Botan source:

1-1. Open developer command prompt for visual studio 2019

1-2. python "c:\botan\configure.py" --cc=msvc --cp=i386

1-3. nmake

1-4. python "c:\botan\install.py"

1-5. nmake install

  1. Right click on application in visual studio --> properties --> VC++ Directories

2-1. Include Directories: Add C:\Botan\include\botan-2

2-2. Library Directories: Add C:\Botan\lib

  1. Right click on application in visual studio --> properties --> Linker --> input --> Additional Dependencies --> add botan.lib

  2. Don't forget to set the debug mode to x86

  3. Thanks to @Alexander I should have include "p11.h" and define using namespace PKCS11;

  4. Rebuild the project :)

Community
  • 1
  • 1
Hana Bzh
  • 2,212
  • 3
  • 18
  • 38