Merge pull request #195 from libtom/pr/hashes

improve hashsum
This commit is contained in:
Steffen Jaeckel 2017-04-23 23:24:11 +02:00 committed by GitHub
commit 76fbac87e2
6 changed files with 62 additions and 26 deletions

View File

@ -32,6 +32,15 @@ fi
./sizes
./constants
./multi
for i in $(./hashsum | tail -n +3 | awk '{print $1}' | sort); do echo -n "$i: " && ./hashsum $i testprof/test.key ; done > hashsum_tv.txt
difftroubles=$(diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt | grep '^<') || true
if [ -n "$difftroubles" ]; then
echo "FAILURE: hashsum_tv.tx"
diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt
echo "hashsum failed" && rm -f testok.txt && exit 1
else
echo "hashsum okay"
fi
# if this was executed as './coverage.sh ...' create coverage locally
if [[ "${0%% *}" == "./${0##*/}" ]]; then

View File

@ -15,10 +15,9 @@ void register_algs(void);
int main(int argc, char **argv)
{
int idx, x, z;
unsigned long w;
int idx, z;
unsigned long w, x;
unsigned char hash_buffer[MAXBLOCKSIZE];
hash_state md;
/* You need to register algorithms before using them */
register_algs();
@ -38,26 +37,25 @@ int main(int argc, char **argv)
}
if (argc == 2) {
hash_descriptor[idx].init(&md);
do {
x = fread(hash_buffer, 1, sizeof(hash_buffer), stdin);
hash_descriptor[idx].process(&md, hash_buffer, x);
} while (x == sizeof(hash_buffer));
hash_descriptor[idx].done(&md, hash_buffer);
for (x = 0; x < (int)hash_descriptor[idx].hashsize; x++) {
printf("%02x",hash_buffer[x]);
w = sizeof(hash_buffer);
if ((errno = hash_filehandle(idx, stdin, hash_buffer, &w)) != CRYPT_OK) {
printf("File hash error: %s\n", error_to_string(errno));
} else {
for (x = 0; x < w; x++) {
printf("%02x",hash_buffer[x]);
}
printf(" *-\n");
}
printf(" (stdin)\n");
} else {
for (z = 2; z < argc; z++) {
w = sizeof(hash_buffer);
if ((errno = hash_file(idx,argv[z],hash_buffer,&w)) != CRYPT_OK) {
printf("File hash error: %s\n", error_to_string(errno));
} else {
for (x = 0; x < (int)hash_descriptor[idx].hashsize; x++) {
for (x = 0; x < w; x++) {
printf("%02x",hash_buffer[x]);
}
printf(" %s\n", argv[z]);
printf(" *%s\n", argv[z]);
}
}
}

View File

@ -1859,7 +1859,7 @@ Hash: sha512-256
255: FD932614F375BF71420530A690CB16E52C08E99CFE741AC8436FCA8C8BFD5676
256: 0837A11D994D5AA860D06917A8A0F63E3111B95633DEEB15EED9949376F37D36
Hash: sha3_224
Hash: sha3-224
0: 6B4E03423667DBB73B6E15454F0EB1ABD4597F9A1B078E3F5B5A6BC7
1: BDD5167212D2DC69665F5A8875AB87F23D5CE7849132F56371A19096
2: 334CDA37A26C0669CC7A5074452F033FD57FD96AE0729582B69F865E
@ -2118,7 +2118,7 @@ Hash: sha3_224
255: D95C168E8F666375A1C7D574686D36293FCFD3717D79B212D47D97B7
256: BD34C1FAA03A01DB5E0C3A3D5E0440D6E5E361060F3DC9D149A26812
Hash: sha3_256
Hash: sha3-256
0: A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A
1: 5D53469F20FEF4F8EAB52B88044EDE69C77A6A68A60728609FC4A65FF531E7D0
2: 76AB70DC46775B641A8E71507B07145AED11AE5EFC0BAA94AC06876AF2B3BF5C
@ -2377,7 +2377,7 @@ Hash: sha3_256
255: CEB94E2E8BD45BBB4AF2A3AAA05CC3F7BC010A6C68E242923CE3731A108DF8E1
256: 9B04C091DA96B997AFB8F2585D608AEBE9C4A904F7D52C8F28C7E4D2DD9FBA5F
Hash: sha3_384
Hash: sha3-384
0: 0C63A75B845E4F7D01107D852E4C2485C51A50AAAA94FC61995E71BBEE983A2AC3713831264ADB47FB6BD1E058D5F004
1: 127677F8B66725BBCB7C3EAE9698351CA41E0EB6D66C784BD28DCDB3B5FB12D0C8E840342DB03AD1AE180B92E3504933
2: 6A4E8EE496C5FACE43BFB748253EF689F1709986EDA8ABEF8ABD5674A0A9ED2B36A31EE29ACB146DB15F36A32B3F2D63
@ -2636,7 +2636,7 @@ Hash: sha3_384
255: F5CC4DE5026A9359382B096635EA02874262DC3E657FD8EB10E297DF8A77326EF8F73220F4564AB23C092F24E68FDA76
256: E834031D7BAB82AC00905187335595E020C5BD3220924F4F551D7485931D2CB9EFE90B6574FC46B63265314781DE017A
Hash: sha3_512
Hash: sha3-512
0: A69F73CCA23A9AC5C8B567DC185A756E97C982164FE25859E0D1DCC1475C80A615B2123AF1F5F94C11E3E9402C3AC558F500199D95B6D3E301758586281DCD26
1: 7127AAB211F82A18D06CF7578FF49D5089017944139AA60D8BEE057811A15FB55A53887600A3ECEBA004DE51105139F32506FE5B53E1913BFA6B32E716FE97DA
2: 23A5743EA4136810A2DD503252708D35151259C859BCB7AC46F5F120429983D14736FFBEC6BF8F174977B44B0C5B73378EA88A4EC1F7AA295C04B5DB9017CA48

29
notes/hashsum_tv.txt Normal file
View File

@ -0,0 +1,29 @@
blake2b-160: 684b540eb245ebba2cd66b7814fe6d787868a5bb *testprof/test.key
blake2b-256: 3aaa08120aa0174c105fd1f3412e3da30c3bbb9073569b0b8ae458b34de7780e *testprof/test.key
blake2b-384: c33f39ab19099d5dea6789479e23447857803a3f45361ea58dd69c7b8037c8697544b6a741e236215adcb8b38fa0cfc4 *testprof/test.key
blake2b-512: a2daabae6996e3bbfb76c5d277fb881107037c756173f510d83a78f669cf0b70a5088b971e30ca2168381568ea3d30b80a7b500944a5e2e3294f25aed4c3a5f1 *testprof/test.key
blake2s-128: 7e1f9b6de11a3c597308f9d8aacd7321 *testprof/test.key
blake2s-160: 3d1c9ae1a0afe8a6ef8b61d5380de7b061cd353c *testprof/test.key
blake2s-224: 95dacd83d0421b2d69a52d92ee54143bb97c91a61450d917a88d4388 *testprof/test.key
blake2s-256: 92ac6dc88b9ce4a75b2a54783435a37919303f713396db0e9ccd976d8c55f1cf *testprof/test.key
chc_hash: d50da1ea9b53c0b891c8bcb0a4c6e5e0 *testprof/test.key
md2: 0b327a17a102580ccde8081c18f137c7 *testprof/test.key
md4: 6df7b3c1f7fbcbf6b8246dc0046e9d6b *testprof/test.key
md5: 48fd9ed11c633069c3cf721611696a73 *testprof/test.key
rmd128: a78170e11d56605eb0f5e05e6a218e61 *testprof/test.key
rmd160: 56236b14cd15958c58136a295fa2b07c5edee009 *testprof/test.key
rmd256: a0a658b25b8841f20be8151eb5e2c1229f085dd5cf7aa8bef4c8e07ea5738913 *testprof/test.key
rmd320: 2ec15ca947f29dd8cef4782aeaeb4541ac00dc29e1649c4f5f4578ef0287091e513f9da423ce7319 *testprof/test.key
sha1: c17a11eef02d7a2ad7250bc2ee22bdf37ed21f0f *testprof/test.key
sha224: b226daa069512c849d55866470c23543d87e1fb768171efdcc6ab59a *testprof/test.key
sha256: 76ec7faebdc42a4de35ca70024c2d273e9f7856ca61612e89f5f66350ba8cf5f *testprof/test.key
sha3-224: 09525d6410c462e00e72ccd4304290bc59ff2b1b8e5322dbc197e169 *testprof/test.key
sha3-256: b9016fc9976545ad0183775d88f20df5295d40b31db00d85f6916333260b8ae2 *testprof/test.key
sha3-384: 5452977763b602df4185bbe7cce193346b09ee20d4a45a780fd44237e335ceaa71b9da06242621e159d796db9043c9be *testprof/test.key
sha3-512: 1fadf63073c8613d38d5c944e2e3f7e086d94d93dceb2eec1e9693fd44158f3127c90cbaa8a13035cc9ff9b3572c9dce836bea15c92e8a78b036ec382caceb0f *testprof/test.key
sha384: 7cc080c662524617e56d5a49f1c185909e9b1858a86684161ddd97fc5426f693b53f59d779de16da25dcb1259df879e5 *testprof/test.key
sha512: f90afe4d254716a9770fd2c4f29ca544f2975f961cbd7fa207117383e4e48f7a2e1ade4aac333a2cb8c227dd6af2fff4d87c31c2a3916ae24d507c7c94c21818 *testprof/test.key
sha512-224: 64ec566b5c2de736eab1b4e8542dc110f736819ea7f8f48e3712fbad *testprof/test.key
sha512-256: db880bce4beb7246510febb961c7595aab57a15de6f90cd079f145e476b5d773 *testprof/test.key
tiger: 97d713850e7affac30a642572c1ee7b18793d5b9e0ef5932 *testprof/test.key
whirlpool: d7d41c755e0f28313f254cb198e0bfa42f56670595d97b80dceec754825d69938a9c11e5bf16e9a3809a62a09bddf021f3dbff4302ceec7ba46c88b41772b711 *testprof/test.key

View File

@ -1859,7 +1859,7 @@ HMAC-sha512-256
255: 2BE7933119BE1B6E7D90983F9475EC3EAD2BEDCFB0C688F92749D05954F93566
256: 4C1E9FE65A4635CF336D6F15BB33142C7940AD8352ED45869BD2D34C1E70AE60
HMAC-sha3_224
HMAC-sha3-224
0: 097615C6977516D579CA50AC3DDBEDDDA8A9EA75DD1456D93C426D61
1: C9794AAB2FD0E1E876B0967BA56469EE3470228B21AFB446F75DB0C0
2: 160F43A44A0D5AD957A97141C117B3CDE7079E2B093FBC2F7BFFB88C
@ -2118,7 +2118,7 @@ HMAC-sha3_224
255: CDDF05CF01FBAD632586BFB8C453021CBC44EAAF7EA155673CC4C110
256: 2E0A0B3D18D78CD2A8F21221C370057E2C2C98FE1AA75FF7381F5622
HMAC-sha3_256
HMAC-sha3-256
0: B3AD6507ABF79F2775C8724FF0659861665296472853A25E1ABD9CEE858A47A8
1: C4C1AC7AE45ED7AA1E6CCC92855E1E034357D4113E59F6F4C588E8A3C310DAA0
2: 91A1098068E71CFDB0F7058087D30C39DA45AF732D6DA46BAE30883043CCB803
@ -2377,7 +2377,7 @@ HMAC-sha3_256
255: 23F29724A5E3DF649EFA1E76E1F7315E4F1AB2B9F6DE9992A7DB3FAB62D19F10
256: 6BB2FF61EF113873D4CF3B131853F2469353A2B1D47FE80DE2FAF576C455212B
HMAC-sha3_384
HMAC-sha3-384
0: 676CD697B065FAAD4707FBB834A0FDA2D40625AE7ECA830E8EC4F37A200DAA5679825BDFF7AFE8FA1F31541D3E6751CF
1: D612288B7131DD6CD179E30BB8E7D22C90C60A9AB3D3DF0D36CA134C724D73755B45C432AE3CAD077368771F7442391D
2: 458CD8A7953C21794EF452522ACB3506F6276D453D2F73F39B26F531327D00E6A0ACD6FECE7275CF86DD9AC30E56BA2A
@ -2636,7 +2636,7 @@ HMAC-sha3_384
255: 2889B249B1941269219272B80770D48D8C6979ADA372DB1EA4C81099E33E6088DFC2DC90526824645D709E79860CCAE9
256: FD717F226A8CDBC52BC9F07BB8DE64F68A2B9C7EDDEAB862A31D2D37E49110254CC3F71091BAB53E988D8E143EC249A0
HMAC-sha3_512
HMAC-sha3-512
0: AA692ACEB6F1BF8F1289D248D78C43F4DEBF46A7CD64F94399E70A788BC60A712AEF1481CD71A431E26484F2C0D93ECD5283BBA8F03870BB3E3A65A1F4B14DE9
1: E01FAED8659C115933FD2CC4050B77C8D51DD79887DA05DFC33716AF581C8E206715D707FD51CC51D1750720B74E88DA39D5BD73736A5D03A968D6AA2BB8C273
2: 9D8246D2A869E8670E9BA80A7B07274AF7EDB693815EC9D6D256AB49746A18F798A46D79F5317DB4BCA94BD51CEEAE32807B0F586A99E106A4A692BE4D00FCD0

View File

@ -15,7 +15,7 @@
const struct ltc_hash_descriptor sha3_224_desc =
{
"sha3_224", /* name of hash */
"sha3-224", /* name of hash */
17, /* internal ID */
28, /* Size of digest in octets */
128, /* Input block size in octets */
@ -30,7 +30,7 @@ const struct ltc_hash_descriptor sha3_224_desc =
const struct ltc_hash_descriptor sha3_256_desc =
{
"sha3_256", /* name of hash */
"sha3-256", /* name of hash */
18, /* internal ID */
32, /* Size of digest in octets */
128, /* Input block size in octets */
@ -45,7 +45,7 @@ const struct ltc_hash_descriptor sha3_256_desc =
const struct ltc_hash_descriptor sha3_384_desc =
{
"sha3_384", /* name of hash */
"sha3-384", /* name of hash */
19, /* internal ID */
48, /* Size of digest in octets */
128, /* Input block size in octets */
@ -60,7 +60,7 @@ const struct ltc_hash_descriptor sha3_384_desc =
const struct ltc_hash_descriptor sha3_512_desc =
{
"sha3_512", /* name of hash */
"sha3-512", /* name of hash */
20, /* internal ID */
64, /* Size of digest in octets */
128, /* Input block size in octets */