working whit dcmsign

All other questions regarding DCMTK

Moderator: Moderator Team

Message
Author
yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

working whit dcmsign

#1 Post by yeganeh »

hello
i wanted to write a simple program which sign a DICOM file.i use the dcmsign example.i included the for example "dcmtk/dcmsign/sicreapr.h" and link dcmsign lib at my project.but my program has error.it says that 'SiCreatorProfile' : undeclared identifier . what should i also include to my program?
regards
________
vapor genie
Last edited by yeganeh on Thu, 2011-02-03, 10:34, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

What exactly is the output of your compiler/linker? What are the command line options used to call the compiler/linker?

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#3 Post by yeganeh »

hi
i write a simple c++ program to use dcmsign example:


//--------- dcmtk Lib
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmdata/dctk.h"
//--------- for SIGNE
#include "dcmtk/dcmsign/sicreapr.h"
#include "dcmtk/dcmsign/siripemd.h"
#include "dcmtk/dcmsign/dcsignat.h"
#include "dcmtk/dcmsign/sicert.h"
#include "dcmtk/dcmsign/siprivat.h"

bool CSignApp::SigneDicomFile(string filename,string certif,string pKey)
{
bool resualt=true;

DcmFileFormat fileformat;
E_TransferSyntax xfer;
OFCondition status;

xfer = (fileformat.getDataset())->getOriginalXfer();
status= fileformat.loadFile(filename.data()
,xfer /*EXS_Unknown*/
,EGL_withoutGL
,DCM_MaxReadLength);
if (status.good())
{
DcmDataset *dataset = fileformat.getDataset();

SiCreatorProfile profile; // select the "RSA Creator Profile"
SiRIPEMD160 mac; // use RIPEMD160 as MAC algorithm
DcmSignature signer; // signature handler
SiCertificate cert; // our certificate
if (cert.loadCertificate(certif.data(), X509_FILETYPE_PEM).bad())
{
cerr << "unable to load certificate" << endl;
return false;
}

SiPrivateKey key; // private key, must be unencrypted here
if (key.loadPrivateKey("privkey.pem", X509_FILETYPE_PEM).bad())
{
cerr << "unable to load private key" << endl;
return false;
}
signer.attach(dataset); // connect handler to data set

if (signer.createSignature(key, cert, mac, profile).good())
{
fileformat.saveFile("test_signed.dcm"); // write back
}
}
return resualt;
}

i put the include path of the dcmtk include files and libs to my project.and link the :Ws2_32.lib Netapi32.lib ofstd.lib dcmdata.lib dcmdsig.lib zlib_o.lib
to my project.but when i compile my prog there is this error:

error C2065: 'SiCreatorProfile' : undeclared identifier

i don't know what's the matter.
thanks in advanced
________
iolite vaporizer
Last edited by yeganeh on Thu, 2011-02-03, 10:34, edited 1 time in total.

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#4 Post by yeganeh »

is it necessery to lik any other library to my project?
________
Venture Royale
Last edited by yeganeh on Thu, 2011-02-03, 10:34, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#5 Post by Jörg Riesmeier »

Of course, you also need to link the OpenSSL libraries (see example in dcmsign/apps).

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#6 Post by yeganeh »

i also add openssl.lib but there is no difference.
________
marijuana dispensary
Last edited by yeganeh on Thu, 2011-02-03, 10:34, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#7 Post by Jörg Riesmeier »

This is what is used for the dcmsign app (CMake format with OpenSSL but without ZLib):

Code: Select all

# make sure executables are linked to the corresponding libraries
TARGET_LINK_LIBRARIES(dcmsign netapi32 wsock32 ofstd dcmdata dcmdsig dcmtkssl_o.lib dcmtkeay_o.lib)

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#8 Post by yeganeh »

in cmake i set the parameter "whit_openssl" to on then reconfig the cmake.then in my project i link this libs:
Ws2_32.lib Netapi32.lib ofstd.lib dcmdata.lib dcmdsig.lib openssl.lib dcmtkssl_o.lib dcmtkeay_o.lib
but there is no diferencde yet
________
Chrysler Airflite
Last edited by yeganeh on Thu, 2011-02-03, 10:34, edited 1 time in total.

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#9 Post by yeganeh »

i download dcmtk-3.5.4-win32-i386-support.zip and use openssl-0.9.8a directory and from here openssl-0.9.8a\lib get the dcmtkeay_o.lib and dcmtkssl_o.lib.then in my project link this libs:
Ws2_32.lib Netapi32.lib ofstd.lib dcmdata.lib dcmdsig.lib dcmtkssl_o.lib dcmtkeay_o.lib
but yet my program could not be compiled.
________
host and design
Last edited by yeganeh on Thu, 2011-02-03, 10:34, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#10 Post by Jörg Riesmeier »

Does the sample application "dcmsign" compile and link?

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#11 Post by yeganeh »

yes
________
buy cheap vaporizer
Last edited by yeganeh on Thu, 2011-02-03, 10:35, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#12 Post by Jörg Riesmeier »

Since "SiCreatorProfile profile;" is the first line in your code that uses a declaration from the dcmsign module: Did you really compile the complete DCMTK and your application with WITH_OPENSSL defined? Because otherwise, the class will be unknown ...

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#13 Post by yeganeh »

i set the parameter "whit_openssl" in cmake and reconfig it.then i open dcmtk.sln and rebuild it.and yet my project can't complie
________
vapir oxygen
Last edited by yeganeh on Thu, 2011-02-03, 10:35, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#14 Post by Jörg Riesmeier »

Could you please check in your program whether WITH_OPENSSL is really defined e.g. by using the following:

Code: Select all

#ifndef WITH_OPENSSL
#error You did not compile with compiler definition WITH_OPENSSL defined
#endif

yeganeh
Posts: 43
Joined: Mon, 2008-10-27, 07:38

#15 Post by yeganeh »

hi
thanks for your help.finally i can run my program.but in this simple code i open a .dcm file then i insert one signature to this.see my question is this: if we wanted to insert more than one signature what should we do?for example if the file has several sequence item and we wanted to insert one signature to each item of this.
thanks in advanced
________
drug tests
Last edited by yeganeh on Thu, 2011-02-03, 10:35, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest