openssl_ext

CI

OpenSSL C Bindings for Crystal (and other extensions)

Installation

Add this to your application's shard.yml:

dependencies:
  openssl_ext:
    github: spider-gazelle/openssl_ext

Usage

require "openssl_ext"

See spec/rsa_spec.cr, spec/ec_spec.cr and spec/x509_spec.cr for usage in depth. The bindings closely follows the API for https://ruby-doc.org/stdlib-2.4.0/libdoc/openssl/rdoc/OpenSSL/PKey/RSA.html

Encoding with a passphrase is not yet supported as OpenSSL fails silently without any errors (in order to fix).

AES-GCM and ECDH

Set cipher.auth_data to the header bytes after setting the key and IV and before calling cipher.update. After encryption finishes with cipher.final, read cipher.gcm_tag. For decryption, supply the same AAD and set cipher.gcm_tag before cipher.final. Use the decrypted bytes only after cipher.final succeeds.

OpenSSL::PKey::EC.compute_shared_secret(private_key, peer_public_key) returns the raw ECDH shared secret for use with a key derivation function.

Contributors