Posts

Showing posts with the label OpenSSL

Multicasting chat with encryption (ECDH P-256 + AES-256-CBC)

Few years ago I published simple Python sample code for the multicasting chat, and this article is a long overdue follow-up that takes that sample to a completely new level. Current IT industry is unimaginable without cybersecurity features, and trends like "zero-trust" rely on complicated crypto algorithms which could be quite overwhelming for beginners. The example C++ code I’ve published could help you to get the ideas and code snippets for your own projects. The full source code is available on Gitlab . DISCLAIMER The code is provided as is, and has issues (including code duplication) as it mostly serves as an education project, not the production-ready code that could benefit from the proper class hierarchies, edge cases handling and better code coverage. First, let’s review the main phases of the application: Parse command line options ( -v - verbose output, -e - apply encryption) Generate EC (elliptic curve, NIST P-256 in the code) k...

Simple HTTP/HTTPS server on Scala/Akka

Let me present a simple Scala script to serve local files over HTTP or HTTPS. I've used Scala/Akka to get the good performance and to play around with the programming language I really like. Toolchain We need Scala, SBT (Scala interactive build tool), Conscript  (a distribution mechanism for Scala apps) and Scalas (the script runner for Scala). Conscript is needed only to install Scalas here, so you may want to install the runner manually (see the Scalas link above) if you don't want to install Conscript. For Mac OS X we're going to use Homebrew to install Scala and SBT:  $ brew install scala sbt Next step is Conscript (please follow the installation instructions on the official site):  $ wget https://dl.bintray.com/foundweekends/maven-releases/org/foundweekends/conscript/conscript_2.11/0.5.1/conscript_2.11-0.5.1-proguard.jar  $ java -jar conscript_2.11-0.5.1-proguard.jar Next step is installing Scalas (please follow the  installat...

wxWidgets and OpenSSL

Securing connections is always a good idea and OpenSSL provides a number of handy ways to do it. Blocking OpenSSL API is the most easiest to use and it could provide a working solution in no time, however it doesn't work with wxWidgets library so smooth as one may hope. I spent some time to find the reason why my application doesn't work as intended (plain sockets work just fine though) and had to do a little research on that matter. Regardless of the flags you provide to wxSocketServer it always creates a socket on the new connection with that ioctl call (UnblockAndRegisterWithEventLoop function in include/wx/unix/private/sockunix.h): ioctl(m_fd, FIONBIO, &trueArg); Basically, it just makes the socket non-blocking. I don't know is it a bug or feature, but we have it now and have to deal with it. Naturally all blocking OpenSSL API doesn't work and we have to develop the code using non-blocking behaviour. However, it's pretty easy to use if we emulate th...