sha3 1.0.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.clang-format +54 -0
- data/.document +4 -3
- data/.rdoc_options +10 -0
- data/.rspec +2 -2
- data/.rubocop.yml +5 -1
- data/CHANGELOG.md +23 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +154 -67
- data/Rakefile +9 -3
- data/certs/io+sha3@jsg.io.pem +26 -0
- data/doc/sha3.rb +81 -0
- data/ext/sha3/digest.c +635 -163
- data/ext/sha3/digest.h +71 -35
- data/ext/sha3/extconf.rb +42 -38
- data/ext/sha3/lib/high/Keccak/KeccakDuplex.c +81 -0
- data/ext/sha3/lib/high/Keccak/KeccakDuplex.h +73 -0
- data/ext/sha3/lib/high/Keccak/KeccakDuplex.inc +201 -0
- data/ext/sha3/lib/high/Keccak/KeccakSponge.c +2 -18
- data/ext/sha3/lib/high/Keccak/KeccakSponge.h +4 -10
- data/ext/sha3/lib/high/Keccak/KeccakSponge.inc +27 -31
- data/ext/sha3/lib/high/Keccak/PRG/KeccakPRG.c +61 -0
- data/ext/sha3/lib/high/Keccak/PRG/KeccakPRG.h +67 -0
- data/ext/sha3/lib/high/Keccak/PRG/KeccakPRG.inc +128 -0
- data/ext/sha3/lib/high/Keccak/SP800-185/SP800-185.c +93 -0
- data/ext/sha3/lib/high/Keccak/SP800-185/SP800-185.h +599 -0
- data/ext/sha3/lib/high/Keccak/SP800-185/SP800-185.inc +573 -0
- data/ext/sha3/lib/high/common/Phases.h +25 -0
- data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +19 -9
- data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +18 -12
- data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +28 -36
- data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +18 -12
- data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +28 -59
- data/ext/sha3/lib/low/common/PlSnP-Fallback.inc +291 -0
- data/ext/sha3/lib/low/common/SnP-Relaned.h +145 -0
- data/lib/sha3.rb +25 -28
- data.tar.gz.sig +0 -0
- metadata +55 -115
- metadata.gz.sig +0 -0
- data/.yardopts +0 -1
- data/ChangeLog.rdoc +0 -27
- data/certs/johanns.pem +0 -25
- data/ext/sha3/sha3.c +0 -62
- data/ext/sha3/sha3.h +0 -26
- data/lib/sha3/doc.rb +0 -121
- data/lib/sha3/version.rb +0 -9
- data/sha3.gemspec +0 -54
- data/tests.sh +0 -29
metadata
CHANGED
@@ -1,125 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sha3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johanns Gregorian
|
8
|
-
|
9
|
-
bindir: exe
|
8
|
+
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
12
11
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
+
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
12
|
+
MIIEYDCCAsigAwIBAgIBATANBgkqhkiG9w0BAQsFADA7MRAwDgYDVQQDDAdpb19z
|
13
|
+
aGEzMRMwEQYKCZImiZPyLGQBGRYDanNnMRIwEAYKCZImiZPyLGQBGRYCaW8wHhcN
|
14
|
+
MjUwMzAxMDYxMTE1WhcNMjYwMzAxMDYxMTE1WjA7MRAwDgYDVQQDDAdpb19zaGEz
|
15
|
+
MRMwEQYKCZImiZPyLGQBGRYDanNnMRIwEAYKCZImiZPyLGQBGRYCaW8wggGiMA0G
|
16
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDMdO1oUQ9FzXYtfFktOXDx6oIf9uSk
|
17
|
+
mg+yfo7uvcyNSa4gsF4+CY/TOYNBtwlD25AlgDqpxVCHFwUaBD+MHKyd8p6Eto1Q
|
18
|
+
Bwb7YrjPOXlmCKQYr5sFfbjeUfQRKBUTAhzM0W/5Zh9C4gkOyZ/7SaU6mI/M/LgQ
|
19
|
+
dZsw2y6l2bAl4aZaXgbnO7B1rPTPr6yQRZTveacmeTGHav1WACdE36Txqyv2QA7+
|
20
|
+
+VdYx04fOe2FEipan7d4TA4XKW+0Z+VWyoWFNyyxJtiT53PB10lztPiycBqZ+A3L
|
21
|
+
aA2VjZekn3NFbsXMOa4fbSTMddb784IWEeySmTMu6W/yYpo1B1PbgRaD/z2Zg0Qj
|
22
|
+
SZ2ldqqk68nvFVWqUlRbT8ZY6McKC1VEbNLLk7jNvdbgr/VPo4Zu5TP3FXjsPlpz
|
23
|
+
1duXTtAGtHjPnS+tdkSinKv4OmbTHid9gnoDcRjlNpWxoULs9iSNb6lOCUeBxvF6
|
24
|
+
4Eh7nyIPmaTDwPQtg5/RTvjZMqprS8D3tKsCAwEAAaNvMG0wCQYDVR0TBAIwADAL
|
25
|
+
BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFLCWxOjmn5qTuhjFG7fwiPXzSIlFMBkGA1Ud
|
26
|
+
EQQSMBCBDmlvK3NoYTNAanNnLmlvMBkGA1UdEgQSMBCBDmlvK3NoYTNAanNnLmlv
|
27
|
+
MA0GCSqGSIb3DQEBCwUAA4IBgQC4Y5pXxtopzHiSBsg6fuozv7zHXXuYXOL2Bq2x
|
28
|
+
l8C8lYjC2pN/Fh+FlgrJkqAoJ0wBlh3+wkhYPhSehkUy/2HaUYYTd1Zv4Odw+C/Q
|
29
|
+
rQnN5+nIv+gMrLwoBXH9sFjAp/iYKd4cDz5aUVNrPqibj8zivcSqFJ9lsyOvIZO6
|
30
|
+
tajU2HVxXOkpTtLzMgPEGdwlFEd2tB7VCGFbrTskxrpv243b0HdpeEVh2e9dNkl4
|
31
|
+
XobOvUPXHzFTDucYe8jpCn7e7Cj43PpTZFnxIRJnO8cVpX6n7UG8+JgBSqvwuv5C
|
32
|
+
YwFBqP6G2+0e0EdIIMdbCDBTmJbFyBr6y4pzED/FvEFzhAmCKOcZ6RJ8H7hkX5rh
|
33
|
+
+L4c9pHTemc2sQl7kH+mrntu7pt6D4EM4FD5eyWujQN1ME7xvLIFm5SczqCzFDfe
|
34
|
+
UjZtrp/rHLfHln46RvB+a1NlMRWxtJ7mQc/CMEbT+cpHlzuYa9qGakA4TmMpK10h
|
35
|
+
uYUv/V6CD4iTEMby0dopwHt5NqE=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date:
|
37
|
+
date: 2025-03-01 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
-
name:
|
40
|
+
name: rdoc
|
41
41
|
requirement: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
43
|
- - "~>"
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
46
|
-
type: :
|
45
|
+
version: '6.12'
|
46
|
+
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: rake-compiler
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '1.2'
|
60
|
-
type: :development
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.2'
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rspec
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '3.11'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '3.11'
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: rubocop
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '1.37'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- - "~>"
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '1.37'
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: rubocop-rake
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0.6'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '0.6'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: rubocop-rspec
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
112
|
-
requirements:
|
113
|
-
- - "~>"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '2.14'
|
116
|
-
type: :development
|
117
|
-
prerelease: false
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - "~>"
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: '2.14'
|
52
|
+
version: '6.12'
|
123
53
|
description: A XKCP based native (C) binding to SHA3 (FIPS 202) cryptographic hashing
|
124
54
|
algorithm.
|
125
55
|
email:
|
@@ -129,16 +59,18 @@ extensions:
|
|
129
59
|
- ext/sha3/extconf.rb
|
130
60
|
extra_rdoc_files: []
|
131
61
|
files:
|
62
|
+
- ".clang-format"
|
132
63
|
- ".document"
|
64
|
+
- ".rdoc_options"
|
133
65
|
- ".rspec"
|
134
66
|
- ".rubocop.yml"
|
135
|
-
-
|
136
|
-
- ChangeLog.rdoc
|
67
|
+
- CHANGELOG.md
|
137
68
|
- Gemfile
|
138
69
|
- LICENSE.txt
|
139
70
|
- README.md
|
140
71
|
- Rakefile
|
141
|
-
- certs/
|
72
|
+
- certs/io+sha3@jsg.io.pem
|
73
|
+
- doc/sha3.rb
|
142
74
|
- ext/sha3/config.h
|
143
75
|
- ext/sha3/digest.c
|
144
76
|
- ext/sha3/digest.h
|
@@ -147,9 +79,19 @@ files:
|
|
147
79
|
- ext/sha3/lib/common/brg_endian.h
|
148
80
|
- ext/sha3/lib/high/Keccak/FIPS202/KeccakHash.c
|
149
81
|
- ext/sha3/lib/high/Keccak/FIPS202/KeccakHash.h
|
82
|
+
- ext/sha3/lib/high/Keccak/KeccakDuplex.c
|
83
|
+
- ext/sha3/lib/high/Keccak/KeccakDuplex.h
|
84
|
+
- ext/sha3/lib/high/Keccak/KeccakDuplex.inc
|
150
85
|
- ext/sha3/lib/high/Keccak/KeccakSponge.c
|
151
86
|
- ext/sha3/lib/high/Keccak/KeccakSponge.h
|
152
87
|
- ext/sha3/lib/high/Keccak/KeccakSponge.inc
|
88
|
+
- ext/sha3/lib/high/Keccak/PRG/KeccakPRG.c
|
89
|
+
- ext/sha3/lib/high/Keccak/PRG/KeccakPRG.h
|
90
|
+
- ext/sha3/lib/high/Keccak/PRG/KeccakPRG.inc
|
91
|
+
- ext/sha3/lib/high/Keccak/SP800-185/SP800-185.c
|
92
|
+
- ext/sha3/lib/high/Keccak/SP800-185/SP800-185.h
|
93
|
+
- ext/sha3/lib/high/Keccak/SP800-185/SP800-185.inc
|
94
|
+
- ext/sha3/lib/high/common/Phases.h
|
153
95
|
- ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros
|
154
96
|
- ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros
|
155
97
|
- ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h
|
@@ -158,22 +100,21 @@ files:
|
|
158
100
|
- ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h
|
159
101
|
- ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c
|
160
102
|
- ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h
|
161
|
-
- ext/sha3/
|
162
|
-
- ext/sha3/
|
103
|
+
- ext/sha3/lib/low/common/PlSnP-Fallback.inc
|
104
|
+
- ext/sha3/lib/low/common/SnP-Relaned.h
|
163
105
|
- lib/sha3.rb
|
164
|
-
- lib/sha3/doc.rb
|
165
|
-
- lib/sha3/version.rb
|
166
|
-
- sha3.gemspec
|
167
|
-
- tests.sh
|
168
106
|
homepage: https://github.com/johanns/sha3
|
169
107
|
licenses:
|
170
108
|
- MIT
|
171
109
|
metadata:
|
172
110
|
changelog_uri: https://github.com/johanns/sha3/CHANGELOG.md
|
173
111
|
homepage_uri: https://github.com/johanns/sha3
|
174
|
-
|
112
|
+
documentation_uri: https://docs.jsg.io/sha3/html/index.html
|
175
113
|
rubygems_mfa_required: 'true'
|
176
|
-
post_install_message:
|
114
|
+
post_install_message: |2
|
115
|
+
[NOTICE] SHA3 version 2.0 introduces breaking changes to the API.
|
116
|
+
Please review the changelog and ensure compatibility with your application.
|
117
|
+
If you need the previous behavior, lock your Gemfile to version '~> 1.0'."
|
177
118
|
rdoc_options: []
|
178
119
|
require_paths:
|
179
120
|
- lib
|
@@ -181,15 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
122
|
requirements:
|
182
123
|
- - ">="
|
183
124
|
- !ruby/object:Gem::Version
|
184
|
-
version: 2.
|
125
|
+
version: 2.7.0
|
185
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
127
|
requirements:
|
187
128
|
- - ">="
|
188
129
|
- !ruby/object:Gem::Version
|
189
130
|
version: '0'
|
190
131
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
132
|
+
rubygems_version: 3.6.2
|
193
133
|
specification_version: 4
|
194
134
|
summary: SHA3 (FIPS 202) cryptographic hashing algorithm
|
195
135
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
lib/**/doc.rb lib/**/version.rb --markup rdoc --title "sha3 Documentation" --protected
|
data/ChangeLog.rdoc
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
=== 0.1.0 / 2012-10-04
|
2
|
-
|
3
|
-
* Initial release:
|
4
|
-
|
5
|
-
=== 0.1.1 / 2012-10-07
|
6
|
-
|
7
|
-
* Replaced Keccak reference code with optimized (~10x faster)
|
8
|
-
|
9
|
-
=== 0.2.0 / 2012-11-1
|
10
|
-
|
11
|
-
* SHA3::Digest: A proper ::Digest subclass.
|
12
|
-
|
13
|
-
=== 0.2.2 / 2012-12-14
|
14
|
-
|
15
|
-
* Added sub-class for each SHA3 supported bit-lengths (example: SHA3::Digest::SHA256). Minor bug fix.
|
16
|
-
|
17
|
-
=== 0.2.3 / 2013-1-28
|
18
|
-
|
19
|
-
* Added documentation file (decoupled form C source); refactored C source.
|
20
|
-
|
21
|
-
=== 0.2.4 / 2013-5-20
|
22
|
-
|
23
|
-
* Fixed instance copy validation code (YANKED)
|
24
|
-
|
25
|
-
=== 0.2.5 / 2013-5-21
|
26
|
-
|
27
|
-
* Fixed the fix to instance copy validation code.
|
data/certs/johanns.pem
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIETDCCArSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA2MQswCQYDVQQDDAJpbzET
|
3
|
-
MBEGCgmSJomT8ixkARkWA2pzZzESMBAGCgmSJomT8ixkARkWAmlvMB4XDTIyMTAy
|
4
|
-
NDA2MzcxMVoXDTIzMTAyNDA2MzcxMVowNjELMAkGA1UEAwwCaW8xEzARBgoJkiaJ
|
5
|
-
k/IsZAEZFgNqc2cxEjAQBgoJkiaJk/IsZAEZFgJpbzCCAaIwDQYJKoZIhvcNAQEB
|
6
|
-
BQADggGPADCCAYoCggGBALQTl5BGmtYGvljWwOTxe2Uul7RoBcSOwFUh03qUvHJf
|
7
|
-
1LmWr6y1j97ogl/VffBXpbtTU4adZa+qTxfMs7GpfKDjikSIieZ7SrMNB68zCH0e
|
8
|
-
undHx+bMutN7919rviHfGyaXlQK4SsuWUl4AOlgT69VPQp6dOBYY9T78jbr/ZcG6
|
9
|
-
+mDlRpNfPVg5i67euvpR5dO9SpO1HNoHmzx5L4wYNr9QykIft1oA+Ne+SAF66ykn
|
10
|
-
agugF/R0Q7s+5Bpt3gr6SF2CvKsNJ2IS5TJO9unhLZ+h8FO7dcQw1EuJ31uHQKiD
|
11
|
-
rWUv2tnKCvLkHg0S69VeQtQv58dklJ3iFJcSen4VRtC7r5JMEd1VrdpXU4JQ54gY
|
12
|
-
tWrqWmazF9SOErbgvDlJgmlkMMkX6aoZ21/f1s6Z2myzP3KkRBjCf51BrgHTXTJD
|
13
|
-
28ANp21H0o0HhrpVFJVDjToXRLczsw0O9lnL+khzkeZoc+YTZuvJDLKokavXhb4a
|
14
|
-
vESgRttXjyN5jBKY7yFhKQIDAQABo2UwYzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
15
|
-
sDAdBgNVHQ4EFgQUKmyX3Q2uwTPM9S5+K/5kg7qe3ugwFAYDVR0RBA0wC4EJaW9A
|
16
|
-
anNnLmlvMBQGA1UdEgQNMAuBCWlvQGpzZy5pbzANBgkqhkiG9w0BAQsFAAOCAYEA
|
17
|
-
TexWHx3uLVObT+ylm3OE8Iue3cHdrDVE3zSjo8VlU3u1WBznH9MdoiPB7wux61Zx
|
18
|
-
jXUzBUaT7y7JnDaVGnECkpHXhfvPOYHBgkqEws6i79lAk/Va2U7EVPj0moM9d4Hv
|
19
|
-
12V8YVM1Z9QnfwBVo7YGb5o7W8lr01jj1gT+Qcw+kln7M3Y9RB+jQ4DwySHVIEMc
|
20
|
-
Ow7//MF7bhCz6T5uAOXlGe88wTHKW+fO1AmW5MIQZUojR5Ioxm80v2YdW/JnQZ1l
|
21
|
-
3VFpCutilnhDuzSw3DhgxReX7AK42aXFFclIzi11twW4KUPdt1KIvaoL/DgbZivl
|
22
|
-
PVG86dx4gfax2Mc2PiM+d1DiSllh+chh4dqRkIyhj0S4V7McQHkwW1ZBJ3kDf5rt
|
23
|
-
1O/udKquzj7egb6uceqzBB40W/1/CsNkGNpNZ8Bk8lrTmKw+3bJpj+nKWxovmF2p
|
24
|
-
VhzZDQf2jkcjBXKNA9Z5ku7g0TCR1/Y1V3ODgkTLqhw+kQZmlbQEVzcwxGk9eL8z
|
25
|
-
-----END CERTIFICATE-----
|
data/ext/sha3/sha3.c
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2012 - 2013 Johanns Gregorian <io+sha3@jsani.com> */
|
2
|
-
|
3
|
-
#include "sha3.h"
|
4
|
-
|
5
|
-
VALUE mSHA3;
|
6
|
-
VALUE eSHA3Error;
|
7
|
-
|
8
|
-
int get_hlen(VALUE obj)
|
9
|
-
{
|
10
|
-
int hlen;
|
11
|
-
|
12
|
-
if (TYPE(obj) == T_SYMBOL)
|
13
|
-
{
|
14
|
-
ID symid;
|
15
|
-
|
16
|
-
symid = SYM2ID(obj);
|
17
|
-
|
18
|
-
if (rb_intern("sha224") == symid)
|
19
|
-
{
|
20
|
-
hlen = 224;
|
21
|
-
}
|
22
|
-
else if (rb_intern("sha256") == symid)
|
23
|
-
{
|
24
|
-
hlen = 256;
|
25
|
-
}
|
26
|
-
else if (rb_intern("sha384") == symid)
|
27
|
-
{
|
28
|
-
hlen = 384;
|
29
|
-
}
|
30
|
-
else if (rb_intern("sha512") == symid)
|
31
|
-
{
|
32
|
-
hlen = 512;
|
33
|
-
}
|
34
|
-
else
|
35
|
-
{
|
36
|
-
rb_raise(eSHA3Error, "invalid hash bit symbol (should be: :sha224, :sha256, :sha384, or :sha512");
|
37
|
-
}
|
38
|
-
}
|
39
|
-
else if (TYPE(obj) == T_FIXNUM)
|
40
|
-
{
|
41
|
-
hlen = NUM2INT(obj);
|
42
|
-
|
43
|
-
if ((hlen != 224) && (hlen != 256) && (hlen != 384) && (hlen != 512))
|
44
|
-
{
|
45
|
-
rb_raise(rb_eArgError, "invalid hash bit length (should be: 224, 256, 384, or 512)");
|
46
|
-
}
|
47
|
-
}
|
48
|
-
else
|
49
|
-
{
|
50
|
-
rb_raise(eSHA3Error, "unknown type value");
|
51
|
-
}
|
52
|
-
|
53
|
-
return hlen;
|
54
|
-
}
|
55
|
-
|
56
|
-
void Init_sha3_n()
|
57
|
-
{
|
58
|
-
mSHA3 = rb_define_module("SHA3");
|
59
|
-
eSHA3Error = rb_define_class_under(mSHA3, "SHA3Error", rb_eStandardError);
|
60
|
-
|
61
|
-
Init_sha3_n_digest();
|
62
|
-
}
|
data/ext/sha3/sha3.h
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2012 - 2013 Johanns Gregorian <io+sha3@jsani.com> */
|
2
|
-
|
3
|
-
#ifndef _SHA3_H_
|
4
|
-
#define _SHA3_H_
|
5
|
-
|
6
|
-
#include <ruby.h>
|
7
|
-
|
8
|
-
#include "KeccakHash.h"
|
9
|
-
#include "digest.h"
|
10
|
-
|
11
|
-
#ifdef __cplusplus
|
12
|
-
extern "C"
|
13
|
-
{
|
14
|
-
#endif
|
15
|
-
|
16
|
-
extern VALUE mSHA3;
|
17
|
-
extern VALUE eSHA3Error;
|
18
|
-
|
19
|
-
int get_hlen(VALUE);
|
20
|
-
void Init_sha3_n(void);
|
21
|
-
|
22
|
-
#ifdef __cplusplus
|
23
|
-
}
|
24
|
-
#endif
|
25
|
-
|
26
|
-
#endif
|
data/lib/sha3/doc.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'digest'
|
4
|
-
|
5
|
-
module SHA3
|
6
|
-
# A sub-class of (MRI Ruby based) Digest::Class, it implements SHA3 (Keccak) digest algorithm.
|
7
|
-
#
|
8
|
-
# @note SHA3::Digest class provides a four sub-classes for the available hash bit lengths (types).
|
9
|
-
# You can instantiate a new instance of Digest sub-class for a given type using the following sub-classes:
|
10
|
-
#
|
11
|
-
# SHA3::Digest::SHA224([data])
|
12
|
-
# SHA3::Digest::SHA256([data])
|
13
|
-
# SHA3::Digest::SHA384([data])
|
14
|
-
# SHA3::Digest::SHA512([data])
|
15
|
-
#
|
16
|
-
# The [data] parameter is optional.
|
17
|
-
class Digest < Digest::Class
|
18
|
-
# Creates a Digest instance based on given hash bit length (type).
|
19
|
-
#
|
20
|
-
# @param type [Number, Symbol] optional parameter used to set hash bit length (type).
|
21
|
-
# Valid options are:
|
22
|
-
#
|
23
|
-
# Number: 224, 256, 384, or 512
|
24
|
-
# Symobols: :sha224, :sha256, :sha384, or :sha512
|
25
|
-
#
|
26
|
-
# Default value: 256 (bits)
|
27
|
-
# @param data [String] optional parameter used to update initial instance state.
|
28
|
-
# #
|
29
|
-
# @return [Digest] self
|
30
|
-
#
|
31
|
-
# @example
|
32
|
-
# digest = SHA3::Digest.new # => Defaults to 256 bits
|
33
|
-
# digest = SHA3::Digest.new(224) # => Initialize a new 224 bit digest instance
|
34
|
-
# digest = SHA3::Digest::SHA224 # => An alternate method for creating a digest class with 224 bit hash bit length
|
35
|
-
def initialize(type, data)
|
36
|
-
# See function: c_digest_init(...) in ext/sha3/_digest.c
|
37
|
-
end
|
38
|
-
|
39
|
-
# Updates, and recalculates Message Digest (state) with given data. If a message digest
|
40
|
-
# is to be computed from several subsequent sources, then each may be passed individually
|
41
|
-
# to the Digest instance.
|
42
|
-
#
|
43
|
-
# @param data [String] data to compute
|
44
|
-
#
|
45
|
-
# @return [Digest] self
|
46
|
-
#
|
47
|
-
# @example
|
48
|
-
# digest = SHA3::Digest::SHA256.new
|
49
|
-
# digest.update('hash me')
|
50
|
-
# digest.update('me too')
|
51
|
-
def update(data)
|
52
|
-
# See function: c_digest_update(...) in ext/sha3/_digest.c
|
53
|
-
end
|
54
|
-
|
55
|
-
# Alias for update method
|
56
|
-
alias << :update
|
57
|
-
|
58
|
-
# Resets the Digest object to initial state, abandoning computed data.
|
59
|
-
#
|
60
|
-
# @return [Digest] self
|
61
|
-
def reset
|
62
|
-
# See function: c_digest_reset(...) in ext/sha3/_digest.c
|
63
|
-
end
|
64
|
-
|
65
|
-
# Returns message digest length in bytes.
|
66
|
-
#
|
67
|
-
# @return [Number] message length in bytes.
|
68
|
-
#
|
69
|
-
# @example
|
70
|
-
# digest = SHA3::Digest::SHA256.new
|
71
|
-
# digest.length # Result => 32 (or 256 bits)
|
72
|
-
def length
|
73
|
-
# See function: c_digest_length(...) in ext/sha3/_digest.c
|
74
|
-
end
|
75
|
-
|
76
|
-
# Returns digest block length in bytes.
|
77
|
-
#
|
78
|
-
# @return [Number] digest block length in bytes.
|
79
|
-
#
|
80
|
-
# @example
|
81
|
-
# digest = SHA3::Digest::SHA384.new
|
82
|
-
# digest.block_length # Result => 104
|
83
|
-
def block_length
|
84
|
-
# See function: c_digest_block_length(...) in ext/sha3/_digest.c
|
85
|
-
end
|
86
|
-
|
87
|
-
# Returns name of initialized digest
|
88
|
-
#
|
89
|
-
# @return [String] name
|
90
|
-
def name
|
91
|
-
# See function: c_digest_name(...) in ext/sha3/_digest.c
|
92
|
-
end
|
93
|
-
|
94
|
-
# Returns computed hash value for given hash type, and data in hex (string).
|
95
|
-
#
|
96
|
-
# @param type [Number, Symbol] See {#initialize} for valid type values.
|
97
|
-
# @param data [String] data to compute hash value
|
98
|
-
#
|
99
|
-
# @return (String) computed hash as hex-encoded string
|
100
|
-
#
|
101
|
-
# @example
|
102
|
-
# SHA3::Digest.hexdigest(256, 'compute me, please')
|
103
|
-
# SHA3::Digest::SHA256.hexdigest('compute me, please') # => Alternate syntax
|
104
|
-
def self.hexdigest(type, data); end
|
105
|
-
|
106
|
-
# Returns computed hash value for given hash type, and data in bytes.
|
107
|
-
#
|
108
|
-
# @param type [Number, Symbol] See {#initialize} for valid type values.
|
109
|
-
# @param data [String] data to compute hash value
|
110
|
-
#
|
111
|
-
# @return [String] computed hash in bytes
|
112
|
-
#
|
113
|
-
# @example
|
114
|
-
# SHA3::Digest.digest(256, 'compute me, please')
|
115
|
-
# SHA3::Digest::SHA256.digest('compute me, please') # => Alternate syntax
|
116
|
-
def self.digest(type, data); end
|
117
|
-
end
|
118
|
-
|
119
|
-
class DigestError < StandardError
|
120
|
-
end
|
121
|
-
end
|
data/lib/sha3/version.rb
DELETED
data/sha3.gemspec
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/sha3/version'
|
4
|
-
|
5
|
-
# rubocop:disable Metrics/BlockLength(Rubocop)
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'sha3'
|
8
|
-
spec.version = SHA3::VERSION
|
9
|
-
|
10
|
-
spec.authors = ['Johanns Gregorian']
|
11
|
-
spec.email = ['io+sha3@jsg.io']
|
12
|
-
|
13
|
-
spec.description = 'A XKCP based native (C) binding to SHA3 (FIPS 202) cryptographic hashing algorithm.'
|
14
|
-
spec.summary = 'SHA3 (FIPS 202) cryptographic hashing algorithm'
|
15
|
-
|
16
|
-
spec.homepage = 'https://github.com/johanns/sha3'
|
17
|
-
spec.license = 'MIT'
|
18
|
-
spec.required_ruby_version = '>= 2.6.0'
|
19
|
-
|
20
|
-
spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
|
21
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
-
spec.metadata['source_code_uri'] = spec.homepage
|
23
|
-
|
24
|
-
# Specify which files should be added to the gem when it is released.
|
25
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
spec.bindir = 'exe'
|
33
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
-
spec.extensions = ['ext/sha3/extconf.rb']
|
35
|
-
spec.require_paths = ['lib']
|
36
|
-
|
37
|
-
# Uncomment to register a new dependency of your gem
|
38
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
39
|
-
|
40
|
-
# For more information and examples about making a new gem, check out our
|
41
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
-
spec.metadata['rubygems_mfa_required'] = 'true'
|
43
|
-
|
44
|
-
spec.add_development_dependency('rake', '~> 13.0')
|
45
|
-
spec.add_development_dependency('rake-compiler', '~> 1.2')
|
46
|
-
spec.add_development_dependency('rspec', '~> 3.11')
|
47
|
-
spec.add_development_dependency('rubocop', '~> 1.37')
|
48
|
-
spec.add_development_dependency('rubocop-rake', '~> 0.6')
|
49
|
-
spec.add_development_dependency('rubocop-rspec', '~> 2.14')
|
50
|
-
|
51
|
-
spec.cert_chain = ['certs/johanns.pem']
|
52
|
-
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
|
53
|
-
end
|
54
|
-
# rubocop:enable Metrics/BlockLength(Rubocop)
|
data/tests.sh
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
rm -fv spec/sha3_compute*.rb
|
4
|
-
rm -fv spec/sha3_digest*.rb
|
5
|
-
|
6
|
-
if [ -d "spec/data" ]
|
7
|
-
then
|
8
|
-
rm -rfv spec/data/*
|
9
|
-
else
|
10
|
-
mkdir "spec/data"
|
11
|
-
fi
|
12
|
-
|
13
|
-
pushd "spec/data"
|
14
|
-
if [ -f "*.txt" ]
|
15
|
-
then
|
16
|
-
rm -v *.txt
|
17
|
-
fi
|
18
|
-
|
19
|
-
curl "https://raw.githubusercontent.com/XKCP/XKCP/master/tests/TestVectors/ShortMsgKAT_SHA3-224.txt" > ShortMsgKAT_SHA3-224.txt
|
20
|
-
curl "https://raw.githubusercontent.com/XKCP/XKCP/master/tests/TestVectors/ShortMsgKAT_SHA3-256.txt" > ShortMsgKAT_SHA3-256.txt
|
21
|
-
curl "https://raw.githubusercontent.com/XKCP/XKCP/master/tests/TestVectors/ShortMsgKAT_SHA3-384.txt" > ShortMsgKAT_SHA3-384.txt
|
22
|
-
curl "https://raw.githubusercontent.com/XKCP/XKCP/master/tests/TestVectors/ShortMsgKAT_SHA3-512.txt" > ShortMsgKAT_SHA3-512.txt
|
23
|
-
popd
|
24
|
-
|
25
|
-
pushd spec
|
26
|
-
ruby generate_tests.rb
|
27
|
-
popd
|
28
|
-
|
29
|
-
rake
|