mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
This reduces the number of exported header files to the minimum needed by
the existing userspace utilities and firmware implementations.
BUG=chromium:221544
BRANCH=none
TEST=manual, trybots
CQ-DEPEND=CL:47019,CL:47022,CL:47023
sudo FEATURES=test emerge vboot_reference
FEATURES=test emerge-$BOARD \
vboot_reference \
chromeos-cryptohome \
chromeos-installer \
chromeos-u-boot \
peach-u-boot \
depthcharge
Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47021
Reviewed-by: Randall Spangler <rspangler@chromium.org>
59 lines
1.6 KiB
C
59 lines
1.6 KiB
C
/* Copyright (c) 2011 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.
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "cryptolib.h"
|
|
#include "host_common.h"
|
|
#include "timer_utils.h"
|
|
|
|
#define NUM_HASH_ALGORITHMS 3
|
|
#define TEST_BUFFER_SIZE 4000000
|
|
|
|
/* Table of hash function pointers and their description. */
|
|
typedef uint8_t* (*Hashptr) (const uint8_t*, uint64_t, uint8_t*);
|
|
typedef struct HashFxTable {
|
|
Hashptr hash;
|
|
char* description;
|
|
} HashFxTable;
|
|
|
|
HashFxTable hash_functions[NUM_HASH_ALGORITHMS] = {
|
|
{internal_SHA1, "sha1"},
|
|
{internal_SHA256, "sha256"},
|
|
{internal_SHA512, "sha512"}
|
|
};
|
|
|
|
int main(int argc, char* argv[]) {
|
|
int i;
|
|
double speed;
|
|
uint32_t msecs;
|
|
uint8_t* buffer = (uint8_t*) malloc(TEST_BUFFER_SIZE);
|
|
uint8_t* digest = (uint8_t*) malloc(SHA512_DIGEST_SIZE); /* Maximum size of
|
|
* the digest. */
|
|
ClockTimerState ct;
|
|
|
|
/* Iterate through all the hash functions. */
|
|
for(i = 0; i < NUM_HASH_ALGORITHMS; i++) {
|
|
StartTimer(&ct);
|
|
hash_functions[i].hash(buffer, TEST_BUFFER_SIZE, digest);
|
|
StopTimer(&ct);
|
|
|
|
msecs = GetDurationMsecs(&ct);
|
|
speed = ((TEST_BUFFER_SIZE / 10e6)
|
|
/ (msecs / 10e3)); /* Mbytes/sec */
|
|
|
|
fprintf(stderr, "# %s Time taken = %u ms, Speed = %f Mbytes/sec\n",
|
|
hash_functions[i].description, msecs, speed);
|
|
fprintf(stdout, "mbytes_per_sec_%s:%f\n",
|
|
hash_functions[i].description, speed);
|
|
}
|
|
|
|
free(digest);
|
|
free(buffer);
|
|
return 0;
|
|
}
|