2011-12-03 22:45:14 +01:00
|
|
|
/**
|
|
|
|
* \file entropy.h
|
|
|
|
*
|
|
|
|
* \brief Entropy accumulator implementation
|
2018-01-05 16:33:17 +01:00
|
|
|
*/
|
|
|
|
/*
|
2020-08-19 16:37:36 +02:00
|
|
|
* Copyright The Mbed TLS Contributors
|
Update license headers to Apache-2.0 OR GPL-2.0-or-later
This will allow us to ship the LTS branches in a single archive
This commit was generated using the following script:
# ========================
#!/bin/sh
header1='\ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later\
*\
* This file is provided under the Apache License 2.0, or the\
* GNU General Public License v2.0 or later.\
*\
* **********\
* Apache License 2.0:\
*\
* Licensed under the Apache License, Version 2.0 (the "License"); you may\
* not use this file except in compliance with the License.\
* You may obtain a copy of the License at\
*\
* http://www.apache.org/licenses/LICENSE-2.0\
*\
* Unless required by applicable law or agreed to in writing, software\
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\
* See the License for the specific language governing permissions and\
* limitations under the License.\
*\
* **********\
*\
* **********\
* GNU General Public License v2.0 or later:\
*\
* This program is free software; you can redistribute it and/or modify\
* it under the terms of the GNU General Public License as published by\
* the Free Software Foundation; either version 2 of the License, or\
* (at your option) any later version.\
*\
* This program is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of\
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
* GNU General Public License for more details.\
*\
* You should have received a copy of the GNU General Public License along\
* with this program; if not, write to the Free Software Foundation, Inc.,\
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\
*\
* **********'
find -path './.git' -prune -o '(' -name '*.c' -o -name '*.cpp' -o -name '*.fmt' -o -name '*.h' ')' -print | xargs sed -i "
# Normalize the first line of the copyright headers (no text on the first line of a block comment)
/^\/\*.*Copyright.*Arm/I s/\/\*/&\n */
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header1
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# Format copyright header for inclusion into scripts
header2=$(echo "$header1" | sed 's/^\\\? \* \?/#/')
find -path './.git' -prune -o '(' -name '*.gdb' -o -name '*.pl' -o -name '*.py' -o -name '*.sh' ')' -print | xargs sed -i "
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header2
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# ========================
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2020-06-05 13:02:18 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
|
|
|
*
|
|
|
|
* This file is provided under the Apache License 2.0, or the
|
|
|
|
* GNU General Public License v2.0 or later.
|
|
|
|
*
|
|
|
|
* **********
|
|
|
|
* Apache License 2.0:
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
Update license headers to Apache-2.0 OR GPL-2.0-or-later
This will allow us to ship the LTS branches in a single archive
This commit was generated using the following script:
# ========================
#!/bin/sh
header1='\ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later\
*\
* This file is provided under the Apache License 2.0, or the\
* GNU General Public License v2.0 or later.\
*\
* **********\
* Apache License 2.0:\
*\
* Licensed under the Apache License, Version 2.0 (the "License"); you may\
* not use this file except in compliance with the License.\
* You may obtain a copy of the License at\
*\
* http://www.apache.org/licenses/LICENSE-2.0\
*\
* Unless required by applicable law or agreed to in writing, software\
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\
* See the License for the specific language governing permissions and\
* limitations under the License.\
*\
* **********\
*\
* **********\
* GNU General Public License v2.0 or later:\
*\
* This program is free software; you can redistribute it and/or modify\
* it under the terms of the GNU General Public License as published by\
* the Free Software Foundation; either version 2 of the License, or\
* (at your option) any later version.\
*\
* This program is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of\
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
* GNU General Public License for more details.\
*\
* You should have received a copy of the GNU General Public License along\
* with this program; if not, write to the Free Software Foundation, Inc.,\
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\
*\
* **********'
find -path './.git' -prune -o '(' -name '*.c' -o -name '*.cpp' -o -name '*.fmt' -o -name '*.h' ')' -print | xargs sed -i "
# Normalize the first line of the copyright headers (no text on the first line of a block comment)
/^\/\*.*Copyright.*Arm/I s/\/\*/&\n */
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header1
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# Format copyright header for inclusion into scripts
header2=$(echo "$header1" | sed 's/^\\\? \* \?/#/')
find -path './.git' -prune -o '(' -name '*.gdb' -o -name '*.pl' -o -name '*.py' -o -name '*.sh' ')' -print | xargs sed -i "
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header2
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# ========================
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2020-06-05 13:02:18 +02:00
|
|
|
* **********
|
|
|
|
*
|
|
|
|
* **********
|
|
|
|
* GNU General Public License v2.0 or later:
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* **********
|
2011-12-03 22:45:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#ifndef MBEDTLS_ENTROPY_H
|
|
|
|
#define MBEDTLS_ENTROPY_H
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
2011-12-15 20:49:30 +01:00
|
|
|
#include "config.h"
|
2014-04-29 12:39:06 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#include MBEDTLS_CONFIG_FILE
|
2014-04-29 12:39:06 +02:00
|
|
|
#endif
|
2011-12-15 20:49:30 +01:00
|
|
|
|
2015-02-06 14:43:58 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256)
|
2013-06-30 14:49:12 +02:00
|
|
|
#include "sha512.h"
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ENTROPY_SHA512_ACCUMULATOR
|
2013-08-27 15:06:26 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_SHA256_C)
|
|
|
|
#define MBEDTLS_ENTROPY_SHA256_ACCUMULATOR
|
2013-08-27 15:06:26 +02:00
|
|
|
#include "sha256.h"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_THREADING_C)
|
2013-09-28 15:23:57 +02:00
|
|
|
#include "threading.h"
|
|
|
|
#endif
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_HAVEGE_C)
|
2011-12-15 20:49:30 +01:00
|
|
|
#include "havege.h"
|
|
|
|
#endif
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ERR_ENTROPY_SOURCE_FAILED -0x003C /**< Critical entropy source failure. */
|
|
|
|
#define MBEDTLS_ERR_ENTROPY_MAX_SOURCES -0x003E /**< No more sources can be added. */
|
|
|
|
#define MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 /**< No sources have been added to poll. */
|
2015-06-19 10:26:32 +02:00
|
|
|
#define MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE -0x003D /**< No strong sources have been added to poll. */
|
|
|
|
#define MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR -0x003F /**< Read/write error in file. */
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2014-04-25 11:11:10 +02:00
|
|
|
/**
|
|
|
|
* \name SECTION: Module settings
|
|
|
|
*
|
|
|
|
* The configuration options you can set for this module are in this section.
|
|
|
|
* Either change them in config.h or define them on the compiler command line.
|
|
|
|
* \{
|
|
|
|
*/
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_ENTROPY_MAX_SOURCES)
|
|
|
|
#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */
|
2014-04-25 11:11:10 +02:00
|
|
|
#endif
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_ENTROPY_MAX_GATHER)
|
|
|
|
#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */
|
2014-04-25 11:11:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* \} name SECTION: Module settings */
|
2013-06-24 19:31:17 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
|
|
|
|
#define MBEDTLS_ENTROPY_BLOCK_SIZE 64 /**< Block size of entropy accumulator (SHA-512) */
|
2013-08-27 15:06:26 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ENTROPY_BLOCK_SIZE 32 /**< Block size of entropy accumulator (SHA-256) */
|
2013-08-27 15:06:26 +02:00
|
|
|
#endif
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ENTROPY_MAX_SEED_SIZE 1024 /**< Maximum size of seed we read from seed file */
|
|
|
|
#define MBEDTLS_ENTROPY_SOURCE_MANUAL MBEDTLS_ENTROPY_MAX_SOURCES
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2015-06-19 10:26:32 +02:00
|
|
|
#define MBEDTLS_ENTROPY_SOURCE_STRONG 1 /**< Entropy source is strong */
|
|
|
|
#define MBEDTLS_ENTROPY_SOURCE_WEAK 0 /**< Entropy source is weak */
|
|
|
|
|
2011-12-03 22:45:14 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Entropy poll callback pointer
|
|
|
|
*
|
|
|
|
* \param data Callback-specific data pointer
|
|
|
|
* \param output Data to fill
|
|
|
|
* \param len Maximum size to provide
|
|
|
|
* \param olen The actual amount of bytes put into the buffer (Can be 0)
|
|
|
|
*
|
|
|
|
* \return 0 if no critical failures occurred,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ENTROPY_SOURCE_FAILED otherwise
|
2011-12-03 22:45:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
typedef int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, size_t len,
|
2013-12-30 17:57:27 +01:00
|
|
|
size_t *olen);
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2011-12-10 18:02:19 +01:00
|
|
|
/**
|
|
|
|
* \brief Entropy source state
|
|
|
|
*/
|
2018-07-24 10:02:47 +02:00
|
|
|
typedef struct mbedtls_entropy_source_state
|
2011-12-10 18:02:19 +01:00
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_entropy_f_source_ptr f_source; /**< The entropy source callback */
|
2011-12-10 18:02:19 +01:00
|
|
|
void * p_source; /**< The callback data pointer */
|
2015-06-19 09:40:51 +02:00
|
|
|
size_t size; /**< Amount received in bytes */
|
|
|
|
size_t threshold; /**< Minimum bytes required before release */
|
2015-06-19 10:26:32 +02:00
|
|
|
int strong; /**< Is the source strong? */
|
2011-12-10 18:02:19 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_entropy_source_state;
|
2011-12-10 18:02:19 +01:00
|
|
|
|
2011-12-03 22:45:14 +01:00
|
|
|
/**
|
|
|
|
* \brief Entropy context structure
|
|
|
|
*/
|
2018-07-24 10:02:47 +02:00
|
|
|
typedef struct mbedtls_entropy_context
|
2011-12-03 22:45:14 +01:00
|
|
|
{
|
2021-02-22 21:26:54 +01:00
|
|
|
int accumulator_started; /* 0 after init.
|
|
|
|
* 1 after the first update.
|
|
|
|
* -1 after free. */
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
|
|
|
|
mbedtls_sha512_context accumulator;
|
2013-08-27 15:06:26 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_sha256_context accumulator;
|
2013-08-27 15:06:26 +02:00
|
|
|
#endif
|
2021-02-22 21:26:54 +01:00
|
|
|
int source_count; /* Number of entries used in source. */
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_entropy_source_state source[MBEDTLS_ENTROPY_MAX_SOURCES];
|
|
|
|
#if defined(MBEDTLS_HAVEGE_C)
|
|
|
|
mbedtls_havege_state havege_data;
|
2011-12-15 20:49:30 +01:00
|
|
|
#endif
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_THREADING_C)
|
|
|
|
mbedtls_threading_mutex_t mutex; /*!< mutex */
|
2013-09-28 15:23:57 +02:00
|
|
|
#endif
|
2016-06-01 16:25:50 +02:00
|
|
|
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
|
|
|
int initial_entropy_run;
|
|
|
|
#endif
|
2011-12-03 22:45:14 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_entropy_context;
|
2011-12-03 22:45:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Initialize the context
|
|
|
|
*
|
|
|
|
* \param ctx Entropy context to initialize
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_entropy_init( mbedtls_entropy_context *ctx );
|
2011-12-03 22:45:14 +01:00
|
|
|
|
2013-09-28 15:23:03 +02:00
|
|
|
/**
|
|
|
|
* \brief Free the data in the context
|
|
|
|
*
|
|
|
|
* \param ctx Entropy context to free
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_entropy_free( mbedtls_entropy_context *ctx );
|
2013-09-28 15:23:03 +02:00
|
|
|
|
2011-12-03 22:45:14 +01:00
|
|
|
/**
|
|
|
|
* \brief Adds an entropy source to poll
|
2015-04-08 12:49:31 +02:00
|
|
|
* (Thread-safe if MBEDTLS_THREADING_C is enabled)
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
|
|
|
* \param ctx Entropy context
|
|
|
|
* \param f_source Entropy function
|
|
|
|
* \param p_source Function data
|
2011-12-10 18:02:19 +01:00
|
|
|
* \param threshold Minimum required from source before entropy is released
|
2015-06-19 09:40:51 +02:00
|
|
|
* ( with mbedtls_entropy_func() ) (in bytes)
|
2015-06-19 10:26:32 +02:00
|
|
|
* \param strong MBEDTLS_ENTROPY_SOURCE_STRONG or
|
2018-03-13 16:22:58 +01:00
|
|
|
* MBEDTLS_ENTROPY_SOURCE_WEAK.
|
2015-06-19 10:26:32 +02:00
|
|
|
* At least one strong source needs to be added.
|
|
|
|
* Weaker sources (such as the cycle counter) can be used as
|
|
|
|
* a complement.
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \return 0 if successful or MBEDTLS_ERR_ENTROPY_MAX_SOURCES
|
2011-12-03 22:45:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_add_source( mbedtls_entropy_context *ctx,
|
|
|
|
mbedtls_entropy_f_source_ptr f_source, void *p_source,
|
2015-06-19 10:26:32 +02:00
|
|
|
size_t threshold, int strong );
|
2011-12-03 22:45:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Trigger an extra gather poll for the accumulator
|
2015-04-08 12:49:31 +02:00
|
|
|
* (Thread-safe if MBEDTLS_THREADING_C is enabled)
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
|
|
|
* \param ctx Entropy context
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \return 0 if successful, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED
|
2011-12-03 22:45:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_gather( mbedtls_entropy_context *ctx );
|
2011-12-03 22:45:14 +01:00
|
|
|
|
|
|
|
/**
|
2014-05-01 14:18:25 +02:00
|
|
|
* \brief Retrieve entropy from the accumulator
|
2015-04-08 12:49:31 +02:00
|
|
|
* (Maximum length: MBEDTLS_ENTROPY_BLOCK_SIZE)
|
|
|
|
* (Thread-safe if MBEDTLS_THREADING_C is enabled)
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
|
|
|
* \param data Entropy context
|
|
|
|
* \param output Buffer to fill
|
2015-04-08 12:49:31 +02:00
|
|
|
* \param len Number of bytes desired, must be at most MBEDTLS_ENTROPY_BLOCK_SIZE
|
2011-12-03 22:45:14 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \return 0 if successful, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED
|
2011-12-03 22:45:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_func( void *data, unsigned char *output, size_t len );
|
2011-12-03 22:45:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Add data to the accumulator manually
|
2015-04-08 12:49:31 +02:00
|
|
|
* (Thread-safe if MBEDTLS_THREADING_C is enabled)
|
2014-05-01 13:03:14 +02:00
|
|
|
*
|
2011-12-03 22:45:14 +01:00
|
|
|
* \param ctx Entropy context
|
|
|
|
* \param data Data to add
|
|
|
|
* \param len Length of data
|
|
|
|
*
|
|
|
|
* \return 0 if successful
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx,
|
2011-12-03 22:45:14 +01:00
|
|
|
const unsigned char *data, size_t len );
|
|
|
|
|
2016-06-01 12:30:54 +02:00
|
|
|
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
|
|
|
/**
|
|
|
|
* \brief Trigger an update of the seed file in NV by using the
|
|
|
|
* current entropy pool.
|
|
|
|
*
|
|
|
|
* \param ctx Entropy context
|
|
|
|
*
|
|
|
|
* \return 0 if successful
|
|
|
|
*/
|
|
|
|
int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx );
|
|
|
|
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_FS_IO)
|
2014-03-26 11:54:05 +01:00
|
|
|
/**
|
|
|
|
* \brief Write a seed file
|
|
|
|
*
|
|
|
|
* \param ctx Entropy context
|
|
|
|
* \param path Name of the file
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR on file error, or
|
|
|
|
* MBEDTLS_ERR_ENTROPY_SOURCE_FAILED
|
2014-03-26 11:54:05 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *path );
|
2014-03-26 11:54:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Read and update a seed file. Seed is added to this
|
2015-04-08 12:49:31 +02:00
|
|
|
* instance. No more than MBEDTLS_ENTROPY_MAX_SEED_SIZE bytes are
|
2014-03-26 11:54:05 +01:00
|
|
|
* read from the seed file. The rest is ignored.
|
|
|
|
*
|
|
|
|
* \param ctx Entropy context
|
|
|
|
* \param path Name of the file
|
|
|
|
*
|
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR on file error,
|
|
|
|
* MBEDTLS_ERR_ENTROPY_SOURCE_FAILED
|
2014-03-26 11:54:05 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *path );
|
|
|
|
#endif /* MBEDTLS_FS_IO */
|
2014-03-26 11:54:05 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_SELF_TEST)
|
2014-05-30 10:34:15 +02:00
|
|
|
/**
|
|
|
|
* \brief Checkup routine
|
|
|
|
*
|
2016-09-13 14:30:02 +02:00
|
|
|
* This module self-test also calls the entropy self-test,
|
|
|
|
* mbedtls_entropy_source_self_test();
|
|
|
|
*
|
2014-05-30 10:34:15 +02:00
|
|
|
* \return 0 if successful, or 1 if a test failed
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_entropy_self_test( int verbose );
|
2016-08-22 12:08:50 +02:00
|
|
|
|
2016-08-25 11:18:50 +02:00
|
|
|
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
2016-08-22 12:08:50 +02:00
|
|
|
/**
|
|
|
|
* \brief Checkup routine
|
|
|
|
*
|
2016-09-13 14:30:02 +02:00
|
|
|
* Verifies the integrity of the hardware entropy source
|
|
|
|
* provided by the function 'mbedtls_hardware_poll()'.
|
|
|
|
*
|
|
|
|
* Note this is the only hardware entropy source that is known
|
|
|
|
* at link time, and other entropy sources configured
|
|
|
|
* dynamically at runtime by the function
|
|
|
|
* mbedtls_entropy_add_source() will not be tested.
|
|
|
|
*
|
2016-08-22 12:08:50 +02:00
|
|
|
* \return 0 if successful, or 1 if a test failed
|
|
|
|
*/
|
2016-08-25 11:18:50 +02:00
|
|
|
int mbedtls_entropy_source_self_test( int verbose );
|
|
|
|
#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_SELF_TEST */
|
2014-05-30 10:34:15 +02:00
|
|
|
|
2011-12-03 22:45:14 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* entropy.h */
|