Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
sol_message_digest_config Struct Reference

The message digest configuration to use when creating a new handle. More...

#include <sol-message-digest.h>

Data Fields

const char * algorithm
 Algorithm name. More...
 
uint16_t api_version
 api_version must match SOL_MESSAGE_DIGEST_CONFIG_API_VERSION at runtime. More...
 
const void * data
 The context data to give to all callbacks. More...
 
size_t feed_size
 The feed buffer max size. More...
 
struct sol_str_slice key
 If provided (length > 0), then is used by the message digest hash function. More...
 
void(* on_digest_ready )(void *data, struct sol_message_digest *handle, struct sol_blob *output)
 The mandatory callback function to report digest is ready. More...
 
void(* on_feed_done )(void *data, struct sol_message_digest *handle, struct sol_blob *input, int status)
 The optional callback function to report digest consumed given data. More...
 

Detailed Description

The message digest configuration to use when creating a new handle.

Note
Message digest follows the Soletta stream design pattern, which can be found here: IO Streams
See Also
sol_message_digest_new()
Examples:
/src/samples/crypto/message-digest.c, and /src/samples/crypto/sha256sum.c.

Field Documentation

const char* sol_message_digest_config::algorithm

Algorithm name.

The name should match Linux kernel's names, such as:

  • md5
  • sha1
  • hmac(sha1)
  • crc32

This pointer must NOT be NULL.

uint16_t sol_message_digest_config::api_version

api_version must match SOL_MESSAGE_DIGEST_CONFIG_API_VERSION at runtime.

Examples:
/src/samples/crypto/message-digest.c, and /src/samples/crypto/sha256sum.c.

Referenced by entry_new(), and startup().

const void* sol_message_digest_config::data

The context data to give to all callbacks.

Examples:
/src/samples/crypto/message-digest.c, and /src/samples/crypto/sha256sum.c.

Referenced by entry_new(), and startup().

size_t sol_message_digest_config::feed_size

The feed buffer max size.

The value 0 means unlimited data. Since sol_message_digest_feed() works with blobs, no extra buffers will be allocated in order to store feed_size bytes. All the blobs that are schedule to be written will be referenced and the sum of all queued blobs must not be equal or exceed feed_size. If it happens sol_message_digest_feed() will return -ENOSPC and one must start to control the writing flow until on_feed_done is called.

See Also
sol_message_digest_feed()
struct sol_str_slice sol_message_digest_config::key

If provided (length > 0), then is used by the message digest hash function.

A slice is used so the key may contain null-bytes inside, the whole slice length will be used.

Examples:
/src/samples/crypto/message-digest.c.

Referenced by startup().

void(* sol_message_digest_config::on_digest_ready)(void *data, struct sol_message_digest *handle, struct sol_blob *output)

The mandatory callback function to report digest is ready.

This pointer must NOT be NULL.

The parameters are:

  • data the context data given with this configuration.
  • handle the handle used to push data.
  • output the resulting digest (hash). It is binary and can be encoded with tools such as sol_buffer_append_as_base16(). The blob is valid while the callback happens, if one wants it to live further increase its reference with sol_blob_ref().
Note
it is safe to delete the message digest handle from inside this callback.
void(* sol_message_digest_config::on_feed_done)(void *data, struct sol_message_digest *handle, struct sol_blob *input, int status)

The optional callback function to report digest consumed given data.

This pointer may be NULL.

This function may be used to report progress of the whole process or to control a possibly lengthy and costly feed pipeline, this way the pipeline will only feed data once its needed.

The parameters are:

  • data the context data given with this configuration.
  • handle the handle used to push data.
  • input the input data originally pushed/fed. There is no need to sol_blob_unref() it is done automatically.
  • status 0 on success -errno on error.
Note
it is safe to delete the message digest handle from inside this callback.

The documentation for this struct was generated from the following file: