Skip to content

Commit 3b4a158

Browse files
authored
Merge pull request #34 from pjbgf/generic-opts
go: Refactor for clarity and performance
2 parents e79c2ef + 73b0ccd commit 3b4a158

15 files changed

+223
-222
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
go-version: [1.19.x]
21+
go-version: [1.20.x]
2222
platform: [ubuntu-latest]
2323

2424
runs-on: ${{ matrix.platform }}

.github/workflows/nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Go
1919
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
2020
with:
21-
go-version: 1.19.x
21+
go-version: 1.20.x
2222
- name: Run fuzzers
2323
env:
2424
FUZZ_TIME: 30m

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
24+
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x]
2525
platform: [ubuntu-latest, macos-latest, windows-latest]
2626

2727
runs-on: ${{ matrix.platform }}
@@ -43,7 +43,7 @@ jobs:
4343
- name: Setup Go
4444
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
4545
with:
46-
go-version: 1.19.x
46+
go-version: 1.20.x
4747
- name: Run benchmarks
4848
run: make bench
4949
- name: Run fuzzers

internal/const.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package shared
2+
3+
const (
4+
// Constants for the SHA-1 hash function.
5+
K0 = 0x5A827999
6+
K1 = 0x6ED9EBA1
7+
K2 = 0x8F1BBCDC
8+
K3 = 0xCA62C1D6
9+
10+
// Initial values for the buffer variables: h0, h1, h2, h3, h4.
11+
Init0 = 0x67452301
12+
Init1 = 0xEFCDAB89
13+
Init2 = 0x98BADCFE
14+
Init3 = 0x10325476
15+
Init4 = 0xC3D2E1F0
16+
17+
// Initial values for the temporary variables (ihvtmp0, ihvtmp1, ihvtmp2, ihvtmp3, ihvtmp4) during the SHA recompression step.
18+
InitTmp0 = 0xD5
19+
InitTmp1 = 0x394
20+
InitTmp2 = 0x8152A8
21+
InitTmp3 = 0x0
22+
InitTmp4 = 0xA7ECE0
23+
24+
// SHA1 contains 2 buffers, each based off 5 32-bit words.
25+
WordBuffers = 5
26+
27+
// The output of SHA1 is 20 bytes (160 bits).
28+
Size = 20
29+
30+
// Rounds represents the number of steps required to process each chunk.
31+
Rounds = 80
32+
33+
// SHA1 processes the input data in chunks. Each chunk contains 64 bytes.
34+
Chunk = 64
35+
36+
Magic = "shacd\x01"
37+
MarshaledSize = len(Magic) + 5*4 + Chunk + 8
38+
)

0 commit comments

Comments
 (0)