noise-ruby 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9731ebe9c0021aacc2dd916c8c37d42a4354a0aea6ef90c1f2983dc6cc200c48
4
- data.tar.gz: 057bf0bf52963ba3f988f75ea0ed69d6c93df359ec0bd9017476960f492fef1c
3
+ metadata.gz: 52f9bedd93319f9cf54acb51c1a83c64fcfd25cfdaef69204f709b59c83060c4
4
+ data.tar.gz: c72fb7afa8aab1c577b305f1d57316ab34ad183b6bbf249d420b3b17d4bb81e6
5
5
  SHA512:
6
- metadata.gz: 908ad0b81ab191a5f90b86a772b2af393ce82ef9df7fcda0deedfae345f449f5f997fa686e554139b1795fd29c74126eb12ef8c03543d362f9d2d1913a47b7b1
7
- data.tar.gz: c11189bf83c51b1b4d80c054f5e0db0c2a43cad1304929816bc155b0cc38ef35e88e9b42f629b7c48de0b754ba87106d16d06b5c0b01776e9f1350a0b81e2273
6
+ metadata.gz: be31e461a923db0af2f6ae19b42fa74ac3b70fcac8e332a281a46377ac0fa0164ce799567ba19e862fbbc40b367b06672bd095ea850bcd4bfaec2291b1b4ab16
7
+ data.tar.gz: e3495a893d23263a534d7f490fdcd84a5f33c81b4e5d8437d1a268abc8111940916ecf6f832f2b13bf610d5ec9f1059129c16a9f2a0728a823b96a147482e7ac
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'secp256k1'
3
+ begin
4
+ require 'secp256k1'
5
+ rescue LoadError
6
+ end
7
+
4
8
 
5
9
  module Noise
6
10
  module Functions
@@ -62,7 +62,7 @@ module Noise
62
62
  raise ArgumentError if out_len == 0 || out_len > 32
63
63
  h = IV.dup
64
64
  h[0] ^= 0x01010000 ^ (key.size << 8) ^ out_len
65
- t = [0, 0]
65
+ t = 0
66
66
  c = 0
67
67
  b = Array.new(Blake2s::BLOCKLEN).fill(0, key.size)
68
68
  ctx = Context.new(b, h, t, c, out_len)
@@ -76,12 +76,7 @@ module Noise
76
76
  def update_internal(ctx, input)
77
77
  input.size.times do |i|
78
78
  if ctx.c == Blake2s::BLOCKLEN
79
- ctx.t[0] += ctx.c
80
- # if ctx.t[0] < ctx.c
81
- if ctx.t[0] > 0xFFFFFFFF
82
- ctx.t[0] = ctx.t[0] - 0xFFFFFFFF
83
- ctx.t[1] += 1
84
- end
79
+ ctx.t += ctx.c
85
80
  compress(ctx, false)
86
81
  ctx.c = 0
87
82
  end
@@ -92,12 +87,7 @@ module Noise
92
87
  end
93
88
 
94
89
  def final(ctx, out)
95
- ctx.t[0] += ctx.c
96
- if ctx.t[0] > 0xFFFFFFFF
97
- ctx.t[0] = ctx.t[0] - 0xFFFFFFFF
98
- ctx.t[1] += 1
99
- end
100
-
90
+ ctx.t += ctx.c
101
91
  while ctx.c < Blake2s::BLOCKLEN
102
92
  ctx.b[ctx.c] = 0
103
93
  ctx.c += 1
@@ -151,12 +141,10 @@ module Noise
151
141
  v[i + 8] = IV[i]
152
142
  end
153
143
 
154
- v[12] ^= ctx.t[0]
155
- v[13] ^= ctx.t[1]
144
+ v[12] ^= ctx.t & 0xFFFFFFFF
145
+ v[13] ^= (ctx.t / 0x100000000) & 0xFFFFFFFF
156
146
 
157
- if last
158
- v[14] = ~v[14] & 0xFFFFFFFF
159
- end
147
+ v[14] = (last ? ~v[14] : v[14]) & 0xFFFFFFFF
160
148
 
161
149
  16.times do |i|
162
150
  m[i] = get32(ctx.b[4 * i], ctx.b[4 * i + 1], ctx.b[4 * i + 2], ctx.b[4 * i + 3])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Noise
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noise-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hajime Yamaguchi