sha3 0.2.2 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sha3 might be problematic. Click here for more details.

Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +232 -17
  3. data/.travis.yml +21 -12
  4. data/.yardopts +1 -1
  5. data/ChangeLog.rdoc +16 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.ci +5 -5
  8. data/LICENSE.txt +1 -1
  9. data/README.md +120 -0
  10. data/Rakefile +15 -18
  11. data/ext/sha3/KeccakF-1600-interface.h +28 -34
  12. data/ext/sha3/KeccakHash.c +80 -0
  13. data/ext/sha3/KeccakHash.h +110 -0
  14. data/ext/sha3/KeccakSponge.c +127 -201
  15. data/ext/sha3/KeccakSponge.h +74 -37
  16. data/ext/sha3/Optimized64/KeccakF-1600-64.macros +2199 -0
  17. data/ext/sha3/Optimized64/KeccakF-1600-opt64-settings.h +3 -0
  18. data/ext/sha3/Optimized64/KeccakF-1600-opt64.c +508 -0
  19. data/ext/sha3/{KeccakF-1600-unrolling.macros → Optimized64/KeccakF-1600-unrolling.macros} +16 -14
  20. data/ext/sha3/Optimized64/SnP-interface.h +47 -0
  21. data/ext/sha3/Reference/KeccakF-1600-reference.c +311 -0
  22. data/ext/sha3/Reference/KeccakF-reference.h +26 -0
  23. data/ext/sha3/Reference/SnP-FBWL-default.c +96 -0
  24. data/ext/sha3/Reference/SnP-FBWL-default.h +26 -0
  25. data/ext/sha3/Reference/SnP-interface.h +42 -0
  26. data/ext/sha3/{displayIntermediateValues.c → Reference/displayIntermediateValues.c} +52 -11
  27. data/ext/sha3/{displayIntermediateValues.h → Reference/displayIntermediateValues.h} +11 -6
  28. data/ext/sha3/SnP-Relaned.h +249 -0
  29. data/ext/sha3/brg_endian.h +0 -0
  30. data/ext/sha3/digest.c +270 -0
  31. data/ext/sha3/digest.h +48 -0
  32. data/ext/sha3/extconf.rb +16 -9
  33. data/ext/sha3/sha3.c +62 -0
  34. data/ext/sha3/sha3.h +26 -0
  35. data/lib/sha3.rb +1 -1
  36. data/lib/sha3/doc.rb +121 -0
  37. data/lib/sha3/version.rb +6 -5
  38. data/sha3.gemspec +13 -15
  39. data/spec/generate_tests.rb +22 -56
  40. data/spec/sha3_core_spec.rb +113 -133
  41. data/spec/spec_helper.rb +2 -2
  42. data/tests.sh +11 -9
  43. metadata +53 -65
  44. data/README.rdoc +0 -133
  45. data/ext/sha3/KeccakF-1600-32-rvk.macros +0 -555
  46. data/ext/sha3/KeccakF-1600-32-s1.macros +0 -1187
  47. data/ext/sha3/KeccakF-1600-32-s2.macros +0 -1187
  48. data/ext/sha3/KeccakF-1600-32.macros +0 -26
  49. data/ext/sha3/KeccakF-1600-64.macros +0 -728
  50. data/ext/sha3/KeccakF-1600-int-set.h +0 -6
  51. data/ext/sha3/KeccakF-1600-opt.c +0 -504
  52. data/ext/sha3/KeccakF-1600-opt32-settings.h +0 -4
  53. data/ext/sha3/KeccakF-1600-opt32.c-arch +0 -524
  54. data/ext/sha3/KeccakF-1600-opt64-settings.h +0 -7
  55. data/ext/sha3/KeccakF-1600-opt64.c-arch +0 -504
  56. data/ext/sha3/KeccakF-1600-reference.c-arch +0 -300
  57. data/ext/sha3/KeccakF-1600-x86-64-gas.s +0 -766
  58. data/ext/sha3/KeccakF-1600-x86-64-shld-gas.s +0 -766
  59. data/ext/sha3/KeccakNISTInterface.c +0 -81
  60. data/ext/sha3/KeccakNISTInterface.h +0 -70
  61. data/ext/sha3/_sha3.c +0 -309
  62. data/ext/sha3/_sha3.h +0 -32
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a4ff3a34d0d9bce72c2ccbfb6a8ad81d9107f538ad2635cab15274c8661dcb71
4
+ data.tar.gz: 8fdab8312082afb9783faf1f9ec2136c5e8812a482fc1a6f0afded96cc9d64a8
5
+ SHA512:
6
+ metadata.gz: e7a38d0f89905ad6f90fdcc4a29ad245aa5f82edfed8b227485623ad05bb591c9cf5493e93c9a93119197b801ef68217c5d165b61a27c9a66ad175343ab89f1e
7
+ data.tar.gz: 497c72e85ad814301adbb4f71c11f53e1434b9b660e70847eb0939bf30faa883d73215740cd425048978b9c1e71c8f2917eed1819a5ed15b12e74076253190a0
data/.gitignore CHANGED
@@ -1,19 +1,234 @@
1
+
2
+ # Created by https://www.toptal.com/developers/gitignore/api/c,clion,visualstudiocode,ruby
3
+ # Edit at https://www.toptal.com/developers/gitignore?templates=c,clion,visualstudiocode,ruby
4
+
5
+ ### C ###
6
+ # Prerequisites
7
+ *.d
8
+
9
+ # Object files
10
+ *.o
11
+ *.ko
12
+ *.obj
13
+ *.elf
14
+
15
+ # Linker output
16
+ *.ilk
17
+ *.map
18
+ *.exp
19
+
20
+ # Precompiled Headers
21
+ *.gch
22
+ *.pch
23
+
24
+ # Libraries
25
+ *.lib
26
+ *.a
27
+ *.la
28
+ *.lo
29
+
30
+ # Shared objects (inc. Windows DLLs)
31
+ *.dll
32
+ *.so
33
+ *.so.*
34
+ *.dylib
35
+
36
+ # Executables
37
+ *.exe
38
+ *.out
39
+ *.app
40
+ *.i*86
41
+ *.x86_64
42
+ *.hex
43
+
44
+ # Debug files
45
+ *.dSYM/
46
+ *.su
47
+ *.idb
48
+ *.pdb
49
+
50
+ # Kernel Module Compile Results
51
+ *.mod*
52
+ *.cmd
53
+ .tmp_versions/
54
+ modules.order
55
+ Module.symvers
56
+ Mkfile.old
57
+ dkms.conf
58
+
59
+ ### CLion ###
60
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
61
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
62
+
63
+ # User-specific stuff
64
+ .idea/**/workspace.xml
65
+ .idea/**/tasks.xml
66
+ .idea/**/usage.statistics.xml
67
+ .idea/**/dictionaries
68
+ .idea/**/shelf
69
+
70
+ # Generated files
71
+ .idea/**/contentModel.xml
72
+
73
+ # Sensitive or high-churn files
74
+ .idea/**/dataSources/
75
+ .idea/**/dataSources.ids
76
+ .idea/**/dataSources.local.xml
77
+ .idea/**/sqlDataSources.xml
78
+ .idea/**/dynamic.xml
79
+ .idea/**/uiDesigner.xml
80
+ .idea/**/dbnavigator.xml
81
+
82
+ # Gradle
83
+ .idea/**/gradle.xml
84
+ .idea/**/libraries
85
+
86
+ # Gradle and Maven with auto-import
87
+ # When using Gradle or Maven with auto-import, you should exclude module files,
88
+ # since they will be recreated, and may cause churn. Uncomment if using
89
+ # auto-import.
90
+ # .idea/artifacts
91
+ # .idea/compiler.xml
92
+ # .idea/jarRepositories.xml
93
+ # .idea/modules.xml
94
+ # .idea/*.iml
95
+ # .idea/modules
96
+ # *.iml
97
+ # *.ipr
98
+
99
+ # CMake
100
+ cmake-build-*/
101
+
102
+ # Mongo Explorer plugin
103
+ .idea/**/mongoSettings.xml
104
+
105
+ # File-based project format
106
+ *.iws
107
+
108
+ # IntelliJ
109
+ out/
110
+
111
+ # mpeltonen/sbt-idea plugin
112
+ .idea_modules/
113
+
114
+ # JIRA plugin
115
+ atlassian-ide-plugin.xml
116
+
117
+ # Cursive Clojure plugin
118
+ .idea/replstate.xml
119
+
120
+ # Crashlytics plugin (for Android Studio and IntelliJ)
121
+ com_crashlytics_export_strings.xml
122
+ crashlytics.properties
123
+ crashlytics-build.properties
124
+ fabric.properties
125
+
126
+ # Editor-based Rest Client
127
+ .idea/httpRequests
128
+
129
+ # Android studio 3.1+ serialized cache file
130
+ .idea/caches/build_file_checksums.ser
131
+
132
+ ### CLion Patch ###
133
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
134
+
135
+ # *.iml
136
+ # modules.xml
137
+ # .idea/misc.xml
138
+ # *.ipr
139
+
140
+ # Sonarlint plugin
141
+ # https://plugins.jetbrains.com/plugin/7973-sonarlint
142
+ .idea/**/sonarlint/
143
+
144
+ # SonarQube Plugin
145
+ # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
146
+ .idea/**/sonarIssues.xml
147
+
148
+ # Markdown Navigator plugin
149
+ # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
150
+ .idea/**/markdown-navigator.xml
151
+ .idea/**/markdown-navigator-enh.xml
152
+ .idea/**/markdown-navigator/
153
+
154
+ # Cache file creation bug
155
+ # See https://youtrack.jetbrains.com/issue/JBR-2257
156
+ .idea/$CACHE_FILE$
157
+
158
+ # CodeStream plugin
159
+ # https://plugins.jetbrains.com/plugin/12206-codestream
160
+ .idea/codestream.xml
161
+
162
+ ### Ruby ###
1
163
  *.gem
