/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef USE_HW_SHA2
#include <immintrin.h>
#ifdef FREEBL_NO_DEPEND #include"stubs.h" #endif
#include"blapii.h" #include"prcpucfg.h" #include"prtypes.h"/* for PRUintXX */ #include"prlong.h" #include"blapi.h" #include"sha256.h"
a = _mm_shuffle_epi8(_mm_loadu_si128(input), shuffle);
b = _mm_shuffle_epi8(_mm_loadu_si128(input + 1), shuffle);
c = _mm_shuffle_epi8(_mm_loadu_si128(input + 2), shuffle);
d = _mm_shuffle_epi8(_mm_loadu_si128(input + 3), shuffle);
w0 = h0;
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, attempt 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) {
__m128i a, b, c, d;
__m128i w0, w1;
a = _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)input), shuffle);
b = _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)(input + 16)), shuffle);
c = _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)(input + 32)), shuffle);
d = _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)(input + 48)), shuffle);
input += SHA256_BLOCK_LENGTH;
inputLen -= SHA256_BLOCK_LENGTH;
w0 = h0;
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)
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.