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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/synacrb/version.rb +1 -1
- data/lib/synacrb.rb +0 -1
- metadata +2 -3
- data/lib/synacrb/encrypter.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6b54b207332754ef4bbc7411129104a8e0acc45
|
4
|
+
data.tar.gz: 5bd5016cc61767185108fa43b2ca85b221f70a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77d71642c12c1367998dbbd45b1329e4f2f19071ba98a94272d43b1c1a237e01e1500bbd150f39e96954fba2340c5ef63de20ce65846d8c3d1484102d6a095fc
|
7
|
+
data.tar.gz: 7b35767a5658f2ed9d0c356f2a64ac9b37ce05f9d54ce49f65b5e02f78a53dbfaf74b61b3ad0658fb0e013a47a6e4b033e549b52a5b96705e0c9289233a50e6c
|
data/Gemfile.lock
CHANGED
data/lib/synacrb/version.rb
CHANGED
data/lib/synacrb.rb
CHANGED
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.
|
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-
|
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
|
data/lib/synacrb/encrypter.rb
DELETED
@@ -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
|