thales-pse 0.2.2 → 0.3.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
  SHA256:
3
- metadata.gz: db6813422fd06fdd141a7d7fc07699068dd41d2f87ccb88e5613c18c2bfbba40
4
- data.tar.gz: 89855eafec6c01c893ae7fc7554c1b2d8c8a178dde5a14b15208cab1b772eda6
3
+ metadata.gz: cb679e7365c1decbdd2d5f67b3730ac74227b0eae1721807fd576043e91a1188
4
+ data.tar.gz: 8d0a0f1a0da459a696989c85a2682afbd4ba9617811497d32023390a7e26e22b
5
5
  SHA512:
6
- metadata.gz: 47bc74b8f11de38a213516e71893c851fa1637be876e7b693293ca99622360fbc2a037d97dc62ce357d18f8c54317a7f486290b02f612c9bf16d5820ce194fc4
7
- data.tar.gz: a5ae951c39783df5f2e68d926214ef701739d37cc90c902a0da237d208283894493b55a32b69aa6bd82db807afb7021cea791766c8177a6434cf31d8b75f777b
6
+ metadata.gz: b12c2861bacc7bb18714ae1d2422577747ed30008bb09c2bf1395fdf4c5dc57808727b57b08e13e157cec3a4b00297e0788524879e4b6451054fa020524fe3f3
7
+ data.tar.gz: 968de2560c771ac44ee12951c41fa484bab289c797cb1fad89b093fa0875e727a9a73c4aa7badc3abf73674a03a6801f7a52c43e655b611c94ad8a375948e819
data/.release_history.yml CHANGED
@@ -4,3 +4,5 @@ thales-pse:
4
4
  :timestamp: 1634916519.8704317
5
5
  - :version: 0.2.1
6
6
  :timestamp: 1640072484.0339034
7
+ - :version: 0.2.2
8
+ :timestamp: 1640072784.0902636
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thales-pse (0.1.1)
4
+ thales-pse (0.2.2)
5
5
  tlogger
6
6
  toolrack
7
7
 
@@ -63,6 +63,7 @@ GEM
63
63
  PLATFORMS
64
64
  java
65
65
  universal-java-1.8
66
+ universal-java-11
66
67
  x86_64-linux
67
68
 
68
69
  DEPENDENCIES
@@ -72,4 +73,4 @@ DEPENDENCIES
72
73
  thales-pse!
73
74
 
74
75
  BUNDLED WITH
75
- 2.2.28
76
+ 2.2.29
data/docker/Dockerfile ADDED
@@ -0,0 +1,15 @@
1
+
2
+ FROM rvm-dev
3
+
4
+ WORKDIR /opt
5
+ COPY PTKcpsdk-5.9.0-RC5.x86_64.rpm .
6
+
7
+ #RUN apt-get update && apt-get install -y alien && alien -i *.rpm
8
+ RUN apt-get install -y alien && cd /opt && alien --scripts -i *.rpm
9
+ RUN ln -s /opt/safenet/protecttoolkit5/cpsdk/lib/linux-x86_64/libctsw.so /usr/lib/libcryptoki.so
10
+ RUN ln -s /opt/safenet/protecttoolkit5/cpsdk/lib/linux-x86_64/libethsm.so /usr/lib/libethsm.so
11
+
12
+ ENV PATH="/opt/safenet/protecttoolkit5/cpsdk/bin:/opt/safenet/protecttoolkit5/cpsdk/bin/linux-x86_64:$PATH"
13
+
14
+ ENTRYPOINT [ "/bin/bash", "--login" ]
15
+
data/docker/build.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ docker build -t thales-pse-test .
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ docker run -it --rm -v $PWD/..:/opt/thales-pse thales-pse-test
@@ -28,29 +28,47 @@ module Thales
28
28
 
29
29
  PTY.spawn(exePath, *params) do |read, write, pid|
30
30
 
31
+ cont = ""
32
+ timeoutAfter = 1
31
33
  begin
32
34
 
35
+ logger.tdebug :cmd, "expect list : #{expect_list}"
33
36
  if not is_empty?(expect_list)
34
37
  expect_list.each do |ex|
38
+ timeoutAfter = ex[:timeout_after] || 5
39
+ logger.tdebug :cmd, "expect list element : #{ex}"
35
40
  to = ex[:timeout] || 1
