mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 02:20:48 +00:00
This function will be used to generate some entropy using the
Clock Recovery System.
BRANCH=none
BUG=b:38486828
TEST=make BOARD=hammer -j tests
./util/flash_ec --board=hammer --image=build/hammer/test-entropy.bin
EC console: runtest
TEST=Test fails when no USB connection is active
TEST=Test passes when USB connection is active
TEST=Pasting the values into:
tr ';' '\n' | awk 'BEGIN { e = 0; tot=16384.0 }
{ p = $1/tot; if (p > 0) { e -= p*log(p)/log(2) } }
END { print e }'
shows an entropy > 4 bits per sample.
Change-Id: I2363c7bce42c72c33ef0bf3f099d709ee9c13d13
Reviewed-on: https://chromium-review.googlesource.com/518608
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
63 lines
1.6 KiB
C
63 lines
1.6 KiB
C
/* Copyright 2017 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef __CROS_EC_ROLLBACK_H
|
|
#define __CROS_EC_ROLLBACK_H
|
|
|
|
#define CROS_EC_ROLLBACK_COOKIE 0x0b112233
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
/**
|
|
* Get minimum version set by rollback protection blocks.
|
|
*
|
|
* @return Minimum rollback version, 0 if neither block is initialized,
|
|
* negative value on error.
|
|
*/
|
|
int rollback_get_minimum_version(void);
|
|
|
|
/**
|
|
* Update rollback protection block to the version passed as parameter.
|
|
*
|
|
* @param next_min_version Minimum version to write in rollback block.
|
|
*
|
|
* @return EC_SUCCESS on success, EC_ERROR_* on error.
|
|
*/
|
|
int rollback_update_version(int32_t next_min_version);
|
|
|
|
/**
|
|
* Add entropy to the rollback block.
|
|
*
|
|
* @param data Data to be added to rollback block secret (after hashing)
|
|
* @param len data length
|
|
*
|
|
* @return EC_SUCCESS on success, EC_ERROR_* on error.
|
|
*/
|
|
int rollback_add_entropy(uint8_t *data, unsigned int len);
|
|
|
|
/**
|
|
* Lock rollback protection block, reboot if necessary.
|
|
*
|
|
* @return EC_SUCCESS if rollback was already protected.
|
|
*/
|
|
int rollback_lock(void);
|
|
|
|
/**
|
|
* Obtain some weak entropy (i.e. not guaranteed to be high quality), based on
|
|
* sensors or timing events.
|
|
*
|
|
* Must be defined if CONFIG_ROLLBACK_SECRET_SIZE is set. May sleep.
|
|
*
|
|
* @param buffer Buffer to fill with entropy.
|
|
* @param len Buffer length.
|
|
*
|
|
* @return true if the buffer was filled, false on error.
|
|
*/
|
|
int board_get_entropy(void *buffer, int len);
|
|
|
|
#endif
|
|
|
|
#endif /* __CROS_EC_ROLLBACK_H */
|