Morning Musings

I'm not ready to wake up yet...

Cryptography Using OpenSSL

| Comments

PGP and GPG are commonly used to encrypt and sign messages for specified recipients, but OpenSSL is capable of performing the same cryptographic operations. The benefit is that more of the magic is exposed to the user, which can be useful for learning more about how cryptographic applications operate.

Below are three bash scripts that can perform the following:

  • Public / private key generation
  • Hybrid asymmetric encryption and signing
  • Hybrid asymmetric decryption and verification

These operations are a subset of the core functionality provided by GPG, and can be used to securely pass sensitive data between users. Unlike GPG, the user is responsible for managing trusted certificates.

Bitcoin Donation Proofs

| Comments

As promised in my previous post, I made some donations to show my support for open source software projects that accept Bitcoin. Below you will find the proofs.

Thank you all for everything you do, it is greatly appreciated and does not go unnoticed. Keep up the great work!

Bitcoin Donations

| Comments

Its that time of year again, and I am reminded by the large banner at the top of Wikipedia. I have some spare change lying around, and I feel like showing my support to fellow programmers who maintain the software I use every day.

I am a strong supporter of Bitcoin and naturally I wanted to use it for donations. I have had my Bitcoin address posted on my blog, and have had a few donations from readers (thank you!). One of the best things about Bitcoin is that anyone can send and receive money without needing to sign up for anything. It is a great way to quickly and convieniently transfer cash, and you can be sure that your transaction reaches the intended person without needing to interact with any middleman.

Object Pool

| Comments

An object pool is a specialized allocator that allocates memory in large chunks and deals them out in small slices. Malloc is typically an expensive call, especially for multiple small allocations, so significant performance improvements can be gained by managing memory directly. The object pool presented here is compatible with C++03, supports all standard containers, and offers O(1) amortized allocation and deallocation with configurable growth, limits, and alignment.

The pool works by allocating blocks of memory, partitioning them for the object type and alignment, then pushing all the addresses onto a stack representing available slots. Each allocation pops an address off the stack, each deallocation pushes an allocation onto the stack. When the stack is empty, another block is allocated and added to the linked list of blocks.

Memory Blocks

| Comments

Memory pools work by taking a large chunk of memory and dealing out small pieces of it upon allocation requests. Object pools are a specialized version that treat the memory as an array of objects, such that each “slot” is the same size. In reality, managing an object pool involves more than just an array of objects due to alignment and padding.

When doing 100% of your own memory management, it becomes useful to have a set of tools to assist with organizing memory. You can think of a chunk of memory as being similar to an empty hard drive; the act of aligning, partitioning, and padding the memory is similar to formatting a hard drive with a filesystem.

Google Test

| Comments

This post is a quick introduction to Google Test and how to use it to test your C++ code. Google Test is a unit testing framework that is easy to use and creates meaningful tests with intuitive output.


| Comments

Object counters and memory pools are great ways to monitor the memory usage of your program from within. It can also be useful to monitor the amount of time being spent executing from within your program. This post presents a stopwatch that can provide statistics on how long something takes to run.