czmq-ffi-gen 0.1.1 → 0.2.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: a13b3283c23574dcb273bb0cceb1e1dea053a3ae
4
- data.tar.gz: 5f53828a3de118cbccdaad5c48158f919b1a7767
3
+ metadata.gz: d73add1339edd404b96de5b47ff0e7513dff7fe2
4
+ data.tar.gz: 3b973b9f975f49eadc315eab5c7ac0b24e25e3f9
5
5
  SHA512:
6
- metadata.gz: 1722efb1d34de52a034f0395b6dfefca180e6106d91c9cb7d498500a20141f3fae8e3e4793690a751acc68da2a354be976202cf2b0699ac37e2a0d27843ce9a7
7
- data.tar.gz: 988aab153814bf5d9cdf9c511eee3bb134456df30f8951778c66933ff5c20ba721d28bddbf3be93a9efe28d186b5f6d7c4b9ef230d14400bfdec1efc8e86ac10
6
+ metadata.gz: 3bfddad065f3a2359bffe941773e4d7c24a36faac3f212d8fa9ac0ef2054fa0ceb41acbc9bd01e87b865af954d999ad087188ac61253c6d74aa90ac5d8f05cd5
7
+ data.tar.gz: 724a03ba6f49474f9080ce6ccae8b8d6da4d6966d7b41758b6c93f2cdfbdfa2cb739fa39a13c496d8b78a6d5015e224f89c3d3dcd7d5c27e0dc98d343c968e35
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.2.0 (12/10/2015)
2
+ -----
3
+ * using new CZMQ version which
4
+ - fixes some security issues
5
+ - adds Zcert and Zcertstore
6
+ * basic specs for each Zclass added
7
+
1
8
  0.1.1 (12/09/2015)
2
9
  -----
3
10
  * include some auxiliary files like CHANGES.md, LICENSE, and README.md into gem