2
164
  *.rbc
3
- *.rbx
4
- .bundle
5
- .config
6
- coverage
7
- InstalledFiles
8
- lib/bundler/man
9
- pkg
10
- rdoc
11
- spec/reports
12
- test/tmp
13
- test/version_tmp
14
- tmp
15
-
16
- # YARD artifacts
17
- .yardoc
18
- _yardoc
19
- doc/
165
+ /.config
166
+ /coverage/
167
+ /InstalledFiles
168
+ /pkg/
169
+ /spec/reports/
170
+ /spec/examples.txt
171
+ /test/tmp/
172
+ /test/version_tmp/
173
+ /tmp/
174
+
175
+ # Used by dotenv library to load environment variables.
176
+ # .env
177
+
178
+ # Ignore Byebug command history file.
179
+ .byebug_history
180
+
181
+ ## Specific to RubyMotion:
182
+ .dat*
183
+ .repl_history
184
+ build/
185
+ *.bridgesupport
186
+ build-iPhoneOS/
187
+ build-iPhoneSimulator/
188
+
189
+ ## Specific to RubyMotion (use of CocoaPods):
190
+ #
191
+ # We recommend against adding the Pods directory to your .gitignore. However
192
+ # you should judge for yourself, the pros and cons are mentioned at:
193
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
194
+ # vendor/Pods/
195
+
196
+ ## Documentation cache and generated files:
197
+ /.yardoc/
198
+ /_yardoc/
199
+ /doc/
200
+ /rdoc/
201
+
202
+ ## Environment normalization:
203
+ /.bundle/
204
+ /vendor/bundle
205
+ /lib/bundler/man/
206
+
207
+ # for a library or gem, you might want to ignore these files since the code is
208
+ # intended to run in multiple environments; otherwise, check them in:
209
+ # Gemfile.lock
210
+ # .ruby-version
211
+ # .ruby-gemset
212
+
213
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
214
+ .rvmrc
215
+
216
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
217
+ # .rubocop-https?--*
218
+
219
+ ### Ruby Patch ###
220
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
221
+ # .rubocop-https?--*
222
+
223
+ ### VisualStudioCode ###
224
+ .vscode/*
225
+ !.vscode/tasks.json
226
+ !.vscode/launch.json
227
+ *.code-workspace
228
+
229
+ ### VisualStudioCode Patch ###
230
+ # Ignore all local history of files
231
+ .history
232
+ .ionide
233
+
234
+ # End of https://www.toptal.com/developers/gitignore/api/c,clion,visualstudiocode,ruby
@@ -1,15 +1,24 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 1.9.2
5
- - 1.8.7
6
- - ruby-head
7
- - rbx-18mode
8
- - rbx-19mode
9
- - ree
10
-
11
- gemfile: Gemfile.ci
1
+ arch:
2
+ - amd64
3
+ - arm64
12
4
 
13
5
  branches:
14
6
  only:
15
- - master
7
+ - master
8
+ - develop
9
+
10
+ gemfile: Gemfile.ci
11
+
12
+ language: ruby
13
+
14
+ os:
15
+ - linux
16
+
17
+ rvm:
18
+ - ruby-head
19
+ - 2.7
20
+ - 2.6
21
+ - 2.5
22
+ - 2.4
23
+ - 2.3
24
+ - 2.2
data/.yardopts CHANGED
@@ -1 +1 @@
1
- lib/**/*.rb ext/**/_sha3.c --markup rdoc --title "sha3 Documentation" --protected
1
+ lib/**/doc.rb lib/**/version.rb --markup rdoc --title "sha3 Documentation" --protected
@@ -9,3 +9,19 @@
9
9
  === 0.2.0 / 2012-11-1
