πŸ”OpenSSL

OpenSSL is a library for general-purpose cryptography. OpenSSL is also an open-source command line tool that is commonly used to generate private keys, create CSRs, install your SSL/TLS certificate, and identify certificate information.

Build + Install

#!/bin/bash -xe

#For X86
export ARCH=""
export CROSS_COMPILE=""
export OPENSSL_TARGET=""

#For arm64, source toolchain and set the below config
<<ARM64
export ARCH=arm64
export CROSS_COMPILE="aarch64-linux-gnu-"
export OPENSSL_TARGET=linux-aarch64
ARM64

echo "Download OpenSSL 1.1.1g"
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz

echo "untaring... openSSL"
tar -xf  openssl-1.1.1g.tar.gz
cd openssl-1.1.1g

echo "Configuring OpenSSL"
./Configure ${OPENSSL_TARGET} shared -pg -fPIC --cross-compile-prefix=$CROSS_COMPILE --prefix=/tmp/openssl11 --openssldir=/tmp/openssl11/etc/ssl

echo "Building ..."
make -j8

echo "Installing ...."
make install_sw DESTDIR=<path to staging dir>

Successful compilation directs output into 3 directories

Commands

These commands are for "secp384r1" curve. The same applies to other supported curves.

  • -engine <engine name> : Accelarate with specified engine

  • -tls1_3 : Use TLSv1.3 for communication

  • -quiet: less verbose

  • -rand <path to node > : use the specified random number from node instead of kernel entrophy

API's

Leverage custom engine

OpenSSL provides flexibility to offload operations onto custom HW. The below code leverages the engine to perform all OpenSSL operations

Load custom Random numbers

Allocate, Initialize and Generate key pair

Sign Key

Verify Signed Key

Point Multiplication

Engine

OpenSSL provides flexibility to offload operations onto custom HW. openssl command searches for the custom engine library (so) in

  • default : /usr/lib/engines-1.1/

  • OpenSSL : <path to openssl>/lib/engines-1.1/

-engine <engine name>

Benchmarking

  • -elapsed gives wall clock time ( actual time lapse ). Without elapsed it measures only active CPU time.

  • -multi <n> : runs on multiple instances on multiple cores.

Last updated