how to do cryptography (digital signature)in linux - c++

I have done PKCS_7_ASN_ENCODING | X509_ASN_ENCODING in windows using wincrypt and I have to verify signature in linux. Can anyone tell by about good light crypto api on linux.
On searching I found http://home.gna.org/cryptodev-linux/ and on compiling it i am getting this error crypto/hash.h: No such file or directory

This error occurs because you don't have the kernel headers for your system/kernel, therefore when you try to compile, it's unable to find those headers.
More on your end goal, do you want to validate whether a certificate is signed by someone else's certificate?
If so, and if you're open to use OpenSSL, take a look at this answer.

NSS

I would either go with GPG (it also has its own API, just look on the side) or Beecrypt which is probably a little easier to understand but not as complex in its functionality

Related

Unexpected error using grpc arena allocation

I am writing a c++ grpc based service. As recommended here, I installed grpc in my local directpry. I am using linux ubuntu 22.04.
Now, at he begginig of a service call implementation, i have these lines of code:
google::protobuf::Arena arena;
ResponseStatus * response_status =
google::protobuf::Arena::CreateMessage<ResponseStatus>(&arena);
response->set_allocated_status(response_status);
When I invoke the service, from a ruby client, the last line causes an exception with the following error message
[libprotobuf FATAL /home/lrleon/grpc/third_party/protobuf/src/google/protobuf/generated_message_util.cc:764] CHECK failed: (submessage_arena) == (nullptr):
I'll be honest: I do not have an good idea about why this problem could be happening. My best hypothesis is that somewhere a different version of the required grpc/protobuf libraries is intervening. I do not believe it because I am almost sure I am not using any system library related to grpc, but eventually another app could have installed some library.
I spent a full day searching in forums without getting a some related post that could help me solve mine.
That said, I kindly ask if some expert in grpc could help me.
Thanls in advance

Compile gmplib on Linux

I try to compile the code of the library for arbitray numeric precision in C(++) at https://gmplib.org/. I want to do this on a Linux system. I use for this the instructions at the page on https://gmplib.org/manual/Installing-GMP.html#Installing-GMP. The problem is that I get the message, that I'm not authorized to do this. I get:
bash: ./configure: No authorization
But the only thing I think of are the file access rights. But setting them to maximum rights does not help. Can anyone please tell me, how I can solve the problem?

How to make QSslSocket support SSL using an OpenSSL installation?

I'm trying to run a simple client/server to implement a communication using QSslSocket. I work on Windows (unfortunately) and I use QtCreator for more convenience.
When I try, from the client side, to connect to the server using MyQSslSocket->connectToHostEncrypted(ip, port), I get the following message:
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
When I print the raised error, I get the following one:
QAbstractSocket::SocketError(20)
In the documentation we can find that this error code corresponds to QAbstractSocket::SslInternalError whose the description is:
"The SSL library being used reported an internal error. This is probably the result of a bad installation or misconfiguration of the library."
After some investigations I found that Qt does not provide OpenSSL by itself so I installed it (the binaries, for both 32 and 64 bits versions to be sure) from here https://slproweb.com/products/Win32OpenSSL.html.
During the installation, the dll was copied to C:\Windows\System32 (for the 64 bits). Then I checked that the PATH environment variable does well contain this folder.
At this point I tried again, but I still had the same problem, as if the OpenSSL installation was still not found.
When I print the output of the following calls (in the main function of my client):
qDebug() << QSslSocket::supportsSsl();
qDebug() << QSslSocket::sslLibraryVersionString();
I get the following outputs:
false""
My question is, how to make QSslSocket::supportsSsl() return true ?
If anyone could teach me what I missed, what I am doing wrong and tell me what I should do to be able to make this SSL connection run properly, I would be very grateful.
Fareanor.
PS: Sorry for the long question but I think it is important to clearly expose the problem and the context to help you to easily understand the problem and give me more relevant answers.
Ok,
Thanks to #AlienPenguin and #Macias advices, it was that my version of OpenSSL was too recent.
Finally I have installed the closest available version of the one used for the Qt build (which does make sense, I should have thought of it) which can be found by running the following call:
qDebug() << QSslSocket::sslLibraryBuildVersionString();
Problem solved.
Thanks again.

