mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/digest/sha2/sha2.c (SHA256_Update, SHA512_Update): avoid Bus
Error caused by unalignment access on Sparc-Solaris (and possibly on other similar environment.) This patch just do memcpy always instead of checking architecture. I see no perf drop on my 64bit env. For more details, see #4320. * test/digest/test_digest.rb: add test for unalignment access. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0419cfc2ed
commit
e56f2abe4b
3 changed files with 23 additions and 2 deletions
|
@ -559,7 +559,8 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
|
|||
}
|
||||
while (len >= SHA256_BLOCK_LENGTH) {
|
||||
/* Process as many complete blocks as we can */
|
||||
SHA256_Transform(context, (sha2_word32*)data);
|
||||
MEMCPY_BCOPY(context->buffer, data, SHA256_BLOCK_LENGTH);
|
||||
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||||
context->bitcount += SHA256_BLOCK_LENGTH << 3;
|
||||
len -= SHA256_BLOCK_LENGTH;
|
||||
data += SHA256_BLOCK_LENGTH;
|
||||
|
@ -880,7 +881,8 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
|
|||
}
|
||||
while (len >= SHA512_BLOCK_LENGTH) {
|
||||
/* Process as many complete blocks as we can */
|
||||
SHA512_Transform(context, (sha2_word64*)data);
|
||||
MEMCPY_BCOPY(context->buffer, data, SHA512_BLOCK_LENGTH);
|
||||
SHA512_Transform(context, (sha2_word64*)context->buffer);
|
||||
ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
|
||||
len -= SHA512_BLOCK_LENGTH;
|
||||
data += SHA512_BLOCK_LENGTH;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue