Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: Refactor for clarity and performance #34

Merged
merged 4 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.19.x]
go-version: [1.20.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Run fuzzers
env:
FUZZ_TIME: 30m
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x]
platform: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.platform }}
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Run benchmarks
run: make bench
- name: Run fuzzers
Expand Down
38 changes: 38 additions & 0 deletions internal/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package shared

const (
// Constants for the SHA-1 hash function.
K0 = 0x5A827999
K1 = 0x6ED9EBA1
K2 = 0x8F1BBCDC
K3 = 0xCA62C1D6

// Initial values for the buffer variables: h0, h1, h2, h3, h4.
Init0 = 0x67452301
Init1 = 0xEFCDAB89
Init2 = 0x98BADCFE
Init3 = 0x10325476
Init4 = 0xC3D2E1F0

// Initial values for the temporary variables (ihvtmp0, ihvtmp1, ihvtmp2, ihvtmp3, ihvtmp4) during the SHA recompression step.
InitTmp0 = 0xD5
InitTmp1 = 0x394
InitTmp2 = 0x8152A8
InitTmp3 = 0x0
InitTmp4 = 0xA7ECE0

// SHA1 contains 2 buffers, each based off 5 32-bit words.
WordBuffers = 5

// The output of SHA1 is 20 bytes (160 bits).
Size = 20

// Rounds represents the number of steps required to process each chunk.
Rounds = 80

// SHA1 processes the input data in chunks. Each chunk contains 64 bytes.
Chunk = 64

Magic = "shacd\x01"
MarshaledSize = len(Magic) + 5*4 + Chunk + 8
)
Loading