naoki 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -77,7 +77,8 @@ else
77
77
  encrypted_data_length_pointer
78
78
  ) }
79
79
 
80
- encrypted_data = FFI::MemoryPointer.new :pointer, encrypted_data_length_pointer.read_int/4
80
+ # add 1 to the size allocated to account for the 3-byte Ciphertext Header, which has the key version
81
+ encrypted_data = FFI::MemoryPointer.new :pointer, encrypted_data_length_pointer.read_int/4 + 1
81
82
 
82
83
  check { I_C_Crypt(
83
84
  @@session_pointer.get_pointer(0),
data/naoki.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  SPEC = Gem::Specification.new do |s|
2
2
  s.name = "naoki"
3
- s.version = "1.0.11"
3
+ s.version = "1.0.12"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.homepage = ""
6
6
  s.summary = "C bindings for SafeNet DataSecure ICAPI"
data/sample.rb CHANGED
@@ -1,11 +1,11 @@
1
- require File.join(File.expand_path(__FILE__), '../data_secure_wrapper')
1
+ require File.join(File.dirname(__FILE__), 'lib/data_secure_wrapper')
2
2
 
3
3
  properties_file = 'IngrianNAE.properties'
4
- user_name = ''
5
- password = ''
6
- algorithm = ''
7
- key_name = ''
8
- initialization_vector = ''
4
+ user_name = 'stg-MySQL_user2'
5
+ password = 'y)$)=M_-c52#!_2'
6
+ algorithm = 'AES/CBC/PKCS5Padding'
7
+ key_name = 'stg-new-test-key'
8
+ initialization_vector = '1234567890123456'
9
9
 
10
10
  input_data = 'qwertyuiopasdfghjkl;zxcvbnm,./'
11
11
 
@@ -13,9 +13,34 @@ input_data = 'qwertyuiopasdfghjkl;zxcvbnm,./'
13
13
 
14
14
  DataSecureWrapper.configure(properties_file)
15
15
  DataSecureWrapper.open(user_name, password)
16
-
17
- puts "encrypting: '#{input_data}'"
18
16
  encrypted_data = DataSecureWrapper.encrypt(algorithm, key_name, initialization_vector, input_data)
19
17
  decrypted_data = DataSecureWrapper.decrypt(algorithm, key_name, initialization_vector, encrypted_data)
20
- puts "decrypted: '#{decrypted_data}'"
18
+
19
+ GC.start
20
+ puts `ps -o rss= -p #{Process.pid}`.to_i
21
+ 1_000.times do
22
+ #puts "encrypting: '#{input_data}'"
23
+ encrypted_data = DataSecureWrapper.encrypt(algorithm, key_name, initialization_vector, input_data)
24
+ decrypted_data = DataSecureWrapper.decrypt(algorithm, key_name, initialization_vector, encrypted_data)
25
+ #puts "decrypted: '#{decrypted_data}'"
26
+ end
27
+ GC.start
28
+ puts `ps -o rss= -p #{Process.pid}`.to_i
29
+ exit(0)
30
+
31
+ # enc1 = encrypt with a key that's versioned
32
+ #enc1 = DataSecureWrapper.encrypt(algorithm, 'stg-encrypt-test2', initialization_vector, input_data)
33
+ # enc2 = encrypt with an unversioned key of the same value
34
+ #enc2 = DataSecureWrapper.encrypt(algorithm, 'stg-new-test-key', initialization_vector, input_data)
35
+ #enc2 = DataSecureWrapper.encrypt(algorithm, 'stg-encrypt-test2', initialization_vector, input_data)
36
+ #p enc1
37
+ #puts "Encrypting:\n#{input_data}:"
38
+ #p enc2
39
+
40
+ enc1 = "\x10\x00\x10k\xBFy\xF6\x8B\xB5\x17\x9F!KWvB\xA6#\xA1_\x10V2\vC\v\xE4\x9F\r\x9A\xDE\xB8\x10R%"
41
+ enc2 = "\x10\x00 ]\xAD\xDFJDa\x10\xB3\x98\xC0\tT\xC4\x1E\xECs\xAA\xE5\xD7B\xF1CWS]N\x16\fdM\"\xA9"
42
+ decrypted_data = DataSecureWrapper.decrypt(algorithm, 'stg-new-test-key', initialization_vector, enc1)
43
+ puts "Decrypted 1:\n#{decrypted_data}"
44
+ decrypted_data = DataSecureWrapper.decrypt(algorithm, 'stg-new-test-key', initialization_vector, enc2)
45
+ puts "Decrypted 2:\n#{decrypted_data}"
21
46
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: naoki
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.11
5
+ version: 1.0.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Apolzon
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-03-21 00:00:00 -07:00
14
+ date: 2011-03-22 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency