PolarSSL v1.3.2
|
Entropy accumulator implementation. More...
Go to the source code of this file.
Data Structures | |
struct | source_state |
Entropy source state. More... | |
struct | entropy_context |
Entropy context structure. More... | |
Macros | |
#define | POLARSSL_ENTROPY_SHA512_ACCUMULATOR |
#define | POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C |
Critical entropy source failure. More... | |
#define | POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E |
No more sources can be added. More... | |
#define | POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 |
No sources have been added to poll. More... | |
#define | ENTROPY_MAX_SOURCES 20 |
Maximum number of sources supported. More... | |
#define | ENTROPY_MAX_GATHER 128 |
Maximum amount requested from entropy sources. More... | |
#define | ENTROPY_BLOCK_SIZE 64 |
Block size of entropy accumulator (SHA-512) More... | |
#define | ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES |
Typedefs | |
typedef int(* | f_source_ptr )(void *, unsigned char *, size_t, size_t *) |
Entropy poll callback pointer. More... | |
Functions | |
void | entropy_init (entropy_context *ctx) |
Initialize the context. More... | |
void | entropy_free (entropy_context *ctx) |
Free the data in the context. More... | |
int | entropy_add_source (entropy_context *ctx, f_source_ptr f_source, void *p_source, size_t threshold) |
Adds an entropy source to poll. More... | |
int | entropy_gather (entropy_context *ctx) |
Trigger an extra gather poll for the accumulator. More... | |
int | entropy_func (void *data, unsigned char *output, size_t len) |
Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE) (Thread-safe if POLARSSL_THREADING_C is enabled) More... | |
int | entropy_update_manual (entropy_context *ctx, const unsigned char *data, size_t len) |
Add data to the accumulator manually. More... | |
Entropy accumulator implementation.
Copyright (C) 2006-2013, Brainspark B.V.
This file is part of PolarSSL (http://www.polarssl.org) Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
All rights reserved.
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.
Definition in file entropy.h.
#define ENTROPY_BLOCK_SIZE 64 |
#define ENTROPY_MAX_GATHER 128 |
#define ENTROPY_MAX_SOURCES 20 |
#define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES |
#define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E |
#define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 |
#define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C |
typedef int(* f_source_ptr)(void *, unsigned char *, size_t, size_t *) |
Entropy poll callback pointer.
data | Callback-specific data pointer |
output | Data to fill |
len | Maximum size to provide |
olen | The actual amount of bytes put into the buffer (Can be 0) |
int entropy_add_source | ( | entropy_context * | ctx, |
f_source_ptr | f_source, | ||
void * | p_source, | ||
size_t | threshold | ||
) |
Adds an entropy source to poll.
ctx | Entropy context |
f_source | Entropy function |
p_source | Function data |
threshold | Minimum required from source before entropy is released ( with entropy_func() ) |
void entropy_free | ( | entropy_context * | ctx | ) |
Free the data in the context.
ctx | Entropy context to free |
int entropy_func | ( | void * | data, |
unsigned char * | output, | ||
size_t | len | ||
) |
Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE) (Thread-safe if POLARSSL_THREADING_C is enabled)
data | Entropy context |
output | Buffer to fill |
len | Length of buffer |
int entropy_gather | ( | entropy_context * | ctx | ) |
Trigger an extra gather poll for the accumulator.
ctx | Entropy context |
void entropy_init | ( | entropy_context * | ctx | ) |
Initialize the context.
ctx | Entropy context to initialize |
int entropy_update_manual | ( | entropy_context * | ctx, |
const unsigned char * | data, | ||
size_t | len | ||
) |
Add data to the accumulator manually.
ctx | Entropy context |
data | Data to add |
len | Length of data |