Skip to content

Commit

Permalink
Specify identifier per line in crypto hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
saprykin committed Oct 2, 2023
1 parent 9bfdc10 commit 268393f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 27 deletions.
15 changes: 11 additions & 4 deletions src/pcryptohash-gost3411.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2010-2017 Alexander Saprykin <saprykin.spb@gmail.com>
* Copyright (C) 2010-2023 Alexander Saprykin <saprykin.spb@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -217,7 +217,11 @@ pp_crypto_hash_gost3411_sum_256 (puint32 a[8],
static void pp_crypto_hash_gost3411_process (PHashGOST3411 *ctx,
const puint32 data[8])
{
puint32 U[8], V[8], W[8], S[8], K[4][8];
puint32 U[8];
puint32 V[8];
puint32 W[8];
puint32 S[8];
puint32 K[4][8];

memcpy (U, ctx->hash, 32);
memcpy (V, data, 32);
Expand Down Expand Up @@ -405,7 +409,9 @@ p_crypto_hash_gost3411_update (PHashGOST3411 *ctx,
const puchar *data,
psize len)
{
puint32 left, to_fill, len256[8];
puint32 left;
puint32 to_fill;
puint32 len256[8];

left = (ctx->len[0] & 0xFF) >> 3;
to_fill = 32 - left;
Expand Down Expand Up @@ -444,7 +450,8 @@ p_crypto_hash_gost3411_update (PHashGOST3411 *ctx,
void
p_crypto_hash_gost3411_finish (PHashGOST3411 *ctx)
{
puint32 left, last;
puint32 left;
puint32 last;

left = ctx->len[0] & 0xFF;
last = 32 - (left >> 3);
Expand Down
16 changes: 11 additions & 5 deletions src/pcryptohash-md5.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2010-2016 Alexander Saprykin <saprykin.spb@gmail.com>
* Copyright (C) 2010-2023 Alexander Saprykin <saprykin.spb@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -89,7 +89,10 @@ static void
pp_crypto_hash_md5_process (PHashMD5 *ctx,
const puint32 data[16])
{
puint32 A, B, C, D;
puint32 A;
puint32 B;
puint32 C;
puint32 D;

A = ctx->hash[0];
B = ctx->hash[1];
Expand Down Expand Up @@ -202,7 +205,8 @@ p_crypto_hash_md5_update (PHashMD5 *ctx,
const puchar *data,
psize len)
{
puint32 left, to_fill;
puint32 left;
puint32 to_fill;

left = ctx->len_low & 0x3F;
to_fill = 64 - left;
Expand Down Expand Up @@ -238,8 +242,10 @@ p_crypto_hash_md5_update (PHashMD5 *ctx,
void
p_crypto_hash_md5_finish (PHashMD5 *ctx)
{
puint32 high, low;
pint left, last;
puint32 high;
puint32 low;
pint left;
pint last;

left = ctx->len_low & 0x3F;
last = (left < 56) ? (56 - left) : (120 - left);
Expand Down
18 changes: 13 additions & 5 deletions src/pcryptohash-sha1.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2010-2016 Alexander Saprykin <saprykin.spb@gmail.com>
* Copyright (C) 2010-2023 Alexander Saprykin <saprykin.spb@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -113,7 +113,12 @@ static void
pp_crypto_hash_sha1_process (PHashSHA1 *ctx,
const puint32 data[16])
{
puint32 W[16], A, B, C, D, E;
puint32 W[16];
puint32 A;
puint32 B;
puint32 C;
puint32 D;
puint32 E;

if (P_UNLIKELY (ctx == NULL))
return;
Expand Down Expand Up @@ -250,7 +255,8 @@ p_crypto_hash_sha1_update (PHashSHA1 *ctx,
const puchar *data,
psize len)
{
puint32 left, to_fill;
puint32 left;
puint32 to_fill;

left = ctx->len_low & 0x3F;
to_fill = 64 - left;
Expand Down Expand Up @@ -286,8 +292,10 @@ p_crypto_hash_sha1_update (PHashSHA1 *ctx,
void
p_crypto_hash_sha1_finish (PHashSHA1 *ctx)
{
puint32 high, low;
pint left, last;
puint32 high;
puint32 low;
pint left;
pint last;

left = ctx->len_low & 0x3F;
last = (left < 56) ? (56 - left) : (120 - left);
Expand Down
14 changes: 9 additions & 5 deletions src/pcryptohash-sha2-256.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2016 Alexander Saprykin <saprykin.spb@gmail.com>
* Copyright (C) 2016-2023 Alexander Saprykin <saprykin.spb@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -116,7 +116,8 @@ static void
pp_crypto_hash_sha2_256_process (PHashSHA2_256 *ctx,
const puint32 data[16])
{
puint32 tmp_sum1, tmp_sum2;
puint32 tmp_sum1;
puint32 tmp_sum2;
puint32 W[64];
puint32 A[8];
puint i;
Expand Down Expand Up @@ -215,7 +216,8 @@ p_crypto_hash_sha2_256_update (PHashSHA2_256 *ctx,
const puchar *data,
psize len)
{
puint32 left, to_fill;
puint32 left;
puint32 to_fill;

left = ctx->len_low & 0x3F;
to_fill = 64 - left;
Expand Down Expand Up @@ -251,8 +253,10 @@ p_crypto_hash_sha2_256_update (PHashSHA2_256 *ctx,
void
p_crypto_hash_sha2_256_finish (PHashSHA2_256 *ctx)
{
puint32 high, low;
pint left, last;
puint32 high;
puint32 low;
pint left;
pint last;

left = ctx->len_low & 0x3F;
last = (left < 56) ? (56 - left) : (120 - left);
Expand Down
14 changes: 9 additions & 5 deletions src/pcryptohash-sha2-512.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2016 Alexander Saprykin <saprykin.spb@gmail.com>
* Copyright (C) 2016-2023 Alexander Saprykin <saprykin.spb@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -138,7 +138,8 @@ static void
pp_crypto_hash_sha2_512_process (PHashSHA2_512 *ctx,
const puint64 data[16])
{
puint64 tmp_sum1, tmp_sum2;
puint64 tmp_sum1;
puint64 tmp_sum2;
puint64 W[80];
puint64 A[8];
puint i;
Expand Down Expand Up @@ -229,7 +230,8 @@ p_crypto_hash_sha2_512_update (PHashSHA2_512 *ctx,
const puchar *data,
psize len)
{
puint32 left, to_fill;
puint32 left;
puint32 to_fill;

left = (puint32) (ctx->len_low & 0x7F);
to_fill = 128 - left;
Expand Down Expand Up @@ -265,8 +267,10 @@ p_crypto_hash_sha2_512_update (PHashSHA2_512 *ctx,
void
p_crypto_hash_sha2_512_finish (PHashSHA2_512 *ctx)
{
puint64 high, low;
pint left, last;
puint64 high;
puint64 low;
pint left;
pint last;

left = (pint) (ctx->len_low & 0x7F);
last = (left < 112) ? (112 - left) : (240 - left);
Expand Down
8 changes: 5 additions & 3 deletions src/pcryptohash-sha3.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2016 Alexander Saprykin <saprykin.spb@gmail.com>
* Copyright (C) 2016-2023 Alexander Saprykin <saprykin.spb@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -86,7 +86,8 @@ static void
pp_crypto_hash_sha3_keccak_theta (PHashSHA3 *ctx)
{
puint i;
puint64 C[5], D[5];
puint64 C[5];
puint64 D[5];

/* Compute the parity of the columns */
for (i = 0; i < 5; ++i)
Expand Down Expand Up @@ -148,7 +149,8 @@ static void
pp_crypto_hash_sha3_keccak_chi (PHashSHA3 *ctx)
{
puint i;
puint64 tmp_A1, tmp_A2;
puint64 tmp_A1;
puint64 tmp_A2;

for (i = 0; i < 25; i += 5) {
tmp_A1 = ctx->hash[i + 0];
Expand Down

0 comments on commit 268393f

Please sign in to comment.