rmega 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/rmega.rb +1 -0
- data/lib/rmega/api_response.rb +3 -0
- data/lib/rmega/nodes/expandable.rb +1 -1
- data/lib/rmega/nodes/node.rb +2 -2
- data/lib/rmega/nodes/uploadable.rb +1 -1
- data/lib/rmega/session.rb +23 -4
- data/lib/rmega/utils.rb +7 -0
- data/lib/rmega/version.rb +1 -1
- data/rmega.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48d1cd2037a5511fdc9adc693fbd1b6e74331327a3e46a93e2326a3c9aef7f42
|
4
|
+
data.tar.gz: 159cd701d79d5fdb8d903a562f01fff6a439fedb2d6efff926acf8df772182f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74c4ac1a15aeafeea21aed3dce4f17e8bdc7f82bf50608d776bc3c9df27e57ece398e8b8cf1b77d6dcd34114a020b7b1bcbcf3bdeca398da80b0ab80c3e72f39
|
7
|
+
data.tar.gz: 48a51f07da3be0c88619068afa1fc93a42d4f77dc008ddf6a5504a66aa536584e46af9e3c799fcf8f70fec44c6d31c5aabdaf74bd13257fa4910df9418c793b9
|
data/CHANGELOG.md
CHANGED
data/lib/rmega.rb
CHANGED
data/lib/rmega/api_response.rb
CHANGED
@@ -26,6 +26,9 @@ module Rmega
|
|
26
26
|
-20 => 'Write failed',
|
27
27
|
-21 => 'Read failed',
|
28
28
|
-22 => 'Invalid application key; request not processed',
|
29
|
+
-23 => 'SSL verification failed',
|
30
|
+
-24 => 'Not enough quota',
|
31
|
+
-26 => '2FA required',
|
29
32
|
}.freeze
|
30
33
|
|
31
34
|
def initialize(http_response)
|
data/lib/rmega/nodes/node.rb
CHANGED
@@ -31,14 +31,14 @@ module Rmega
|
|
31
31
|
def serialize_attributes(hash)
|
32
32
|
str = "MEGA"
|
33
33
|
str << hash.to_json
|
34
|
-
str << ("\x00" * (16 - (str.
|
34
|
+
str << ("\x00" * (16 - (str.bytesize % 16)))
|
35
35
|
return str
|
36
36
|
end
|
37
37
|
|
38
38
|
def rename(new_name)
|
39
39
|
node_key = NodeKey.load(decrypted_file_key)
|
40
40
|
|
41
|
-
_attr = serialize_attributes(attributes.merge("n" => new_name))
|
41
|
+
_attr = serialize_attributes(attributes.merge("n" => Utils.utf8(new_name)))
|
42
42
|
_attr = aes_cbc_encrypt(node_key.aes_key, _attr)
|
43
43
|
_attr = Utils.base64urlencode(_attr)
|
44
44
|
|
@@ -69,7 +69,7 @@ module Rmega
|
|
69
69
|
pool.shutdown
|
70
70
|
|
71
71
|
# encrypt attributes
|
72
|
-
_attr = serialize_attributes(:n => ::File.basename(path))
|
72
|
+
_attr = serialize_attributes(:n => Utils.utf8(::File.basename(path)))
|
73
73
|
_attr = aes_cbc_encrypt(rnd_node_key.aes_key, _attr)
|
74
74
|
|
75
75
|
# Calculate meta_mac
|
data/lib/rmega/session.rb
CHANGED
@@ -86,12 +86,31 @@ module Rmega
|
|
86
86
|
# * The user master_key (128 bit for AES) encrypted with the password_hash
|
87
87
|
# * The RSA private key ecrypted with the master_key
|
88
88
|
# * A brand new session_id encrypted with the RSA private key
|
89
|
-
def login(email, password)
|
89
|
+
def login(email, password)
|
90
|
+
# discover the version of the account (1: old accounts, >=2: newer accouts)
|
91
|
+
resp = request(a: 'us0', user: email.strip)
|
92
|
+
account_version = resp["v"].to_i
|
93
|
+
|
90
94
|
# Derive an hash from the user password
|
91
|
-
|
92
|
-
|
95
|
+
if account_version == 1
|
96
|
+
password_hash = hash_password(password)
|
97
|
+
u_hash = user_hash(password_hash, email.strip.downcase)
|
98
|
+
else
|
99
|
+
df2 = PBKDF2.new(
|
100
|
+
:password => password,
|
101
|
+
:salt => Utils.base64urldecode(resp['s']),
|
102
|
+
:iterations => 100000,
|
103
|
+
:hash_function => :sha512,
|
104
|
+
:key_length => 16 * 2,
|
105
|
+
).bin_string
|
106
|
+
password_hash = df2[0,16]
|
107
|
+
u_hash = Utils.base64urlencode(df2[16,32])
|
108
|
+
end
|
93
109
|
|
94
|
-
|
110
|
+
# Send the login request
|
111
|
+
req = {a: 'us', user: email.strip, uh: u_hash}
|
112
|
+
req[:sek] = Utils.base64urlencode(SecureRandom.random_bytes(16)) if account_version != 1
|
113
|
+
resp = request(req)
|
95
114
|
|
96
115
|
@master_key = aes_cbc_decrypt(password_hash, Utils.base64urldecode(resp['k']))
|
97
116
|
@rsa_privk = decrypt_rsa_private_key(resp['privk'])
|
data/lib/rmega/utils.rb
CHANGED
data/lib/rmega/version.rb
CHANGED
data/rmega.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.license = 'MIT'
|
18
18
|
gem.required_ruby_version = '>= 1.9.3'
|
19
19
|
|
20
|
+
gem.add_dependency "pbkdf2-ruby"
|
21
|
+
|
20
22
|
gem.add_development_dependency "pry"
|
21
23
|
gem.add_development_dependency "rspec"
|
22
24
|
gem.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmega
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- topac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pbkdf2-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: pry
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|