vacman_controller 0.8.0 → 0.9.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: a360beaa57827bbf141c8950a6c710b45d36407b
4
- data.tar.gz: 763194f1e0d63f46459631545c8604429a0b0d92
3
+ metadata.gz: e0ca16e795a315dcd5ef2264252c02822ee49dea
4
+ data.tar.gz: 8ae0fdc80a88b506d2bb6c15791e12c3a13122ab
5
5
  SHA512:
6
- metadata.gz: d9764b70e7b0d0523ef1e48b9edf5714afaf3db4fef884bf4e13c917b81a2e40f896c315e65cd8a0fdf04a51289a6359acdbcb5ca62c2cd5e3f0a80b8846718f
7
- data.tar.gz: 410138647a65b8106aa8517be8551dc45a240a0891df397f6f3a9f91bd3af22e9bc0f4b6a00dd5722e4de52e1e9b49fd573ff9bafcf0c98bbc283d4f20f8c0e6
6
+ metadata.gz: 27ec0832a4df5c74031f088cccebcc86be7356b344c4d2f68499293260c5df18d737f3994d5b1e586618fecd733e0d26703300998b6c601867464a680294a8fb
7
+ data.tar.gz: 18c0f21970fddd3cb094715040ba578b7919d025689545cbea7cbc7e7fed330d2c3a73a61026120aaf11a3f1c6a3946201cfb0fb469754536a7578cb769d3bdb
@@ -31,11 +31,26 @@ VALUE vacman_dpx_import(VALUE module, VALUE filename, VALUE key) {
31
31
  appl_names,
32
32
  &token_count);
33
33
 
34
+ /* Open the DPX */
34
35
  if (result != 0) {
35
36
  vacman_library_error("AAL2DPXInit", result);
36
37
  return Qnil;
37
38
  }
38
39
 
40
+ /* Get static vector for token activation code generation */
41
+ aat_ascii sw_out_static_vector[4094+1];
42
+ aat_int32 sw_out_static_vector_len = sizeof(sw_out_static_vector);
43
+ result = AAL2DPXGetStaticVector(&dpx_handle,
44
+ &g_KernelParms,
45
+ sw_out_static_vector,
46
+ &sw_out_static_vector_len);
47
+
48
+ /* If no static vector is present, clear the buffer */
49
+ if (result != 0) {
50
+ memset(sw_out_static_vector, 0, sizeof(sw_out_static_vector));
51
+ }
52
+
53
+ /* Get the tokens */
39
54
  aat_ascii sw_out_serial_No[22+1];
40
55
  aat_ascii sw_out_type[5+1];
41
56
  aat_ascii sw_out_authmode[2+1];
@@ -62,7 +77,7 @@ VALUE vacman_dpx_import(VALUE module, VALUE filename, VALUE key) {
62
77
 
63
78
  VALUE hash = rb_hash_new();
64
79
 
65
- vacman_digipass_to_rbhash(&dpdata, hash);
80
+ vacman_digipass_to_rbhash_sv(&dpdata, sw_out_static_vector, hash);
66
81
 
67
82
  rb_ary_push(list, hash);
68
83
  }
@@ -71,3 +86,42 @@ VALUE vacman_dpx_import(VALUE module, VALUE filename, VALUE key) {
71
86
 
72
87
  return list;
73
88
  }
89
+
90
+
91
+ /*
92
+ * Generate token activation code
93
+ */
94
+ VALUE vacman_dpx_generate_token_activation(VALUE module, VALUE token) {
95
+ TDigipassBlob dpdata;
96
+
97
+ aat_ascii static_vector[4094+1];
98
+ vacman_rbhash_to_digipass_sv(token, &dpdata, static_vector, sizeof(static_vector));
99
+
100
+ TDigipassBlob *dpdata_ary[8] = { &dpdata, 0, 0, 0, 0, 0, 0, 0 };
101
+
102
+ aat_int32 actv_flags = ACTV_OFFLINE;
103
+ aat_ascii serial_num[14+1];
104
+ aat_ascii actv_code[4142+1];
105
+
106
+ aat_int32 result = AAL2GenActivationCodeXErc(dpdata_ary, /* DPData */
107
+ 1, /* Appl_count */
108
+ &g_KernelParms, /* CallParms */
109
+ static_vector, /* aStaticVectorIn DIGIPASS parameter setting */
110
+ NULL, /* aSharedData for encryption */
111
+ NULL, /* aAlea for encryption */
112
+ &actv_flags, /* ActivationFlags */
113
+ serial_num, /* aSerialNumberSuffix */
114
+ actv_code, /* aXFAD */
115
+ NULL); /* aXERC */
116
+
117
+ if (result != 0) {
118
+ vacman_library_error("AAL2GenActivationCodeXErc", result);
119
+ return Qnil;
120
+ }
121
+
122
+ VALUE ret = rb_hash_new();
123
+ rb_hash_aset(ret, rb_str_new2("serial"), rb_str_new2(serial_num));
124
+ rb_hash_aset(ret, rb_str_new2("activation"), rb_str_new2(actv_code));
125
+
126
+ return ret;
127
+ }
@@ -22,7 +22,10 @@ void Init_vacman_low_level(void) {
22
22
 
23
23
  /* Global methods */
24
24
  rb_define_singleton_method(lowlevel, "library_version", vacman_library_version, 0);
25
+
26
+ /* DPX methods */
25
27
  rb_define_singleton_method(lowlevel, "import", vacman_dpx_import, 2);
28
+ rb_define_singleton_method(lowlevel, "generate_activation", vacman_dpx_generate_token_activation, 1);
26
29
 
27
30
  /* Token methods */
28
31
  rb_define_singleton_method(lowlevel, "token_property_names", vacman_token_get_property_names, 0);
@@ -36,7 +36,30 @@ void vacman_rbhash_to_digipass(VALUE token, TDigipassBlob* dpdata) {
36
36
  }
37
37
 
38
38
  /*
39
- * Convert a TDigipassBlob structure into a Ruby Hash
39
+ * Convert a Ruby Hash with the required keys to a TDigipassBlob structure,
40
+ * and extract the token static vector into the buffer pointed to by dpsv,
41
+ * copying at most dpsv_len bytes.
42
+ *
43
+ * The inner beauty of using an hash to store this data back and forth is
44
+ * that optional data such as the static vector can only be taken into account
45
+ * in routines that need it, leaving it completely opaque for the rest of the
46
+ * code.
47
+ *
48
+ * Given that the token hash is meant to be updated by the calls, and given
49
+ * that everything is allocated on the stack, this stays threadsafe and does
50
+ * not induce oddities as no routine here is removing keys from the provided
51
+ * hash - only using the ones that are needed.
52
+ */
53
+ void vacman_rbhash_to_digipass_sv(VALUE token, TDigipassBlob* dpdata, aat_ascii* dpsv, aat_int32 dpsv_len) {
54
+ vacman_rbhash_to_digipass(token, dpdata);
55
+
56
+ VALUE sv = rbhash_get_key(token, "sv", T_STRING);
57
+
58
+ strncpy(dpsv, rb_string_value_cstr(&sv), dpsv_len);
59
+ }
60
+
61
+ /*
62
+ * Convert a TDigipassBlob structure into a Ruby Hash.
40
63
  */
41
64
  void vacman_digipass_to_rbhash(TDigipassBlob* dpdata, VALUE hash) {
42
65
  char buffer[256];
@@ -57,6 +80,19 @@ void vacman_digipass_to_rbhash(TDigipassBlob* dpdata, VALUE hash) {
57
80
  rb_hash_aset(hash, rb_str_new2("flags2"), rb_fix_new(dpdata->DPFlags[1]));
58
81
  }
59
82
 
83
+ /*
84
+ * Convert the given TDigipassBlob and the given token static vector into a
85
+ * Ruby hash.
86
+ *
87
+ * Calls vacman_digipass_to_rbhash() and then adds to it the additional "sv"
88
+ * key with the token static vector passed in as a C string.
89
+ */
90
+ void vacman_digipass_to_rbhash_sv(TDigipassBlob* dpdata, aat_ascii* dpsv, VALUE hash) {
91
+ vacman_digipass_to_rbhash(dpdata, hash);
92
+
93
+ rb_hash_aset(hash, rb_str_new2("sv"), rb_str_new2(dpsv));
94
+ }
95
+
60
96
  /*
61
97
  * Gets the given property from the given token hash and raises an Error
62
98
  * if the following conditions occur:
@@ -37,11 +37,15 @@ VALUE vacman_token_verify_password(VALUE module, VALUE token, VALUE password);
37
37
  VALUE vacman_token_generate_password(VALUE module, VALUE token);
38
38
 
39
39
  /* Token interchange format between Ruby and libaal2 (serialize.c) */
40
- void vacman_rbhash_to_digipass(VALUE token, TDigipassBlob* dpdata);
41
40
  void vacman_digipass_to_rbhash(TDigipassBlob* dpdata, VALUE hash);
41
+ void vacman_digipass_to_rbhash_sv(TDigipassBlob* dpdata, aat_ascii* dpsv, VALUE hash);
42
+
43
+ void vacman_rbhash_to_digipass(VALUE token, TDigipassBlob* dpdata);
44
+ void vacman_rbhash_to_digipass_sv(VALUE token, TDigipassBlob* dpdata, aat_ascii* dpsv, aat_int32 dpsv_len);
42
45
 
43
46
  /* DPX methods (dpx.c) */
44
47
  VALUE vacman_dpx_import(VALUE module, VALUE filename, VALUE key);
48
+ VALUE vacman_dpx_generate_token_activation(VALUE module, VALUE token);
45
49
 
46
50
  #if defined(__cplusplus)
47
51
  #if 0
@@ -79,8 +79,8 @@ module VacmanController
79
79
  end
80
80
 
81
81
 
82
- # Generate an OTPfrom this token. This does the same as hitting the button
83
- # on the hardware token.
82
+ # Generate an OTP from this token. This does the same as hitting the
83
+ # button on the hardware token.
84
84
  #
85
85
  # == Returns:
86
86
  # The OTP as a String. The OTP is only valid for a limited time period.
@@ -92,6 +92,24 @@ module VacmanController
92
92
  end
93
93
 
94
94
 
95
+ # Generate activation data from the token blob and the digipass parameters
96
+ # embodied in the token static initialisation vector.
97
+ #
98
+ # == Returns:
99
+ # The token serial number and the activation code as an Array, suitable
100
+ # for multiple assignment.
101
+ #
102
+ # Not all tokens support activation data generation. This is determined by
103
+ # the DPX having a static vector or not. You can check whether your token
104
+ # instance has a static vector by assessing the presence of the 'sv' key
105
+ # in the token hash.
106
+ #
107
+ def activation
108
+ ad = VacmanController::LowLevel.generate_activation(@token_hash)
109
+ [ ad.fetch('serial').scan(/\d(\d)/).flatten.join, ad.fetch('activation') ]
110
+ end
111
+
112
+
95
113
  # Set this token's PIN
96
114
  #
97
115
  # == Parameters:
@@ -1,3 +1,3 @@
1
1
  module VacmanController
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vacman_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Lankenau
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.5.2.3
140
+ rubygems_version: 2.5.2
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Ruby layer to access VASCO Vacman Controller functions