On this page:
2.1 All Factories
2.2 Libcrypto (Open  SSL)
2.3 GCrypt
2.4 Nettle
2.5 Sodium
2.6 B2 (Blake2)
2.7 Argon2

2 Cryptography Factories

This library relies on foreign libraries for the implementations of cryptographic primitives. Each foreign library is called a cryptography provider and it has an associated factory that map cryptographic algorithm specifiers to implementations.

Cryptography providers may be used to obtain algorithm implementations either explicitly or implicitly. An implementation of a cryptographic algorithm may be obtained explicitly by calling the appropriate function (eg, get-digest, get-cipher, etc) on a factory or list of factories. Alternatively, most functions provided by this library for performing cryptographic operations accept either a implementation object or an algorithm specifier. If an algorithm specifier is given, an implementation is implicitly sought from the factories in (crypto-factories); if no implementation is available, an exception is raised.


(crypto-factory? v)  boolean?

  v : any/c
Returns #t if v is a crypto factory, #f otherwise.


(crypto-factories)  (listof crypto-factory?)

(crypto-factories factories)  void?
  factories : (listof crypto-factory?)
The list of crypto factories used when implicitly finding an implementation of a cryptographic algorithm from an algorithm specifier.

The initial value is '().

Gets the factory associated with a particular cryptographic algorithm implementation or context.


(factory-version factory)

  (or/c (listof exact-nonnegative-integer?) #f)
  factory : crypto-factory?
Returns a list representing the library version associated with factory, or #f if the library could not be loaded. A version list starts with the major version number; the total number of elements depends on the library’s versioning conventions. If the library does not provide version information, the result is '().


(factory-print-info factory)  void?

  factory : crypto-factory?
Prints information about factory to the current output port. In particular, the following information is customarily included, if relevant:
  • the version of the underlying foreign library (if known)

  • the available digests

  • the available ciphers

  • the available PK systems

  • the available EC named curves

  • the available key-derivation functions

Different crypto providers support different levels of introspection, so the information is generally provided on a best-effort basis.

2.1 All Factories

 (require crypto/all) package: crypto-lib

A list containing all of the factories available in the library.

Warning: the order of the factories may change in future versions of this library. This module is intended as a convenience for interactive use, not for developing libraries or applications.


(use-all-factories!)  void?

2.2 Libcrypto (OpenSSL)

 (require crypto/libcrypto) package: crypto-lib

Factory for libcrypto, the cryptography library of OpenSSL. The necessary foreign library is typically part of the operating system or distributed with Racket.

2.3 GCrypt

 (require crypto/gcrypt) package: crypto-lib

Factory for GCrypt (aka libgcrypt), a cryptography library from the GNU project, originally part of GnuPG. The libgcrypt.so.20 foreign library is required.

2.4 Nettle

 (require crypto/nettle) package: crypto-lib

Factory for Nettle, a lightweight cryptography library. The libnettle.so.6 foreign library is required, and libhogweed.so.4 is required for public-key crypto support.

2.5 Sodium

 (require crypto/sodium) package: crypto-lib

Factory for Sodium (aka libsodium). This factory does not provide the high-level Sodium APIs; it only provides access to some of the low-level primitives. The libsodium.so.{23,18} library is required.

2.6 B2 (Blake2)

 (require crypto/b2) package: crypto-lib

Factory for libb2, a small library implementing the Blake2 digest and MAC algorithm. The libb2.so.1 foreign library is required.

2.7 Argon2

 (require crypto/argon2) package: crypto-lib

Factory for Argon2, a tiny library implementing the Argon2 password hashing (and key derivation) function. The libargon2.so.1 foreign library is required.