Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/rsync-generation/
Date: Mon, 27 Nov 2017 13:07:10
Message-Id: 1511788015.192190568f7ef7b98695c88b20d92ef1e90b516b.grobian@gentoo
1 commit: 192190568f7ef7b98695c88b20d92ef1e90b516b
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 27 13:06:55 2017 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 27 13:06:55 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=19219056
7
8 hashgen: activate new hash set
9
10 scripts/rsync-generation/hashgen.c | 65 +++++++++++++++++++++++++++-----------
11 1 file changed, 47 insertions(+), 18 deletions(-)
12
13 diff --git a/scripts/rsync-generation/hashgen.c b/scripts/rsync-generation/hashgen.c
14 index fed99a3132..ddc52752b4 100644
15 --- a/scripts/rsync-generation/hashgen.c
16 +++ b/scripts/rsync-generation/hashgen.c
17 @@ -20,6 +20,15 @@
18 * ${CC} -o hashgen -fopenmp ${CFLAGS} -lssl -lcrypto -lb2 hashgen.c
19 */
20
21 +enum hash_impls {
22 + HASH_SHA256 = 1<<0,
23 + HASH_SHA512 = 1<<1,
24 + HASH_WHIRLPOOL = 1<<2,
25 + HASH_BLAKE2B = 1<<3
26 +};
27 +/* default changed from sha256, sha512, whirlpool to blake2b, sha512 */
28 +static int hashes = HASH_BLAKE2B | HASH_SHA512;
29 +
30 static inline void
31 hex_hash(char *out, const unsigned char *buf, const int length)
32 {
33 @@ -61,19 +70,23 @@ write_hashes(const char *root, const char *name, const char *type, FILE *m)
34 {
35 #pragma omp section
36 {
37 - SHA256_Update(&s256, data, len);
38 + if (hashes & HASH_SHA256)
39 + SHA256_Update(&s256, data, len);
40 }
41 #pragma omp section
42 {
43 - SHA512_Update(&s512, data, len);
44 + if (hashes & HASH_SHA512)
45 + SHA512_Update(&s512, data, len);
46 }
47 #pragma omp section
48 {
49 - WHIRLPOOL_Update(&whrl, data, len);
50 + if (hashes & HASH_WHIRLPOOL)
51 + WHIRLPOOL_Update(&whrl, data, len);
52 }
53 #pragma omp section
54 {
55 - blake2b_update(&bl2b, data, len);
56 + if (hashes & HASH_BLAKE2B)
57 + blake2b_update(&bl2b, data, len);
58 }
59 }
60 }
61 @@ -81,33 +94,49 @@ write_hashes(const char *root, const char *name, const char *type, FILE *m)
62 #pragma omp parallel sections
63 {
64 {
65 - unsigned char sha256buf[SHA256_DIGEST_LENGTH];
66 - SHA256_Final(sha256buf, &s256);
67 - hex_hash(sha256, sha256buf, SHA256_DIGEST_LENGTH);
68 + if (hashes & HASH_SHA256) {
69 + unsigned char sha256buf[SHA256_DIGEST_LENGTH];
70 + SHA256_Final(sha256buf, &s256);
71 + hex_hash(sha256, sha256buf, SHA256_DIGEST_LENGTH);
72 + }
73 }
74 #pragma omp section
75 {
76 - unsigned char sha512buf[SHA512_DIGEST_LENGTH];
77 - SHA512_Final(sha512buf, &s512);
78 - hex_hash(sha512, sha512buf, SHA512_DIGEST_LENGTH);
79 + if (hashes & HASH_SHA512) {
80 + unsigned char sha512buf[SHA512_DIGEST_LENGTH];
81 + SHA512_Final(sha512buf, &s512);
82 + hex_hash(sha512, sha512buf, SHA512_DIGEST_LENGTH);
83 + }
84 }
85 #pragma omp section
86 {
87 - unsigned char whrlplbuf[WHIRLPOOL_DIGEST_LENGTH];
88 - WHIRLPOOL_Final(whrlplbuf, &whrl);
89 - hex_hash(whrlpl, whrlplbuf, WHIRLPOOL_DIGEST_LENGTH);
90 + if (hashes & HASH_WHIRLPOOL) {
91 + unsigned char whrlplbuf[WHIRLPOOL_DIGEST_LENGTH];
92 + WHIRLPOOL_Final(whrlplbuf, &whrl);
93 + hex_hash(whrlpl, whrlplbuf, WHIRLPOOL_DIGEST_LENGTH);
94 + }
95 }
96 #pragma omp section
97 {
98 - unsigned char blak2bbuf[BLAKE2B_OUTBYTES];
99 - blake2b_final(&bl2b, blak2bbuf, BLAKE2B_OUTBYTES);
100 - hex_hash(blak2b, blak2bbuf, WHIRLPOOL_DIGEST_LENGTH);
101 + if (hashes & HASH_BLAKE2B) {
102 + unsigned char blak2bbuf[BLAKE2B_OUTBYTES];
103 + blake2b_final(&bl2b, blak2bbuf, BLAKE2B_OUTBYTES);
104 + hex_hash(blak2b, blak2bbuf, WHIRLPOOL_DIGEST_LENGTH);
105 + }
106 }
107 }
108 fclose(f);
109
110 - fprintf(m, "%s %s %zd SHA256 %s SHA512 %s WHIRLPOOL %s BLAKE2B %s\n",
111 - type, name, flen, sha256, sha512, whrlpl, blak2b);
112 + fprintf(m, "%s %s %zd",type, name, flen);
113 + if (hashes & HASH_BLAKE2B)
114 + fprintf(m, " BLAKE2B %s", blak2b);
115 + if (hashes & HASH_SHA256)
116 + fprintf(m, " SHA256 %s", sha256);
117 + if (hashes & HASH_SHA512)
118 + fprintf(m, " SHA512 %s", sha512);
119 + if (hashes & HASH_WHIRLPOOL)
120 + fprintf(m, " WHIRLPOOL %s", whrlpl);
121 + fprintf(m, "\n");
122 }
123
124 static char