sha512.c: fullfull implicit API contract in SHA512_Transform.
authorAndy Polyakov <appro@openssl.org>
Wed, 18 Dec 2013 20:27:35 +0000 (21:27 +0100)
committerAndy Polyakov <appro@openssl.org>
Wed, 18 Dec 2013 20:27:35 +0000 (21:27 +0100)
SHA512_Transform was initially added rather as tribute to tradition
than for practucal reasons. But use was recently found in ssl/s3_cbc.c
and it turned to be problematic on platforms that don't tolerate
misasligned references to memory and lack assembly subroutine.

crypto/sha/sha512.c

index 59b4ace23496b6d8d5d9ba466e1c23eb267c21dc..279999009b1aa07b638d4e6acb357494f1123210 100644 (file)
@@ -234,7 +234,14 @@ int SHA384_Update (SHA512_CTX *c, const void *data, size_t len)
 {   return SHA512_Update (c,data,len);   }
 
 void SHA512_Transform (SHA512_CTX *c, const unsigned char *data)
-{   sha512_block_data_order (c,data,1);  }
+       {
+#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
+       if ((size_t)data%sizeof(c->u.d[0]) != 0)
+               memcpy(c->u.p,data,sizeof(c->u.p)),
+               data = c->u.p;
+#endif
+       sha512_block_data_order (c,data,1);
+       }
 
 unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md)
        {