a good library for calculating sha-256 in c++ [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I'm trying to find a good library for calculating sha256. I found already a lot of options
crypto++ : http://www.cryptopp.com/
openSSL: http://www.openssl.org/
MIRACL: http://www.shamus.ie/
I would much prefer a library that's well-known, widely industrially used and works on all operating systems, rather than the most efficient one.
What do you recommend for me? (feel free to recommend on a library that I didn't mention here).

You should consider cryptlib
Works on all operating systems
Cryptlib is supplied as source code for AMX, BeOS, ChorusOS, DOS, DOS32, eCOS, µC/OS-II, embedded Linux, FreeRTOS/OpenRTOS, IBM MVS, µITRON, Macintosh/OS X, OS/2, PalmOS, RTEMS, Tandem, ThreadX, a variety of Unix versions (including AIX, Digital Unix, DGUX, FreeBSD/NetBSD/OpenBSD, HP-UX, IRIX, Linux, MP-RAS, OSF/1, QNX, SCO/UnixWare, Solaris, SunOS, Ultrix, and UTS4), uClinux, VM/CMS, VxWorks, Windows 3.x, Windows 95/98/ME, Windows CE/PocketPC/SmartPhone, Windows NT/2000/XP/Vista/Windows 7 (32- and 64-bit versions), VDK, and Xilinx XMK. cryptlib’s highly portable nature means that it is also being used in a variety of custom embedded system environments.
Widely industrially used
see Clients
It's not free for commercial use, though.

I've recently needed a small library to do some hashing.
After lots of searching, I found this little one : https://create.stephan-brumme.com/hash-library/ .
Its a tiny single-headered library (or bunch of standalone implementations really) that one can use. it supports sha1,sha256, sha3, etc.
Just include the header you need and you are done.

There is also s2n: a C99 implementation of the TLS/SSL protocols that is designed to be simple, small, fast, and with security as a priority. It is released and licensed under the Apache License 2.0.
s2n hash functions.

See also the implementation in Mbed TLS: https://tls.mbed.org/

Related

How can I validate digital signatures for Microsoft's Portable Executable format in portable code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am looking for sample code (or libraries) that can help me validate digital signatures for Windows PE files (.exe, .dll, .cab, .etc) on non-Windows platforms using C++. I am looking for a platform-independent approach.
Thanks!
You could check at WINE's WinVerifyTrust implementation for a full programmatic way.
And, actually, here is a good link How to verify executable digital signatures under Linux? that complains about WINE implementation (that was back in 2008), and thus, explains the process in a quite "portable" way, provided you have something similar to OpenSSL available in your platform.
There is no general answer to this, especially as you have not specified on how far do you want to port it. Linux on x86 with open source libraries will be easier, uCos running on MIPS32 or Arduino will be next to impossible ..
First, you obviously have to be able to read and parse the PE format itself, in particular you have to be able to get contents of individual sections and hash them, like .text, .data etc. For in depth look at how its put together, look here:
http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
http://msdn.microsoft.com/en-us/magazine/ms809762.aspx
Now you want this to be portable, so you can either roll your own PE reader/limited writer, or look around in some of the open source projects that already do this. Try ReactOS or Mono.
Or if you are happy running python, try this http://code.google.com/p/pefile/
Second, as you are dealing with cryptography, digital signatures, and X.509 certificates, you pretty much need a full blown portable crypto library to perform signing, certificate chain validation and so on. If you are happy with GPL, try OpenSSL or CyaSSL, or Botan if you want BSD license.
The precise format of Authenticode signatures, the signing process and the validations process is desribed here:
http://www.microsoft.com/whdc/winlogo/drvsign/Authenticode_PE.mspx ( Authenticode_PE.docx )
It will require quite a bit of code to pull everything together.
The question is rather old, but I put my answer for those who's still facing the same problem.
You can use osslsigncode tool to verify MS Authenticode signatures on Linux or other *nix systems. However the tool just verifies the signature itself and doesn't checks certificate revocation, timestamp validity etc. though you can extract the data from the signature and do it manually.
Microsoft Authenticode is certainly not a big hush-hush secret and you can download technical specs and more about how Authenticode works. You can also download technical information about Windows PE file format. Since you did not clearly state weather you wanted something for Linux, Mac, or a smartphone, I can not provide you with an adequate solution. However, with the information I provided you above, along with OpenSSL, you should be able to create your own program to do this in the language and OS of your choice.

LDAP c++ API choice [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I would like to write my own LDAP client under Linux, specific to our local environment. Most probably I will use QT4 to provide a shiny frontend without much hassle.
I found that there seems to be no standard C++ library for this. OpenLDAP provides a C API and there should also be a C++ API (experimental?) somewhere..
Do I need to use the C stuff or is there a C++ API out there worth of recommendation?
I've actually written a C++ wrapper for OpenLDAP's C API for my day job and it wasn't my most enjoyable experience.
I didn't find a suitable C++ wrapper out there for my purposes (this was in 2006 so things may have changed since). I wound up directly interacting with the C api, which wasn't terrible but it does have some oddities. Assuming you go to the C/OpenLDAP route I can offer you a couple of tips.
Something that I found a little weird, the C API is defined in RFC1823 which means that pretty much every library has the same API.
In the case of OpenLDAP however a number of the RFC1823 API calls have been deprecated, particularly around the authentication parts. Depending on who distributed your OpenLDAP library and what version it is will determine if these deprecated functions have been disabled.
The main changes to avoid the deprecated API are switching from ldap_init() and ldap_open() to ldap_initialize() and using ldap_sasl_bind() (which confusingly handles all types of auth)
I found following c++ wrapper useful. Open Source C++ wrapper
This question is not easy to answer without knowing specifics of libraries you need.
I would say if C++ library based on Qt and available in source code - that'd be the front runner for sure. And if C++ library depends on some other not-Qt framework - don't even try to mix it with Qt.
C-based libraries generally have less dependencies, though a bit awkward and require more attention to details (initialization / deinitialization) comparing to C++ (destructing class usually means releasing all tied to it resources).

Cross platform Networking API [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I was wondering if there was an API to do networking that would work on Windows, Mac and Linux. I would like to make a card game that 2 people can play through a TCP connection.
There are a few options for this, some easier to use than others:
APR (Apache Portable Runtime) - Very popular. Quite easy to use. Includes lots of additional features handy for network programming (threads, mutexes, etc.)
ACE - Popular among the embedded space. Personally, I found it quite a complicated API, and not very straightforward to use.
Boost - If you have a decent level of sophistication with C++ (templates, metaprogramming, etc.), then Boost libraries are generally very good. I'm not sure how popular the Boost asynchronous networking libraries are in the real world.
QT - Popular as a UI toolkit, but has a great set of threading, event management, networking libraries. IMO, this is by far the easiest to use.
It's important to stay away from using the berkeley sockets library, as the implementations across operating systems vary wildly, and you'll lose a fair bit of time to tuning them as you port your software across OSs.
My personal preference: APR.
most of the berkeley sockets api works everywhere.
You can use ACE or Boost.Asio:
About ACE:
Increased portability -- ACE components make it easy to write concurrent networked applications on one OS platform and quickly port them to many other OS platforms. Moreover, because ACE is open source, free software, you never have to worry about getting locked into a particular operating system platform or compiler configuration.
About boost:
Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.
The NRL has a really great library of networking methods that supports a large variety of platforms. They have excellent support from the actual developers on their mailing lists as well.
Protolib
For this simple application you can use the standard "Berkeley socket" functions that are mostly portable. You can also use Boost's abstractions.
If you needed security functions like SSL/TLS (which you don't need for a simple game I guess), there are open source libraries like OpenSSL, GNU TLS, Mozilla NSS.
I've got a feeling the Apache Portable Runtime might help with what you're looking for. Apache HTTPD used this library internally to abstract its platform-specific code so that the server code focuses on the logic and calls the methods in the APR and these translate to underlying operating system functions.
Of course, it might have more tools in it than you strictly need...
Synapse is good multiplatform network library. Open source and very easy to use.
http://www.ararat.cz/synapse/doku.php/download
SDL Net is a very simple abstraction layer on top of sockets, that's very easy to use. See http://www.libsdl.org/projects/SDL_net.

Best operating system abstraction? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm looking for something to abstract the standard operating system functionality in C/C++: span/kill a thread, send/receive a message, start/stop a timer, maybe even memory management, although I can probably handle that myself with my own buffer pool.
I want to to be able to develop and unit test on Linux/windows and then recompile the c/c++ code for various target O/Ses (for embedded systems: eCos, FreeRTOS, VxWorks, etc)
Something as "light" as possible would be best, hopefully just a library, maybe even a collection of macros.
Have you looked at the Boost library? It has threads, timers, memory management, and a signals library.
The library is not a small download, but most of the library components are header-only implementations (though the OS abstraction libraries tend to have to be linked), and you only have to use what you need.
I keep a (long) list of OS Abstraction Libraries. Hope it helps.
Why don't you directly call only POSIX functions (POSIX1 seems to fill all your needs) and install a POSIX layer above non-compliant operating system (to be read as Microsoft Windows)?
I think boost is worth to look into; it can provide you an os abstraction, but also a compiler independence, and much, much more. It does require C++ of course. Other options: Posix.
In your list:
eCos, VxWorks, Linux : good posix support, so you can use this.
freertos: see link
Windows lacks good posix support out of the box (see wikipedia Posix)
If cygwin is ok for you, you can propably use it. If you need to mix with Visual Studio, a library like boost seems more interesting (you'd abstract away from it)

What book or online resource do you suggest to learn programming C++ in Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have years of C++ programming experience in Windows. Now I need to program some applications for Linux. Is there any resource that helps me quickly get the required information about Linux technologies available to C++ developers?
Programming in C++ under Linux isn't all that different at the core. Linux compilers are generally more standard's conforming than MSVC; however, that is changing as MSVC is becoming a better compiler. The difference is more from the environment and available libraries. Visual Studio isn't available (obviously) but some other environments like Visual SlickEdit and Eclipse are available on both.
The build system is widely varied and will probably be dictated by your preference between Gnome, KDE, or the ever-present command line. Personally, I find the latter to be the cleanest and most consistent. If you end up at the command line, then learn GNU Make and pick up a copy of GNU Autoconf, Automake, and Libtool. This will introduce the GNU command line development stack pretty nicely.
Debugging is a lot different being that VS provides a nice GUI debugging environment. Most Linux environments simply wrap a command line debugger (usually gdb) with a GUI. The result is less than satisfactory if you expect a nicely integrated debugger. I would recommend getting comfortable with gdb. There are some decent tutorials for gdb online. Just google for a bunch of them. Once you get a little comfortable, read the online manual for the really neat stuff.
The other choice is to use whatever development environment is packaged with your windowing system or to use something like Eclipse and some C++ plug-in
As for books on the subject, Advanced Programming in the UNIX Environment is a must-read. UNIX Systems Programming is also a good read since it gives you a solid grounding in shells, processes, and what not. I would recommend both the POSIX Programmer's Guide and POSIX.4 Programmer's Guide since they give you a lot of the systems programming stuff.
With all of that said, enjoy your foray into an operating system that really cater to programmers ;)
I'm in the process of making the switch from Windows to Linux right now for a program and so far I have found that man and grep are great. Instead of looking up function prototypes in MSDN (or similar) I just use man.
If I need a code example, greping through an existing project that has some similarities to mine is a great help. Or if there is a project similar enough to warrant this, setting up an LXR of their code-base to more easily facilitate reading really helps a lot.
In general, the open source nature of Linux has been the greatest resource to learning to program on Linux.
Also Stevens' Advanced Programming in the UNIX Environment was a huge boon. But as for IDE's and the like, call me a luddite, but I just like vim and make.
I've learned a lot from Beginning Linux Programming by Matthew and Stones, though it's more C than C++.
I use die.net and lookup at The Open Group's website a lot, http://www.opengroup.org/onlinepubs/000095399/functions/{function}.html. They have much the same information as man. I use SciTE, and have the C API and The Open Group POSIX lookup as hotkeys, as described here.