digest-kangarootwelve 0.1.0 → 0.1.1
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
- data/Rakefile +5 -10
- data/digest-kangarootwelve.gemspec +30 -1
- data/ext/digest/kangarootwelve/ext.c +18 -5
- data/lib/digest/kangarootwelve/version.rb +1 -1
- data/test/test.rb +12 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b090ff25bd1a6c8c8c42fdaa409d5cdb1145317
|
4
|
+
data.tar.gz: 309680e470afa1dc5ebb24df8cd92ee55841c7b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf0b362aa1b0fc4c32f13ba935c280de74defa7615dc6e1797a493d6a82b06dd2b1c88b04e86abb387d3beb29015665bee24315f99ceecf589b94155a83c04bf
|
7
|
+
data.tar.gz: 3002cbc9564d3324fcd373d5ce3f03a3b7758d899e6ed623b2012a7d1108c6a9c6373b823312ba1a50fd4f0e389596518e8ed281d99fb73f608b9cb3af403824
|
data/Rakefile
CHANGED
@@ -1,20 +1,15 @@
|
|
1
|
+
# build, clean, clobber, install, install:local, release[remote]
|
1
2
|
require 'bundler/gem_tasks'
|
2
|
-
require 'rake/testtask'
|
3
3
|
|
4
|
-
# clean, clobber, compile,
|
4
|
+
# clean, clobber, compile, compile:digest/kangarootwelve
|
5
5
|
require 'rake/extensiontask'
|
6
6
|
Rake::ExtensionTask.new('digest/kangarootwelve', Bundler::GemHelper.gemspec)
|
7
7
|
|
8
8
|
# test
|
9
|
-
|
9
|
+
require 'rake/testtask'
|
10
|
+
Rake::TestTask.new do |t|
|
10
11
|
t.test_files = FileList['test/test.rb']
|
11
12
|
t.verbose = true
|
12
13
|
end
|
13
14
|
|
14
|
-
#
|
15
|
-
task :clean do
|
16
|
-
list = FileList.new('test/*.tmp', 'test/*.temp')
|
17
|
-
rm_f list unless list.empty?
|
18
|
-
end
|
19
|
-
|
20
|
-
# Run `rake --tasks` for a list of tasks.
|
15
|
+
# Run `rake --tasks` or `rake --tasks --all` for a list of tasks.
|
@@ -16,7 +16,36 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.required_ruby_version = '>= 2.2'
|
18
18
|
|
19
|
-
spec.files
|
19
|
+
spec.files = %w{Gemfile
|
20
|
+
LICENSE
|
21
|
+
README.md
|
22
|
+
Rakefile
|
23
|
+
digest-kangarootwelve.gemspec
|
24
|
+
ext/digest/kangarootwelve/KangarooTwelve.c
|
25
|
+
ext/digest/kangarootwelve/KangarooTwelve.h
|
26
|
+
ext/digest/kangarootwelve/KeccakP-1600-SnP.h
|
27
|
+
ext/digest/kangarootwelve/KeccakP-1600-compact64.c
|
28
|
+
ext/digest/kangarootwelve/KeccakP-1600-times2-SnP.h
|
29
|
+
ext/digest/kangarootwelve/KeccakP-1600-times2-on1.c
|
30
|
+
ext/digest/kangarootwelve/KeccakP-1600-times4-SnP.h
|
31
|
+
ext/digest/kangarootwelve/KeccakP-1600-times4-on1.c
|
32
|
+
ext/digest/kangarootwelve/KeccakP-1600-times8-SnP.h
|
33
|
+
ext/digest/kangarootwelve/KeccakP-1600-times8-on1.c
|
34
|
+
ext/digest/kangarootwelve/KeccakSponge-common.h
|
35
|
+
ext/digest/kangarootwelve/KeccakSponge.inc
|
36
|
+
ext/digest/kangarootwelve/KeccakSpongeWidth1600.c
|
37
|
+
ext/digest/kangarootwelve/KeccakSpongeWidth1600.h
|
38
|
+
ext/digest/kangarootwelve/Phases.h
|
39
|
+
ext/digest/kangarootwelve/PlSnP-Fallback.inc
|
40
|
+
ext/digest/kangarootwelve/SnP-Relaned.h
|
41
|
+
ext/digest/kangarootwelve/align.h
|
42
|
+
ext/digest/kangarootwelve/brg_endian.h
|
43
|
+
ext/digest/kangarootwelve/ext.c
|
44
|
+
ext/digest/kangarootwelve/extconf.rb
|
45
|
+
ext/digest/kangarootwelve/utils.h
|
46
|
+
lib/digest/kangarootwelve/version.rb
|
47
|
+
test/test.rb}
|
48
|
+
|
20
49
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
50
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
51
|
spec.require_paths = ["lib"]
|
@@ -320,7 +320,10 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE customization)
|
|
320
320
|
*/
|
321
321
|
static VALUE _Digest_KangarooTwelve_singleton_default(VALUE self)
|
322
322
|
{
|
323
|
-
VALUE default_ =
|
323
|
+
VALUE default_ = Qnil;
|
324
|
+
|
325
|
+
if (rb_ivar_defined(self, _id_default) == Qtrue)
|
326
|
+
default_ = rb_ivar_get(self, _id_default);
|
324
327
|
|
325
328
|
if (NIL_P(default_)) {
|
326
329
|
default_ = implement(ID2SYM(_id_auto), INT2FIX(KT_DEFAULT_DIGEST_LENGTH), Qnil);
|
@@ -453,7 +456,7 @@ static VALUE _Digest_KangarooTwelve_Impl_singleton_new(VALUE self)
|
|
453
456
|
if (self == _Digest_KangarooTwelve_Impl)
|
454
457
|
rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
|
455
458
|
|
456
|
-
if (rb_obj_class(rb_ivar_get(self, _id_metadata)) != _Digest_KangarooTwelve_Metadata)
|
459
|
+
if (rb_ivar_defined(self, _id_metadata) == Qfalse || rb_obj_class(rb_ivar_get(self, _id_metadata)) != _Digest_KangarooTwelve_Metadata)
|
457
460
|
rb_raise(rb_eRuntimeError, "Metadata not set or invalid. Please do not manually inherit KangarooTwelve.");
|
458
461
|
|
459
462
|
return rb_call_super(0, 0);
|
@@ -492,7 +495,7 @@ static VALUE _Digest_KangarooTwelve_Impl_singleton_customization(VALUE self)
|
|
492
495
|
if (self == _Digest_KangarooTwelve_Impl)
|
493
496
|
rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
|
494
497
|
|
495
|
-
return rb_ivar_get(self, _id_customization);
|
498
|
+
return rb_ivar_defined(self, _id_customization) == Qtrue ? rb_ivar_get(self, _id_customization) : Qnil;
|
496
499
|
}
|
497
500
|
|
498
501
|
/*
|
@@ -505,8 +508,18 @@ static VALUE _Digest_KangarooTwelve_Impl_singleton_customization_hex(VALUE self)
|
|
505
508
|
if (self == _Digest_KangarooTwelve_Impl)
|
506
509
|
rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
|
507
510
|
|
508
|
-
|
509
|
-
|
511
|
+
if (rb_ivar_defined(self, _id_customization)) {
|
512
|
+
VALUE customization = rb_ivar_get(self, _id_customization);
|
513
|
+
|
514
|
+
if (!NIL_P(customization)) {
|
515
|
+
if (TYPE(customization) != T_STRING)
|
516
|
+
rb_raise(rb_eTypeError, "Unexpected class for a customization string.");
|
517
|
+
|
518
|
+
return hex_encode_str(customization);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
522
|
+
return Qnil;
|
510
523
|
}
|
511
524
|
|
512
525
|
/*
|
data/test/test.rb
CHANGED
@@ -85,10 +85,19 @@ describe Digest::KangarooTwelve do
|
|
85
85
|
d.customization.must_equal a.customization
|
86
86
|
end
|
87
87
|
|
88
|
+
it "has a customization method that returns nil when customization string is undefined" do
|
89
|
+
Digest::KangarooTwelve.implement.customization.must_be_nil
|
90
|
+
end
|
91
|
+
|
92
|
+
it "has a customization_hex method that returns hex of customization string, or nil" do
|
93
|
+
Digest::KangarooTwelve.implement(c: "abcd").customization_hex.must_equal "61626364"
|
94
|
+
Digest::KangarooTwelve.implement.customization_hex.must_be_nil
|
95
|
+
end
|
96
|
+
|
88
97
|
it "has a declared block length of 8192 bytes" do
|
89
|
-
Digest::KangarooTwelve::BLOCK_LENGTH
|
90
|
-
Digest::KangarooTwelve.default.block_length
|
91
|
-
Digest::KangarooTwelve.default.new.block_length
|
98
|
+
Digest::KangarooTwelve::BLOCK_LENGTH.must_equal 8192
|
99
|
+
Digest::KangarooTwelve.default.block_length.must_equal 8192
|
100
|
+
Digest::KangarooTwelve.default.new.block_length.must_equal 8192
|
92
101
|
end
|
93
102
|
|
94
103
|
it "produces valid hashes" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digest-kangarootwelve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- konsolebox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|