Commit Graph

10 Commits

Author SHA1 Message Date
Brad King 6a365d0901 sha2: Avoid type-punned pointer dereference (#14314)
GCC warns:

 dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

on constructs like

 *(sha_word64*)&var =

so use memcpy to perform such assignments instead.
2013-07-25 13:10:13 -04:00
Brad King 0599c5f546 sha2: Zero entire SHA_CTX structure during cleanup
Convert lines of the form

  MEMSET_BZERO(context, sizeof(context));

to the correct form

  MEMSET_BZERO(context, sizeof(*context));

as suggested by Clang.
2011-11-17 11:18:08 -05:00
Brad King 0a6705cbda sha2: Suppress -Wcast-align warning from Clang
The code does contain a cast that increases alignment but only for
pointers into structures known to be sufficiently aligned.
2011-11-17 11:12:00 -05:00
Brad King 24b1feb5ca sha2: Cast safe conversions to smaller integer types
Add a cast to lines converting "uint64_t" to "unsigned int" that are
known safe due to use of modulus with a small integer.  This avoids
compiler warnings such as

  conversion from 'cm_sha2_uint64_t' to 'unsigned int',
  possible loss of data

from MSVC.
2011-11-17 11:07:43 -05:00
Brad King 9da8340a6d sha2: Suppress Borland warnings in third-party code
The sha2 implementation performs cleanup on local variables.  Suppress
the warning instead of fixing it to minimize modification.
2011-11-16 10:54:56 -05:00
Brad King 23b3df76a0 sha2: Use KWIML fixed-size integer constant macros
Define SHA_UINT32_C and SHA_UINT64_C using the KWIML versions.
Use them in place of hard-coded UL and ULL constant suffixes.
2011-11-16 10:48:10 -05:00
Brad King 46ab0561fc sha2: Use "static const" instead of "const static" declarations
Fix old-style declarations in the original code.
2011-11-16 10:15:44 -05:00
Brad King c1856a33d4 sha2: Use KWIML fixed-size integer types and endian-ness
These are more portable than those named in the original sha2 code.
2011-11-16 10:15:44 -05:00
Brad King 8251b20d4b Import sha2 implementation 1.1 from Aaron D. Gifford
Update cm_sha2.[hc] from sha2.[hc] in "sha2-1.1-ALPHA.tgz" downloaded
today from

  http://www.aarongifford.com/computers/sha.html

with trivial whitespace cleanup.  This adds SHA-224 support.
2011-06-27 14:55:30 -04:00
Brad King 9912c41c17 Import sha2 implementation 1.0 from Aaron D. Gifford
Copy cm_sha2.[hc] from sha2.[hc] in "sha2-1.0.tar.gz" downloaded today
from

  http://www.aarongifford.com/computers/sha.html

with trivial whitespace cleanup.  Also fix #include to account for
rename.
2011-06-27 14:52:25 -04:00