/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef USE_HW_SHA2
#ifndef __ARM_FEATURE_CRYPTO #error"Compiler option is invalid" #endif
#ifdef FREEBL_NO_DEPEND #include"stubs.h" #endif
#include"prcpucfg.h" #include"prtypes.h"/* for PRUintXX */ #include"prlong.h" #include"blapi.h" #include"sha256.h"
uint32x4_t a = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input)));
uint32x4_t b = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input + 16)));
uint32x4_t c = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input + 32)));
uint32x4_t d = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input + 48)));
uint32x4_t w0 = h0;
uint32x4_t w1 = h1;
ROUND(0, a, b, c, d)
ROUND(1, b, c, d, a)
ROUND(2, c, d, a, b)
ROUND(3, d, a, b, c)
ROUND(4, a, b, c, d)
ROUND(5, b, c, d, a)
ROUND(6, c, d, a, b)
ROUND(7, d, a, b, c)
ROUND(8, a, b, c, d)
ROUND(9, b, c, d, a)
ROUND(10, c, d, a, b)
ROUND(11, d, a, b, c)
ROUND(12, a, b, c, d)
ROUND(13, b, c, d, a)
ROUND(14, c, d, a, b)
ROUND(15, d, a, b, c)
/* Add inputLen into the count of bytes processed, before processing */ if ((ctx->sizeLo += inputLen) < inputLen) {
ctx->sizeHi++;
}
/* if data already in buffer, attemp to fill rest of buffer */ if (inBuf) { unsignedint todo = SHA256_BLOCK_LENGTH - inBuf; if (inputLen < todo) {
todo = inputLen;
}
memcpy(ctx->u.b + inBuf, input, todo);
input += todo;
inputLen -= todo; if (inBuf + todo == SHA256_BLOCK_LENGTH) {
SHA256_Compress_Native(ctx);
}
}
/* if enough data to fill one or more whole buffers, process them. */ while (inputLen >= SHA256_BLOCK_LENGTH) {
uint32x4_t a, b, c, d;
a = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input)));
b = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input + 16)));
c = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input + 32)));
d = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(input + 48)));
input += SHA256_BLOCK_LENGTH;
inputLen -= SHA256_BLOCK_LENGTH;
uint32x4_t w0 = h0;
uint32x4_t w1 = h1;
ROUND(0, a, b, c, d)
ROUND(1, b, c, d, a)
ROUND(2, c, d, a, b)
ROUND(3, d, a, b, c)
ROUND(4, a, b, c, d)
ROUND(5, b, c, d, a)
ROUND(6, c, d, a, b)
ROUND(7, d, a, b, c)
ROUND(8, a, b, c, d)
ROUND(9, b, c, d, a)
ROUND(10, c, d, a, b)
ROUND(11, d, a, b, c)
ROUND(12, a, b, c, d)
ROUND(13, b, c, d, a)
ROUND(14, c, d, a, b)
ROUND(15, d, a, b, c)
h0 = vaddq_u32(h0, w0);
h1 = vaddq_u32(h1, w1);
}
vst1q_u32(ctx->h, h0);
vst1q_u32(ctx->h + 4, h1);
/* if data left over, fill it into buffer */ if (inputLen) {
memcpy(ctx->u.b, input, inputLen);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.