summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-11-27 07:21:46 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-03 16:08:39 -0800
commit5de8d35d113dcb2595207d490d55ac0c78ece270 (patch)
tree2f4e3476579f1dfcccd86f22b1395c295ad7b021 /include
parentbf91b0048620b5b22a8636f989cbfa89c0a4ee59 (diff)
downloadchrome-ec-5de8d35d113dcb2595207d490d55ac0c78ece270.tar.gz
cr50: add extension command for testing hash primitives
A new extended subcommand code (1) is being added to handle hash testing. The new subcommand handler keeps track of multiple sha1 and sha256 contexts the host might want to exercise. The number of available contexts is limited by the amount of available free memory. One of four hash operations could be requested by the host: 'Start', 'Continue', 'Finish' - when hashing a single stream over multiple extended command messages, and 'Single' when the entire message to be hashed is included in one extended command payload. The command payload had the following format: * field | size | note * =================================================================== * mode | 1 | 0 - start, 1 - cont., 2 - finish, 3 - single * hash_mode | 1 | 0 - sha1, 1 - sha256 * handle | 1 | seassion handle, ignored in 'single' mode * text_len | 2 | size of the text to process, big endian * text | text_len | text to hash As soon as the first 'Start' message is encountered, the handler tries to allocate shared memory to keep track of the test contexts, the amount of available memory determines how many contexts the handler can support concurrently. As soon as the last 'Finish' command is encountered, the handler returns the shared memory to the 'heap'. BRANCH=none BUG=chrome-os-partner:43025 TEST=after adding the host side implementation and fixing a couple of bugs, hash tests pass (see upcoming patches). Change-Id: Iae18552d6220d670d1c6f32294f0af1a8d0d5c90 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314692 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/extension.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/extension.h b/include/extension.h
index 45637d9518..f9757c1510 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -30,8 +30,9 @@ typedef void (*extension_handler)(void *buffer,
* @param buffer Data to be processd by the handler, the same space
* is used for data returned by the handler.
* @command_size Size of the input data.
- * @param size On input - max size of the buffer, on output - actual
- * number of data returned by the handler.
+ * @param size On input - max size of the buffer, on output - actual number of
+ * data returned by the handler. A single byte return
+ * usually indicates an error and contains the error code.
*/
void extension_route_command(uint16_t command_code,
void *buffer,
@@ -43,9 +44,21 @@ struct extension_command {
extension_handler handler;
} __packed;
-/* Values for different extension commands. */
+/* Values for different extension subcommands. */
enum {
EXTENSION_AES = 0,
+ EXTENSION_HASH = 1,
+};
+
+
+/* Error codes reported by extension commands. */
+enum {
+ /* EXTENSION_HASH error codes */
+ /* Attempt to start a session on an active handle. */
+ EXC_HASH_DUPLICATED_HANDLE = 1,
+ EXC_HASH_TOO_MANY_HANDLES = 2, /* No room to allocate a new context. */
+ /* Continuation/finish on unknown context. */
+ EXC_HASH_UNKNOWN_CONTEXT = 3
};
#define DECLARE_EXTENSION_COMMAND(code, handler) \