Copyright(c) 2011-2016 Intel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
+ modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
/* Reference digest global to reduce stack usage */
static uint8_t digest_ssl[TEST_BUFS][4 * SHA256_DIGEST_NWORDS];
-inline unsigned int byteswap32(unsigned int x)
-{
- return (x >> 24) | (x >> 8 & 0xff00) | (x << 8 & 0xff0000) | (x << 24);
-}
-
int main(void)
{
SHA256_HASH_CTX_MGR *mgr = NULL;
struct perf start, stop;
for (i = 0; i < TEST_BUFS; i++) {
- bufs[i] = (unsigned char *)calloc((size_t) TEST_LEN, 1);
+ bufs[i] = (unsigned char *)calloc((size_t)TEST_LEN, 1);
if (bufs[i] == NULL) {
printf("calloc failed test aborted\n");
return 1;
ctxpool[i].user_data = (void *)((uint64_t) i);
}
- posix_memalign((void *)&mgr, 16, sizeof(SHA256_HASH_CTX_MGR));
+ int ret = posix_memalign((void *)&mgr, 16, sizeof(SHA256_HASH_CTX_MGR));
+ if (ret) {
+ printf("alloc error: Fail");
+ return -1;
+ }
sha256_ctx_mgr_init(mgr);
// Start OpenSSL tests
for (i = 0; i < TEST_BUFS; i++) {
for (j = 0; j < SHA256_DIGEST_NWORDS; j++) {
if (ctxpool[i].job.result_digest[j] !=
- byteswap32(((uint32_t *) digest_ssl[i])[j])) {
+ to_be32(((uint32_t *) digest_ssl[i])[j])) {
fail++;
printf("Test%d, digest%d fail %08X <=> %08X\n",
i, j, ctxpool[i].job.result_digest[j],
- byteswap32(((uint32_t *) digest_ssl[i])[j]));
+ to_be32(((uint32_t *) digest_ssl[i])[j]));
}
}
}