10
10
 
11
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/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
data/Gemfile.ci CHANGED
@@ -1,8 +1,8 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rubygems-tasks', '> 0.2'
6
- gem 'rake', '> 0.9'
7
- gem 'rspec', '~> 2.11'
8
- gem 'yard', '~> 0.8'
5
+ gem 'rake'
6
+ gem 'rspec'
7
+ gem 'rubygems-tasks'
8
+ gem 'yard'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Johanns Gregorian
1
+ Copyright (c) 2015 Johanns Gregorian
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,120 @@
1
+ # sha3
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/sha3.svg)](https://badge.fury.io/rb/sha3) [![CI](https://secure.travis-ci.org/johanns/sha3.png)](https://secure.travis-ci.org/johanns/sha3) [![CodeClimate](https://codeclimate.com/github/johanns/sha3.png)](https://codeclimate.com/github/johanns/sha3)
4
+
5
+ **SHA3 for Ruby** is a native (C) binding to SHA3 (Keccak FIPS 202) cryptographic hashing algorithm.
6
+
7
+ - [Home](https://github.com/johanns/sha3#readme)
8
+ - [Issues](https://github.com/johanns/sha3/issues)
9
+ - [Documentation](http://rubydoc.info/gems/sha3/frames)
10
+
11
+ ## Warnings
12
+
13
+ - Please do NOT use SHA3 to hash passwords -- use a slow hashing function instead (e.g.: `pbkdf2`, `argon2`, `bcrypt` or `scrypt`)
14
+ - Version 1.0 introduces new API and is incompatible with previous versions (0.x).
15
+
16
+ ## Module details
17
+
18
+ **SHA3::Digest**: A standard *Digest* _subclass_. The interface, and operation of this class are parallel to digest classes bundled with MRI-based Rubies (e.g.: **Digest::SHA2**, and **OpenSSL::Digest**).
19
+
20
+ See [documentation for Ruby's **Digest** class for additional details](http://www.ruby-doc.org/stdlib-2.2.3/libdoc/digest/rdoc/Digest.html).
21
+
22
+ ## Installation
23
+
24
+ ```shell
25
+ gem install sha3
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ require 'sha3'
32
+ ```
33
+
34
+ Valid hash bit-lengths are: *224*, *256*, *384*, *512*.
35
+
36
+ ```ruby
37
+ :sha224 :sha256 :sha384 :sha512
38
+
39
+ # SHA3::Digest.new(224) is SHA3::Digest.new(:sha224)
40
+ ```
41
+
42
+ Alternatively, you can instantiate using one of four sub-classes:
43
+
44
+ ```ruby
45
+ SHA3::Digest::SHA224.new() # 224 bits
46
+ SHA3::Digest::SHA256.new() # 256 bits
47
+ SHA3::Digest::SHA384.new() # 384 bits
48
+ SHA3::Digest::SHA512.new() # 512 bits
49
+ ```
50
+
51
+ ### Basics
52
+
53
+ ```ruby
54
+ # Instantiate a new SHA3::Digest class with 256 bit length
55
+ s = SHA3::Digest.new(:sha256)
56
+
57
+ # OR #
58
+
59
+ s = SHA3::Digest::SHA256.new()
60
+
61
+ # Update hash state, and compute new value
62
+ s.update "Compute Me"
63
+
64
+ # << is an .update() alias
65
+ s << "Me too"
66
+
67
+ # Returns digest value in bytes
68
+ s.digest
69
+ # => "\xBE\xDF\r\xD9\xA1..."
70
+
71
+ # Returns digest value as hex string
72
+ s.hexdigest
73
+ # => "bedf0dd9a15b647..."
74
+
75
+ ### Digest class-methods: ###
76
+
77
+ SHA3::Digest.hexdigest(:sha224, "Hash me, please")
78
+ # => "200e7bc18cd613..."
79
+
80
+ SHA3::Digest::SHA384.digest("Hash me, please")
81
+ # => "\xF5\xCEpC\xB0eV..."
82
+ ```
83
+
84
+ ### Hashing a file
85
+
86
+ ```ruby
87
+ # Compute the hash value for given file, and return the result as hex
88
+ s = SHA3::Digest::SHA224.file("my_fantastical_file.bin").hexdigest
89
+
90
+ # Calling SHA3::Digest.file(...) defaults to SHA256
91
+ s = SHA3::Digest.file("tests.sh")
92
+ # => #<SHA3::Digest: a9801db49389339...>
93
+ ```
94
+
95
+ ## Development
96
+
97
+ * Native build tools (e.g., GCC, Minigw, etc.)
98
+ * Gems: rubygems-tasks, rake, rspec, yard
99
+
100
+ ### Testing
101
+
102
+ Call ```rake``` to run the included RSpec tests.
103
+
104
+ Only a small subset of test vectors are included in the source repository; however, the complete test vectors suite is available for download. Simply run the ```tests.sh``` shell script (available in the root of source directory) to generate full byte-length RSpec test files.
105
+
106
+ ```sh tests.sh```
107
+
108
+ ### Rubies
109
+
110
+ Supported Ruby versions:
111
+
112
+ - MRI Ruby 2.4 - 3.0
113
+
114
+
115
+
116
+ ## Copyright
117
+
118
+ Copyright (c) 2012 - 2020 Johanns Gregorian (https://github.com/johanns)
119
+
120
+ **See LICENSE.txt for details.**