mbedtls 0.1.0.beta1

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.
@@ -0,0 +1 @@
1
+ void Init_ssl();
File without changes
@@ -0,0 +1,2 @@
1
+ require "polarssl/polarssl"
2
+ require "polarssl/version"
@@ -0,0 +1,3 @@
1
+ module PolarSSL
2
+ VERSION = '0.1.0.beta1'
3
+ end
@@ -0,0 +1,23 @@
1
+ lib = File.expand_path("../lib/", __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require 'polarssl/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'mbedtls'
8
+ s.version = PolarSSL::VERSION
9
+ s.date = Date.today
10
+ s.summary = 'Use the mbed TLS cryptographic and SSL library in Ruby.'
11
+ s.description = 'A gem that lets you use the mbed TLS cryptography library with Ruby.'
12
+ s.authors = ['Adam Caudill']
13
+ s.email = 'adam@adamcaudill.com'
14
+ s.files = `git ls-files`.split("\n")
15
+ s.homepage = 'https://github.com/adamcaudill/mbedtls-ruby'
16
+ s.license = 'LGPL-3'
17
+ s.test_files = Dir.glob('test/*_test.rb')
18
+ s.requirements = 'mbedtls, >= v2.4.x'
19
+ #s.cert_chain = ["certs/michiels.pem"]
20
+ #s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
21
+
22
+ s.extensions = %w[ext/polarssl/extconf.rb]
23
+ end
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders":
3
+ [
4
+ {
5
+ "path": "/Users/michiel/Code/polarssl-ruby"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,40 @@
1
+ require 'test_helper'
2
+ require 'base64'
3
+ require 'securerandom'
4
+
5
+ class CipherTest < MiniTest::Test
6
+ CIPHER = 'AES-128-CTR'
7
+ VALUE = 'test data value'
8
+ KEY = 'bar'
9
+
10
+ def test_aes_128_ctr_encrypt
11
+ iv = SecureRandom.random_bytes(16)
12
+
13
+ cipher = PolarSSL::Cipher.new CIPHER
14
+ cipher.setkey KEY, 128, PolarSSL::Cipher::OPERATION_ENCRYPT
15
+ cipher.set_iv(iv, 16)
16
+ cipher.update(VALUE)
17
+ encrypted = cipher.finish
18
+
19
+ cipher = PolarSSL::Cipher.new CIPHER
20
+ cipher.setkey KEY, 128, PolarSSL::Cipher::OPERATION_DECRYPT
21
+ cipher.set_iv(iv, 16)
22
+ cipher.update(encrypted)
23
+ decrypted = cipher.finish
24
+
25
+ assert_equal VALUE, decrypted
26
+ end
27
+
28
+ def test_unsupported_cipher
29
+ assert_raises PolarSSL::Cipher::UnsupportedCipher do
30
+ PolarSSL::Cipher.new("meh")
31
+ end
32
+ end
33
+
34
+ def test_unsupported_key
35
+ assert_raises PolarSSL::Cipher::Error do
36
+ cipher = PolarSSL::Cipher.new("AES-128-CTR")
37
+ cipher.setkey("1234567890123456", 127, PolarSSL::Cipher::OPERATION_ENCRYPT)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class CtrDrbgTest < MiniTest::Test
4
+
5
+ def test_new
6
+ entropy = PolarSSL::Entropy.new
7
+ ctr_drbg = PolarSSL::CtrDrbg.new(entropy)
8
+ end
9
+
10
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class EntropyTest < MiniTest::Test
4
+
5
+ def test_initialize
6
+ entropy = PolarSSL::Entropy.new
7
+ end
8
+
9
+ def test_gather
10
+ entropy = PolarSSL::Entropy.new
11
+ assert entropy.gather()
12
+ end
13
+
14
+ end
@@ -0,0 +1,41 @@
1
+ require 'test_helper'
2
+ require 'socket'
3
+
4
+ class SSLConnectionTest < MiniTest::Test
5
+
6
+ def test_simple_connection
7
+
8
+ socket = TCPSocket.new('polarssl.org', 443)
9
+
10
+ entropy = PolarSSL::Entropy.new
11
+
12
+ ctr_drbg = PolarSSL::CtrDrbg.new(entropy)
13
+
14
+ ssl = PolarSSL::SSL.new
15
+
16
+ ssl.set_endpoint(PolarSSL::SSL::SSL_IS_CLIENT)
17
+ ssl.set_authmode(PolarSSL::SSL::SSL_VERIFY_NONE)
18
+ ssl.set_rng(ctr_drbg)
19
+
20
+ ssl.set_socket(socket)
21
+
22
+ ssl.handshake
23
+
24
+ ssl.write("GET / HTTP/1.0\r\nHost: polarssl.org\r\n\r\n")
25
+
26
+ response = ""
27
+
28
+ while chunk = ssl.read(1024)
29
+ response << chunk
30
+ end
31
+
32
+ assert response.length > 0
33
+
34
+ ssl.close_notify
35
+
36
+ socket.close
37
+
38
+ ssl.close
39
+ end
40
+
41
+ end
@@ -0,0 +1,2 @@
1
+ require 'minitest/autorun'
2
+ require 'polarssl'
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mbedtls
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.beta1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Caudill
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem that lets you use the mbed TLS cryptography library with Ruby.
14
+ email: adam@adamcaudill.com
15
+ executables: []
16
+ extensions:
17
+ - ext/polarssl/extconf.rb
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".ruby-version"
22
+ - ".travis.yml"
23
+ - COPYING
24
+ - COPYING.LESSER
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - RDOC_MAIN.rdoc
28
+ - README.md
29
+ - Rakefile
30
+ - certs/michiels.pem
31
+ - checksum/polarssl-1.0.1.gem.sha512
32
+ - ext/polarssl/cipher.c
33
+ - ext/polarssl/cipher.h
34
+ - ext/polarssl/ctr_drbg.c
35
+ - ext/polarssl/ctr_drbg.h
36
+ - ext/polarssl/entropy.c
37
+ - ext/polarssl/entropy.h
38
+ - ext/polarssl/extconf.rb
39
+ - ext/polarssl/polarssl.c
40
+ - ext/polarssl/polarssl.h
41
+ - ext/polarssl/ssl.c
42
+ - ext/polarssl/ssl.h
43
+ - lib/.gitkeep
44
+ - lib/polarssl.rb
45
+ - lib/polarssl/version.rb
46
+ - mbedtls.gemspec
47
+ - polarssl-ruby.sublime-project
48
+ - test/cipher_encryption_test.rb
49
+ - test/ctr_drbg_test.rb
50
+ - test/entropy_test.rb
51
+ - test/ssl_connection_test.rb
52
+ - test/test_helper.rb
53
+ homepage: https://github.com/adamcaudill/mbedtls-ruby
54
+ licenses:
55
+ - LGPL-3
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">"
69
+ - !ruby/object:Gem::Version
70
+ version: 1.3.1
71
+ requirements:
72
+ - mbedtls, >= v2.4.x
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.8
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Use the mbed TLS cryptographic and SSL library in Ruby.
78
+ test_files:
79
+ - test/cipher_encryption_test.rb
80
+ - test/ctr_drbg_test.rb
81
+ - test/entropy_test.rb
82
+ - test/ssl_connection_test.rb