Echo cancellation with PJSIP on Mac

I'm building an SIP-based Mac application with PJSIP and I can't set the echo cancellation.
Already tried to set PJSUA_DEFAULT_EC_TAIL_LEN at compilation-time to a bigger value than 200 (the default one).
I set the media the EC value through the pjsua_media_config.ec_tail_len field, which should be the same as PJSUA_DEFAULT_EC_TAIL_LEN (here is the PJSIP ref).
Also tried to change pjmedia_echo_flag to every value: PJMEDIA_ECHO_DEFAULT, PJMEDIA_ECHO_SPEEX, PJMEDIA_ECHO_SPEEX (here is the PJSIP ref) but that does not seems to have any effect.
Does someone have already succeed setting EC with PJSIP? Am I missing something?
Thanks a lot!
Actually found a good Echo Canceler library: bdIMAD!
With the 2.4 PJSIP version, you can easily plug bdIMAD, check this link :)
Our experience shows that implementation of media engine in PJSIP is bad. I'd advice to use third party media engine that perfectly integrated with PJSIP - IntegrIT CrystalVu SDK www.integrit.com. It has advanced wideband echo canceller and many other voice enhancements.

WS-Discovery & gSOAP set up in VS2013

My overarching goal is to create a small ONVIF client for getting camera information in either C or C++.
gSOAP seemed like a good candidate and first thing I wanted to achieve was to make a small console application which would list the addresses of a bunch of cameras I have on my network using WS-Discovery, something I've done before with a little .NET application.
The problem is I'm stumbling at the first hurdle and I'm a touch confused as to what I'm supposed to be doing. I started out by doing the following:
wsdl2h.exe -o WSDiscovery.h WS-Discovery.wsdl http://www.w3.org/2006/03/addressing/ws-addr.xsd
soapcpp2.exe -i -C -Iimport WSDiscovery.h -d output
,
I then made a project from the resulting soapC.cpp stdsoap2.cpp soapH.h soapStub.h. Adding in threads.h wsaapi.h wsddapi.h threads.c wsaapi.c wsddapi.c from gsoap
This doesn't compile however giving:
wsaapi.h(134): error C2061: syntax error : identifier 'wsa__FaultSubcodeValues'
I think I'm going very wrong here and I'm confused about exactly what a 'plugin' is in the context of gSOAP (my experience with external libraries like this is extremely limited and I have no real formal training in CS). Am I just supposed to be doing what I'm doing now with the wsdd files or are they supposed to be used as part of the soapcpp2.exe process? Am I actually supposed to be using wsdl2h.exe if I just want WS-Discovery?
I can't really make sense of the documentation and don't understand how I'm supposed to get this working. Some help would be greatly appreciated so I can crack on with the actual hard part!
I guess the problem is coming from usage of WS-Adressing plugins (wsaapi.h/.c) with http://www.w3.org/2006/03/addressing/ws-addr.xsd schema.
gSOAP contains the wsdl2h generated file that could be used by WS-discovery plugins (wsddapi.h/.c).
[GSOAP_DIR]/import/wsdd10.h for WS-Discovery 1.0 2005 that use WS-Adressing 2004/08
[GSOAP_DIR]/import/wsdd.h for WS-Discovery 1.1 2009 that use WS-Adressing 2005/08
As ONVIF use WS-Discovery 1.0 you could generate discovery implementation using :
soapcpp2 -Cx [GSOAP_DIR]/import/wsdd10.h -I [GSOAP_DIR]/import -d output
Next you should be able to build your project including wsddapi.c wsaapi.c soapClient.cpp soapC.cpp
You can find some of my experiments from github ws-discovery