@@ -0,0 +1,296 @@
1
+ ################################################################################
2
+ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
3
+ # Please refer to the README for information about making permanent changes. #
4
+ ################################################################################
5
+
6
+ module CZMQ
7
+ module FFI
8
+
9
+ # zcert - work with CURVE security certificates
10
+ # @note This class is 100% generated using zproject.
11
+ class Zcert
12
+ # Raised when one tries to use an instance of {Zcert} after
13
+ # the internal pointer to the native object has been nullified.
14
+ class DestroyedError < RuntimeError; end
15
+
16
+ # Boilerplate for self pointer, initializer, and finalizer
17
+ class << self
18
+ alias :__new :new
19
+ end
20
+ # Attaches the pointer _ptr_ to this instance and defines a finalizer for
21
+ # it if necessary.
22
+ # @param ptr [::FFI::Pointer]
23
+ # @param finalize [Boolean]
24
+ def initialize(ptr, finalize = true)
25
+ @ptr = ptr
26
+ if @ptr.null?
27
+ @ptr = nil # Remove null pointers so we don't have to test for them.
28
+ elsif finalize
29
+ @finalizer = self.class.create_finalizer_for @ptr
30
+ ObjectSpace.define_finalizer self, @finalizer
31
+ end
32
+ end
33
+ # @param ptr [::FFI::Pointer]
34
+ # @return [Proc]
35
+ def self.create_finalizer_for(ptr)
36
+ Proc.new do
37
+ ptr_ptr = ::FFI::MemoryPointer.new :pointer
38
+ ptr_ptr.write_pointer ptr
39
+ ::CZMQ::FFI.zcert_destroy ptr_ptr
40
+ end
41
+ end
42
+ # @return [Boolean]
43
+ def null?
44
+ !@ptr or @ptr.null?
45
+ end
46
+ # Return internal pointer
47
+ # @return [::FFI::Pointer]
48
+ def __ptr
49
+ raise DestroyedError unless @ptr
50
+ @ptr
51
+ end
52
+ # So external Libraries can just pass the Object to a FFI function which expects a :pointer
53
+ alias_method :to_ptr, :__ptr
54
+ # Nullify internal pointer and return pointer pointer.
55
+ # @note This detaches the current instance from the native object
56
+ # and thus makes it unusable.
57
+ # @return [::FFI::MemoryPointer] the pointer pointing to a pointer
58
+ # pointing to the native object
59
+ def __ptr_give_ref
60
+ raise DestroyedError unless @ptr
61
+ ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
+ ptr_ptr.write_pointer @ptr
63
+ ObjectSpace.undefine_finalizer self if @finalizer
64
+ @finalizer = nil
65
+ @ptr = nil
66
+ ptr_ptr
67
+ end
68
+
69
+ # Create and initialize a new certificate in memory
70
+ # @return [CZMQ::Zcert]
71
+ def self.new()
72
+ ptr = ::CZMQ::FFI.zcert_new()
73
+ __new ptr
74
+ end
75
+
76
+ # Accepts public/secret key pair from caller
77
+ # @param public_key [::FFI::Pointer, #to_ptr]
78
+ # @param secret_key [::FFI::Pointer, #to_ptr]
79
+ # @return [CZMQ::Zcert]
80
+ def self.new_from(public_key, secret_key)
81
+ ptr = ::CZMQ::FFI.zcert_new_from(public_key, secret_key)
82
+ __new ptr
83
+ end
84
+
85
+ # Load certificate from file
86
+ # @param filename [String, #to_str, #to_s]
87
+ # @return [CZMQ::Zcert]
88
+ def self.load(filename)
89
+ filename = String(filename)
90
+ ptr = ::CZMQ::FFI.zcert_load(filename)
91
+ __new ptr
92
+ end
93
+
94
+ # Destroy a certificate in memory
95
+ #
96
+ # @return [void]
97
+ def destroy()
98
+ return unless @ptr
99
+ self_p = __ptr_give_ref
100
+ result = ::CZMQ::FFI.zcert_destroy(self_p)
101
+ result
102
+ end
103
+
104
+ # Return public part of key pair as 32-byte binary string
105
+ #
106
+ # @return [::FFI::Pointer]
107
+ def public_key()
108
+ raise DestroyedError unless @ptr
109
+ self_p = @ptr
110
+ result = ::CZMQ::FFI.zcert_public_key(self_p)
111
+ result
112
+ end
113
+
114
+ # Return secret part of key pair as 32-byte binary string
115
+ #
116
+ # @return [::FFI::Pointer]
117
+ def secret_key()
118
+ raise DestroyedError unless @ptr
119
+ self_p = @ptr
120
+ result = ::CZMQ::FFI.zcert_secret_key(self_p)
121
+ result
122
+ end
123
+
124
+ # Return public part of key pair as Z85 armored string
125
+ #
126
+ # @return [::FFI::Pointer]
127
+ def public_txt()
128
+ raise DestroyedError unless @ptr
129
+ self_p = @ptr
130
+ result = ::CZMQ::FFI.zcert_public_txt(self_p)
131
+ result
132
+ end
133
+
134
+ # Return secret part of key pair as Z85 armored string
135
+ #
136
+ # @return [::FFI::Pointer]
137
+ def secret_txt()
138
+ raise DestroyedError unless @ptr
139
+ self_p = @ptr
140
+ result = ::CZMQ::FFI.zcert_secret_txt(self_p)
141
+ result
142
+ end
143
+
144
+ # Set certificate metadata from formatted string.
145
+ #
146
+ # @param name [String, #to_str, #to_s]
147
+ # @param format [String, #to_str, #to_s]
148
+ # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
149
+ # @return [void]
150
+ def set_meta(name, format, *args)
151
+ raise DestroyedError unless @ptr
152
+ self_p = @ptr
153
+ name = String(name)
154
+ format = String(format)
155
+ result = ::CZMQ::FFI.zcert_set_meta(self_p, name, format, *args)
156
+ result
157
+ end
158
+
159
+ # Get metadata value from certificate; if the metadata value doesn't
160
+ # exist, returns NULL.
161
+ #
162
+ # @param name [String, #to_str, #to_s]
163
+ # @return [::FFI::Pointer]
164
+ def meta(name)
165
+ raise DestroyedError unless @ptr
166
+ self_p = @ptr
167
+ name = String(name)
168
+ result = ::CZMQ::FFI.zcert_meta(self_p, name)
169
+ result
170
+ end
171
+
172
+ # Get list of metadata fields from certificate. Caller is responsible for
173
+ # destroying list. Caller should not modify the values of list items.
174
+ #
175
+ # @return [Zlist]
176
+ def meta_keys()
177
+ raise DestroyedError unless @ptr
178
+ self_p = @ptr
179
+ result = ::CZMQ::FFI.zcert_meta_keys(self_p)
180
+ result = Zlist.__new result, false
181
+ result
182
+ end
183
+
184
+ # Save full certificate (public + secret) to file for persistent storage
185
+ # This creates one public file and one secret file (filename + "_secret").
186
+ #
187
+ # @param filename [String, #to_str, #to_s]
188
+ # @return [Integer]
189
+ def save(filename)
190
+ raise DestroyedError unless @ptr
191
+ self_p = @ptr
192
+ filename = String(filename)
193
+ result = ::CZMQ::FFI.zcert_save(self_p, filename)
194
+ result
195
+ end
196
+
197
+ # Save public certificate only to file for persistent storage
198
+ #
199
+ # @param filename [String, #to_str, #to_s]
200
+ # @return [Integer]
201
+ def save_public(filename)
202
+ raise DestroyedError unless @ptr
203
+ self_p = @ptr
204
+ filename = String(filename)
205
+ result = ::CZMQ::FFI.zcert_save_public(self_p, filename)
206
+ result
207
+ end
208
+
209
+ # Save secret certificate only to file for persistent storage
210
+ #
211
+ # @param filename [String, #to_str, #to_s]
212
+ # @return [Integer]
213
+ def save_secret(filename)
214
+ raise DestroyedError unless @ptr
215
+ self_p = @ptr
216
+ filename = String(filename)
217
+ result = ::CZMQ::FFI.zcert_save_secret(self_p, filename)
218
+ result
219
+ end
220
+
221
+ # Apply certificate to socket, i.e. use for CURVE security on socket.
222
+ # If certificate was loaded from public file, the secret key will be
223
+ # undefined, and this certificate will not work successfully.
224
+ #
225
+ # @param zocket [::FFI::Pointer, #to_ptr]
226
+ # @return [void]
227
+ def apply(zocket)
228
+ raise DestroyedError unless @ptr
229
+ self_p = @ptr
230
+ result = ::CZMQ::FFI.zcert_apply(self_p, zocket)
231
+ result
232
+ end
233
+
234
+ # Return copy of certificate; if certificate is NULL or we exhausted
235
+ # heap memory, returns NULL.
236
+ #
237
+ # @return [Zcert]
238
+ def dup()
239
+ raise DestroyedError unless @ptr
240
+ self_p = @ptr
241
+ result = ::CZMQ::FFI.zcert_dup(self_p)
242
+ result = Zcert.__new result, true
243
+ result
244
+ end
245
+
246
+ # Return true if two certificates have the same keys
247
+ #
248
+ # @param compare [Zcert, #__ptr]
249
+ # @return [Boolean]
250
+ def eq(compare)
251
+ raise DestroyedError unless @ptr
252
+ self_p = @ptr
253
+ compare = compare.__ptr if compare
254
+ result = ::CZMQ::FFI.zcert_eq(self_p, compare)
255
+ result
256
+ end
257
+
258
+ # Print certificate contents to stdout
259
+ #
260
+ # @return [void]
261
+ def print()
262
+ raise DestroyedError unless @ptr
263
+ self_p = @ptr
264
+ result = ::CZMQ::FFI.zcert_print(self_p)
265
+ result
266
+ end
267
+
268
+ # DEPRECATED as incompatible with centralized logging
269
+ # Print certificate contents to open stream
270
+ #
271
+ # @param file [::FFI::Pointer, #to_ptr]
272
+ # @return [void]
273
+ def fprint(file)
274
+ raise DestroyedError unless @ptr
275
+ self_p = @ptr
276
+ result = ::CZMQ::FFI.zcert_fprint(self_p, file)
277
+ result
278
+ end
279
+
280
+ # Self test of this class
281
+ #
282
+ # @param verbose [Boolean]
283
+ # @return [void]
284
+ def self.test(verbose)
285
+ verbose = !(0==verbose||!verbose) # boolean
286
+ result = ::CZMQ::FFI.zcert_test(verbose)
287
+ result
288
+ end
289
+ end
290
+ end
291
+ end
292
+
293
+ ################################################################################
294
+ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
295
+ # Please refer to the README for information about making permanent changes. #
296
+ ################################################################################
@@ -0,0 +1,160 @@
1
+ ################################################################################
2
+ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
3
+ # Please refer to the README for information about making permanent changes. #
4
+ ################################################################################
5
+
6
+ module CZMQ
7
+ module FFI
8
+
9
+ # zcertstore - work with CURVE security certificate stores
10
+ # @note This class is 100% generated using zproject.
11
+ class Zcertstore
12
+ # Raised when one tries to use an instance of {Zcertstore} after
13
+ # the internal pointer to the native object has been nullified.
14
+ class DestroyedError < RuntimeError; end
15
+
16
+ # Boilerplate for self pointer, initializer, and finalizer
17
+ class << self
18
+ alias :__new :new
19
+ end
20
+ # Attaches the pointer _ptr_ to this instance and defines a finalizer for
21
+ # it if necessary.
22
+ # @param ptr [::FFI::Pointer]
23
+ # @param finalize [Boolean]
24
+ def initialize(ptr, finalize = true)
25
+ @ptr = ptr
26
+ if @ptr.null?
27
+ @ptr = nil # Remove null pointers so we don't have to test for them.
28
+ elsif finalize
29
+ @finalizer = self.class.create_finalizer_for @ptr
30
+ ObjectSpace.define_finalizer self, @finalizer
31
+ end
32
+ end
33
+ # @param ptr [::FFI::Pointer]
34
+ # @return [Proc]
35
+ def self.create_finalizer_for(ptr)
36
+ Proc.new do
37
+ ptr_ptr = ::FFI::MemoryPointer.new :pointer
38
+ ptr_ptr.write_pointer ptr
39
+ ::CZMQ::FFI.zcertstore_destroy ptr_ptr
40
+ end
41
+ end
42
+ # @return [Boolean]
43
+ def null?
44
+ !@ptr or @ptr.null?
45
+ end
46
+ # Return internal pointer
47
+ # @return [::FFI::Pointer]
48
+ def __ptr
49
+ raise DestroyedError unless @ptr
50
+ @ptr
51
+ end
52
+ # So external Libraries can just pass the Object to a FFI function which expects a :pointer
53
+ alias_method :to_ptr, :__ptr
54
+ # Nullify internal pointer and return pointer pointer.
55
+ # @note This detaches the current instance from the native object
56
+ # and thus makes it unusable.
57
+ # @return [::FFI::MemoryPointer] the pointer pointing to a pointer
58
+ # pointing to the native object
59
+ def __ptr_give_ref
60
+ raise DestroyedError unless @ptr
61
+ ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
+ ptr_ptr.write_pointer @ptr
63
+ ObjectSpace.undefine_finalizer self if @finalizer
64
+ @finalizer = nil
65
+ @ptr = nil
66
+ ptr_ptr
67
+ end
68
+
69
+ # Create a new certificate store from a disk directory, loading and
70
+ # indexing all certificates in that location. The directory itself may be
71
+ # absent, and created later, or modified at any time. The certificate store
72
+ # is automatically refreshed on any zcertstore_lookup() call. If the
73
+ # location is specified as NULL, creates a pure-memory store, which you
74
+ # can work with by inserting certificates at runtime.
75
+ # @param location [String, #to_str, #to_s]
76
+ # @return [CZMQ::Zcertstore]
77
+ def self.new(location)
78
+ location = String(location)
79
+ ptr = ::CZMQ::FFI.zcertstore_new(location)
80
+ __new ptr
81
+ end
82
+
83
+ # Destroy a certificate store object in memory. Does not affect anything
84
+ # stored on disk.
85
+ #
86
+ # @return [void]
87
+ def destroy()
88
+ return unless @ptr
89
+ self_p = __ptr_give_ref
90
+ result = ::CZMQ::FFI.zcertstore_destroy(self_p)
91
+ result
92
+ end
93
+
94
+ # Look up certificate by public key, returns zcert_t object if found,
95
+ # else returns NULL. The public key is provided in Z85 text format.
96
+ #
97
+ # @param public_key [String, #to_str, #to_s]
98
+ # @return [Zcert]
99
+ def lookup(public_key)
100
+ raise DestroyedError unless @ptr
101
+ self_p = @ptr
102
+ public_key = String(public_key)
103
+ result = ::CZMQ::FFI.zcertstore_lookup(self_p, public_key)
104
+ result = Zcert.__new result, false
105
+ result
106
+ end
107
+
108
+ # Insert certificate into certificate store in memory. Note that this
109
+ # does not save the certificate to disk. To do that, use zcert_save()
110
+ # directly on the certificate. Takes ownership of zcert_t object.
111
+ #
112
+ # @param cert_p [#__ptr_give_ref]
113
+ # @return [void]
114
+ def insert(cert_p)
115
+ raise DestroyedError unless @ptr
116
+ self_p = @ptr
117
+ cert_p = cert_p.__ptr_give_ref
118
+ result = ::CZMQ::FFI.zcertstore_insert(self_p, cert_p)
119
+ result
120
+ end
121
+
122
+ # Print list of certificates in store to logging facility
123
+ #
124
+ # @return [void]
125
+ def print()
126
+ raise DestroyedError unless @ptr
127
+ self_p = @ptr
128
+ result = ::CZMQ::FFI.zcertstore_print(self_p)
129
+ result
130
+ end
131
+
132
+ # DEPRECATED as incompatible with centralized logging
133
+ # Print list of certificates in store to open stream
134
+ #
135
+ # @param file [::FFI::Pointer, #to_ptr]
136
+ # @return [void]
137
+ def fprint(file)
138
+ raise DestroyedError unless @ptr
139
+ self_p = @ptr
140
+ result = ::CZMQ::FFI.zcertstore_fprint(self_p, file)
141
+ result
142
+ end
143
+
144
+ # Self test of this class
145
+ #
146
+ # @param verbose [Boolean]
147
+ # @return [void]
148
+ def self.test(verbose)
149
+ verbose = !(0==verbose||!verbose) # boolean
150
+ result = ::CZMQ::FFI.zcertstore_test(verbose)
151
+ result
152
+ end
153
+ end
154
+ end
155
+ end
156
+
157
+ ################################################################################
158
+ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
159
+ # Please refer to the README for information about making permanent changes. #
160
+ ################################################################################
@@ -78,6 +78,39 @@ module CZMQ
78
78
 
