On this page:
crypto-clear-ffi-cache!
crypto-get-lib!
crypto-get-obj!
crypto-dump-error-queue!
crypto-translate-error!
crypto-raise!
$crypto
$crypto:  error
8.12

31 Cryptography🔗ℹ

 (require denxi/crypto) package: denxi

denxi/crypto interacts with a bundled derivative of an OpenSSL library. This module has no side-effects on instantiation, but will mutate either a FFI object in the Racket runtime, or an error code cache in the C runtime. To reset the Racket runtime cache, call crypto-clear-ffi-cache!. To dump the error code cache, call crypto-dump-error-queue!.

Clears an internal cache for the low-level library and its objects. The cache operates independently of accumulated errors.

procedure

(crypto-get-lib!)  (or/c ffi-lib? exn?)

Returns a foreign-library value for the bundled cryptographic library, or an exception explaining why it failed to load.

The value returned from this function is cached in Racket-managed memory. If the cached value is an exception, then (get-crypto-lib!) will attempt to load the library again. This will replace the cached exception.

procedure

(crypto-get-obj! objname type)  any/c

  objname : (or/c bytes? symbol? string?)
  type : ctype?
Behaves like get-ffi-obj when (get-crypto-lib!) is a foreign-library value.

Returns #f if the cryptography library is cached as an exception, or if objname was not found in the library.

The value returned from this function is cached in Racket-managed memory.

procedure

(crypto-dump-error-queue!)  (or/c #f list?)

Empties the error queue in the C runtime, then returns the error codes as a Racket list.

If the cryptography library is currently cached as an exception, this function will always return #f.

procedure

(crypto-translate-error! code)  (or/c #f string?)

  code : exact-integer?
Returns a human-readable string of the given error code from the underlying C library, or #f if the cryptography library is currently cached as an exception.

This function operates independently from denxi/l10n. If the output string does not respect the user’s locale, then supply translations to the correct denxi/l10n extention and use that extension instead.

procedure

(crypto-raise!)  any

Note that the side-effect implies movement of the entire error queue from the C runtime into the raised Racket value. Leverage this when you have reason to expect that the queue contains only the errors that pertain to a failed operation.

struct

(struct $crypto ())

A message about a cryptographic operation.

struct

(struct $crypto:error $crypto (queue))

  queue : (listof exact-integer?)
A low-level cryptographic option failed. queue holds all error codes on the bundled libcrypto error queue at the time the instance was constructed. In the unlikely event of (null? queue), a context trace may be necessary to interpret the root cause.