===========
CSP example
===========


    Introduction
    Content of the folder CSP-CNG sample
    Prerequisites
     Windows
    Running the example
     Windows
    Compiling the example
     Windows
     


Introduction
============

It is highly recommended to read the Manual for System Administrators  

Further informations are available in
[CSADM]         CryptoServer LAN / CryptoServer – Command-line Adminstration Tool - csadm, Utimaco GmbH

This sample will allow you to see an example running on the CSP-CNG API.
 

Content of the folder ``sample``
========================================

The directories have the following content:

bin        Compiled executables will be placed here. Go here to run one of the example program

etc        Scripts to create the user

prj_xx     This folder contains Visual Studio project files. Executables will be placed in the folder ``bin``.  
           The environment variable ``%CS_PATH%`` is automatically set by the installer and used in the 
           Visual Studio project files to locate the necessary libraries.

src        The sample source file is found here.

readme.txt This text file explains the steps to be followed during installation


 
Prerequisites
=============

Please make sure that the <Device> has been configured in cs-cng.cfg file which can be found under C:\ProgramData\Utimaco\CNG\cs_cng.cfg

Windows:
-------

You've already launched the Windows SecurityServer installer and the Windows CryptoServerSDK 
installer on the product CD. The installer automatically sets several environment variables, like  
"%CS_PKCS11_R3_CFG%" and "%CS_PATH%"
Please pay attention to use installer defaults, if not you might need to change some commands accordingly

CryptoServer SDK and SecurityServer create and use the same environment variables,

Please verify the following env vars are set:
     CS_PATH=C:\Program Files\Utimaco\SecurityServer\  
     CS_PKCS11_R3_CFG=C:\ProgramData\Utimaco\PKCS11_R3\cs_pkcs11_R3.cfg 
     CS_CNG_CFG=C:\ProgramData\Utimaco\CNG\cs_cng.cfg


Running the example:
===================

Sometimes you need to enter the the <device> as specified in the following line 
<Device> = IP address(CSLAN)or PCI(CryptoServer)or 3001@127.0.0.1(simulator)

Windows:
-------

Start the simulator from the Desktop(an icon would have been visible post installation)
 
For your convenience, the example is already available as exectuable in folder: ``C:\Program Files\Utimaco\SecurityServer\Software\CSP\sample\bin``

To run the sample, open in folder "bin" a DOS command-line interface and type:

        ..\etc\setup_device.bat "%CS_PATH%\Administration\ADMIN.key" <Device>
	csp_demo.exe 

       Please open the config file(CS_CNG.CFG) and you can set the login i.e in the line "optionally, the login mechanism can also be given" as below:
       Login = CNG_USER,HMACPwd=12345678

       OR

       As soon as the csp_demo.exe is run,the CNG_USER should be selected and password(12345678) should be provided.Click on 'OK' button will run the .exe

     
        
     
Instead of CS_PATH, user can decide where he/she needs to locate the sample, just like below instance:

        C:\Program Files\Utimaco\SecurityServer\Software\CSP\sample\etc>setup_device.bat "C:\Program Files\Utimaco\SecurityServer\Administration\ADMIN.key" <Device>



Compiling the example
=====================

We assume here, that you've already read the section Prerequisites.

Windows
-------

Go to folder ``prj_14`` and open the file ``csp_demo.sln`` with Visual Studio 2015.  
Pay attention under which platform (x64 or Win32) you are compiling. It has to fit your system architecture. 
You'll find your compiled executable in folder ``bin\<platform>``.




