x25519 1.0.1 → 1.0.2
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/CHANGES.md +8 -0
- data/README.md +6 -0
- data/ext/x25519_precomputed/x25519_precomputed.h +3 -3
- data/ext/x25519_ref10/x25519_ref10.h +3 -3
- data/lib/x25519.rb +12 -9
- data/lib/x25519/version.rb +1 -1
- data/x25519.gemspec +1 -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: fb37496fe14ef2bf58826e5b30805597b7031c5b
|
4
|
+
data.tar.gz: 02e5d45c634da965b9d351da48c1213f16de2eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c40748f5937cba15380f71e729924764ee8e50f2992aff31ae91100d3efad634ee03ba51da02a62d4de5f243e56c7fc31af47d615b4b4a492df7f5ab937e43
|
7
|
+
data.tar.gz: afae5c90642ae8eeec06c2e107d522f0da19b4b74f6c6b22cd386ffe6590ec8bcab665b1affd136505a38a0b1aed3011d6034a9f7ce392bd106f3f2321492858
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# [1.0.2] (2017-12-13)
|
2
|
+
|
3
|
+
[1.0.2]: https://github.com/cryptosphere/x25519/compare/v1.0.1...v1.0.2
|
4
|
+
|
5
|
+
* [#9](https://github.com/cryptosphere/x25519/pull/9)
|
6
|
+
Make `X25519.provider` an `attr_accessor`
|
7
|
+
* Raise `X25519::SelfTestFailure` when self-test fails
|
8
|
+
|
1
9
|
# [1.0.1] (2017-12-12)
|
2
10
|
|
3
11
|
[1.0.1]: https://github.com/cryptosphere/x25519/compare/v1.0.0...v1.0.1
|
data/README.md
CHANGED
@@ -18,9 +18,15 @@ high performance [rfc7748_precomputed] implementation based on the paper
|
|
18
18
|
[How to (pre-)compute a ladder]
|
19
19
|
(with fallback to the ref10 C implementation).
|
20
20
|
|
21
|
+
X25519 is one of two notable algorithms implemented atop the Curve25519
|
22
|
+
elliptic curve. The [ed25519 gem] is a related project of this one,
|
23
|
+
and implements the Ed25519 signature scheme on the twisted Edwards form of
|
24
|
+
Curve25519.
|
25
|
+
|
21
26
|
[RFC7748]: https://tools.ietf.org/html/rfc7748
|
22
27
|
[How to (pre-)compute a ladder]: https://eprint.iacr.org/2017/264
|
23
28
|
[rfc7748_precomputed]: https://github.com/armfazh/rfc7748_precomputed
|
29
|
+
[ed25519 gem]: https://github.com/cryptosphere/ed25519
|
24
30
|
|
25
31
|
## Requirements
|
26
32
|
|
@@ -15,8 +15,8 @@
|
|
15
15
|
* You should have received a copy of the GNU Lesser General Public License
|
16
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
*/
|
18
|
-
#ifndef
|
19
|
-
#define
|
18
|
+
#ifndef X25519_PRECOMPUTED_H
|
19
|
+
#define X25519_PRECOMPUTED_H
|
20
20
|
|
21
21
|
#include <stdint.h>
|
22
22
|
|
@@ -34,4 +34,4 @@ void x25519_precomputed_scalarmult(uint8_t *shared, uint8_t *private_key, uint8_
|
|
34
34
|
void x25519_precomputed_scalarmult_base(uint8_t *session_key, uint8_t *private_key);
|
35
35
|
int check_4th_gen_intel_core_features();
|
36
36
|
|
37
|
-
#endif /*
|
37
|
+
#endif /* X25519_PRECOMPUTED_H */
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef X25519_REF10_H
|
2
|
+
#define X25519_REF10_H
|
3
3
|
|
4
4
|
#include <stdint.h>
|
5
5
|
|
@@ -12,4 +12,4 @@ int x25519_ref10_scalarmult(uint8_t *q, const uint8_t *n, const uint8_t *p);
|
|
12
12
|
/* Variable-base scalar multiplication */
|
13
13
|
int x25519_ref10_scalarmult_base(uint8_t *q, const uint8_t *n);
|
14
14
|
|
15
|
-
#endif /*
|
15
|
+
#endif /* X25519_REF10_H */
|
data/lib/x25519.rb
CHANGED
@@ -19,18 +19,21 @@ module X25519
|
|
19
19
|
# Size of an X25519 key (public or private) in bytes
|
20
20
|
KEY_SIZE = 32
|
21
21
|
|
22
|
+
# Raised when the built-in self-test fails
|
23
|
+
SelfTestFailure = Class.new(StandardError)
|
24
|
+
|
25
|
+
class << self
|
26
|
+
# Obtain the backend provider module
|
27
|
+
attr_accessor :provider
|
28
|
+
end
|
29
|
+
|
22
30
|
# ref10 is the default provider
|
23
|
-
|
31
|
+
self.provider = X25519::Provider::Ref10
|
24
32
|
|
25
33
|
# X25519::Precomputed requires a 4th generation Intel Core CPU or newer,
|
26
34
|
# so only enable it if we detect we're on a supported platform. Otherwise,
|
27
35
|
# fall back to the ref10 portable C implementation.
|
28
|
-
|
29
|
-
|
30
|
-
# Selected provider based on the logic above
|
31
|
-
def provider
|
32
|
-
@provider
|
33
|
-
end
|
36
|
+
self.provider = X25519::Provider::Precomputed if X25519::Provider::Precomputed.available?
|
34
37
|
|
35
38
|
# Raw Diffie-Hellman function that acts directly on bytestrings. An
|
36
39
|
# alternative to the object-oriented API
|
@@ -56,12 +59,12 @@ module X25519
|
|
56
59
|
def self_test
|
57
60
|
X25519::TestVectors::VARIABLE_BASE.each do |v|
|
58
61
|
shared_secret = provider.scalarmult([v.scalar].pack("H*"), [v.input_coord].pack("H*"))
|
59
|
-
raise "self test failed!" unless shared_secret.unpack("H*").first == v.output_coord
|
62
|
+
raise SelfTestFailure, "self test failed!" unless shared_secret.unpack("H*").first == v.output_coord
|
60
63
|
end
|
61
64
|
|
62
65
|
X25519::TestVectors::FIXED_BASE.each do |v|
|
63
66
|
public_key = provider.scalarmult_base([v.scalar].pack("H*"))
|
64
|
-
raise "self test failed!" unless public_key.unpack("H*").first == v.output_coord
|
67
|
+
raise SelfTestFailure, "self test failed!" unless public_key.unpack("H*").first == v.output_coord
|
65
68
|
end
|
66
69
|
|
67
70
|
true
|
data/lib/x25519/version.rb
CHANGED
data/x25519.gemspec
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "x25519/version"
|
3
|
+
require File.expand_path("lib/x25519/version", __dir__)
|
6
4
|
|
7
5
|
Gem::Specification.new do |spec|
|
8
6
|
spec.name = "x25519"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: x25519
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|