mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-04 16:36:17 +01:00
Remove redundant header inclusions
and clean up some whitespace
This commit is contained in:
parent
9b3fb41a5e
commit
ebcdbd9555
@ -22,9 +22,11 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "glibconfig.h"
|
|
||||||
#include "gchecksum.h"
|
#include "gchecksum.h"
|
||||||
#include "glib.h"
|
|
||||||
|
#include "gmem.h"
|
||||||
|
#include "gtestutils.h"
|
||||||
|
#include "gtypes.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
guint32 buf[4];
|
guint32 buf[4];
|
||||||
guint32 bits[2];
|
guint32 bits[2];
|
||||||
|
|
||||||
guchar data[MD5_DATASIZE];
|
guchar data[MD5_DATASIZE];
|
||||||
|
|
||||||
guchar digest[MD5_DIGEST_LEN];
|
guchar digest[MD5_DIGEST_LEN];
|
||||||
@ -208,9 +210,9 @@ md5_sum_init (Md5sum *md5)
|
|||||||
* reflect the addition of 16 longwords of new data. md5_sum_update()
|
* reflect the addition of 16 longwords of new data. md5_sum_update()
|
||||||
* blocks the data and converts bytes into longwords for this routine.
|
* blocks the data and converts bytes into longwords for this routine.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
md5_transform (guint32 buf[4],
|
md5_transform (guint32 buf[4],
|
||||||
guint32 const in[16])
|
guint32 const in[16])
|
||||||
{
|
{
|
||||||
register guint32 a, b, c, d;
|
register guint32 a, b, c, d;
|
||||||
|
|
||||||
@ -222,7 +224,7 @@ md5_transform (guint32 buf[4],
|
|||||||
|
|
||||||
/* This is the central step in the MD5 algorithm. */
|
/* This is the central step in the MD5 algorithm. */
|
||||||
#define md5_step(f, w, x, y, z, data, s) \
|
#define md5_step(f, w, x, y, z, data, s) \
|
||||||
( w += f (x, y, z) + data, w = w << s | w >> (32 - s), w += x )
|
( w += f (x, y, z) + data, w = w << s | w >> (32 - s), w += x )
|
||||||
|
|
||||||
a = buf[0];
|
a = buf[0];
|
||||||
b = buf[1];
|
b = buf[1];
|
||||||
@ -245,7 +247,7 @@ md5_transform (guint32 buf[4],
|
|||||||
md5_step (F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
md5_step (F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||||
md5_step (F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
md5_step (F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||||
md5_step (F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
md5_step (F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||||
|
|
||||||
md5_step (F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
md5_step (F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||||
md5_step (F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
md5_step (F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||||
md5_step (F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
md5_step (F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||||
@ -341,7 +343,7 @@ md5_sum_update (Md5sum *md5,
|
|||||||
}
|
}
|
||||||
|
|
||||||
memcpy (p, data, bit);
|
memcpy (p, data, bit);
|
||||||
|
|
||||||
md5_byte_reverse (md5->data, 16);
|
md5_byte_reverse (md5->data, 16);
|
||||||
md5_transform (md5->buf, (guint32 *) md5->data);
|
md5_transform (md5->buf, (guint32 *) md5->data);
|
||||||
|
|
||||||
@ -353,7 +355,7 @@ md5_sum_update (Md5sum *md5,
|
|||||||
while (length >= MD5_DATASIZE)
|
while (length >= MD5_DATASIZE)
|
||||||
{
|
{
|
||||||
memcpy (md5->data, data, MD5_DATASIZE);
|
memcpy (md5->data, data, MD5_DATASIZE);
|
||||||
|
|
||||||
md5_byte_reverse (md5->data, 16);
|
md5_byte_reverse (md5->data, 16);
|
||||||
md5_transform (md5->buf, (guint32 *) md5->data);
|
md5_transform (md5->buf, (guint32 *) md5->data);
|
||||||
|
|
||||||
@ -389,7 +391,7 @@ md5_sum_close (Md5sum *md5)
|
|||||||
{
|
{
|
||||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||||
memset (p, 0, count);
|
memset (p, 0, count);
|
||||||
|
|
||||||
md5_byte_reverse (md5->data, 16);
|
md5_byte_reverse (md5->data, 16);
|
||||||
md5_transform (md5->buf, (guint32 *) md5->data);
|
md5_transform (md5->buf, (guint32 *) md5->data);
|
||||||
|
|
||||||
@ -410,7 +412,7 @@ md5_sum_close (Md5sum *md5)
|
|||||||
|
|
||||||
md5_transform (md5->buf, (guint32 *) md5->data);
|
md5_transform (md5->buf, (guint32 *) md5->data);
|
||||||
md5_byte_reverse ((guchar *) md5->buf, 4);
|
md5_byte_reverse ((guchar *) md5->buf, 4);
|
||||||
|
|
||||||
memcpy (md5->digest, md5->buf, 16);
|
memcpy (md5->digest, md5->buf, 16);
|
||||||
|
|
||||||
/* Reset buffers in case they contain sensitive data */
|
/* Reset buffers in case they contain sensitive data */
|
||||||
@ -602,7 +604,7 @@ sha1_transform (guint32 buf[5],
|
|||||||
subRound (D, E, A, B, C, f2, K2, expand (in, 37));
|
subRound (D, E, A, B, C, f2, K2, expand (in, 37));
|
||||||
subRound (C, D, E, A, B, f2, K2, expand (in, 38));
|
subRound (C, D, E, A, B, f2, K2, expand (in, 38));
|
||||||
subRound (B, C, D, E, A, f2, K2, expand (in, 39));
|
subRound (B, C, D, E, A, f2, K2, expand (in, 39));
|
||||||
|
|
||||||
subRound (A, B, C, D, E, f3, K3, expand (in, 40));
|
subRound (A, B, C, D, E, f3, K3, expand (in, 40));
|
||||||
subRound (E, A, B, C, D, f3, K3, expand (in, 41));
|
subRound (E, A, B, C, D, f3, K3, expand (in, 41));
|
||||||
subRound (D, E, A, B, C, f3, K3, expand (in, 42));
|
subRound (D, E, A, B, C, f3, K3, expand (in, 42));
|
||||||
@ -693,7 +695,7 @@ sha1_sum_update (Sha1sum *sha1,
|
|||||||
memcpy (p, buffer, count);
|
memcpy (p, buffer, count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (p, buffer, dataCount);
|
memcpy (p, buffer, dataCount);
|
||||||
|
|
||||||
sha_byte_reverse (sha1->data, SHA1_DATASIZE);
|
sha_byte_reverse (sha1->data, SHA1_DATASIZE);
|
||||||
@ -707,7 +709,7 @@ sha1_sum_update (Sha1sum *sha1,
|
|||||||
while (count >= SHA1_DATASIZE)
|
while (count >= SHA1_DATASIZE)
|
||||||
{
|
{
|
||||||
memcpy (sha1->data, buffer, SHA1_DATASIZE);
|
memcpy (sha1->data, buffer, SHA1_DATASIZE);
|
||||||
|
|
||||||
sha_byte_reverse (sha1->data, SHA1_DATASIZE);
|
sha_byte_reverse (sha1->data, SHA1_DATASIZE);
|
||||||
sha1_transform (sha1->buf, sha1->data);
|
sha1_transform (sha1->buf, sha1->data);
|
||||||
|
|
||||||
@ -1075,7 +1077,7 @@ sha256_sum_digest (Sha256sum *sha256,
|
|||||||
*
|
*
|
||||||
* Return value: the checksum length, or -1 if @checksum_type is
|
* Return value: the checksum length, or -1 if @checksum_type is
|
||||||
* not supported.
|
* not supported.
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
*/
|
*/
|
||||||
gssize
|
gssize
|
||||||
@ -1106,7 +1108,7 @@ g_checksum_type_get_length (GChecksumType checksum_type)
|
|||||||
* g_checksum_new:
|
* g_checksum_new:
|
||||||
* @checksum_type: the desired type of checksum
|
* @checksum_type: the desired type of checksum
|
||||||
*
|
*
|
||||||
* Creates a new #GChecksum, using the checksum algorithm @checksum_type.
|
* Creates a new #GChecksum, using the checksum algorithm @checksum_type.
|
||||||
* If the @checksum_type is not known, %NULL is returned.
|
* If the @checksum_type is not known, %NULL is returned.
|
||||||
* A #GChecksum can be used to compute the checksum, or digest, of an
|
* A #GChecksum can be used to compute the checksum, or digest, of an
|
||||||
* arbitrary binary blob, using different hashing algorithms.
|
* arbitrary binary blob, using different hashing algorithms.
|
||||||
@ -1120,7 +1122,7 @@ g_checksum_type_get_length (GChecksumType checksum_type)
|
|||||||
* will be closed and it won't be possible to call g_checksum_update()
|
* will be closed and it won't be possible to call g_checksum_update()
|
||||||
* on it anymore.
|
* on it anymore.
|
||||||
*
|
*
|
||||||
* Return value: the newly created #GChecksum, or %NULL.
|
* Return value: the newly created #GChecksum, or %NULL.
|
||||||
* Use g_checksum_free() to free the memory allocated by it.
|
* Use g_checksum_free() to free the memory allocated by it.
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
@ -1277,13 +1279,13 @@ g_checksum_update (GChecksum *checksum,
|
|||||||
*
|
*
|
||||||
* Once this function has been called the #GChecksum can no longer be
|
* Once this function has been called the #GChecksum can no longer be
|
||||||
* updated with g_checksum_update().
|
* updated with g_checksum_update().
|
||||||
*
|
*
|
||||||
* The hexadecimal characters will be lower case.
|
* The hexadecimal characters will be lower case.
|
||||||
*
|
*
|
||||||
* Return value: the hexadecimal representation of the checksum. The
|
* Return value: the hexadecimal representation of the checksum. The
|
||||||
* returned string is owned by the checksum and should not be modified
|
* returned string is owned by the checksum and should not be modified
|
||||||
* or freed.
|
* or freed.
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
*/
|
*/
|
||||||
G_CONST_RETURN gchar *
|
G_CONST_RETURN gchar *
|
||||||
@ -1292,7 +1294,7 @@ g_checksum_get_string (GChecksum *checksum)
|
|||||||
gchar *str = NULL;
|
gchar *str = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (checksum != NULL, NULL);
|
g_return_val_if_fail (checksum != NULL, NULL);
|
||||||
|
|
||||||
if (checksum->digest_str)
|
if (checksum->digest_str)
|
||||||
return checksum->digest_str;
|
return checksum->digest_str;
|
||||||
|
|
||||||
@ -1397,7 +1399,7 @@ g_checksum_get_digest (GChecksum *checksum,
|
|||||||
* Computes the checksum for a binary @data of @length. This is a
|
* Computes the checksum for a binary @data of @length. This is a
|
||||||
* convenience wrapper for g_checksum_new(), g_checksum_get_string()
|
* convenience wrapper for g_checksum_new(), g_checksum_get_string()
|
||||||
* and g_checksum_free().
|
* and g_checksum_free().
|
||||||
*
|
*
|
||||||
* The hexadecimal string returned will be in lower case.
|
* The hexadecimal string returned will be in lower case.
|
||||||
*
|
*
|
||||||
* Return value: the digest of the binary data as a string in hexadecimal.
|
* Return value: the digest of the binary data as a string in hexadecimal.
|
||||||
@ -1434,7 +1436,7 @@ g_compute_checksum_for_data (GChecksumType checksum_type,
|
|||||||
* @length: the length of the string, or -1 if the string is null-terminated.
|
* @length: the length of the string, or -1 if the string is null-terminated.
|
||||||
*
|
*
|
||||||
* Computes the checksum of a string.
|
* Computes the checksum of a string.
|
||||||
*
|
*
|
||||||
* The hexadecimal string returned will be in lower case.
|
* The hexadecimal string returned will be in lower case.
|
||||||
*
|
*
|
||||||
* Return value: the checksum as a hexadecimal string. The returned string
|
* Return value: the checksum as a hexadecimal string. The returned string
|
||||||
|
@ -38,8 +38,8 @@ G_BEGIN_DECLS
|
|||||||
* The hashing algorithm to be used by #GChecksum when performing the
|
* The hashing algorithm to be used by #GChecksum when performing the
|
||||||
* digest of some data.
|
* digest of some data.
|
||||||
*
|
*
|
||||||
* Note that the #GChecksumType enumeration may be extended at a later
|
* Note that the #GChecksumType enumeration may be extended at a later
|
||||||
* date to include new hashing algorithm types.
|
* date to include new hashing algorithm types.
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
*/
|
*/
|
||||||
@ -60,26 +60,26 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
typedef struct _GChecksum GChecksum;
|
typedef struct _GChecksum GChecksum;
|
||||||
|
|
||||||
gssize g_checksum_type_get_length (GChecksumType checksum_type);
|
gssize g_checksum_type_get_length (GChecksumType checksum_type);
|
||||||
|
|
||||||
GChecksum * g_checksum_new (GChecksumType checksum_type);
|
GChecksum * g_checksum_new (GChecksumType checksum_type);
|
||||||
void g_checksum_reset (GChecksum *checksum);
|
void g_checksum_reset (GChecksum *checksum);
|
||||||
GChecksum * g_checksum_copy (const GChecksum *checksum);
|
GChecksum * g_checksum_copy (const GChecksum *checksum);
|
||||||
void g_checksum_free (GChecksum *checksum);
|
void g_checksum_free (GChecksum *checksum);
|
||||||
void g_checksum_update (GChecksum *checksum,
|
void g_checksum_update (GChecksum *checksum,
|
||||||
const guchar *data,
|
const guchar *data,
|
||||||
gssize length);
|
gssize length);
|
||||||
G_CONST_RETURN gchar *g_checksum_get_string (GChecksum *checksum);
|
G_CONST_RETURN gchar *g_checksum_get_string (GChecksum *checksum);
|
||||||
void g_checksum_get_digest (GChecksum *checksum,
|
void g_checksum_get_digest (GChecksum *checksum,
|
||||||
guint8 *buffer,
|
guint8 *buffer,
|
||||||
gsize *digest_len);
|
gsize *digest_len);
|
||||||
|
|
||||||
gchar *g_compute_checksum_for_data (GChecksumType checksum_type,
|
gchar *g_compute_checksum_for_data (GChecksumType checksum_type,
|
||||||
const guchar *data,
|
const guchar *data,
|
||||||
gsize length);
|
gsize length);
|
||||||
gchar *g_compute_checksum_for_string (GChecksumType checksum_type,
|
gchar *g_compute_checksum_for_string (GChecksumType checksum_type,
|
||||||
const gchar *str,
|
const gchar *str,
|
||||||
gssize length);
|
gssize length);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user