<commit_before>/*
 * This file is part of the Soletta Project
 *
 * Copyright (C) 2015 Intel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *   * Neither the name of Intel Corporation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#pragma once

#include <stdbool.h>
#include <stdint.h>
#include <sol-common-buildopts.h>
#include <sol-types.h>
#include <sol-str-slice.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @file
 * @brief These routines are used to calculate message digest.
 */

/**
 * @defgroup Crypto Cryptography And Signatures
 *
 * These routines are used for cryptography and signature of data
 * using Soletta's API.
 */

/**
 * @defgroup Message_Digest Message Digest (Hash)
 * @ingroup Crypto
 *
 * Message Digest algorithms will take a byte stream and
 * compute a hash that may be used to later validate the
 * identity. Even the smallest variation of the input data
 * will have an avalanche effect that drastically change the
 * output data.
 *
 * Wikipedia says (https://en.wikipedia.org/wiki/Cryptographic_hash_function):
 * The ideal cryptographic hash function has four main properties:
 *  - it is easy to compute the hash value for any given message
 *  - it is infeasible to generate a message from its hash
 *  - it is infeasible to modify a message without changing the hash
 *  - it is infeasible to find two different messages with the same hash.
 *
 * Common Message Digest algorithms are CRC32, MD5, SHA1,
 * SHA256 and SHA512. Most of these are already broken, such
 * as CRC32 and nowadays MD5 and even SHA1, then before
 * picking one for your application, check the one that is
 * more secure and hard to break, such as SHA512.
 *
 * @{
 */

struct sol_message_digest;
<commit_msg>crypto: Add clarification about how the wrapper works<commit_after>/*
 * This file is part of the Soletta Project
 *
 * Copyright (C) 2015 Intel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *   * Neither the name of Intel Corporation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#pragma once

#include <stdbool.h>
#include <stdint.h>
#include <sol-common-buildopts.h>
#include <sol-types.h>
#include <sol-str-slice.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @file
 * @brief These routines are used to calculate message digest.
 */

/**
 * @defgroup Crypto Cryptography And Signatures
 *
 * These routines are used for cryptography and signature of data
 * using Soletta's API.
 */

/**
 * @defgroup Message_Digest Message Digest (Hash)
 * @ingroup Crypto
 *
 * Message Digest algorithms will take a byte stream and
 * compute a hash that may be used to later validate the
 * identity. Even the smallest variation of the input data
 * will have an avalanche effect that drastically change the
 * output data.
 *
 * Wikipedia says (https://en.wikipedia.org/wiki/Cryptographic_hash_function):
 * The ideal cryptographic hash function has four main properties:
 *  - it is easy to compute the hash value for any given message
 *  - it is infeasible to generate a message from its hash
 *  - it is infeasible to modify a message without changing the hash
 *  - it is infeasible to find two different messages with the same hash.
 *
 * Common Message Digest algorithms are CRC32, MD5, SHA1,
 * SHA256 and SHA512. Most of these are already broken, such
 * as CRC32 and nowadays MD5 and even SHA1, then before
 * picking one for your application, check the one that is
 * more secure and hard to break, such as SHA512.
 *
 * Soletta provides a portable API for message digests, but it doesn't
 * implement any of them. The actual work is done by the engine underneath,
 * which will depend on the build configuration. On Linux, either the kernel's
 * crypo API or OpenSSL's crypto library are available to choose at build time.
 * On RIOT-OS, only the algorithms provided by the OS are implemented. Other
 * systems lack support currently.
 *
 * When choosing an algorithm, Soletta will pass it down to the engine selected
 * for use, and to keep applications portable, it was chosen to always follow
 * the names used by the Linux kernel. If they don't match on other implementations,
 * Soletta will translate accordingly, keeping those difference transparent
 * for developers.
 *
 * @{
 */

struct sol_message_digest;

{'fraction_non_alphanumeric': 0.05927907631653055, 'fraction_numerical': 0.005913827090960293, 'mean_word_length': 3.8952446588559613, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4430531', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1757, 'n_words': 976}