onnistuu_fi 0.1.0 → 1.0.0

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
  SHA1:
3
- metadata.gz: 2d8c750ed0ddbe0401d908a47a5dc306b1ee07b5
4
- data.tar.gz: bb7a70479ed65d1c3a98ee28062275dbb0dc27ec
3
+ metadata.gz: 8e2d47ad652d33ffa6f0cf337649740357d36d2a
4
+ data.tar.gz: a4cd132595c28603f3239d3feba4193a1b8f12f3
5
5
  SHA512:
6
- metadata.gz: 76377b3df828ce8b4affe483d69158c0fa7759b3beba5afeb0ea09e7a4791803d67b5d1d7e3c1cc13cb30c1ae4d476cbfd28f0722eae3c3f81009e369a2bd9f4
7
- data.tar.gz: 2d63342c6558ed73b7707f90db5480cc2ac978ee5db1728c85a33da06be2f1926551ef3ee30f6cc0a2f7636d8d856c5b91e917b859b666855e3ab26928912a3a
6
+ metadata.gz: 9ea37983e3b854b88474c52e3ae50a2949dbd7d2cad1beb8c8ee35f9152218d5781ac3e293e0cbc6a7a0846d09450b8a0fd5c68992c8f6597bc46dc5c04c971a
7
+ data.tar.gz: 0d89a6fe38dd27566c021c28d22608d1f5461308f2d3382502833055298550007a88d9a47402eb3a939988a516107a84e22d5c2d3f4ca86e4de9df326b864a92
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Dependencies
22
22
 
23
- Mcrypt needs to be installed for the library to work.
23
+ None.
24
24
 
25
25
  ## Usage
26
26
 
@@ -81,3 +81,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
81
81
 
82
82
  Bug reports and pull requests are welcome on GitHub at https://github.com/kiskolabs/onnistuu_fi.
83
83
 
84
+ ## License
85
+
86
+ The library is released under the MIT License.
data/bin/setup CHANGED
@@ -4,4 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
- brew install mcrypt
@@ -23,6 +23,7 @@ module OnnistuuFi
23
23
  "<form action='#{API_ENDPOINT}' method='post'>
24
24
  #{fields.compact.join("\n")}
25
25
  <input type='hidden' name='padding' value='pkcs5' />
26
+ <input type='hidden' name='cipher' value='rijndael-128' />
26
27
  #{@options[:button]}
27
28
  </form>"
28
29
  end
@@ -1,31 +1,36 @@
1
- require "mcrypt"
2
1
  require "base64"
3
2
  require "openssl"
4
3
 
5
4
  module OnnistuuFi
6
5
  class Signer
7
- def initialize(client_identifier, encryption_key)
8
- @client_identifier = client_identifier
9
- @encryption_key = Base64.decode64(encryption_key)
6
+ attr_accessor :key
7
+
8
+ def initialize(_key, keycode)
9
+ self.key = Base64.decode64(keycode)
10
10
  end
11
11
 
12
- # Returns [base64_iv, base64_encrypted_data]
13
- def encrypt(data)
14
- iv = OpenSSL::Cipher::Cipher.new("AES-256-CBC").random_iv.unpack("H*").first
15
- mcrypt = Mcrypt.new(:rijndael_256, :cbc, @encryption_key, iv, :pkcs)
12
+ def encrypt(message)
13
+ return nil if message.nil?
16
14
 
17
- [Base64.encode64(iv), Base64.encode64(mcrypt.encrypt(JSON.dump(data)))]
15
+ iv = OpenSSL::Cipher::Cipher.new("AES-128-CBC").random_iv
16
+ aes = OpenSSL::Cipher.new('AES-256-CBC')
17
+ aes.encrypt
18
+ aes.key = key
19
+ aes.iv = iv
20
+ encrypted_data = aes.update(JSON.dump(message)) + aes.final
21
+ [Base64.encode64(iv), Base64.encode64(encrypted_data)]
18
22
  end
19
23
 
20
- # Parameters:
21
- # - encrypted data in base64
22
- # - iv in base64
23
- #
24
- # Returns decrypted data
25
- def decrypt(encrypted, iv)
26
- mcrypt = Mcrypt.new(:rijndael_256, :cbc, @encryption_key, Base64.decode64(iv), :pkcs)
27
-
28
- JSON.load(mcrypt.decrypt(Base64.decode64(encrypted)))
24
+ def decrypt(encrypted_data, iv)
25
+ return nil if encrypted_data.nil?
26
+ encrypted_data = Base64.decode64(encrypted_data).strip
27
+ iv = Base64.decode64(iv).strip
28
+ aes = OpenSSL::Cipher.new('AES-256-CBC')
29
+ aes.decrypt
30
+ aes.key = key
31
+ aes.iv = iv
32
+ message = (aes.update(encrypted_data) + aes.final)
33
+ JSON.load(message)
29
34
  end
30
35
  end
31
36
  end
@@ -1,3 +1,3 @@
1
1
  module OnnistuuFi
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/onnistuu_fi.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Implements Onnistuu.fi interface.}
13
13
  spec.description = %q{Implements Onnistuu.fi interface}
14
14
  spec.homepage = "https://github.com/kiskolabs/onnistuu_fi"
15
+ spec.licenses = ["MIT"]
15
16
 
16
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -31,6 +32,4 @@ Gem::Specification.new do |spec|
31
32
  spec.add_development_dependency "rspec", "~> 3.0"
32
33
  spec.add_development_dependency "rspec-html-matchers", "~> 0.8.0"
33
34
  spec.add_development_dependency "byebug"
34
- spec.add_dependency "aes", "~> 0.5.0"
35
- spec.add_dependency "ruby-mcrypt", "~> 0.2.0"
36
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onnistuu_fi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vesa Vänskä
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,34 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: aes
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.5.0
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.5.0
97
- - !ruby/object:Gem::Dependency
98
- name: ruby-mcrypt
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.2.0
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.2.0
111
83
  description: Implements Onnistuu.fi interface
112
84
  email:
113
85
  - vesa@vesavanska.com
@@ -130,7 +102,8 @@ files:
130
102
  - lib/onnistuu_fi/version.rb
131
103
  - onnistuu_fi.gemspec
132
104
  homepage: https://github.com/kiskolabs/onnistuu_fi
133
- licenses: []
105
+ licenses:
106
+ - MIT
134
107
  metadata:
135
108
  allowed_push_host: https://rubygems.org
136
109
  post_install_message:
@@ -149,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
122
  version: '0'
150
123
  requirements: []
151
124
  rubyforge_project:
152
- rubygems_version: 2.4.5.1
125
+ rubygems_version: 2.6.8
153
126
  signing_key:
154
127
  specification_version: 4
155
128
  summary: Implements Onnistuu.fi interface.