diff options
| author | 2026-04-02 06:23:30 +0000 | |
|---|---|---|
| committer | 2026-04-02 06:28:39 +0000 | |
| commit | a041d523de389b65b98a5373a8034041db2a8d83 (patch) | |
| tree | 7b423dc735f463be616045f2c3c2095a7737aca7 /object/id/algorithm_tables.go | |
| parent | research: Add dynamic pack resources (diff) | |
| signature | No signature | |
*: Remove
Diffstat (limited to 'object/id/algorithm_tables.go')
| -rw-r--r-- | object/id/algorithm_tables.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/object/id/algorithm_tables.go b/object/id/algorithm_tables.go deleted file mode 100644 index e4ec3257..00000000 --- a/object/id/algorithm_tables.go +++ /dev/null @@ -1,72 +0,0 @@ -package objectid - -import ( - "crypto/sha1" //#nosec:G505 - "crypto/sha256" -) - -//nolint:gochecknoglobals -var algorithmTable = [...]algorithmDetails{ - AlgorithmUnknown: {}, - AlgorithmSHA1: { - name: "sha1", - size: sha1.Size, - packHashID: 1, - signatureHeaderName: "gpgsig", - sum: func(data []byte) ObjectID { - sum := sha1.Sum(data) //#nosec G401 - - var id ObjectID - copy(id.data[:], sum[:]) - id.algo = AlgorithmSHA1 - - return id - }, - new: sha1.New, - }, - AlgorithmSHA256: { - name: "sha256", - size: sha256.Size, - packHashID: 2, - signatureHeaderName: "gpgsig-sha256", - sum: func(data []byte) ObjectID { - sum := sha256.Sum256(data) - - var id ObjectID - copy(id.data[:], sum[:]) - id.algo = AlgorithmSHA256 - - return id - }, - new: sha256.New, - }, -} - -var ( - //nolint:gochecknoglobals - algorithmByName = map[string]Algorithm{} - //nolint:gochecknoglobals - algorithmBySignatureHeaderName = map[string]Algorithm{} - //nolint:gochecknoglobals - supportedAlgorithms []Algorithm -) - -func init() { //nolint:gochecknoinits - emptyTreeInput := []byte("tree 0\x00") - - for algo := Algorithm(0); int(algo) < len(algorithmTable); algo++ { - info := &algorithmTable[algo] - if info.name == "" { - continue - } - - info.emptyTree = info.sum(emptyTreeInput) - - algorithmByName[info.name] = algo - if info.signatureHeaderName != "" { - algorithmBySignatureHeaderName[info.signatureHeaderName] = algo - } - - supportedAlgorithms = append(supportedAlgorithms, algo) - } -} |
