digest-blake2b 0.0.1 → 0.0.5
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/.circleci/config.yml +11 -33
- data/.gitignore +4 -3
- data/Gemfile +4 -0
- data/LICENSE +0 -0
- data/README.md +20 -18
- data/Rakefile +4 -2
- data/digest-blake2b.gemspec +11 -10
- data/ext/digest/{blake2b_ext → blake2b/ext}/blake2-impl.h +8 -7
- data/ext/digest/{blake2b_ext → blake2b/ext}/blake2.h +4 -3
- data/ext/digest/blake2b/ext/blake2b-ref.c +7 -0
- data/ext/digest/blake2b/ext/extconf.rb +14 -0
- data/ext/digest/{blake2b_ext → blake2b/ext}/rbext.c +3 -2
- data/ext/digest/blake2b/ext/ref/blake2b-ref.c +379 -0
- data/ext/digest/{blake2b_ext → blake2b/ext/sse}/blake2-config.h +6 -6
- data/ext/digest/{blake2b_ext → blake2b/ext/sse}/blake2b-load-sse2.h +0 -0
- data/ext/digest/{blake2b_ext → blake2b/ext/sse}/blake2b-load-sse41.h +0 -0
- data/ext/digest/{blake2b_ext → blake2b/ext/sse}/blake2b-ref.c +7 -7
- data/ext/digest/{blake2b_ext → blake2b/ext/sse}/blake2b-round.h +3 -2
- data/lib/digest/blake2b/key.rb +0 -0
- data/lib/digest/blake2b/version.rb +1 -1
- data/lib/digest/blake2b.rb +2 -3
- metadata +35 -29
- data/ext/digest/blake2b_ext/extconf.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa9d422fef855a4edaa9c46b813a70b96d50a97aa7f6c5d940bdc57f2c42b7b9
|
4
|
+
data.tar.gz: 9b1d6085a3882c9ab957e16d0b5342ac429cb3edeff0ac8e463505719f0d3c4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7712099b5d3a8cae79e41b5d88542ae033ae9c9c4cf019e6abf08d8d3f92f89eff1e819aa2a3978db67c9c50e5943bdf64fafa13a5983403b78ff2391d8d127
|
7
|
+
data.tar.gz: 190c8a94604b7d45c1a16ae7ece720eeb906fe3196f0a38f15e259facfa0f6abb0914c855aaad2059d7ccdde562788bf737bec743cca8cdefbecd3f631914683
|
data/.circleci/config.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
version: 2
|
1
|
+
version: 2.1
|
2
2
|
|
3
3
|
jobs:
|
4
|
-
|
4
|
+
ruby_2_6_x86_64:
|
5
5
|
docker:
|
6
|
-
- image:
|
6
|
+
- image: ruby:2.6
|
7
7
|
environment:
|
8
8
|
STEALTH_ENV: test
|
9
9
|
|
@@ -12,30 +12,19 @@ jobs:
|
|
12
12
|
steps:
|
13
13
|
- checkout
|
14
14
|
|
15
|
-
# Download and cache dependencies
|
16
|
-
- restore_cache:
|
17
|
-
keys:
|
18
|
-
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
19
|
-
# fallback to using the latest cache if no exact match is found
|
20
|
-
- v1-dependencies-
|
21
|
-
|
22
15
|
- run:
|
23
16
|
name: install dependencies
|
24
17
|
command: |
|
18
|
+
gem install bundler
|
25
19
|
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
26
20
|
|
27
|
-
- save_cache:
|
28
|
-
paths:
|
29
|
-
- ./vendor/bundle
|
30
|
-
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
31
|
-
|
32
21
|
# run tests!
|
33
22
|
- run:
|
34
23
|
name: run tests
|
35
24
|
command: |
|
36
25
|
mkdir /tmp/test-results
|
37
26
|
|
38
|
-
bundle exec rake
|
27
|
+
bundle exec rake full
|
39
28
|
|
40
29
|
# collect reports
|
41
30
|
- store_test_results:
|
@@ -43,39 +32,28 @@ jobs:
|
|
43
32
|
- store_artifacts:
|
44
33
|
path: /tmp/test-results
|
45
34
|
destination: test-results
|
46
|
-
|
35
|
+
ruby_2_7_x86_64:
|
47
36
|
docker:
|
48
|
-
- image:
|
37
|
+
- image: ruby:2.7
|
49
38
|
|
50
39
|
working_directory: ~/repo
|
51
40
|
|
52
41
|
steps:
|
53
42
|
- checkout
|
54
43
|
|
55
|
-
# Download and cache dependencies
|
56
|
-
- restore_cache:
|
57
|
-
keys:
|
58
|
-
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
59
|
-
# fallback to using the latest cache if no exact match is found
|
60
|
-
- v1-dependencies-
|
61
|
-
|
62
44
|
- run:
|
63
45
|
name: install dependencies
|
64
46
|
command: |
|
47
|
+
gem install bundler
|
65
48
|
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
66
49
|
|
67
|
-
- save_cache:
|
68
|
-
paths:
|
69
|
-
- ./vendor/bundle
|
70
|
-
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
71
|
-
|
72
50
|
# run tests!
|
73
51
|
- run:
|
74
52
|
name: run tests
|
75
53
|
command: |
|
76
54
|
mkdir /tmp/test-results
|
77
55
|
|
78
|
-
bundle exec rake
|
56
|
+
bundle exec rake full
|
79
57
|
|
80
58
|
# collect reports
|
81
59
|
- store_test_results:
|
@@ -88,5 +66,5 @@ workflows:
|
|
88
66
|
version: 2
|
89
67
|
build:
|
90
68
|
jobs:
|
91
|
-
-
|
92
|
-
-
|
69
|
+
- ruby_2_6_x86_64
|
70
|
+
- ruby_2_7_x86_64
|
data/.gitignore
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files
|
1
|
+
# See https://help.github.com/articles/ignoring-files
|
2
|
+
# for more about ignoring files.
|
2
3
|
#
|
3
4
|
# If you find yourself ignoring temporary files generated by your text editor
|
4
5
|
# or operating system, you probably want to add a global ignore instead:
|
@@ -6,8 +7,8 @@
|
|
6
7
|
|
7
8
|
/checksums/*
|
8
9
|
!/checksums/.keep
|
9
|
-
/lib
|
10
|
-
/lib/digest/
|
10
|
+
/lib/**/*.bundle
|
11
|
+
/lib/digest/blake2b/ext.so
|
11
12
|
|
12
13
|
*.o
|
13
14
|
*.gem
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
Digest::Blake2b
|
2
2
|
===============
|
3
3
|
|
4
|
+
[](https://circleci.com/gh/kotovalexarian/digest-blake2b/tree/master)
|
5
|
+
|
4
6
|
BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and SHA-3, yet is at least as secure as the latest standard SHA-3. BLAKE2 has been adopted by many projects due to its high speed, security, and simplicity.
|
5
7
|
|
6
8
|
More info at: [https://blake2.net](https://blake2.net).
|
7
9
|
|
8
10
|
## Summary
|
9
11
|
|
10
|
-
This gem is a C-extension to enable using BLAKE2b in Ruby. This BLAKE2b implementation (or just BLAKE2)
|
12
|
+
This gem is a C-extension to enable using BLAKE2b in Ruby. This reference BLAKE2b implementation (or just BLAKE2). For 64-bit x86 platforms with SSE support optimized implementation is used. It produces digests of any size between 1 and 64 bytes.
|
11
13
|
|
12
14
|
The C code for this gem is taken from the [official reference C implementation](https://github.com/BLAKE2/BLAKE2) as of commit [ca4c89314abff54e3806b44e4a08164f8204f09a](https://github.com/BLAKE2/BLAKE2/tree/ca4c89314abff54e3806b44e4a08164f8204f09a).
|
13
15
|
|
14
16
|
## Install
|
15
17
|
|
16
18
|
```
|
17
|
-
gem install blake2b
|
19
|
+
gem install digest-blake2b
|
18
20
|
```
|
19
21
|
|
20
22
|
## Usage
|
21
23
|
|
22
24
|
``` ruby
|
23
|
-
require 'blake2b'
|
25
|
+
require 'digest/blake2b'
|
24
26
|
|
25
27
|
# The UTF-8 String (Required) that you want to digest.
|
26
28
|
input = 'abc'
|
27
29
|
|
28
30
|
# The main application of keyed BLAKE2 is as a message authentication code (MAC)
|
29
|
-
# By default `Blake2b::Key.none` is used.
|
30
|
-
key = Blake2b::Key.none
|
31
|
-
# key = Blake2b::Key.from_string("foo bar baz")
|
32
|
-
# key = Blake2b::Key.from_hex('DEADBEAF')
|
33
|
-
# key = Blake2b::Key.from_bytes([222, 173, 190, 175])
|
31
|
+
# By default `Digest::Blake2b::Key.none` is used.
|
32
|
+
key = Digest::Blake2b::Key.none
|
33
|
+
# key = Digest::Blake2b::Key.from_string("foo bar baz")
|
34
|
+
# key = Digest::Blake2b::Key.from_hex('DEADBEAF')
|
35
|
+
# key = Digest::Blake2b::Key.from_bytes([222, 173, 190, 175])
|
34
36
|
|
35
37
|
# The output length in Bytes of the Hash, Max and Default is 32.
|
36
38
|
out_len = 32
|
@@ -38,32 +40,32 @@ out_len = 32
|
|
38
40
|
# HEX OUTPUT
|
39
41
|
############
|
40
42
|
|
41
|
-
Blake2b.hex(input)
|
43
|
+
Digest::Blake2b.hex(input)
|
42
44
|
=> "508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982"
|
43
45
|
|
44
|
-
Blake2b.hex(input, key)
|
46
|
+
Digest::Blake2b.hex(input, key)
|
45
47
|
=> "508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982"
|
46
48
|
|
47
|
-
Blake2b.hex(input, key, out_len)
|
49
|
+
Digest::Blake2b.hex(input, key, out_len)
|
48
50
|
=> "508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982"
|
49
51
|
|
50
52
|
# BYTES OUTPUT
|
51
53
|
##############
|
52
54
|
|
53
|
-
Blake2b.bytes(input)
|
55
|
+
Digest::Blake2b.bytes(input)
|
54
56
|
=> [80, 140, 94, ...]
|
55
57
|
|
56
|
-
Blake2b.bytes(input, key)
|
58
|
+
Digest::Blake2b.bytes(input, key)
|
57
59
|
=> [80, 140, 94, ...]
|
58
60
|
|
59
|
-
Blake2b.bytes(input, key, out_len)
|
61
|
+
Digest::Blake2b.bytes(input, key, out_len)
|
60
62
|
=> [80, 140, 94, ...]
|
61
63
|
|
62
64
|
```
|
63
65
|
|
64
66
|
## Performance
|
65
67
|
|
66
|
-
`Blake2b` really shines on larger inputs. Here are some benchmarks on various input sizes. You can find the performance suite used for these benchmarks at `performance/performance_suite.rb`. All tests were run on an iMac 27" Late 2014, 4GHz Core i7 CPU (4790K) w/ SSE4.1 + SSE4.2, 32GB DDR3 RAM.
|
68
|
+
`Digest::Blake2b` really shines on larger inputs. Here are some benchmarks on various input sizes. You can find the performance suite used for these benchmarks at `performance/performance_suite.rb`. All tests were run on an iMac 27" Late 2014, 4GHz Core i7 CPU (4790K) w/ SSE4.1 + SSE4.2, 32GB DDR3 RAM.
|
67
69
|
|
68
70
|
### 1KB (1M digests)
|
69
71
|
|
@@ -108,8 +110,8 @@ Hopefully this gem will not be required once Ruby [issue #12802](https://bugs.ru
|
|
108
110
|
|
109
111
|
## License
|
110
112
|
|
111
|
-
Blake2b is based heavily on [Blake2](https://github.com/franckverrot/blake2) by Franck Verrot, Copyright 2014.
|
113
|
+
Digest::Blake2b is based heavily on [Blake2](https://github.com/franckverrot/blake2) by Franck Verrot, Copyright 2014.
|
112
114
|
|
113
|
-
Blake2b is copyright 2018, Mauricio Gomes.
|
115
|
+
Digest::Blake2b is copyright 2018, Mauricio Gomes.
|
114
116
|
|
115
|
-
The original work (Blake2) and the modified work (Blake2b) are licensed GPL v3.0. See LICENSE for details.
|
117
|
+
The original work (Blake2) and the modified work (Digest::Blake2b) are licensed GPL v3.0. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rake/testtask'
|
3
5
|
require 'rake/extensiontask'
|
4
6
|
|
5
7
|
spec = Gem::Specification.load('digest-blake2b.gemspec')
|
6
8
|
|
7
|
-
Rake::ExtensionTask.new
|
9
|
+
Rake::ExtensionTask.new 'digest/blake2b/ext', spec do |ext|
|
8
10
|
ext.source_pattern = '*.{c,h}'
|
9
11
|
end
|
10
12
|
|
@@ -18,7 +20,7 @@ end
|
|
18
20
|
task default: :full
|
19
21
|
|
20
22
|
desc 'clean, compile, and run the full test suite'
|
21
|
-
task full: %
|
23
|
+
task full: %i[clean compile test]
|
22
24
|
|
23
25
|
def gemspec
|
24
26
|
@gemspec ||= begin
|
data/digest-blake2b.gemspec
CHANGED
@@ -9,12 +9,13 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.name = 'digest-blake2b'
|
10
10
|
spec.version = Digest::Blake2b::VERSION
|
11
11
|
spec.license = 'GPL-3.0'
|
12
|
-
spec.homepage = 'https://github.com/kotovalexarian/digest-blake2b
|
12
|
+
spec.homepage = 'https://github.com/kotovalexarian/digest-blake2b'
|
13
13
|
spec.summary = 'The BLAKE2b cryptographic hash function.'
|
14
|
+
spec.platform = Gem::Platform::RUBY
|
14
15
|
|
15
|
-
spec.required_ruby_version = '
|
16
|
+
spec.required_ruby_version = '>= 2.1', '< 4'
|
16
17
|
|
17
|
-
spec.authors = ['Franck Verrot', 'Mauricio Gomes']
|
18
|
+
spec.authors = ['Alex Kotov', 'Franck Verrot', 'Mauricio Gomes']
|
18
19
|
spec.email = %w[mauricio@edge14.com]
|
19
20
|
|
20
21
|
spec.description = <<-DESCRIPTION.split.join ' '
|
@@ -23,10 +24,10 @@ Gem::Specification.new do |spec|
|
|
23
24
|
DESCRIPTION
|
24
25
|
|
25
26
|
spec.metadata = {
|
26
|
-
'homepage_uri' => 'https://github.com/kotovalexarian/digest-blake2b
|
27
|
-
'source_code_uri' => 'https://github.com/kotovalexarian/digest-blake2b
|
27
|
+
'homepage_uri' => 'https://github.com/kotovalexarian/digest-blake2b',
|
28
|
+
'source_code_uri' => 'https://github.com/kotovalexarian/digest-blake2b',
|
28
29
|
'bug_tracker_uri' =>
|
29
|
-
'https://github.com/kotovalexarian/digest-blake2b
|
30
|
+
'https://github.com/kotovalexarian/digest-blake2b/issues',
|
30
31
|
}.freeze
|
31
32
|
|
32
33
|
spec.bindir = 'exe'
|
@@ -40,10 +41,10 @@ Gem::Specification.new do |spec|
|
|
40
41
|
|
41
42
|
spec.executables = spec.files.grep %r{^exe/}, &File.method(:basename)
|
42
43
|
|
43
|
-
spec.extensions << 'ext/digest/
|
44
|
+
spec.extensions << 'ext/digest/blake2b/ext/extconf.rb'
|
44
45
|
|
45
|
-
spec.add_development_dependency '
|
46
|
-
spec.add_development_dependency 'bundler' , '~> 1.5'
|
47
|
-
spec.add_development_dependency 'rake' , '~> 11.1'
|
46
|
+
spec.add_development_dependency 'bundler' , '~> 2.2'
|
48
47
|
spec.add_development_dependency 'minitest' , '~> 5.11'
|
48
|
+
spec.add_development_dependency 'rake' , '~> 13.0'
|
49
|
+
spec.add_development_dependency 'rake-compiler', '~> 0.9'
|
49
50
|
end
|
@@ -12,6 +12,7 @@
|
|
12
12
|
More information about the BLAKE2 hash function can be found at
|
13
13
|
https://blake2.net.
|
14
14
|
*/
|
15
|
+
|
15
16
|
#ifndef BLAKE2_IMPL_H
|
16
17
|
#define BLAKE2_IMPL_H
|
17
18
|
|
@@ -19,7 +20,7 @@
|
|
19
20
|
#include <string.h>
|
20
21
|
|
21
22
|
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
22
|
-
#
|
23
|
+
#ifdef _MSC_VER
|
23
24
|
#define BLAKE2_INLINE __inline
|
24
25
|
#elif defined(__GNUC__)
|
25
26
|
#define BLAKE2_INLINE __inline__
|
@@ -32,7 +33,7 @@
|
|
32
33
|
|
33
34
|
static BLAKE2_INLINE uint32_t load32( const void *src )
|
34
35
|
{
|
35
|
-
#
|
36
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
36
37
|
uint32_t w;
|
37
38
|
memcpy(&w, src, sizeof w);
|
38
39
|
return w;
|
@@ -47,7 +48,7 @@ static BLAKE2_INLINE uint32_t load32( const void *src )
|
|
47
48
|
|
48
49
|
static BLAKE2_INLINE uint64_t load64( const void *src )
|
49
50
|
{
|
50
|
-
#
|
51
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
51
52
|
uint64_t w;
|
52
53
|
memcpy(&w, src, sizeof w);
|
53
54
|
return w;
|
@@ -66,7 +67,7 @@ static BLAKE2_INLINE uint64_t load64( const void *src )
|
|
66
67
|
|
67
68
|
static BLAKE2_INLINE uint16_t load16( const void *src )
|
68
69
|
{
|
69
|
-
#
|
70
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
70
71
|
uint16_t w;
|
71
72
|
memcpy(&w, src, sizeof w);
|
72
73
|
return w;
|
@@ -79,7 +80,7 @@ static BLAKE2_INLINE uint16_t load16( const void *src )
|
|
79
80
|
|
80
81
|
static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
81
82
|
{
|
82
|
-
#
|
83
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
83
84
|
memcpy(dst, &w, sizeof w);
|
84
85
|
#else
|
85
86
|
uint8_t *p = ( uint8_t * )dst;
|
@@ -90,7 +91,7 @@ static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
|
90
91
|
|
91
92
|
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
92
93
|
{
|
93
|
-
#
|
94
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
94
95
|
memcpy(dst, &w, sizeof w);
|
95
96
|
#else
|
96
97
|
uint8_t *p = ( uint8_t * )dst;
|
@@ -103,7 +104,7 @@ static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
|
103
104
|
|
104
105
|
static BLAKE2_INLINE void store64( void *dst, uint64_t w )
|
105
106
|
{
|
106
|
-
#
|
107
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
107
108
|
memcpy(dst, &w, sizeof w);
|
108
109
|
#else
|
109
110
|
uint8_t *p = ( uint8_t * )dst;
|
@@ -12,19 +12,20 @@
|
|
12
12
|
More information about the BLAKE2 hash function can be found at
|
13
13
|
https://blake2.net.
|
14
14
|
*/
|
15
|
+
|
15
16
|
#ifndef BLAKE2_H
|
16
17
|
#define BLAKE2_H
|
17
18
|
|
18
19
|
#include <stddef.h>
|
19
20
|
#include <stdint.h>
|
20
21
|
|
21
|
-
#
|
22
|
+
#ifdef _MSC_VER
|
22
23
|
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
|
23
24
|
#else
|
24
25
|
#define BLAKE2_PACKED(x) x __attribute__((packed))
|
25
26
|
#endif
|
26
27
|
|
27
|
-
#
|
28
|
+
#ifdef __cplusplus
|
28
29
|
extern "C" {
|
29
30
|
#endif
|
30
31
|
|
@@ -188,7 +189,7 @@ extern "C" {
|
|
188
189
|
/* This is simply an alias for blake2b */
|
189
190
|
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
190
191
|
|
191
|
-
#
|
192
|
+
#ifdef __cplusplus
|
192
193
|
}
|
193
194
|
#endif
|
194
195
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mkmf'
|
4
|
+
|
5
|
+
$CFLAGS += ' -std=c99 -pedantic -Wall -Wextra'
|
6
|
+
|
7
|
+
if RUBY_PLATFORM =~ /^x86_64/
|
8
|
+
$CPPFLAGS += ' -DIMPL_SSE'
|
9
|
+
$CFLAGS += ' -Wno-long-long'
|
10
|
+
else
|
11
|
+
$CPPFLAGS += ' -DIMPL_REF'
|
12
|
+
end
|
13
|
+
|
14
|
+
create_makefile 'digest/blake2b/ext'
|
@@ -1,6 +1,7 @@
|
|
1
|
+
#include "blake2.h"
|
2
|
+
|
1
3
|
#include <ruby/ruby.h>
|
2
4
|
#include <ruby/encoding.h>
|
3
|
-
#include "blake2.h"
|
4
5
|
|
5
6
|
typedef struct {
|
6
7
|
size_t key_length;
|
@@ -100,7 +101,7 @@ VALUE m_blake2_digest(VALUE self, VALUE _input, VALUE _representation) {
|
|
100
101
|
return result;
|
101
102
|
}
|
102
103
|
|
103
|
-
void
|
104
|
+
void Init_ext() {
|
104
105
|
mDigest = rb_define_module("Digest");
|
105
106
|
|
106
107
|
mDigest_cBlake2 = rb_define_class_under(mDigest, "Blake2b", rb_cObject);
|
@@ -0,0 +1,379 @@
|
|
1
|
+
/*
|
2
|
+
BLAKE2 reference source code package - reference C implementations
|
3
|
+
|
4
|
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
5
|
+
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
6
|
+
your option. The terms of these licenses can be found at:
|
7
|
+
|
8
|
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
9
|
+
- OpenSSL license : https://www.openssl.org/source/license.html
|
10
|
+
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
More information about the BLAKE2 hash function can be found at
|
13
|
+
https://blake2.net.
|
14
|
+
*/
|
15
|
+
|
16
|
+
#include <stdint.h>
|
17
|
+
#include <string.h>
|
18
|
+
#include <stdio.h>
|
19
|
+
|
20
|
+
#include "blake2.h"
|
21
|
+
#include "blake2-impl.h"
|
22
|
+
|
23
|
+
static const uint64_t blake2b_IV[8] =
|
24
|
+
{
|
25
|
+
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
26
|
+
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
27
|
+
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
28
|
+
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
29
|
+
};
|
30
|
+
|
31
|
+
static const uint8_t blake2b_sigma[12][16] =
|
32
|
+
{
|
33
|
+
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
34
|
+
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
35
|
+
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
36
|
+
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
37
|
+
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
38
|
+
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
39
|
+
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
40
|
+
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
41
|
+
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
42
|
+
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
43
|
+
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
44
|
+
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
45
|
+
};
|
46
|
+
|
47
|
+
|
48
|
+
static void blake2b_set_lastnode( blake2b_state *S )
|
49
|
+
{
|
50
|
+
S->f[1] = (uint64_t)-1;
|
51
|
+
}
|
52
|
+
|
53
|
+
/* Some helper functions, not necessarily useful */
|
54
|
+
static int blake2b_is_lastblock( const blake2b_state *S )
|
55
|
+
{
|
56
|
+
return S->f[0] != 0;
|
57
|
+
}
|
58
|
+
|
59
|
+
static void blake2b_set_lastblock( blake2b_state *S )
|
60
|
+
{
|
61
|
+
if( S->last_node ) blake2b_set_lastnode( S );
|
62
|
+
|
63
|
+
S->f[0] = (uint64_t)-1;
|
64
|
+
}
|
65
|
+
|
66
|
+
static void blake2b_increment_counter( blake2b_state *S, const uint64_t inc )
|
67
|
+
{
|
68
|
+
S->t[0] += inc;
|
69
|
+
S->t[1] += ( S->t[0] < inc );
|
70
|
+
}
|
71
|
+
|
72
|
+
static void blake2b_init0( blake2b_state *S )
|
73
|
+
{
|
74
|
+
size_t i;
|
75
|
+
memset( S, 0, sizeof( blake2b_state ) );
|
76
|
+
|
77
|
+
for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
|
78
|
+
}
|
79
|
+
|
80
|
+
/* init xors IV with input parameter block */
|
81
|
+
int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
82
|
+
{
|
83
|
+
const uint8_t *p = ( const uint8_t * )( P );
|
84
|
+
size_t i;
|
85
|
+
|
86
|
+
blake2b_init0( S );
|
87
|
+
|
88
|
+
/* IV XOR ParamBlock */
|
89
|
+
for( i = 0; i < 8; ++i )
|
90
|
+
S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
|
91
|
+
|
92
|
+
S->outlen = P->digest_length;
|
93
|
+
return 0;
|
94
|
+
}
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
int blake2b_init( blake2b_state *S, size_t outlen )
|
99
|
+
{
|
100
|
+
blake2b_param P[1];
|
101
|
+
|
102
|
+
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
103
|
+
|
104
|
+
P->digest_length = (uint8_t)outlen;
|
105
|
+
P->key_length = 0;
|
106
|
+
P->fanout = 1;
|
107
|
+
P->depth = 1;
|
108
|
+
store32( &P->leaf_length, 0 );
|
109
|
+
store32( &P->node_offset, 0 );
|
110
|
+
store32( &P->xof_length, 0 );
|
111
|
+
P->node_depth = 0;
|
112
|
+
P->inner_length = 0;
|
113
|
+
memset( P->reserved, 0, sizeof( P->reserved ) );
|
114
|
+
memset( P->salt, 0, sizeof( P->salt ) );
|
115
|
+
memset( P->personal, 0, sizeof( P->personal ) );
|
116
|
+
return blake2b_init_param( S, P );
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen )
|
121
|
+
{
|
122
|
+
blake2b_param P[1];
|
123
|
+
|
124
|
+
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
125
|
+
|
126
|
+
if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) return -1;
|
127
|
+
|
128
|
+
P->digest_length = (uint8_t)outlen;
|
129
|
+
P->key_length = (uint8_t)keylen;
|
130
|
+
P->fanout = 1;
|
131
|
+
P->depth = 1;
|
132
|
+
store32( &P->leaf_length, 0 );
|
133
|
+
store32( &P->node_offset, 0 );
|
134
|
+
store32( &P->xof_length, 0 );
|
135
|
+
P->node_depth = 0;
|
136
|
+
P->inner_length = 0;
|
137
|
+
memset( P->reserved, 0, sizeof( P->reserved ) );
|
138
|
+
memset( P->salt, 0, sizeof( P->salt ) );
|
139
|
+
memset( P->personal, 0, sizeof( P->personal ) );
|
140
|
+
|
141
|
+
if( blake2b_init_param( S, P ) < 0 ) return -1;
|
142
|
+
|
143
|
+
{
|
144
|
+
uint8_t block[BLAKE2B_BLOCKBYTES];
|
145
|
+
memset( block, 0, BLAKE2B_BLOCKBYTES );
|
146
|
+
memcpy( block, key, keylen );
|
147
|
+
blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
|
148
|
+
secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */
|
149
|
+
}
|
150
|
+
return 0;
|
151
|
+
}
|
152
|
+
|
153
|
+
#define G(r,i,a,b,c,d) \
|
154
|
+
do { \
|
155
|
+
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
156
|
+
d = rotr64(d ^ a, 32); \
|
157
|
+
c = c + d; \
|
158
|
+
b = rotr64(b ^ c, 24); \
|
159
|
+
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
160
|
+
d = rotr64(d ^ a, 16); \
|
161
|
+
c = c + d; \
|
162
|
+
b = rotr64(b ^ c, 63); \
|
163
|
+
} while(0)
|
164
|
+
|
165
|
+
#define ROUND(r) \
|
166
|
+
do { \
|
167
|
+
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
168
|
+
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
169
|
+
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
170
|
+
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
171
|
+
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
172
|
+
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
173
|
+
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
174
|
+
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
175
|
+
} while(0)
|
176
|
+
|
177
|
+
static void blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
|
178
|
+
{
|
179
|
+
uint64_t m[16];
|
180
|
+
uint64_t v[16];
|
181
|
+
size_t i;
|
182
|
+
|
183
|
+
for( i = 0; i < 16; ++i ) {
|
184
|
+
m[i] = load64( block + i * sizeof( m[i] ) );
|
185
|
+
}
|
186
|
+
|
187
|
+
for( i = 0; i < 8; ++i ) {
|
188
|
+
v[i] = S->h[i];
|
189
|
+
}
|
190
|
+
|
191
|
+
v[ 8] = blake2b_IV[0];
|
192
|
+
v[ 9] = blake2b_IV[1];
|
193
|
+
v[10] = blake2b_IV[2];
|
194
|
+
v[11] = blake2b_IV[3];
|
195
|
+
v[12] = blake2b_IV[4] ^ S->t[0];
|
196
|
+
v[13] = blake2b_IV[5] ^ S->t[1];
|
197
|
+
v[14] = blake2b_IV[6] ^ S->f[0];
|
198
|
+
v[15] = blake2b_IV[7] ^ S->f[1];
|
199
|
+
|
200
|
+
ROUND( 0 );
|
201
|
+
ROUND( 1 );
|
202
|
+
ROUND( 2 );
|
203
|
+
ROUND( 3 );
|
204
|
+
ROUND( 4 );
|
205
|
+
ROUND( 5 );
|
206
|
+
ROUND( 6 );
|
207
|
+
ROUND( 7 );
|
208
|
+
ROUND( 8 );
|
209
|
+
ROUND( 9 );
|
210
|
+
ROUND( 10 );
|
211
|
+
ROUND( 11 );
|
212
|
+
|
213
|
+
for( i = 0; i < 8; ++i ) {
|
214
|
+
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
#undef G
|
219
|
+
#undef ROUND
|
220
|
+
|
221
|
+
int blake2b_update( blake2b_state *S, const void *pin, size_t inlen )
|
222
|
+
{
|
223
|
+
const unsigned char * in = (const unsigned char *)pin;
|
224
|
+
if( inlen > 0 )
|
225
|
+
{
|
226
|
+
size_t left = S->buflen;
|
227
|
+
size_t fill = BLAKE2B_BLOCKBYTES - left;
|
228
|
+
if( inlen > fill )
|
229
|
+
{
|
230
|
+
S->buflen = 0;
|
231
|
+
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
232
|
+
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
233
|
+
blake2b_compress( S, S->buf ); /* Compress */
|
234
|
+
in += fill; inlen -= fill;
|
235
|
+
while(inlen > BLAKE2B_BLOCKBYTES) {
|
236
|
+
blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES);
|
237
|
+
blake2b_compress( S, in );
|
238
|
+
in += BLAKE2B_BLOCKBYTES;
|
239
|
+
inlen -= BLAKE2B_BLOCKBYTES;
|
240
|
+
}
|
241
|
+
}
|
242
|
+
memcpy( S->buf + S->buflen, in, inlen );
|
243
|
+
S->buflen += inlen;
|
244
|
+
}
|
245
|
+
return 0;
|
246
|
+
}
|
247
|
+
|
248
|
+
int blake2b_final( blake2b_state *S, void *out, size_t outlen )
|
249
|
+
{
|
250
|
+
uint8_t buffer[BLAKE2B_OUTBYTES] = {0};
|
251
|
+
size_t i;
|
252
|
+
|
253
|
+
if( out == NULL || outlen < S->outlen )
|
254
|
+
return -1;
|
255
|
+
|
256
|
+
if( blake2b_is_lastblock( S ) )
|
257
|
+
return -1;
|
258
|
+
|
259
|
+
blake2b_increment_counter( S, S->buflen );
|
260
|
+
blake2b_set_lastblock( S );
|
261
|
+
memset( S->buf + S->buflen, 0, BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
|
262
|
+
blake2b_compress( S, S->buf );
|
263
|
+
|
264
|
+
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
265
|
+
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
266
|
+
|
267
|
+
memcpy( out, buffer, S->outlen );
|
268
|
+
secure_zero_memory(buffer, sizeof(buffer));
|
269
|
+
return 0;
|
270
|
+
}
|
271
|
+
|
272
|
+
/* inlen, at least, should be uint64_t. Others can be size_t. */
|
273
|
+
int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen )
|
274
|
+
{
|
275
|
+
blake2b_state S[1];
|
276
|
+
|
277
|
+
/* Verify parameters */
|
278
|
+
if ( NULL == in && inlen > 0 ) return -1;
|
279
|
+
|
280
|
+
if ( NULL == out ) return -1;
|
281
|
+
|
282
|
+
if( NULL == key && keylen > 0 ) return -1;
|
283
|
+
|
284
|
+
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
|
285
|
+
|
286
|
+
if( keylen > BLAKE2B_KEYBYTES ) return -1;
|
287
|
+
|
288
|
+
if( keylen > 0 )
|
289
|
+
{
|
290
|
+
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
291
|
+
}
|
292
|
+
else
|
293
|
+
{
|
294
|
+
if( blake2b_init( S, outlen ) < 0 ) return -1;
|
295
|
+
}
|
296
|
+
|
297
|
+
blake2b_update( S, ( const uint8_t * )in, inlen );
|
298
|
+
blake2b_final( S, out, outlen );
|
299
|
+
return 0;
|
300
|
+
}
|
301
|
+
|
302
|
+
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ) {
|
303
|
+
return blake2b(out, outlen, in, inlen, key, keylen);
|
304
|
+
}
|
305
|
+
|
306
|
+
#ifdef SUPERCOP
|
307
|
+
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
308
|
+
{
|
309
|
+
return blake2b( out, BLAKE2B_OUTBYTES, in, inlen, NULL, 0 );
|
310
|
+
}
|
311
|
+
#endif
|
312
|
+
|
313
|
+
#ifdef BLAKE2B_SELFTEST
|
314
|
+
#include <string.h>
|
315
|
+
#include "blake2-kat.h"
|
316
|
+
int main( void )
|
317
|
+
{
|
318
|
+
uint8_t key[BLAKE2B_KEYBYTES];
|
319
|
+
uint8_t buf[BLAKE2_KAT_LENGTH];
|
320
|
+
size_t i, step;
|
321
|
+
|
322
|
+
for( i = 0; i < BLAKE2B_KEYBYTES; ++i )
|
323
|
+
key[i] = ( uint8_t )i;
|
324
|
+
|
325
|
+
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
326
|
+
buf[i] = ( uint8_t )i;
|
327
|
+
|
328
|
+
/* Test simple API */
|
329
|
+
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
330
|
+
{
|
331
|
+
uint8_t hash[BLAKE2B_OUTBYTES];
|
332
|
+
blake2b( hash, BLAKE2B_OUTBYTES, buf, i, key, BLAKE2B_KEYBYTES );
|
333
|
+
|
334
|
+
if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
|
335
|
+
{
|
336
|
+
goto fail;
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
/* Test streaming API */
|
341
|
+
for(step = 1; step < BLAKE2B_BLOCKBYTES; ++step) {
|
342
|
+
for (i = 0; i < BLAKE2_KAT_LENGTH; ++i) {
|
343
|
+
uint8_t hash[BLAKE2B_OUTBYTES];
|
344
|
+
blake2b_state S;
|
345
|
+
uint8_t * p = buf;
|
346
|
+
size_t mlen = i;
|
347
|
+
int err = 0;
|
348
|
+
|
349
|
+
if( (err = blake2b_init_key(&S, BLAKE2B_OUTBYTES, key, BLAKE2B_KEYBYTES)) < 0 ) {
|
350
|
+
goto fail;
|
351
|
+
}
|
352
|
+
|
353
|
+
while (mlen >= step) {
|
354
|
+
if ( (err = blake2b_update(&S, p, step)) < 0 ) {
|
355
|
+
goto fail;
|
356
|
+
}
|
357
|
+
mlen -= step;
|
358
|
+
p += step;
|
359
|
+
}
|
360
|
+
if ( (err = blake2b_update(&S, p, mlen)) < 0) {
|
361
|
+
goto fail;
|
362
|
+
}
|
363
|
+
if ( (err = blake2b_final(&S, hash, BLAKE2B_OUTBYTES)) < 0) {
|
364
|
+
goto fail;
|
365
|
+
}
|
366
|
+
|
367
|
+
if (0 != memcmp(hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES)) {
|
368
|
+
goto fail;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
puts( "ok" );
|
374
|
+
return 0;
|
375
|
+
fail:
|
376
|
+
puts("error");
|
377
|
+
return -1;
|
378
|
+
}
|
379
|
+
#endif
|
@@ -12,6 +12,7 @@
|
|
12
12
|
More information about the BLAKE2 hash function can be found at
|
13
13
|
https://blake2.net.
|
14
14
|
*/
|
15
|
+
|
15
16
|
#ifndef BLAKE2_CONFIG_H
|
16
17
|
#define BLAKE2_CONFIG_H
|
17
18
|
|
@@ -20,23 +21,22 @@
|
|
20
21
|
#define HAVE_SSE2
|
21
22
|
#endif
|
22
23
|
|
23
|
-
#
|
24
|
+
#ifdef __SSSE3__
|
24
25
|
#define HAVE_SSSE3
|
25
26
|
#endif
|
26
27
|
|
27
|
-
#
|
28
|
+
#ifdef __SSE4_1__
|
28
29
|
#define HAVE_SSE41
|
29
30
|
#endif
|
30
31
|
|
31
|
-
#
|
32
|
+
#ifdef __AVX__
|
32
33
|
#define HAVE_AVX
|
33
34
|
#endif
|
34
35
|
|
35
|
-
#
|
36
|
+
#ifdef __XOP__
|
36
37
|
#define HAVE_XOP
|
37
38
|
#endif
|
38
39
|
|
39
|
-
|
40
40
|
#ifdef HAVE_AVX2
|
41
41
|
#ifndef HAVE_AVX
|
42
42
|
#define HAVE_AVX
|
@@ -65,7 +65,7 @@
|
|
65
65
|
#define HAVE_SSE2
|
66
66
|
#endif
|
67
67
|
|
68
|
-
#
|
68
|
+
#ifndef HAVE_SSE2
|
69
69
|
#error "This code requires at least SSE2."
|
70
70
|
#endif
|
71
71
|
|
File without changes
|
File without changes
|
@@ -26,16 +26,16 @@
|
|
26
26
|
#include <intrin.h> /* for _mm_set_epi64x */
|
27
27
|
#endif
|
28
28
|
#include <emmintrin.h>
|
29
|
-
#
|
29
|
+
#ifdef HAVE_SSSE3
|
30
30
|
#include <tmmintrin.h>
|
31
31
|
#endif
|
32
|
-
#
|
32
|
+
#ifdef HAVE_SSE41
|
33
33
|
#include <smmintrin.h>
|
34
34
|
#endif
|
35
|
-
#
|
35
|
+
#ifdef HAVE_AVX
|
36
36
|
#include <immintrin.h>
|
37
37
|
#endif
|
38
|
-
#
|
38
|
+
#ifdef HAVE_XOP
|
39
39
|
#include <x86intrin.h>
|
40
40
|
#endif
|
41
41
|
|
@@ -160,7 +160,7 @@ static void blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOC
|
|
160
160
|
const __m128i r16 = _mm_setr_epi8( 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9 );
|
161
161
|
const __m128i r24 = _mm_setr_epi8( 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10 );
|
162
162
|
#endif
|
163
|
-
#
|
163
|
+
#ifdef HAVE_SSE41
|
164
164
|
const __m128i m0 = LOADU( block + 00 );
|
165
165
|
const __m128i m1 = LOADU( block + 16 );
|
166
166
|
const __m128i m2 = LOADU( block + 32 );
|
@@ -297,14 +297,14 @@ int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *
|
|
297
297
|
return blake2b(out, outlen, in, inlen, key, keylen);
|
298
298
|
}
|
299
299
|
|
300
|
-
#
|
300
|
+
#ifdef SUPERCOP
|
301
301
|
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
302
302
|
{
|
303
303
|
return blake2b( out, BLAKE2B_OUTBYTES, in, inlen, NULL, 0 );
|
304
304
|
}
|
305
305
|
#endif
|
306
306
|
|
307
|
-
#
|
307
|
+
#ifdef BLAKE2B_SELFTEST
|
308
308
|
#include <string.h>
|
309
309
|
#include "blake2-kat.h"
|
310
310
|
int main( void )
|
@@ -12,6 +12,7 @@
|
|
12
12
|
More information about the BLAKE2 hash function can be found at
|
13
13
|
https://blake2.net.
|
14
14
|
*/
|
15
|
+
|
15
16
|
#ifndef BLAKE2B_ROUND_H
|
16
17
|
#define BLAKE2B_ROUND_H
|
17
18
|
|
@@ -80,7 +81,7 @@
|
|
80
81
|
row2l = _mm_roti_epi64(row2l, -63); \
|
81
82
|
row2h = _mm_roti_epi64(row2h, -63); \
|
82
83
|
|
83
|
-
#
|
84
|
+
#ifdef HAVE_SSSE3
|
84
85
|
#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
85
86
|
t0 = _mm_alignr_epi8(row2h, row2l, 8); \
|
86
87
|
t1 = _mm_alignr_epi8(row2l, row2h, 8); \
|
@@ -136,7 +137,7 @@
|
|
136
137
|
|
137
138
|
#endif
|
138
139
|
|
139
|
-
#
|
140
|
+
#ifdef HAVE_SSE41
|
140
141
|
#include "blake2b-load-sse41.h"
|
141
142
|
#else
|
142
143
|
#include "blake2b-load-sse2.h"
|
data/lib/digest/blake2b/key.rb
CHANGED
File without changes
|
data/lib/digest/blake2b.rb
CHANGED
metadata
CHANGED
@@ -1,79 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digest-blake2b
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Alex Kotov
|
7
8
|
- Franck Verrot
|
8
9
|
- Mauricio Gomes
|
9
10
|
autorequire:
|
10
11
|
bindir: exe
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
+
name: bundler
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
requirements:
|
18
19
|
- - "~>"
|
19
20
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
21
|
+
version: '2.2'
|
21
22
|
type: :development
|
22
23
|
prerelease: false
|
23
24
|
version_requirements: !ruby/object:Gem::Requirement
|
24
25
|
requirements:
|
25
26
|
- - "~>"
|
26
27
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
28
|
+
version: '2.2'
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
30
|
+
name: minitest
|
30
31
|
requirement: !ruby/object:Gem::Requirement
|
31
32
|
requirements:
|
32
33
|
- - "~>"
|
33
34
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
35
|
+
version: '5.11'
|
35
36
|
type: :development
|
36
37
|
prerelease: false
|
37
38
|
version_requirements: !ruby/object:Gem::Requirement
|
38
39
|
requirements:
|
39
40
|
- - "~>"
|
40
41
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
42
|
+
version: '5.11'
|
42
43
|
- !ruby/object:Gem::Dependency
|
43
44
|
name: rake
|
44
45
|
requirement: !ruby/object:Gem::Requirement
|
45
46
|
requirements:
|
46
47
|
- - "~>"
|
47
48
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
49
|
+
version: '13.0'
|
49
50
|
type: :development
|
50
51
|
prerelease: false
|
51
52
|
version_requirements: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
54
|
- - "~>"
|
54
55
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
56
|
+
version: '13.0'
|
56
57
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
58
|
+
name: rake-compiler
|
58
59
|
requirement: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
61
|
- - "~>"
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
63
|
+
version: '0.9'
|
63
64
|
type: :development
|
64
65
|
prerelease: false
|
65
66
|
version_requirements: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
68
|
- - "~>"
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
70
|
+
version: '0.9'
|
70
71
|
description: BLAKE2b is a cryptographic hash function faster than MD5, SHA-1, SHA-2,
|
71
72
|
and SHA-3 for 64-bit systems.
|
72
73
|
email:
|
73
74
|
- mauricio@edge14.com
|
74
75
|
executables: []
|
75
76
|
extensions:
|
76
|
-
- ext/digest/
|
77
|
+
- ext/digest/blake2b/ext/extconf.rb
|
77
78
|
extra_rdoc_files: []
|
78
79
|
files:
|
79
80
|
- ".circleci/config.yml"
|
@@ -84,42 +85,47 @@ files:
|
|
84
85
|
- Rakefile
|
85
86
|
- checksums/.keep
|
86
87
|
- digest-blake2b.gemspec
|
87
|
-
- ext/digest/
|
88
|
-
- ext/digest/
|
89
|
-
- ext/digest/
|
90
|
-
- ext/digest/
|
91
|
-
- ext/digest/
|
92
|
-
- ext/digest/
|
93
|
-
- ext/digest/
|
94
|
-
- ext/digest/
|
95
|
-
- ext/digest/
|
88
|
+
- ext/digest/blake2b/ext/blake2-impl.h
|
89
|
+
- ext/digest/blake2b/ext/blake2.h
|
90
|
+
- ext/digest/blake2b/ext/blake2b-ref.c
|
91
|
+
- ext/digest/blake2b/ext/extconf.rb
|
92
|
+
- ext/digest/blake2b/ext/rbext.c
|
93
|
+
- ext/digest/blake2b/ext/ref/blake2b-ref.c
|
94
|
+
- ext/digest/blake2b/ext/sse/blake2-config.h
|
95
|
+
- ext/digest/blake2b/ext/sse/blake2b-load-sse2.h
|
96
|
+
- ext/digest/blake2b/ext/sse/blake2b-load-sse41.h
|
97
|
+
- ext/digest/blake2b/ext/sse/blake2b-ref.c
|
98
|
+
- ext/digest/blake2b/ext/sse/blake2b-round.h
|
96
99
|
- lib/digest/blake2b.rb
|
97
100
|
- lib/digest/blake2b/key.rb
|
98
101
|
- lib/digest/blake2b/version.rb
|
99
102
|
- performance/performance_suite.rb
|
100
|
-
homepage: https://github.com/kotovalexarian/digest-blake2b
|
103
|
+
homepage: https://github.com/kotovalexarian/digest-blake2b
|
101
104
|
licenses:
|
102
105
|
- GPL-3.0
|
103
106
|
metadata:
|
104
|
-
homepage_uri: https://github.com/kotovalexarian/digest-blake2b
|
105
|
-
source_code_uri: https://github.com/kotovalexarian/digest-blake2b
|
106
|
-
bug_tracker_uri: https://github.com/kotovalexarian/digest-blake2b
|
107
|
+
homepage_uri: https://github.com/kotovalexarian/digest-blake2b
|
108
|
+
source_code_uri: https://github.com/kotovalexarian/digest-blake2b
|
109
|
+
bug_tracker_uri: https://github.com/kotovalexarian/digest-blake2b/issues
|
107
110
|
post_install_message:
|
108
111
|
rdoc_options: []
|
109
112
|
require_paths:
|
110
113
|
- lib
|
111
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
115
|
requirements:
|
113
|
-
- - "
|
116
|
+
- - ">="
|
114
117
|
- !ruby/object:Gem::Version
|
115
118
|
version: '2.1'
|
119
|
+
- - "<"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '4'
|
116
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
123
|
requirements:
|
118
124
|
- - ">="
|
119
125
|
- !ruby/object:Gem::Version
|
120
126
|
version: '0'
|
121
127
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.2.22
|
123
129
|
signing_key:
|
124
130
|
specification_version: 4
|
125
131
|
summary: The BLAKE2b cryptographic hash function.
|