79
79
  require_relative 'ffi/zarmour'
80
80
 
81
+ attach_function :zcert_new, [], :pointer, **opts
82
+ attach_function :zcert_new_from, [:pointer, :pointer], :pointer, **opts
83
+ attach_function :zcert_load, [:string], :pointer, **opts
84
+ attach_function :zcert_destroy, [:pointer], :void, **opts
85
+ attach_function :zcert_public_key, [:pointer], :pointer, **opts
86
+ attach_function :zcert_secret_key, [:pointer], :pointer, **opts
87
+ attach_function :zcert_public_txt, [:pointer], :pointer, **opts
88
+ attach_function :zcert_secret_txt, [:pointer], :pointer, **opts
89
+ attach_function :zcert_set_meta, [:pointer, :string, :string, :varargs], :void, **opts
90
+ attach_function :zcert_meta, [:pointer, :string], :pointer, **opts
91
+ attach_function :zcert_meta_keys, [:pointer], :pointer, **opts
92
+ attach_function :zcert_save, [:pointer, :string], :int, **opts
93
+ attach_function :zcert_save_public, [:pointer, :string], :int, **opts
94
+ attach_function :zcert_save_secret, [:pointer, :string], :int, **opts
95
+ attach_function :zcert_apply, [:pointer, :pointer], :void, **opts
96
+ attach_function :zcert_dup, [:pointer], :pointer, **opts
97
+ attach_function :zcert_eq, [:pointer, :pointer], :bool, **opts
98
+ attach_function :zcert_print, [:pointer], :void, **opts
99
+ attach_function :zcert_fprint, [:pointer, :pointer], :void, **opts
100
+ attach_function :zcert_test, [:bool], :void, **opts
101
+
102
+ require_relative 'ffi/zcert'
103
+
104
+ attach_function :zcertstore_new, [:string], :pointer, **opts
105
+ attach_function :zcertstore_destroy, [:pointer], :void, **opts
106
+ attach_function :zcertstore_lookup, [:pointer, :string], :pointer, **opts
107
+ attach_function :zcertstore_insert, [:pointer, :pointer], :void, **opts
108
+ attach_function :zcertstore_print, [:pointer], :void, **opts
109
+ attach_function :zcertstore_fprint, [:pointer, :pointer], :void, **opts
110
+ attach_function :zcertstore_test, [:bool], :void, **opts
111
+
112
+ require_relative 'ffi/zcertstore'
113
+
81
114
  attach_function :zconfig_new, [:string, :pointer], :pointer, **opts
82
115
  attach_function :zconfig_load, [:string], :pointer, **opts
83
116
  attach_function :zconfig_loadf, [:string, :varargs], :pointer, **opts
@@ -1,5 +1,5 @@
1
1
  module CZMQ
2
2
  module FFI
3
- GEM_VERSION = "0.1.1"
3
+ GEM_VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: czmq-ffi-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -97,6 +97,8 @@ files:
97
97
  - lib/czmq-ffi-gen/czmq/ffi/version.rb
98
98
  - lib/czmq-ffi-gen/czmq/ffi/zactor.rb
99
99
  - lib/czmq-ffi-gen/czmq/ffi/zarmour.rb
100
+ - lib/czmq-ffi-gen/czmq/ffi/zcert.rb
101
+ - lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb
100
102
  - lib/czmq-ffi-gen/czmq/ffi/zconfig.rb
101
103
  - lib/czmq-ffi-gen/czmq/ffi/zdir.rb
102
104
  - lib/czmq-ffi-gen/czmq/ffi/zdir_patch.rb