synacrb 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2a86ffcf864c1c52ef8f62231b6fb2d098d217f
4
- data.tar.gz: 8d5cb8688ecf2390fa1d7bdee94fbc90fa6a51a9
3
+ metadata.gz: c6b54b207332754ef4bbc7411129104a8e0acc45
4
+ data.tar.gz: 5bd5016cc61767185108fa43b2ca85b221f70a3e
5
5
  SHA512:
6
- metadata.gz: be7827c0d1cc992564e4bed849feb150588b1c1321c097a58b107b694cbce10c39aa662563a057d9f8dfbbe83356bc61772a9f8ab824daa32a10f5b5900b4cf6
7
- data.tar.gz: 3bad3e5d8c38897c359dfad211c8416cdc24929d12ded6f0b962bfb05c50b5b8905fc587c29f68b5999322c2c74c7068d96a07fd846e005a97d80b9668a5422b
6
+ metadata.gz: 77d71642c12c1367998dbbd45b1329e4f2f19071ba98a94272d43b1c1a237e01e1500bbd150f39e96954fba2340c5ef63de20ce65846d8c3d1484102d6a095fc
7
+ data.tar.gz: 7b35767a5658f2ed9d0c356f2a64ac9b37ce05f9d54ce49f65b5e02f78a53dbfaf74b61b3ad0658fb0e013a47a6e4b033e549b52a5b96705e0c9289233a50e6c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synacrb (0.3.0)
4
+ synacrb (0.3.2)
5
5
  msgpack (~> 1.2)
6
6
  openssl (~> 2.1)
7
7
 
@@ -1,3 +1,3 @@
1
1
  module Synacrb
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/lib/synacrb.rb CHANGED
@@ -3,7 +3,6 @@ require "openssl"
3
3
  require "socket"
4
4
 
5
5
  require "synacrb/common"
6
- require "synacrb/encrypter"
7
6
  require "synacrb/state"
8
7
  require "synacrb/version"
9
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synacrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jD91mZM2
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -83,7 +83,6 @@ files:
83
83
  - bin/setup
84
84
  - lib/synacrb.rb
85
85
  - lib/synacrb/common.rb
86
- - lib/synacrb/encrypter.rb
87
86
  - lib/synacrb/state.rb
88
87
  - lib/synacrb/version.rb
89
88
  - synacrb.gemspec
@@ -1,43 +0,0 @@
1
- module Synacrb
2
- # Encrypt `input` with `rsa` instance.
3
- # The difference between just encrypting it normally
4
- # is that this has a larger max-length and is
5
- # following the standard synac format.
6
- def self.encrypt(input, rsa)
7
- cipher = OpenSSL::Cipher.new "AES-256-CBC"
8
- cipher.encrypt
9
- key = cipher.random_key
10
- iv = cipher.random_iv
11
-
12
- encrypted_aes = cipher.update(input) + cipher.final
13
- size_aes = encrypted_aes.bytesize
14
-
15
- keyiv = key + iv
16
- encrypted_rsa = rsa.public_encrypt keyiv
17
- size_rsa = encrypted_rsa.bytesize
18
-
19
- Common.encode_u16(size_rsa) +
20
- Common.encode_u16(size_aes) +
21
- encrypted_rsa +
22
- encrypted_aes
23
- end
24
-
25
- # Decrypt `input` with `rsa` instance.
26
- # The difference between just decrypting it normally
27
- # is that this has a larger max-length and is
28
- # following the standard synac format.
29
- def self.decrypt(input, rsa)
30
- size_rsa = Common.decode_u16(input.byteslice(0, 2));
31
- size_aes = Common.decode_u16(input.byteslice(2, 4));
32
-
33
- input = input.byteslice(4, input.bytesize)
34
-
35
- keyiv = rsa.private_decrypt input.byteslice(0, size_rsa)
36
-
37
- cipher = OpenSSL::Cipher.new "AES-256-CBC"
38
- cipher.decrypt
39
- cipher.key = keyiv.byteslice(0, 32)
40
- cipher.iv = keyiv.byteslice(32, 32+16)
41
- cipher.update(input.byteslice(size_rsa, input.bytesize)) + cipher.final
42
- end
43
- end