41
+ logger.tdebug :cmd, "Expecting : #{ex[:matcher]}"
36
42
  cont = read.expect(/#{ex[:matcher]}/, to)
37
- output.puts cont
38
- write.puts block.call(ex[:block_key], cont)
43
+ output.puts cont.first if not_empty?(cont)
44
+ v = block.call(ex[:block_key],cont)
45
+ #logger.tdebug :cmd, "Calling block_key '#{ex[:block_key]}' got #{v}"
46
+ if not_empty?(v)
47
+ write.puts v
48
+ else
49
+ write.puts ""
50
+ end
51
+ #write.puts block.call(ex[:block_key], cont)
39
52
  end
40
53
  end
41
54
 
42
- Timeout.timeout(1) do
55
+ Timeout.timeout(timeoutAfter) do
43
56
  read.each do |l|
44
57
  output.puts l if not_empty?(l)
45
58
  end
46
59
  end
47
60
 
61
+ output.puts "[Done2] #{cmd}"
62
+
48
63
  rescue Timeout::Error => e
49
64
  read.close
50
65
  write.close
51
66
  Process.kill('TERM',pid)
52
67
  output.puts "Process #{cmd} ('#{pid}') killed due to timeout"
53
- rescue Errno::EIO
68
+ rescue Errno::EIO => e
69
+ #output.puts e.message
70
+ #output.puts e.backtrace.join("\n")
71
+ #output.puts "Read : #{cont}"
54
72
  output.puts "[Done] #{cmd}"
55
73
  end
56
74
  end
@@ -23,9 +23,9 @@ module Thales
23
23
  raise TokenError, "Slot is not available!" if is_empty?(@slot)
24
24
 
25
25
  expect = [
26
- { matcher: "new token label:", block_key: :token_label, timeout: 1 },
27
- { matcher: "enter Security Officer\'s pin:", block_key: :token_so_pin, timeout: 1 },
28
- { matcher: "confirm Security Officer\'s pin:", block_key: :token_so_pin_confirm, timeout: 1 }
26
+ { matcher: "new token label:", block_key: :token_label, timeout: 5 },
27
+ { matcher: "enter Security Officer\'s pin:", block_key: :token_so_pin, timeout: 5 },
28
+ { matcher: "confirm Security Officer\'s pin:", block_key: :token_so_pin_confirm, timeout: 5 }
29
29
  ]
30
30
 
31
31
  #slot = block.call(:slot) || 0
@@ -57,9 +57,9 @@ module Thales
57
57
 
58
58
  expect = [
59
59
  # this key is handled locally not passed to external
60
- { matcher: "Security Officer PIN.+:|current user PIN.+:", block_key: :auth_pin, timeout: 3 },
61
- { matcher: "enter the new user PIN.+:", block_key: :token_user_pin, timeout: 1 },
62
- { matcher: "confirm the new user PIN.+:", block_key: :token_user_pin_confirm, timeout: 1 }
60
+ { matcher: "Security Officer PIN.+:|current user PIN.+:", block_key: :auth_pin, timeout: 5 },
61
+ { matcher: "enter the new user PIN.+:", block_key: :token_user_pin, timeout: 5 },
62
+ { matcher: "confirm the new user PIN.+:", block_key: :token_user_pin_confirm, timeout: 5 }
63
63
  ]
64
64
 
65
65
  #slot = block.call(:slot) || 0
@@ -98,7 +98,7 @@ module Thales
98
98
  raise TokenError, "Slot is not available!" if is_empty?(@slot)
99
99
 
100
100
  expect = [
101
- { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 1 }
101
+ { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 1, timeout_after: 60*5 }
102
102
  ]
103
103
 
104
104
  type = args.first
@@ -183,7 +183,7 @@ module Thales
183
183
  raise TokenError, "Slot is not available!" if is_empty?(@slot)
184
184
 
185
185
  expect = [
186
- { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 1 }
186
+ { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 60 }
187
187
  ]
188
188
 
189
189
  keylabel = block.call(:keylabel)
@@ -208,19 +208,19 @@ module Thales
208
208
 
209
209
  cn = block.call(:common_name)
210
210
  raise Error, "Common name is mandatory" if is_empty?(cn)
211
- expect << { matcher: "Common Name:", block_key: :cn, timeout: 1 }
211
+ expect << { matcher: "Common Name:", block_key: :cn, timeout: 5 }
212
212
  org = block.call(:org)
213
- expect << { matcher: "Organization:", block_key: :org, timeout: 1 }
213
+ expect << { matcher: "Organization:", block_key: :org, timeout: 5 }
214
214
  ou = block.call(:ou)
215
- expect << { matcher: "Organizational Unit:", block_key: :ou, timeout: 1 }
215
+ expect << { matcher: "Organizational Unit:", block_key: :ou, timeout: 5 }
216
216
  loc = block.call(:locality)
217
- expect << { matcher: "Locality:", block_key: :loc, timeout: 1 }
217
+ expect << { matcher: "Locality:", block_key: :loc, timeout: 5 }
218
218
  st = block.call(:state)
219
- expect << { matcher: "State:", block_key: :st, timeout: 1 }
219
+ expect << { matcher: "State:", block_key: :st, timeout: 5 }
220
220
  ctry = block.call(:country)
221
- expect << { matcher: "Country:", block_key: :ctry, timeout: 1 }
221
+ expect << { matcher: "Country:", block_key: :ctry, timeout: 5 }
222
222
  sn = block.call(:serial_no) || SecureRandom.uuid.gsub("-","")
223
- expect << { matcher: "certificate\'s serial number.+:", block_key: :sn, timeout: 1 }
223
+ expect << { matcher: "certificate\'s serial number.+:", block_key: :sn, timeout: 5 }
224
224
 
225
225
  params = ["c","-l#{keylabel}", "-s#{slot}"]
226
226
  if not_empty?(validFrom)
@@ -240,6 +240,7 @@ module Thales
240
240
  when :params
241
241
  params
242
242
  when :expect_list
243
+ #[expect[0]]
243
244
  expect
244
245
  when :cn
245
246
  cn
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Thales
4
4
  module Pse
5
- VERSION = "0.2.2"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thales-pse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian
@@ -68,6 +68,9 @@ files:
68
68
  - Rakefile
69
69
  - bin/console
70
70
  - bin/setup
71
+ - docker/Dockerfile
72
+ - docker/build.sh
73
+ - docker/container.sh
71
74
  - lib/thales/pse.rb
72
75
  - lib/thales/pse/cli.rb
73
76
  - lib/thales/pse/config.rb