ed25519_blake2b 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/CODE_OF_CONDUCT.md +74 -0
  4. data/Gemfile +6 -0
  5. data/Gemfile.lock +23 -0
  6. data/LICENSE +21 -0
  7. data/README.md +39 -0
  8. data/Rakefile +13 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/ed25519_blake2b.gemspec +31 -0
  12. data/ext/ed25519_blake2b/blake2-config.h +72 -0
  13. data/ext/ed25519_blake2b/blake2-impl.h +160 -0
  14. data/ext/ed25519_blake2b/blake2.h +195 -0
  15. data/ext/ed25519_blake2b/blake2b-load-sse2.h +68 -0
  16. data/ext/ed25519_blake2b/blake2b-load-sse41.h +402 -0
  17. data/ext/ed25519_blake2b/blake2b-ref.c +373 -0
  18. data/ext/ed25519_blake2b/blake2b-round.h +157 -0
  19. data/ext/ed25519_blake2b/curve25519-donna-32bit.h +579 -0
  20. data/ext/ed25519_blake2b/curve25519-donna-64bit.h +413 -0
  21. data/ext/ed25519_blake2b/curve25519-donna-helpers.h +67 -0
  22. data/ext/ed25519_blake2b/curve25519-donna-sse2.h +1112 -0
  23. data/ext/ed25519_blake2b/ed25519-donna-32bit-sse2.h +513 -0
  24. data/ext/ed25519_blake2b/ed25519-donna-32bit-tables.h +61 -0
  25. data/ext/ed25519_blake2b/ed25519-donna-64bit-sse2.h +436 -0
  26. data/ext/ed25519_blake2b/ed25519-donna-64bit-tables.h +53 -0
  27. data/ext/ed25519_blake2b/ed25519-donna-64bit-x86-32bit.h +435 -0
  28. data/ext/ed25519_blake2b/ed25519-donna-64bit-x86.h +351 -0
  29. data/ext/ed25519_blake2b/ed25519-donna-basepoint-table.h +259 -0
  30. data/ext/ed25519_blake2b/ed25519-donna-batchverify.h +275 -0
  31. data/ext/ed25519_blake2b/ed25519-donna-impl-base.h +364 -0
  32. data/ext/ed25519_blake2b/ed25519-donna-impl-sse2.h +390 -0
  33. data/ext/ed25519_blake2b/ed25519-donna-portable-identify.h +103 -0
  34. data/ext/ed25519_blake2b/ed25519-donna-portable.h +135 -0
  35. data/ext/ed25519_blake2b/ed25519-donna.h +115 -0
  36. data/ext/ed25519_blake2b/ed25519-hash-custom.c +28 -0
  37. data/ext/ed25519_blake2b/ed25519-hash-custom.h +30 -0
  38. data/ext/ed25519_blake2b/ed25519-hash.h +219 -0
  39. data/ext/ed25519_blake2b/ed25519-randombytes-custom.h +10 -0
  40. data/ext/ed25519_blake2b/ed25519-randombytes.h +91 -0
  41. data/ext/ed25519_blake2b/ed25519.c +150 -0
  42. data/ext/ed25519_blake2b/ed25519.h +30 -0
  43. data/ext/ed25519_blake2b/extconf.rb +3 -0
  44. data/ext/ed25519_blake2b/fuzz/README.md +173 -0
  45. data/ext/ed25519_blake2b/fuzz/build-nix.php +134 -0
  46. data/ext/ed25519_blake2b/fuzz/curve25519-ref10.c +1272 -0
  47. data/ext/ed25519_blake2b/fuzz/curve25519-ref10.h +8 -0
  48. data/ext/ed25519_blake2b/fuzz/ed25519-donna-sse2.c +3 -0
  49. data/ext/ed25519_blake2b/fuzz/ed25519-donna.c +1 -0
  50. data/ext/ed25519_blake2b/fuzz/ed25519-donna.h +34 -0
  51. data/ext/ed25519_blake2b/fuzz/ed25519-ref10.c +4647 -0
  52. data/ext/ed25519_blake2b/fuzz/ed25519-ref10.h +9 -0
  53. data/ext/ed25519_blake2b/fuzz/fuzz-curve25519.c +172 -0
  54. data/ext/ed25519_blake2b/fuzz/fuzz-ed25519.c +219 -0
  55. data/ext/ed25519_blake2b/modm-donna-32bit.h +469 -0
  56. data/ext/ed25519_blake2b/modm-donna-64bit.h +361 -0
  57. data/ext/ed25519_blake2b/rbext.c +25 -0
  58. data/ext/ed25519_blake2b/regression.h +1024 -0
  59. data/lib/ed25519_blake2b/ed25519_blake2b.rb +4 -0
  60. data/lib/ed25519_blake2b/version.rb +3 -0
  61. metadata +147 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 66629eae704ace47870855f54ed1b13e6c3e7f2f5d8c97e946d8d34f7ef3fe43
4
+ data.tar.gz: 86226a8f9655119ec4d8ce659ea9e6c2c2b9982c2e8355d26acb4846a3fcd14b
5
+ SHA512:
6
+ metadata.gz: '083dd037c5ad910be8df049651f420b957a6e42522613f96a7381097ba0545aa64907b501275078eaaa3d5e6fa5827294d520819801f153bef163aba1a8616b1'
7
+ data.tar.gz: 6ded417aef0e25f0c87124224812c7680b99342d0a4a6977b574c48a2f4cb4bee6ab61c27d8ee4c2e217ca9822d085931b7f172050839ef7ba2a20774be1006d
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ lib/*.bundle
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at meltingice8917@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ed25519-blake2b.gemspec
6
+ gemspec
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ed25519_blake2b (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+ rake-compiler (1.0.4)
11
+ rake
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.16)
18
+ ed25519_blake2b!
19
+ rake (~> 10.0)
20
+ rake-compiler (~> 1.0)
21
+
22
+ BUNDLED WITH
23
+ 1.16.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Kitepay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Ed25519Blake2b
2
+
3
+ This is a simple library for producing public keys from corresponding private keys using Ed25519, but with Blake2b as the hashing algorithm. Note that this is _not_ a full-featured Ed25519 hashing library at this time, but that could change in the future.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ed25519_blake2b'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ed25519_blake2b
20
+
21
+ ## Usage
22
+
23
+ Right now there is only one method available for use, that produces a public key from a private key. The private key is currently expected to be 64 bytes in length.
24
+
25
+ ```ruby
26
+ Ed25519Blake2b.public_key(private_key)
27
+ ```
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Kitepay/ed25519_blake2b. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Ed25519Blake2b project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Kitepay/ed25519_blake2b/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/extensiontask'
3
+
4
+ spec = Gem::Specification.load('ed25519_blake2b.gemspec')
5
+
6
+ Rake::ExtensionTask.new('ed25519_blake2b', spec) do |ext|
7
+ ext.source_pattern = '*.{c,h}'
8
+ end
9
+
10
+ task default: :full
11
+
12
+ desc 'Clean and compile'
13
+ task full: %w(clean compile)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ed25519_blake2b"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ed25519_blake2b/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ed25519_blake2b"
8
+ spec.version = Ed25519Blake2b::VERSION
9
+ spec.authors = ["Ryan LeFevre"]
10
+ spec.email = ["meltingice8917@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby library for ed25519, but with blake2b as the hashing function.}
13
+ spec.description = %q{Ruby library for ed25519, but with blake2b as the hashing function as required by the Nano cryptocurrency.}
14
+ spec.homepage = "https://github.com/Kitepay/ed25519_blake2b"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.extensions << "ext/ed25519_blake2b/extconf.rb"
27
+
28
+ spec.add_development_dependency "rake-compiler", "~> 1.0"
29
+ spec.add_development_dependency "bundler", "~> 1.16"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
@@ -0,0 +1,72 @@
1
+ /*
2
+ BLAKE2 reference source code package - optimized 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
+ #ifndef BLAKE2_CONFIG_H
16
+ #define BLAKE2_CONFIG_H
17
+
18
+ /* These don't work everywhere */
19
+ #if defined(__SSE2__) || defined(__x86_64__) || defined(__amd64__)
20
+ #define HAVE_SSE2
21
+ #endif
22
+
23
+ #if defined(__SSSE3__)
24
+ #define HAVE_SSSE3
25
+ #endif
26
+
27
+ #if defined(__SSE4_1__)
28
+ #define HAVE_SSE41
29
+ #endif
30
+
31
+ #if defined(__AVX__)
32
+ #define HAVE_AVX
33
+ #endif
34
+
35
+ #if defined(__XOP__)
36
+ #define HAVE_XOP
37
+ #endif
38
+
39
+
40
+ #ifdef HAVE_AVX2
41
+ #ifndef HAVE_AVX
42
+ #define HAVE_AVX
43
+ #endif
44
+ #endif
45
+
46
+ #ifdef HAVE_XOP
47
+ #ifndef HAVE_AVX
48
+ #define HAVE_AVX
49
+ #endif
50
+ #endif
51
+
52
+ #ifdef HAVE_AVX
53
+ #ifndef HAVE_SSE41
54
+ #define HAVE_SSE41
55
+ #endif
56
+ #endif
57
+
58
+ #ifdef HAVE_SSE41
59
+ #ifndef HAVE_SSSE3
60
+ #define HAVE_SSSE3
61
+ #endif
62
+ #endif
63
+
64
+ #ifdef HAVE_SSSE3
65
+ #define HAVE_SSE2
66
+ #endif
67
+
68
+ #if !defined(HAVE_SSE2)
69
+ #error "This code requires at least SSE2."
70
+ #endif
71
+
72
+ #endif
@@ -0,0 +1,160 @@
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
+ #ifndef BLAKE2_IMPL_H
16
+ #define BLAKE2_IMPL_H
17
+
18
+ #include <stdint.h>
19
+ #include <string.h>
20
+
21
+ #if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
22
+ #if defined(_MSC_VER)
23
+ #define BLAKE2_INLINE __inline
24
+ #elif defined(__GNUC__)
25
+ #define BLAKE2_INLINE __inline__
26
+ #else
27
+ #define BLAKE2_INLINE
28
+ #endif
29
+ #else
30
+ #define BLAKE2_INLINE inline
31
+ #endif
32
+
33
+ static BLAKE2_INLINE uint32_t load32( const void *src )
34
+ {
35
+ #if defined(NATIVE_LITTLE_ENDIAN)
36
+ uint32_t w;
37
+ memcpy(&w, src, sizeof w);
38
+ return w;
39
+ #else
40
+ const uint8_t *p = ( const uint8_t * )src;
41
+ return (( uint32_t )( p[0] ) << 0) |
42
+ (( uint32_t )( p[1] ) << 8) |
43
+ (( uint32_t )( p[2] ) << 16) |
44
+ (( uint32_t )( p[3] ) << 24) ;
45
+ #endif
46
+ }
47
+
48
+ static BLAKE2_INLINE uint64_t load64( const void *src )
49
+ {
50
+ #if defined(NATIVE_LITTLE_ENDIAN)
51
+ uint64_t w;
52
+ memcpy(&w, src, sizeof w);
53
+ return w;
54
+ #else
55
+ const uint8_t *p = ( const uint8_t * )src;
56
+ return (( uint64_t )( p[0] ) << 0) |
57
+ (( uint64_t )( p[1] ) << 8) |
58
+ (( uint64_t )( p[2] ) << 16) |
59
+ (( uint64_t )( p[3] ) << 24) |
60
+ (( uint64_t )( p[4] ) << 32) |
61
+ (( uint64_t )( p[5] ) << 40) |
62
+ (( uint64_t )( p[6] ) << 48) |
63
+ (( uint64_t )( p[7] ) << 56) ;
64
+ #endif
65
+ }
66
+
67
+ static BLAKE2_INLINE uint16_t load16( const void *src )
68
+ {
69
+ #if defined(NATIVE_LITTLE_ENDIAN)
70
+ uint16_t w;
71
+ memcpy(&w, src, sizeof w);
72
+ return w;
73
+ #else
74
+ const uint8_t *p = ( const uint8_t * )src;
75
+ return (( uint16_t )( p[0] ) << 0) |
76
+ (( uint16_t )( p[1] ) << 8) ;
77
+ #endif
78
+ }
79
+
80
+ static BLAKE2_INLINE void store16( void *dst, uint16_t w )
81
+ {
82
+ #if defined(NATIVE_LITTLE_ENDIAN)
83
+ memcpy(dst, &w, sizeof w);
84
+ #else
85
+ uint8_t *p = ( uint8_t * )dst;
86
+ *p++ = ( uint8_t )w; w >>= 8;
87
+ *p++ = ( uint8_t )w;
88
+ #endif
89
+ }
90
+
91
+ static BLAKE2_INLINE void store32( void *dst, uint32_t w )
92
+ {
93
+ #if defined(NATIVE_LITTLE_ENDIAN)
94
+ memcpy(dst, &w, sizeof w);
95
+ #else
96
+ uint8_t *p = ( uint8_t * )dst;
97
+ p[0] = (uint8_t)(w >> 0);
98
+ p[1] = (uint8_t)(w >> 8);
99
+ p[2] = (uint8_t)(w >> 16);
100
+ p[3] = (uint8_t)(w >> 24);
101
+ #endif
102
+ }
103
+
104
+ static BLAKE2_INLINE void store64( void *dst, uint64_t w )
105
+ {
106
+ #if defined(NATIVE_LITTLE_ENDIAN)
107
+ memcpy(dst, &w, sizeof w);
108
+ #else
109
+ uint8_t *p = ( uint8_t * )dst;
110
+ p[0] = (uint8_t)(w >> 0);
111
+ p[1] = (uint8_t)(w >> 8);
112
+ p[2] = (uint8_t)(w >> 16);
113
+ p[3] = (uint8_t)(w >> 24);
114
+ p[4] = (uint8_t)(w >> 32);
115
+ p[5] = (uint8_t)(w >> 40);
116
+ p[6] = (uint8_t)(w >> 48);
117
+ p[7] = (uint8_t)(w >> 56);
118
+ #endif
119
+ }
120
+
121
+ static BLAKE2_INLINE uint64_t load48( const void *src )
122
+ {
123
+ const uint8_t *p = ( const uint8_t * )src;
124
+ return (( uint64_t )( p[0] ) << 0) |
125
+ (( uint64_t )( p[1] ) << 8) |
126
+ (( uint64_t )( p[2] ) << 16) |
127
+ (( uint64_t )( p[3] ) << 24) |
128
+ (( uint64_t )( p[4] ) << 32) |
129
+ (( uint64_t )( p[5] ) << 40) ;
130
+ }
131
+
132
+ static BLAKE2_INLINE void store48( void *dst, uint64_t w )
133
+ {
134
+ uint8_t *p = ( uint8_t * )dst;
135
+ p[0] = (uint8_t)(w >> 0);
136
+ p[1] = (uint8_t)(w >> 8);
137
+ p[2] = (uint8_t)(w >> 16);
138
+ p[3] = (uint8_t)(w >> 24);
139
+ p[4] = (uint8_t)(w >> 32);
140
+ p[5] = (uint8_t)(w >> 40);
141
+ }
142
+
143
+ static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c )
144
+ {
145
+ return ( w >> c ) | ( w << ( 32 - c ) );
146
+ }
147
+
148
+ static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c )
149
+ {
150
+ return ( w >> c ) | ( w << ( 64 - c ) );
151
+ }
152
+
153
+ /* prevents compiler optimizing out memset() */
154
+ static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)
155
+ {
156
+ static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
157
+ memset_v(v, 0, n);
158
+ }
159
+
160
+ #endif