SHA2 renamed to SHA256, SHA4 renamed to SHA512 and functions accordingly
The SHA4 name was not clear with regards to the new SHA-3 standard. So
SHA2 and SHA4 have been renamed to better represent what they are:
SHA256 and SHA512 modules.
diff --git a/include/polarssl/sha4.h b/include/polarssl/sha4.h
index 450ef59..711353a 100644
--- a/include/polarssl/sha4.h
+++ b/include/polarssl/sha4.h
@@ -39,9 +39,9 @@
#define UL64(x) x##ULL
#endif
-#define POLARSSL_ERR_SHA4_FILE_IO_ERROR -0x007A /**< Read/write error in file. */
+#define POLARSSL_ERR_SHA512_FILE_IO_ERROR -0x007A /**< Read/write error in file. */
-#if !defined(POLARSSL_SHA1_ALT)
+#if !defined(POLARSSL_SHA512_ALT)
// Regular implementation
//
@@ -62,7 +62,7 @@
unsigned char opad[128]; /*!< HMAC: outer padding */
int is384; /*!< 0 => SHA-512, else SHA-384 */
}
-sha4_context;
+sha512_context;
/**
* \brief SHA-512 context setup
@@ -70,7 +70,7 @@
* \param ctx context to be initialized
* \param is384 0 = use SHA512, 1 = use SHA384
*/
-void sha4_starts( sha4_context *ctx, int is384 );
+void sha512_starts( sha512_context *ctx, int is384 );
/**
* \brief SHA-512 process buffer
@@ -79,7 +79,7 @@
* \param input buffer holding the data
* \param ilen length of the input data
*/
-void sha4_update( sha4_context *ctx, const unsigned char *input, size_t ilen );
+void sha512_update( sha512_context *ctx, const unsigned char *input, size_t ilen );
/**
* \brief SHA-512 final digest
@@ -87,15 +87,15 @@
* \param ctx SHA-512 context
* \param output SHA-384/512 checksum result
*/
-void sha4_finish( sha4_context *ctx, unsigned char output[64] );
+void sha512_finish( sha512_context *ctx, unsigned char output[64] );
#ifdef __cplusplus
}
#endif
-#else /* POLARSSL_SHA4_ALT */
+#else /* POLARSSL_SHA512_ALT */
#include "sha4_alt.h"
-#endif /* POLARSSL_SHA4_ALT */
+#endif /* POLARSSL_SHA512_ALT */
#ifdef __cplusplus
extern "C" {
@@ -109,8 +109,8 @@
* \param output SHA-384/512 checksum result
* \param is384 0 = use SHA512, 1 = use SHA384
*/
-void sha4( const unsigned char *input, size_t ilen,
- unsigned char output[64], int is384 );
+void sha512( const unsigned char *input, size_t ilen,
+ unsigned char output[64], int is384 );
/**
* \brief Output = SHA-512( file contents )
@@ -119,9 +119,9 @@
* \param output SHA-384/512 checksum result
* \param is384 0 = use SHA512, 1 = use SHA384
*
- * \return 0 if successful, or POLARSSL_ERR_SHA4_FILE_IO_ERROR
+ * \return 0 if successful, or POLARSSL_ERR_SHA512_FILE_IO_ERROR
*/
-int sha4_file( const char *path, unsigned char output[64], int is384 );
+int sha512_file( const char *path, unsigned char output[64], int is384 );
/**
* \brief SHA-512 HMAC context setup
@@ -131,8 +131,8 @@
* \param key HMAC secret key
* \param keylen length of the HMAC key
*/
-void sha4_hmac_starts( sha4_context *ctx, const unsigned char *key, size_t keylen,
- int is384 );
+void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key,
+ size_t keylen, int is384 );
/**
* \brief SHA-512 HMAC process buffer
@@ -141,7 +141,7 @@
* \param input buffer holding the data
* \param ilen length of the input data
*/
-void sha4_hmac_update( sha4_context *ctx, const unsigned char *input, size_t ilen );
+void sha512_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen );
/**
* \brief SHA-512 HMAC final digest
@@ -149,14 +149,14 @@
* \param ctx HMAC context
* \param output SHA-384/512 HMAC checksum result
*/
-void sha4_hmac_finish( sha4_context *ctx, unsigned char output[64] );
+void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] );
/**
* \brief SHA-512 HMAC context reset
*
* \param ctx HMAC context to be reset
*/
-void sha4_hmac_reset( sha4_context *ctx );
+void sha512_hmac_reset( sha512_context *ctx );
/**
* \brief Output = HMAC-SHA-512( hmac key, input buffer )
@@ -168,7 +168,7 @@
* \param output HMAC-SHA-384/512 result
* \param is384 0 = use SHA512, 1 = use SHA384
*/
-void sha4_hmac( const unsigned char *key, size_t keylen,
+void sha512_hmac( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char output[64], int is384 );
@@ -177,10 +177,10 @@
*
* \return 0 if successful, or 1 if the test failed
*/
-int sha4_self_test( int verbose );
+int sha512_self_test( int verbose );
/* Internal use */
-void sha4_process( sha4_context *ctx, const unsigned char data[128] );
+void sha512_process( sha512_context *ctx, const unsigned char data[128] );
#ifdef __cplusplus
}