k9o 1.0.0-aarch64-linux
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.
Potentially problematic release.
This version of k9o might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +38 -0
- data/LICENSE +201 -0
- data/NOTICE +4 -0
- data/README.md +67 -0
- data/k9o.gemspec +41 -0
- data/lib/k9o/_ffi/kibo_kms_rest_ffi.rb +1912 -0
- data/lib/k9o/_ffi/libkibo_kms_rest_ffi.so +0 -0
- data/lib/k9o/ai.rb +28 -0
- data/lib/k9o/audit.rb +29 -0
- data/lib/k9o/barbican.rb +239 -0
- data/lib/k9o/client.rb +59 -0
- data/lib/k9o/compute.rb +67 -0
- data/lib/k9o/data.rb +157 -0
- data/lib/k9o/envelope.rb +64 -0
- data/lib/k9o/functions.rb +51 -0
- data/lib/k9o/gate.rb +64 -0
- data/lib/k9o/http_transport.rb +318 -0
- data/lib/k9o/kerror.rb +52 -0
- data/lib/k9o/kibo.rb +114 -0
- data/lib/k9o/me.rb +160 -0
- data/lib/k9o/migrations.rb +244 -0
- data/lib/k9o/multipart.rb +42 -0
- data/lib/k9o/org.rb +213 -0
- data/lib/k9o/orgs.rb +33 -0
- data/lib/k9o/policies.rb +65 -0
- data/lib/k9o/projects.rb +33 -0
- data/lib/k9o/realtime.rb +80 -0
- data/lib/k9o/region.rb +95 -0
- data/lib/k9o/storage.rb +176 -0
- data/lib/k9o/studio.rb +175 -0
- data/lib/k9o/url_grammar.rb +113 -0
- data/lib/k9o/vault.rb +235 -0
- data/lib/k9o/version.rb +5 -0
- data/lib/k9o.rb +54 -0
- data/sig/k9o/ai.rbs +16 -0
- data/sig/k9o/gate.rbs +11 -0
- data/sig/k9o/migrations.rbs +138 -0
- data/sig/k9o/region.rbs +19 -0
- data/sig/k9o/storage.rbs +41 -0
- metadata +100 -0
|
@@ -0,0 +1,1912 @@
|
|
|
1
|
+
# This file was autogenerated by some hot garbage in the `uniffi` crate.
|
|
2
|
+
# Trust me, you don't want to mess with it!
|
|
3
|
+
|
|
4
|
+
# Common helper code.
|
|
5
|
+
#
|
|
6
|
+
# Ideally this would live in a separate .rb file where it can be unittested etc
|
|
7
|
+
# in isolation, and perhaps even published as a re-useable package.
|
|
8
|
+
#
|
|
9
|
+
# However, it's important that the details of how this helper code works (e.g. the
|
|
10
|
+
# way that different builtin types are passed across the FFI) exactly match what's
|
|
11
|
+
# expected by the rust code on the other side of the interface. In practice right
|
|
12
|
+
# now that means coming from the exact some version of `uniffi` that was used to
|
|
13
|
+
# compile the rust component. The easiest way to ensure this is to bundle the Ruby
|
|
14
|
+
# helpers directly inline like we're doing here.
|
|
15
|
+
|
|
16
|
+
require 'ffi'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
module KiboKmsRestFfi
|
|
20
|
+
def self.uniffi_in_range(i, type_name, min, max)
|
|
21
|
+
raise TypeError, "no implicit conversion of #{i} into Integer" unless i.respond_to?(:to_int)
|
|
22
|
+
i = i.to_int
|
|
23
|
+
raise RangeError, "#{type_name} requires #{min} <= value < #{max}" unless (min <= i && i < max)
|
|
24
|
+
i
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.uniffi_utf8(v)
|
|
28
|
+
raise TypeError, "no implicit conversion of #{v} into String" unless v.respond_to?(:to_str)
|
|
29
|
+
v = v.to_str.encode(Encoding::UTF_8)
|
|
30
|
+
raise Encoding::InvalidByteSequenceError, "not a valid UTF-8 encoded string" unless v.valid_encoding?
|
|
31
|
+
v
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.uniffi_bytes(v)
|
|
35
|
+
raise TypeError, "no implicit conversion of #{v} into String" unless v.respond_to?(:to_str)
|
|
36
|
+
v.to_str
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class RustBuffer < FFI::Struct
|
|
40
|
+
layout :capacity, :uint64,
|
|
41
|
+
:len, :uint64,
|
|
42
|
+
:data, :pointer
|
|
43
|
+
|
|
44
|
+
def self.alloc(size)
|
|
45
|
+
return KiboKmsRestFfi.rust_call(:ffi_kibo_kms_rest_ffi_rustbuffer_alloc, size)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.reserve(rbuf, additional)
|
|
49
|
+
return KiboKmsRestFfi.rust_call(:ffi_kibo_kms_rest_ffi_rustbuffer_reserve, rbuf, additional)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def free
|
|
53
|
+
KiboKmsRestFfi.rust_call(:ffi_kibo_kms_rest_ffi_rustbuffer_free, self)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def capacity
|
|
57
|
+
self[:capacity]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def len
|
|
61
|
+
self[:len]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def len=(value)
|
|
65
|
+
self[:len] = value
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def data
|
|
69
|
+
self[:data]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def to_s
|
|
73
|
+
"RustBuffer(capacity=#{capacity}, len=#{len}, data=#{data.read_bytes len})"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# The allocated buffer will be automatically freed if an error occurs, ensuring that
|
|
77
|
+
# we don't accidentally leak it.
|
|
78
|
+
def self.allocWithBuilder
|
|
79
|
+
builder = RustBufferBuilder.new
|
|
80
|
+
|
|
81
|
+
begin
|
|
82
|
+
yield builder
|
|
83
|
+
rescue => e
|
|
84
|
+
builder.discard
|
|
85
|
+
raise e
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# The RustBuffer will be freed once the context-manager exits, ensuring that we don't
|
|
90
|
+
# leak it even if an error occurs.
|
|
91
|
+
def consumeWithStream
|
|
92
|
+
stream = RustBufferStream.new self
|
|
93
|
+
|
|
94
|
+
yield stream
|
|
95
|
+
|
|
96
|
+
raise RuntimeError, 'junk data left in buffer after consuming' if stream.remaining != 0
|
|
97
|
+
ensure
|
|
98
|
+
free
|
|
99
|
+
end# The primitive String type.
|
|
100
|
+
|
|
101
|
+
def self.allocFromString(value)
|
|
102
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
103
|
+
builder.write value.encode('utf-8')
|
|
104
|
+
return builder.finalize
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def consumeIntoString
|
|
109
|
+
consumeWithStream do |stream|
|
|
110
|
+
return stream.read(stream.remaining).force_encoding(Encoding::UTF_8)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# The primitive Bytes type.
|
|
115
|
+
|
|
116
|
+
def self.allocFromBytes(value)
|
|
117
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
118
|
+
builder.write_Bytes(value)
|
|
119
|
+
return builder.finalize
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def consumeIntoBytes
|
|
124
|
+
consumeWithStream do |stream|
|
|
125
|
+
return stream.readBytes
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# The Record type DecryptInput.
|
|
130
|
+
|
|
131
|
+
def self.check_lower_TypeDecryptInput(v)
|
|
132
|
+
RustBuffer.check_lower_TypeFfiCredential(v.kms_cred)
|
|
133
|
+
RustBuffer.check_lower_TypeFfiProviderConfig(v.provider_config)
|
|
134
|
+
|
|
135
|
+
RustBuffer.check_lower_TypeFfiStrategy(v.strategy)
|
|
136
|
+
RustBuffer.check_lower_TypeFfiAttestationTier(v.attestation_tier)
|
|
137
|
+
RustBuffer.check_lower_SequenceTypeFfiKvPair(v.encryption_context)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.alloc_from_TypeDecryptInput(v)
|
|
141
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
142
|
+
builder.write_TypeDecryptInput(v)
|
|
143
|
+
return builder.finalize
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def consumeIntoTypeDecryptInput
|
|
148
|
+
consumeWithStream do |stream|
|
|
149
|
+
return stream.readTypeDecryptInput
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# The Record type DecryptOutput.
|
|
154
|
+
|
|
155
|
+
def self.check_lower_TypeDecryptOutput(v)
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def self.alloc_from_TypeDecryptOutput(v)
|
|
160
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
161
|
+
builder.write_TypeDecryptOutput(v)
|
|
162
|
+
return builder.finalize
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def consumeIntoTypeDecryptOutput
|
|
167
|
+
consumeWithStream do |stream|
|
|
168
|
+
return stream.readTypeDecryptOutput
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# The Record type EncryptInput.
|
|
173
|
+
|
|
174
|
+
def self.check_lower_TypeEncryptInput(v)
|
|
175
|
+
RustBuffer.check_lower_TypeKmsProvider(v.provider)
|
|
176
|
+
RustBuffer.check_lower_TypeFfiPosture(v.posture)
|
|
177
|
+
RustBuffer.check_lower_OptionalTypeFfiStrategy(v.strategy)
|
|
178
|
+
RustBuffer.check_lower_OptionalTypeFfiOracleMode(v.oracle_mode)
|
|
179
|
+
RustBuffer.check_lower_TypeFfiCredential(v.kms_cred)
|
|
180
|
+
RustBuffer.check_lower_TypeFfiKeyRef(v.key_ref)
|
|
181
|
+
RustBuffer.check_lower_TypeFfiProviderConfig(v.provider_config)
|
|
182
|
+
RustBuffer.check_lower_TypeFfiAttestationTier(v.attestation_tier)
|
|
183
|
+
RustBuffer.check_lower_SequenceTypeFfiKvPair(v.encryption_context)
|
|
184
|
+
|
|
185
|
+
RustBuffer.check_lower_OptionalTypeFfiPosturePolicy(v.posture_policy)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def self.alloc_from_TypeEncryptInput(v)
|
|
189
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
190
|
+
builder.write_TypeEncryptInput(v)
|
|
191
|
+
return builder.finalize
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def consumeIntoTypeEncryptInput
|
|
196
|
+
consumeWithStream do |stream|
|
|
197
|
+
return stream.readTypeEncryptInput
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# The Record type EncryptOutput.
|
|
202
|
+
|
|
203
|
+
def self.check_lower_TypeEncryptOutput(v)
|
|
204
|
+
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def self.alloc_from_TypeEncryptOutput(v)
|
|
208
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
209
|
+
builder.write_TypeEncryptOutput(v)
|
|
210
|
+
return builder.finalize
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def consumeIntoTypeEncryptOutput
|
|
215
|
+
consumeWithStream do |stream|
|
|
216
|
+
return stream.readTypeEncryptOutput
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# The Record type FfiAllowedOracleModes.
|
|
221
|
+
|
|
222
|
+
def self.check_lower_TypeFfiAllowedOracleModes(v)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def self.alloc_from_TypeFfiAllowedOracleModes(v)
|
|
228
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
229
|
+
builder.write_TypeFfiAllowedOracleModes(v)
|
|
230
|
+
return builder.finalize
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def consumeIntoTypeFfiAllowedOracleModes
|
|
235
|
+
consumeWithStream do |stream|
|
|
236
|
+
return stream.readTypeFfiAllowedOracleModes
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# The Record type FfiCredential.
|
|
241
|
+
|
|
242
|
+
def self.check_lower_TypeFfiCredential(v)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def self.alloc_from_TypeFfiCredential(v)
|
|
248
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
249
|
+
builder.write_TypeFfiCredential(v)
|
|
250
|
+
return builder.finalize
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def consumeIntoTypeFfiCredential
|
|
255
|
+
consumeWithStream do |stream|
|
|
256
|
+
return stream.readTypeFfiCredential
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# The Record type FfiKeyRef.
|
|
261
|
+
|
|
262
|
+
def self.check_lower_TypeFfiKeyRef(v)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def self.alloc_from_TypeFfiKeyRef(v)
|
|
268
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
269
|
+
builder.write_TypeFfiKeyRef(v)
|
|
270
|
+
return builder.finalize
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def consumeIntoTypeFfiKeyRef
|
|
275
|
+
consumeWithStream do |stream|
|
|
276
|
+
return stream.readTypeFfiKeyRef
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# The Record type FfiKvPair.
|
|
281
|
+
|
|
282
|
+
def self.check_lower_TypeFfiKvPair(v)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def self.alloc_from_TypeFfiKvPair(v)
|
|
288
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
289
|
+
builder.write_TypeFfiKvPair(v)
|
|
290
|
+
return builder.finalize
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def consumeIntoTypeFfiKvPair
|
|
295
|
+
consumeWithStream do |stream|
|
|
296
|
+
return stream.readTypeFfiKvPair
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# The Record type FfiPosturePolicy.
|
|
301
|
+
|
|
302
|
+
def self.check_lower_TypeFfiPosturePolicy(v)
|
|
303
|
+
RustBuffer.check_lower_OptionalTypeFfiMinPosture(v.min_custody_posture)
|
|
304
|
+
RustBuffer.check_lower_OptionalTypeFfiAllowedOracleModes(v.allowed_oracle_modes)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def self.alloc_from_TypeFfiPosturePolicy(v)
|
|
308
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
309
|
+
builder.write_TypeFfiPosturePolicy(v)
|
|
310
|
+
return builder.finalize
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def consumeIntoTypeFfiPosturePolicy
|
|
315
|
+
consumeWithStream do |stream|
|
|
316
|
+
return stream.readTypeFfiPosturePolicy
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
# The Record type FfiProviderConfig.
|
|
321
|
+
|
|
322
|
+
def self.check_lower_TypeFfiProviderConfig(v)
|
|
323
|
+
RustBuffer.check_lower_Optionalstring(v.aws_region)
|
|
324
|
+
RustBuffer.check_lower_Optionalstring(v.vault_address)
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def self.alloc_from_TypeFfiProviderConfig(v)
|
|
328
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
329
|
+
builder.write_TypeFfiProviderConfig(v)
|
|
330
|
+
return builder.finalize
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def consumeIntoTypeFfiProviderConfig
|
|
335
|
+
consumeWithStream do |stream|
|
|
336
|
+
return stream.readTypeFfiProviderConfig
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# The Enum type FfiAttestationTier.
|
|
341
|
+
|
|
342
|
+
def self.check_lower_TypeFfiAttestationTier(v)
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
def self.alloc_from_TypeFfiAttestationTier(v)
|
|
346
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
347
|
+
builder.write_TypeFfiAttestationTier(v)
|
|
348
|
+
return builder.finalize
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def consumeIntoTypeFfiAttestationTier
|
|
353
|
+
consumeWithStream do |stream|
|
|
354
|
+
return stream.readTypeFfiAttestationTier
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
# The Enum type FfiMinPosture.
|
|
360
|
+
|
|
361
|
+
def self.check_lower_TypeFfiMinPosture(v)
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def self.alloc_from_TypeFfiMinPosture(v)
|
|
365
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
366
|
+
builder.write_TypeFfiMinPosture(v)
|
|
367
|
+
return builder.finalize
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def consumeIntoTypeFfiMinPosture
|
|
372
|
+
consumeWithStream do |stream|
|
|
373
|
+
return stream.readTypeFfiMinPosture
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
# The Enum type FfiOracleMode.
|
|
379
|
+
|
|
380
|
+
def self.check_lower_TypeFfiOracleMode(v)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def self.alloc_from_TypeFfiOracleMode(v)
|
|
384
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
385
|
+
builder.write_TypeFfiOracleMode(v)
|
|
386
|
+
return builder.finalize
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def consumeIntoTypeFfiOracleMode
|
|
391
|
+
consumeWithStream do |stream|
|
|
392
|
+
return stream.readTypeFfiOracleMode
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
# The Enum type FfiPosture.
|
|
398
|
+
|
|
399
|
+
def self.check_lower_TypeFfiPosture(v)
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
def self.alloc_from_TypeFfiPosture(v)
|
|
403
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
404
|
+
builder.write_TypeFfiPosture(v)
|
|
405
|
+
return builder.finalize
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def consumeIntoTypeFfiPosture
|
|
410
|
+
consumeWithStream do |stream|
|
|
411
|
+
return stream.readTypeFfiPosture
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
# The Enum type FfiStrategy.
|
|
417
|
+
|
|
418
|
+
def self.check_lower_TypeFfiStrategy(v)
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
def self.alloc_from_TypeFfiStrategy(v)
|
|
422
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
423
|
+
builder.write_TypeFfiStrategy(v)
|
|
424
|
+
return builder.finalize
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def consumeIntoTypeFfiStrategy
|
|
429
|
+
consumeWithStream do |stream|
|
|
430
|
+
return stream.readTypeFfiStrategy
|
|
431
|
+
end
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
# The Enum type KmsProvider.
|
|
436
|
+
|
|
437
|
+
def self.check_lower_TypeKmsProvider(v)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def self.alloc_from_TypeKmsProvider(v)
|
|
441
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
442
|
+
builder.write_TypeKmsProvider(v)
|
|
443
|
+
return builder.finalize
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
def consumeIntoTypeKmsProvider
|
|
448
|
+
consumeWithStream do |stream|
|
|
449
|
+
return stream.readTypeKmsProvider
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
# The Optional<T> type for string.
|
|
457
|
+
|
|
458
|
+
def self.check_lower_Optionalstring(v)
|
|
459
|
+
if not v.nil?
|
|
460
|
+
|
|
461
|
+
end
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def self.alloc_from_Optionalstring(v)
|
|
465
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
466
|
+
builder.write_Optionalstring(v)
|
|
467
|
+
return builder.finalize()
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
def consumeIntoOptionalstring
|
|
472
|
+
consumeWithStream do |stream|
|
|
473
|
+
return stream.readOptionalstring
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
# The Optional<T> type for TypeFfiAllowedOracleModes.
|
|
478
|
+
|
|
479
|
+
def self.check_lower_OptionalTypeFfiAllowedOracleModes(v)
|
|
480
|
+
if not v.nil?
|
|
481
|
+
RustBuffer.check_lower_TypeFfiAllowedOracleModes(v)
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
def self.alloc_from_OptionalTypeFfiAllowedOracleModes(v)
|
|
486
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
487
|
+
builder.write_OptionalTypeFfiAllowedOracleModes(v)
|
|
488
|
+
return builder.finalize()
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def consumeIntoOptionalTypeFfiAllowedOracleModes
|
|
493
|
+
consumeWithStream do |stream|
|
|
494
|
+
return stream.readOptionalTypeFfiAllowedOracleModes
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# The Optional<T> type for TypeFfiPosturePolicy.
|
|
499
|
+
|
|
500
|
+
def self.check_lower_OptionalTypeFfiPosturePolicy(v)
|
|
501
|
+
if not v.nil?
|
|
502
|
+
RustBuffer.check_lower_TypeFfiPosturePolicy(v)
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
def self.alloc_from_OptionalTypeFfiPosturePolicy(v)
|
|
507
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
508
|
+
builder.write_OptionalTypeFfiPosturePolicy(v)
|
|
509
|
+
return builder.finalize()
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
def consumeIntoOptionalTypeFfiPosturePolicy
|
|
514
|
+
consumeWithStream do |stream|
|
|
515
|
+
return stream.readOptionalTypeFfiPosturePolicy
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
# The Optional<T> type for TypeFfiMinPosture.
|
|
520
|
+
|
|
521
|
+
def self.check_lower_OptionalTypeFfiMinPosture(v)
|
|
522
|
+
if not v.nil?
|
|
523
|
+
RustBuffer.check_lower_TypeFfiMinPosture(v)
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
def self.alloc_from_OptionalTypeFfiMinPosture(v)
|
|
528
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
529
|
+
builder.write_OptionalTypeFfiMinPosture(v)
|
|
530
|
+
return builder.finalize()
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
def consumeIntoOptionalTypeFfiMinPosture
|
|
535
|
+
consumeWithStream do |stream|
|
|
536
|
+
return stream.readOptionalTypeFfiMinPosture
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
# The Optional<T> type for TypeFfiOracleMode.
|
|
541
|
+
|
|
542
|
+
def self.check_lower_OptionalTypeFfiOracleMode(v)
|
|
543
|
+
if not v.nil?
|
|
544
|
+
RustBuffer.check_lower_TypeFfiOracleMode(v)
|
|
545
|
+
end
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
def self.alloc_from_OptionalTypeFfiOracleMode(v)
|
|
549
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
550
|
+
builder.write_OptionalTypeFfiOracleMode(v)
|
|
551
|
+
return builder.finalize()
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
def consumeIntoOptionalTypeFfiOracleMode
|
|
556
|
+
consumeWithStream do |stream|
|
|
557
|
+
return stream.readOptionalTypeFfiOracleMode
|
|
558
|
+
end
|
|
559
|
+
end
|
|
560
|
+
|
|
561
|
+
# The Optional<T> type for TypeFfiStrategy.
|
|
562
|
+
|
|
563
|
+
def self.check_lower_OptionalTypeFfiStrategy(v)
|
|
564
|
+
if not v.nil?
|
|
565
|
+
RustBuffer.check_lower_TypeFfiStrategy(v)
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
def self.alloc_from_OptionalTypeFfiStrategy(v)
|
|
570
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
571
|
+
builder.write_OptionalTypeFfiStrategy(v)
|
|
572
|
+
return builder.finalize()
|
|
573
|
+
end
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def consumeIntoOptionalTypeFfiStrategy
|
|
577
|
+
consumeWithStream do |stream|
|
|
578
|
+
return stream.readOptionalTypeFfiStrategy
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
# The Sequence<T> type for TypeFfiKvPair.
|
|
583
|
+
|
|
584
|
+
def self.check_lower_SequenceTypeFfiKvPair(v)
|
|
585
|
+
v.each do |item|
|
|
586
|
+
RustBuffer.check_lower_TypeFfiKvPair(item)
|
|
587
|
+
end
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
def self.alloc_from_SequenceTypeFfiKvPair(v)
|
|
591
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
592
|
+
builder.write_SequenceTypeFfiKvPair(v)
|
|
593
|
+
return builder.finalize()
|
|
594
|
+
end
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
def consumeIntoSequenceTypeFfiKvPair
|
|
598
|
+
consumeWithStream do |stream|
|
|
599
|
+
return stream.readSequenceTypeFfiKvPair
|
|
600
|
+
end
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
end
|
|
605
|
+
|
|
606
|
+
module UniFFILib
|
|
607
|
+
class ForeignBytes < FFI::Struct
|
|
608
|
+
layout :len, :int32,
|
|
609
|
+
:data, :pointer
|
|
610
|
+
|
|
611
|
+
def len
|
|
612
|
+
self[:len]
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
def data
|
|
616
|
+
self[:data]
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
def to_s
|
|
620
|
+
"ForeignBytes(len=#{len}, data=#{data.read_bytes(len)})"
|
|
621
|
+
end
|
|
622
|
+
end
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
private_constant :UniFFILib
|
|
626
|
+
|
|
627
|
+
# Helper for structured reading of values from a RustBuffer.
|
|
628
|
+
class RustBufferStream
|
|
629
|
+
|
|
630
|
+
def initialize(rbuf)
|
|
631
|
+
@rbuf = rbuf
|
|
632
|
+
@offset = 0
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
def remaining
|
|
636
|
+
@rbuf.len - @offset
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
def read(size)
|
|
640
|
+
raise InternalError, 'read past end of rust buffer' if @offset + size > @rbuf.len
|
|
641
|
+
|
|
642
|
+
data = @rbuf.data.get_bytes @offset, size
|
|
643
|
+
|
|
644
|
+
@offset += size
|
|
645
|
+
|
|
646
|
+
data
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
def readU64
|
|
650
|
+
unpack_from 8, 'Q>'
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
def readBool
|
|
654
|
+
v = unpack_from 1, 'c'
|
|
655
|
+
|
|
656
|
+
return false if v == 0
|
|
657
|
+
return true if v == 1
|
|
658
|
+
|
|
659
|
+
raise InternalError, 'Unexpected byte for Boolean type'
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
def readString
|
|
663
|
+
size = unpack_from 4, 'l>'
|
|
664
|
+
|
|
665
|
+
raise InternalError, 'Unexpected negative string length' if size.negative?
|
|
666
|
+
|
|
667
|
+
read(size).force_encoding(Encoding::UTF_8)
|
|
668
|
+
end
|
|
669
|
+
|
|
670
|
+
def readBytes
|
|
671
|
+
size = unpack_from 4, 'l>'
|
|
672
|
+
|
|
673
|
+
raise InternalError, 'Unexpected negative byte string length' if size.negative?
|
|
674
|
+
|
|
675
|
+
read(size).force_encoding(Encoding::BINARY)
|
|
676
|
+
end
|
|
677
|
+
|
|
678
|
+
# The Record type DecryptInput.
|
|
679
|
+
|
|
680
|
+
def readTypeDecryptInput
|
|
681
|
+
DecryptInput.new(
|
|
682
|
+
kms_cred: readTypeFfiCredential,
|
|
683
|
+
provider_config: readTypeFfiProviderConfig,
|
|
684
|
+
envelope: readBytes,
|
|
685
|
+
strategy: readTypeFfiStrategy,
|
|
686
|
+
attestation_tier: readTypeFfiAttestationTier,
|
|
687
|
+
encryption_context: readSequenceTypeFfiKvPair
|
|
688
|
+
)
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
# The Record type DecryptOutput.
|
|
692
|
+
|
|
693
|
+
def readTypeDecryptOutput
|
|
694
|
+
DecryptOutput.new(
|
|
695
|
+
plaintext: readBytes
|
|
696
|
+
)
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
# The Record type EncryptInput.
|
|
700
|
+
|
|
701
|
+
def readTypeEncryptInput
|
|
702
|
+
EncryptInput.new(
|
|
703
|
+
provider: readTypeKmsProvider,
|
|
704
|
+
posture: readTypeFfiPosture,
|
|
705
|
+
strategy: readOptionalTypeFfiStrategy,
|
|
706
|
+
oracle_mode: readOptionalTypeFfiOracleMode,
|
|
707
|
+
kms_cred: readTypeFfiCredential,
|
|
708
|
+
key_ref: readTypeFfiKeyRef,
|
|
709
|
+
provider_config: readTypeFfiProviderConfig,
|
|
710
|
+
attestation_tier: readTypeFfiAttestationTier,
|
|
711
|
+
encryption_context: readSequenceTypeFfiKvPair,
|
|
712
|
+
plaintext: readBytes,
|
|
713
|
+
posture_policy: readOptionalTypeFfiPosturePolicy
|
|
714
|
+
)
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
# The Record type EncryptOutput.
|
|
718
|
+
|
|
719
|
+
def readTypeEncryptOutput
|
|
720
|
+
EncryptOutput.new(
|
|
721
|
+
envelope: readBytes
|
|
722
|
+
)
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
# The Record type FfiAllowedOracleModes.
|
|
726
|
+
|
|
727
|
+
def readTypeFfiAllowedOracleModes
|
|
728
|
+
FfiAllowedOracleModes.new(
|
|
729
|
+
brokered: readBool,
|
|
730
|
+
direct: readBool
|
|
731
|
+
)
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
# The Record type FfiCredential.
|
|
735
|
+
|
|
736
|
+
def readTypeFfiCredential
|
|
737
|
+
FfiCredential.new(
|
|
738
|
+
secret: readString,
|
|
739
|
+
expires_at_unix_secs: readU64
|
|
740
|
+
)
|
|
741
|
+
end
|
|
742
|
+
|
|
743
|
+
# The Record type FfiKeyRef.
|
|
744
|
+
|
|
745
|
+
def readTypeFfiKeyRef
|
|
746
|
+
FfiKeyRef.new(
|
|
747
|
+
version: readU64,
|
|
748
|
+
external_ref: readString
|
|
749
|
+
)
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
# The Record type FfiKvPair.
|
|
753
|
+
|
|
754
|
+
def readTypeFfiKvPair
|
|
755
|
+
FfiKvPair.new(
|
|
756
|
+
key: readString,
|
|
757
|
+
value: readString
|
|
758
|
+
)
|
|
759
|
+
end
|
|
760
|
+
|
|
761
|
+
# The Record type FfiPosturePolicy.
|
|
762
|
+
|
|
763
|
+
def readTypeFfiPosturePolicy
|
|
764
|
+
FfiPosturePolicy.new(
|
|
765
|
+
min_custody_posture: readOptionalTypeFfiMinPosture,
|
|
766
|
+
allowed_oracle_modes: readOptionalTypeFfiAllowedOracleModes
|
|
767
|
+
)
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
# The Record type FfiProviderConfig.
|
|
771
|
+
|
|
772
|
+
def readTypeFfiProviderConfig
|
|
773
|
+
FfiProviderConfig.new(
|
|
774
|
+
aws_region: readOptionalstring,
|
|
775
|
+
vault_address: readOptionalstring
|
|
776
|
+
)
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
# The Enum type FfiAttestationTier.
|
|
782
|
+
|
|
783
|
+
def readTypeFfiAttestationTier
|
|
784
|
+
variant = unpack_from 4, 'l>'
|
|
785
|
+
|
|
786
|
+
if variant == 1
|
|
787
|
+
return FfiAttestationTier::SOFTWARE
|
|
788
|
+
end
|
|
789
|
+
if variant == 2
|
|
790
|
+
return FfiAttestationTier::HARDWARE_BACKED
|
|
791
|
+
end
|
|
792
|
+
if variant == 3
|
|
793
|
+
return FfiAttestationTier::CONFIDENTIAL
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
raise InternalError, 'Unexpected variant tag for TypeFfiAttestationTier'
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
# The Enum type FfiMinPosture.
|
|
804
|
+
|
|
805
|
+
def readTypeFfiMinPosture
|
|
806
|
+
variant = unpack_from 4, 'l>'
|
|
807
|
+
|
|
808
|
+
if variant == 1
|
|
809
|
+
return FfiMinPosture::PLATFORM_MANAGED
|
|
810
|
+
end
|
|
811
|
+
if variant == 2
|
|
812
|
+
return FfiMinPosture::BYOK
|
|
813
|
+
end
|
|
814
|
+
if variant == 3
|
|
815
|
+
return FfiMinPosture::HYOK
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
raise InternalError, 'Unexpected variant tag for TypeFfiMinPosture'
|
|
819
|
+
end
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
# The Enum type FfiOracleMode.
|
|
826
|
+
|
|
827
|
+
def readTypeFfiOracleMode
|
|
828
|
+
variant = unpack_from 4, 'l>'
|
|
829
|
+
|
|
830
|
+
if variant == 1
|
|
831
|
+
return FfiOracleMode::BROKERED
|
|
832
|
+
end
|
|
833
|
+
if variant == 2
|
|
834
|
+
return FfiOracleMode::DIRECT
|
|
835
|
+
end
|
|
836
|
+
|
|
837
|
+
raise InternalError, 'Unexpected variant tag for TypeFfiOracleMode'
|
|
838
|
+
end
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
# The Enum type FfiPosture.
|
|
845
|
+
|
|
846
|
+
def readTypeFfiPosture
|
|
847
|
+
variant = unpack_from 4, 'l>'
|
|
848
|
+
|
|
849
|
+
if variant == 1
|
|
850
|
+
return FfiPosture::BYOK
|
|
851
|
+
end
|
|
852
|
+
if variant == 2
|
|
853
|
+
return FfiPosture::HYOK
|
|
854
|
+
end
|
|
855
|
+
|
|
856
|
+
raise InternalError, 'Unexpected variant tag for TypeFfiPosture'
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
# The Enum type FfiStrategy.
|
|
864
|
+
|
|
865
|
+
def readTypeFfiStrategy
|
|
866
|
+
variant = unpack_from 4, 'l>'
|
|
867
|
+
|
|
868
|
+
if variant == 1
|
|
869
|
+
return FfiStrategy::LOCAL_ENVELOPE
|
|
870
|
+
end
|
|
871
|
+
if variant == 2
|
|
872
|
+
return FfiStrategy::CUSTOMER_KMS_ORACLE
|
|
873
|
+
end
|
|
874
|
+
|
|
875
|
+
raise InternalError, 'Unexpected variant tag for TypeFfiStrategy'
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
# The Enum type KmsProvider.
|
|
883
|
+
|
|
884
|
+
def readTypeKmsProvider
|
|
885
|
+
variant = unpack_from 4, 'l>'
|
|
886
|
+
|
|
887
|
+
if variant == 1
|
|
888
|
+
return KmsProvider::AWS_KMS
|
|
889
|
+
end
|
|
890
|
+
if variant == 2
|
|
891
|
+
return KmsProvider::GCP_KMS
|
|
892
|
+
end
|
|
893
|
+
if variant == 3
|
|
894
|
+
return KmsProvider::AZURE_KV
|
|
895
|
+
end
|
|
896
|
+
if variant == 4
|
|
897
|
+
return KmsProvider::HASHICORP_VAULT
|
|
898
|
+
end
|
|
899
|
+
|
|
900
|
+
raise InternalError, 'Unexpected variant tag for TypeKmsProvider'
|
|
901
|
+
end
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
# The Error type ZkFfiUniffiError
|
|
910
|
+
|
|
911
|
+
def readTypeZkFfiUniffiError
|
|
912
|
+
variant = unpack_from 4, 'l>'
|
|
913
|
+
|
|
914
|
+
if variant == 1
|
|
915
|
+
return ZkFfiUniffiError::Platform.new(
|
|
916
|
+
readString(),
|
|
917
|
+
readString()
|
|
918
|
+
)
|
|
919
|
+
end
|
|
920
|
+
if variant == 2
|
|
921
|
+
return ZkFfiUniffiError::UpstreamKms.new(
|
|
922
|
+
readString()
|
|
923
|
+
)
|
|
924
|
+
end
|
|
925
|
+
if variant == 3
|
|
926
|
+
return ZkFfiUniffiError::PostureViolation.new(
|
|
927
|
+
readString(),
|
|
928
|
+
readString(),
|
|
929
|
+
readString(),
|
|
930
|
+
readString(),
|
|
931
|
+
readString()
|
|
932
|
+
)
|
|
933
|
+
end
|
|
934
|
+
|
|
935
|
+
raise InternalError, 'Unexpected variant tag for TypeZkFfiUniffiError'
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
# The Optional<T> type for string.
|
|
940
|
+
|
|
941
|
+
def readOptionalstring
|
|
942
|
+
flag = unpack_from 1, 'c'
|
|
943
|
+
|
|
944
|
+
if flag == 0
|
|
945
|
+
return nil
|
|
946
|
+
elsif flag == 1
|
|
947
|
+
return readString
|
|
948
|
+
else
|
|
949
|
+
raise InternalError, 'Unexpected flag byte for Optionalstring'
|
|
950
|
+
end
|
|
951
|
+
end
|
|
952
|
+
|
|
953
|
+
# The Optional<T> type for TypeFfiAllowedOracleModes.
|
|
954
|
+
|
|
955
|
+
def readOptionalTypeFfiAllowedOracleModes
|
|
956
|
+
flag = unpack_from 1, 'c'
|
|
957
|
+
|
|
958
|
+
if flag == 0
|
|
959
|
+
return nil
|
|
960
|
+
elsif flag == 1
|
|
961
|
+
return readTypeFfiAllowedOracleModes
|
|
962
|
+
else
|
|
963
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypeFfiAllowedOracleModes'
|
|
964
|
+
end
|
|
965
|
+
end
|
|
966
|
+
|
|
967
|
+
# The Optional<T> type for TypeFfiPosturePolicy.
|
|
968
|
+
|
|
969
|
+
def readOptionalTypeFfiPosturePolicy
|
|
970
|
+
flag = unpack_from 1, 'c'
|
|
971
|
+
|
|
972
|
+
if flag == 0
|
|
973
|
+
return nil
|
|
974
|
+
elsif flag == 1
|
|
975
|
+
return readTypeFfiPosturePolicy
|
|
976
|
+
else
|
|
977
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypeFfiPosturePolicy'
|
|
978
|
+
end
|
|
979
|
+
end
|
|
980
|
+
|
|
981
|
+
# The Optional<T> type for TypeFfiMinPosture.
|
|
982
|
+
|
|
983
|
+
def readOptionalTypeFfiMinPosture
|
|
984
|
+
flag = unpack_from 1, 'c'
|
|
985
|
+
|
|
986
|
+
if flag == 0
|
|
987
|
+
return nil
|
|
988
|
+
elsif flag == 1
|
|
989
|
+
return readTypeFfiMinPosture
|
|
990
|
+
else
|
|
991
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypeFfiMinPosture'
|
|
992
|
+
end
|
|
993
|
+
end
|
|
994
|
+
|
|
995
|
+
# The Optional<T> type for TypeFfiOracleMode.
|
|
996
|
+
|
|
997
|
+
def readOptionalTypeFfiOracleMode
|
|
998
|
+
flag = unpack_from 1, 'c'
|
|
999
|
+
|
|
1000
|
+
if flag == 0
|
|
1001
|
+
return nil
|
|
1002
|
+
elsif flag == 1
|
|
1003
|
+
return readTypeFfiOracleMode
|
|
1004
|
+
else
|
|
1005
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypeFfiOracleMode'
|
|
1006
|
+
end
|
|
1007
|
+
end
|
|
1008
|
+
|
|
1009
|
+
# The Optional<T> type for TypeFfiStrategy.
|
|
1010
|
+
|
|
1011
|
+
def readOptionalTypeFfiStrategy
|
|
1012
|
+
flag = unpack_from 1, 'c'
|
|
1013
|
+
|
|
1014
|
+
if flag == 0
|
|
1015
|
+
return nil
|
|
1016
|
+
elsif flag == 1
|
|
1017
|
+
return readTypeFfiStrategy
|
|
1018
|
+
else
|
|
1019
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypeFfiStrategy'
|
|
1020
|
+
end
|
|
1021
|
+
end
|
|
1022
|
+
|
|
1023
|
+
# The Sequence<T> type for TypeFfiKvPair.
|
|
1024
|
+
|
|
1025
|
+
def readSequenceTypeFfiKvPair
|
|
1026
|
+
count = unpack_from 4, 'l>'
|
|
1027
|
+
|
|
1028
|
+
raise InternalError, 'Unexpected negative sequence length' if count.negative?
|
|
1029
|
+
|
|
1030
|
+
items = []
|
|
1031
|
+
|
|
1032
|
+
count.times do
|
|
1033
|
+
items.append readTypeFfiKvPair
|
|
1034
|
+
end
|
|
1035
|
+
|
|
1036
|
+
items
|
|
1037
|
+
end
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
def unpack_from(size, format)
|
|
1042
|
+
raise InternalError, 'read past end of rust buffer' if @offset + size > @rbuf.len
|
|
1043
|
+
|
|
1044
|
+
value = @rbuf.data.get_bytes(@offset, size).unpack format
|
|
1045
|
+
|
|
1046
|
+
@offset += size
|
|
1047
|
+
|
|
1048
|
+
# TODO: verify this
|
|
1049
|
+
raise 'more than one element!!!' if value.size > 1
|
|
1050
|
+
|
|
1051
|
+
value[0]
|
|
1052
|
+
end
|
|
1053
|
+
end
|
|
1054
|
+
|
|
1055
|
+
private_constant :RustBufferStream
|
|
1056
|
+
|
|
1057
|
+
# Helper for structured writing of values into a RustBuffer.
|
|
1058
|
+
class RustBufferBuilder
|
|
1059
|
+
def initialize
|
|
1060
|
+
@rust_buf = RustBuffer.alloc 16
|
|
1061
|
+
@rust_buf.len = 0
|
|
1062
|
+
end
|
|
1063
|
+
|
|
1064
|
+
def finalize
|
|
1065
|
+
rbuf = @rust_buf
|
|
1066
|
+
|
|
1067
|
+
@rust_buf = nil
|
|
1068
|
+
|
|
1069
|
+
rbuf
|
|
1070
|
+
end
|
|
1071
|
+
|
|
1072
|
+
def discard
|
|
1073
|
+
return if @rust_buf.nil?
|
|
1074
|
+
|
|
1075
|
+
rbuf = finalize
|
|
1076
|
+
rbuf.free
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
def write(value)
|
|
1080
|
+
reserve(value.bytes.size) do
|
|
1081
|
+
@rust_buf.data.put_array_of_char @rust_buf.len, value.bytes
|
|
1082
|
+
end
|
|
1083
|
+
end
|
|
1084
|
+
|
|
1085
|
+
def write_U64(v)
|
|
1086
|
+
v = KiboKmsRestFfi::uniffi_in_range(v, "u64", 0, 2**64)
|
|
1087
|
+
pack_into(8, 'Q>', v)
|
|
1088
|
+
end
|
|
1089
|
+
|
|
1090
|
+
def write_Bool(v)
|
|
1091
|
+
pack_into(1, 'c', v ? 1 : 0)
|
|
1092
|
+
end
|
|
1093
|
+
|
|
1094
|
+
def write_String(v)
|
|
1095
|
+
v = KiboKmsRestFfi::uniffi_utf8(v)
|
|
1096
|
+
pack_into 4, 'l>', v.bytes.size
|
|
1097
|
+
write v
|
|
1098
|
+
end
|
|
1099
|
+
|
|
1100
|
+
def write_Bytes(v)
|
|
1101
|
+
v = KiboKmsRestFfi::uniffi_bytes(v)
|
|
1102
|
+
pack_into 4, 'l>', v.bytes.size
|
|
1103
|
+
write v
|
|
1104
|
+
end
|
|
1105
|
+
|
|
1106
|
+
# The Record type DecryptInput.
|
|
1107
|
+
|
|
1108
|
+
def write_TypeDecryptInput(v)
|
|
1109
|
+
self.write_TypeFfiCredential(v.kms_cred)
|
|
1110
|
+
self.write_TypeFfiProviderConfig(v.provider_config)
|
|
1111
|
+
self.write_Bytes(v.envelope)
|
|
1112
|
+
self.write_TypeFfiStrategy(v.strategy)
|
|
1113
|
+
self.write_TypeFfiAttestationTier(v.attestation_tier)
|
|
1114
|
+
self.write_SequenceTypeFfiKvPair(v.encryption_context)
|
|
1115
|
+
end
|
|
1116
|
+
|
|
1117
|
+
# The Record type DecryptOutput.
|
|
1118
|
+
|
|
1119
|
+
def write_TypeDecryptOutput(v)
|
|
1120
|
+
self.write_Bytes(v.plaintext)
|
|
1121
|
+
end
|
|
1122
|
+
|
|
1123
|
+
# The Record type EncryptInput.
|
|
1124
|
+
|
|
1125
|
+
def write_TypeEncryptInput(v)
|
|
1126
|
+
self.write_TypeKmsProvider(v.provider)
|
|
1127
|
+
self.write_TypeFfiPosture(v.posture)
|
|
1128
|
+
self.write_OptionalTypeFfiStrategy(v.strategy)
|
|
1129
|
+
self.write_OptionalTypeFfiOracleMode(v.oracle_mode)
|
|
1130
|
+
self.write_TypeFfiCredential(v.kms_cred)
|
|
1131
|
+
self.write_TypeFfiKeyRef(v.key_ref)
|
|
1132
|
+
self.write_TypeFfiProviderConfig(v.provider_config)
|
|
1133
|
+
self.write_TypeFfiAttestationTier(v.attestation_tier)
|
|
1134
|
+
self.write_SequenceTypeFfiKvPair(v.encryption_context)
|
|
1135
|
+
self.write_Bytes(v.plaintext)
|
|
1136
|
+
self.write_OptionalTypeFfiPosturePolicy(v.posture_policy)
|
|
1137
|
+
end
|
|
1138
|
+
|
|
1139
|
+
# The Record type EncryptOutput.
|
|
1140
|
+
|
|
1141
|
+
def write_TypeEncryptOutput(v)
|
|
1142
|
+
self.write_Bytes(v.envelope)
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
# The Record type FfiAllowedOracleModes.
|
|
1146
|
+
|
|
1147
|
+
def write_TypeFfiAllowedOracleModes(v)
|
|
1148
|
+
self.write_Bool(v.brokered)
|
|
1149
|
+
self.write_Bool(v.direct)
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
# The Record type FfiCredential.
|
|
1153
|
+
|
|
1154
|
+
def write_TypeFfiCredential(v)
|
|
1155
|
+
self.write_String(v.secret)
|
|
1156
|
+
self.write_U64(v.expires_at_unix_secs)
|
|
1157
|
+
end
|
|
1158
|
+
|
|
1159
|
+
# The Record type FfiKeyRef.
|
|
1160
|
+
|
|
1161
|
+
def write_TypeFfiKeyRef(v)
|
|
1162
|
+
self.write_U64(v.version)
|
|
1163
|
+
self.write_String(v.external_ref)
|
|
1164
|
+
end
|
|
1165
|
+
|
|
1166
|
+
# The Record type FfiKvPair.
|
|
1167
|
+
|
|
1168
|
+
def write_TypeFfiKvPair(v)
|
|
1169
|
+
self.write_String(v.key)
|
|
1170
|
+
self.write_String(v.value)
|
|
1171
|
+
end
|
|
1172
|
+
|
|
1173
|
+
# The Record type FfiPosturePolicy.
|
|
1174
|
+
|
|
1175
|
+
def write_TypeFfiPosturePolicy(v)
|
|
1176
|
+
self.write_OptionalTypeFfiMinPosture(v.min_custody_posture)
|
|
1177
|
+
self.write_OptionalTypeFfiAllowedOracleModes(v.allowed_oracle_modes)
|
|
1178
|
+
end
|
|
1179
|
+
|
|
1180
|
+
# The Record type FfiProviderConfig.
|
|
1181
|
+
|
|
1182
|
+
def write_TypeFfiProviderConfig(v)
|
|
1183
|
+
self.write_Optionalstring(v.aws_region)
|
|
1184
|
+
self.write_Optionalstring(v.vault_address)
|
|
1185
|
+
end
|
|
1186
|
+
|
|
1187
|
+
# The Enum type FfiAttestationTier.
|
|
1188
|
+
|
|
1189
|
+
def write_TypeFfiAttestationTier(v)
|
|
1190
|
+
pack_into(4, 'l>', v)
|
|
1191
|
+
end
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
# The Enum type FfiMinPosture.
|
|
1195
|
+
|
|
1196
|
+
def write_TypeFfiMinPosture(v)
|
|
1197
|
+
pack_into(4, 'l>', v)
|
|
1198
|
+
end
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
# The Enum type FfiOracleMode.
|
|
1202
|
+
|
|
1203
|
+
def write_TypeFfiOracleMode(v)
|
|
1204
|
+
pack_into(4, 'l>', v)
|
|
1205
|
+
end
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
# The Enum type FfiPosture.
|
|
1209
|
+
|
|
1210
|
+
def write_TypeFfiPosture(v)
|
|
1211
|
+
pack_into(4, 'l>', v)
|
|
1212
|
+
end
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
# The Enum type FfiStrategy.
|
|
1216
|
+
|
|
1217
|
+
def write_TypeFfiStrategy(v)
|
|
1218
|
+
pack_into(4, 'l>', v)
|
|
1219
|
+
end
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
# The Enum type KmsProvider.
|
|
1223
|
+
|
|
1224
|
+
def write_TypeKmsProvider(v)
|
|
1225
|
+
pack_into(4, 'l>', v)
|
|
1226
|
+
end
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
# The Optional<T> type for string.
|
|
1232
|
+
|
|
1233
|
+
def write_Optionalstring(v)
|
|
1234
|
+
if v.nil?
|
|
1235
|
+
pack_into(1, 'c', 0)
|
|
1236
|
+
else
|
|
1237
|
+
pack_into(1, 'c', 1)
|
|
1238
|
+
self.write_String(v)
|
|
1239
|
+
end
|
|
1240
|
+
end
|
|
1241
|
+
|
|
1242
|
+
# The Optional<T> type for TypeFfiAllowedOracleModes.
|
|
1243
|
+
|
|
1244
|
+
def write_OptionalTypeFfiAllowedOracleModes(v)
|
|
1245
|
+
if v.nil?
|
|
1246
|
+
pack_into(1, 'c', 0)
|
|
1247
|
+
else
|
|
1248
|
+
pack_into(1, 'c', 1)
|
|
1249
|
+
self.write_TypeFfiAllowedOracleModes(v)
|
|
1250
|
+
end
|
|
1251
|
+
end
|
|
1252
|
+
|
|
1253
|
+
# The Optional<T> type for TypeFfiPosturePolicy.
|
|
1254
|
+
|
|
1255
|
+
def write_OptionalTypeFfiPosturePolicy(v)
|
|
1256
|
+
if v.nil?
|
|
1257
|
+
pack_into(1, 'c', 0)
|
|
1258
|
+
else
|
|
1259
|
+
pack_into(1, 'c', 1)
|
|
1260
|
+
self.write_TypeFfiPosturePolicy(v)
|
|
1261
|
+
end
|
|
1262
|
+
end
|
|
1263
|
+
|
|
1264
|
+
# The Optional<T> type for TypeFfiMinPosture.
|
|
1265
|
+
|
|
1266
|
+
def write_OptionalTypeFfiMinPosture(v)
|
|
1267
|
+
if v.nil?
|
|
1268
|
+
pack_into(1, 'c', 0)
|
|
1269
|
+
else
|
|
1270
|
+
pack_into(1, 'c', 1)
|
|
1271
|
+
self.write_TypeFfiMinPosture(v)
|
|
1272
|
+
end
|
|
1273
|
+
end
|
|
1274
|
+
|
|
1275
|
+
# The Optional<T> type for TypeFfiOracleMode.
|
|
1276
|
+
|
|
1277
|
+
def write_OptionalTypeFfiOracleMode(v)
|
|
1278
|
+
if v.nil?
|
|
1279
|
+
pack_into(1, 'c', 0)
|
|
1280
|
+
else
|
|
1281
|
+
pack_into(1, 'c', 1)
|
|
1282
|
+
self.write_TypeFfiOracleMode(v)
|
|
1283
|
+
end
|
|
1284
|
+
end
|
|
1285
|
+
|
|
1286
|
+
# The Optional<T> type for TypeFfiStrategy.
|
|
1287
|
+
|
|
1288
|
+
def write_OptionalTypeFfiStrategy(v)
|
|
1289
|
+
if v.nil?
|
|
1290
|
+
pack_into(1, 'c', 0)
|
|
1291
|
+
else
|
|
1292
|
+
pack_into(1, 'c', 1)
|
|
1293
|
+
self.write_TypeFfiStrategy(v)
|
|
1294
|
+
end
|
|
1295
|
+
end
|
|
1296
|
+
|
|
1297
|
+
# The Sequence<T> type for TypeFfiKvPair.
|
|
1298
|
+
|
|
1299
|
+
def write_SequenceTypeFfiKvPair(items)
|
|
1300
|
+
pack_into(4, 'l>', items.size)
|
|
1301
|
+
|
|
1302
|
+
items.each do |item|
|
|
1303
|
+
self.write_TypeFfiKvPair(item)
|
|
1304
|
+
end
|
|
1305
|
+
end
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
private
|
|
1310
|
+
|
|
1311
|
+
def reserve(num_bytes)
|
|
1312
|
+
if @rust_buf.len + num_bytes > @rust_buf.capacity
|
|
1313
|
+
@rust_buf = RustBuffer.reserve(@rust_buf, num_bytes)
|
|
1314
|
+
end
|
|
1315
|
+
|
|
1316
|
+
yield
|
|
1317
|
+
|
|
1318
|
+
@rust_buf.len += num_bytes
|
|
1319
|
+
end
|
|
1320
|
+
|
|
1321
|
+
def pack_into(size, format, value)
|
|
1322
|
+
reserve(size) do
|
|
1323
|
+
@rust_buf.data.put_array_of_char @rust_buf.len, [value].pack(format).bytes
|
|
1324
|
+
end
|
|
1325
|
+
end
|
|
1326
|
+
end
|
|
1327
|
+
|
|
1328
|
+
private_constant :RustBufferBuilder
|
|
1329
|
+
|
|
1330
|
+
# Error definitions
|
|
1331
|
+
class RustCallStatus < FFI::Struct
|
|
1332
|
+
layout :code, :int8,
|
|
1333
|
+
:error_buf, RustBuffer
|
|
1334
|
+
|
|
1335
|
+
def code
|
|
1336
|
+
self[:code]
|
|
1337
|
+
end
|
|
1338
|
+
|
|
1339
|
+
def error_buf
|
|
1340
|
+
self[:error_buf]
|
|
1341
|
+
end
|
|
1342
|
+
|
|
1343
|
+
def to_s
|
|
1344
|
+
"RustCallStatus(code=#{self[:code]})"
|
|
1345
|
+
end
|
|
1346
|
+
end
|
|
1347
|
+
|
|
1348
|
+
# These match the values from the uniffi::rustcalls module
|
|
1349
|
+
CALL_SUCCESS = 0
|
|
1350
|
+
CALL_ERROR = 1
|
|
1351
|
+
CALL_PANIC = 2
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
module ZkFfiUniffiError
|
|
1361
|
+
class Platform < StandardError
|
|
1362
|
+
def initialize(code, message)
|
|
1363
|
+
@code = code
|
|
1364
|
+
@message = message
|
|
1365
|
+
super()
|
|
1366
|
+
end
|
|
1367
|
+
|
|
1368
|
+
attr_reader :code, :message
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
def to_s
|
|
1372
|
+
"#{self.class.name}(code=#{@code.inspect}, message=#{@message.inspect})"
|
|
1373
|
+
end
|
|
1374
|
+
end
|
|
1375
|
+
class UpstreamKms < StandardError
|
|
1376
|
+
def initialize(message)
|
|
1377
|
+
@message = message
|
|
1378
|
+
super()
|
|
1379
|
+
end
|
|
1380
|
+
|
|
1381
|
+
attr_reader :message
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
def to_s
|
|
1385
|
+
"#{self.class.name}(message=#{@message.inspect})"
|
|
1386
|
+
end
|
|
1387
|
+
end
|
|
1388
|
+
class PostureViolation < StandardError
|
|
1389
|
+
def initialize(code, message, dimension, requested, declared)
|
|
1390
|
+
@code = code
|
|
1391
|
+
@message = message
|
|
1392
|
+
@dimension = dimension
|
|
1393
|
+
@requested = requested
|
|
1394
|
+
@declared = declared
|
|
1395
|
+
super()
|
|
1396
|
+
end
|
|
1397
|
+
|
|
1398
|
+
attr_reader :code, :message, :dimension, :requested, :declared
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
def to_s
|
|
1402
|
+
"#{self.class.name}(code=#{@code.inspect}, message=#{@message.inspect}, dimension=#{@dimension.inspect}, requested=#{@requested.inspect}, declared=#{@declared.inspect})"
|
|
1403
|
+
end
|
|
1404
|
+
end
|
|
1405
|
+
|
|
1406
|
+
end
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
# Map error modules to the RustBuffer method name that reads them
|
|
1410
|
+
ERROR_MODULE_TO_READER_METHOD = {
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
ZkFfiUniffiError => :readTypeZkFfiUniffiError,
|
|
1419
|
+
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CALL_PANIC,
|
|
1423
|
+
:RustCallStatus
|
|
1424
|
+
|
|
1425
|
+
def self.consume_buffer_into_error(error_module, rust_buffer)
|
|
1426
|
+
rust_buffer.consumeWithStream do |stream|
|
|
1427
|
+
reader_method = ERROR_MODULE_TO_READER_METHOD[error_module]
|
|
1428
|
+
return stream.send(reader_method)
|
|
1429
|
+
end
|
|
1430
|
+
end
|
|
1431
|
+
|
|
1432
|
+
class InternalError < StandardError
|
|
1433
|
+
end
|
|
1434
|
+
|
|
1435
|
+
def self.rust_call(fn_name, *args)
|
|
1436
|
+
# Call a rust function
|
|
1437
|
+
rust_call_with_error(nil, fn_name, *args)
|
|
1438
|
+
end
|
|
1439
|
+
|
|
1440
|
+
def self.rust_call_with_error(error_module, fn_name, *args)
|
|
1441
|
+
# Call a rust function and handle errors
|
|
1442
|
+
#
|
|
1443
|
+
# Use this when the rust function returns a Result<>. error_module must be the error_module that corresponds to that Result.
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
# Note: RustCallStatus.new zeroes out the struct, which is exactly what we
|
|
1447
|
+
# want to pass to Rust (code=0, error_buf=RustBuffer(len=0, capacity=0,
|
|
1448
|
+
# data=NULL))
|
|
1449
|
+
status = RustCallStatus.new
|
|
1450
|
+
args << status
|
|
1451
|
+
|
|
1452
|
+
result = UniFFILib.public_send(fn_name, *args)
|
|
1453
|
+
|
|
1454
|
+
case status.code
|
|
1455
|
+
when CALL_SUCCESS
|
|
1456
|
+
result
|
|
1457
|
+
when CALL_ERROR
|
|
1458
|
+
if error_module.nil?
|
|
1459
|
+
status.error_buf.free
|
|
1460
|
+
raise InternalError, "CALL_ERROR with no error_module set"
|
|
1461
|
+
else
|
|
1462
|
+
raise consume_buffer_into_error(error_module, status.error_buf)
|
|
1463
|
+
end
|
|
1464
|
+
when CALL_PANIC
|
|
1465
|
+
# When the rust code sees a panic, it tries to construct a RustBuffer
|
|
1466
|
+
# with the message. But if that code panics, then it just sends back
|
|
1467
|
+
# an empty buffer.
|
|
1468
|
+
if status.error_buf.len > 0
|
|
1469
|
+
raise InternalError, status.error_buf.consumeIntoString()
|
|
1470
|
+
else
|
|
1471
|
+
raise InternalError, "Rust panic"
|
|
1472
|
+
end
|
|
1473
|
+
else
|
|
1474
|
+
raise InternalError, "Unknown call status: #{status.code}"
|
|
1475
|
+
end
|
|
1476
|
+
end
|
|
1477
|
+
|
|
1478
|
+
private_class_method :consume_buffer_into_error
|
|
1479
|
+
|
|
1480
|
+
# This is how we find and load the dynamic library provided by the component.
|
|
1481
|
+
# For now we just look it up by name.
|
|
1482
|
+
module UniFFILib
|
|
1483
|
+
extend FFI::Library
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
ffi_lib File.expand_path(FFI::Platform::LIBPREFIX + 'kibo_kms_rest_ffi.' + FFI::Platform::LIBSUFFIX, __dir__)
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
attach_function :uniffi_kibo_kms_rest_ffi_fn_func_zk_decrypt,
|
|
1490
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1491
|
+
:uint64
|
|
1492
|
+
attach_function :uniffi_kibo_kms_rest_ffi_fn_func_zk_decrypt_blocking,
|
|
1493
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1494
|
+
RustBuffer.by_value
|
|
1495
|
+
attach_function :uniffi_kibo_kms_rest_ffi_fn_func_zk_encrypt,
|
|
1496
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1497
|
+
:uint64
|
|
1498
|
+
attach_function :uniffi_kibo_kms_rest_ffi_fn_func_zk_encrypt_blocking,
|
|
1499
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1500
|
+
RustBuffer.by_value
|
|
1501
|
+
attach_function :ffi_kibo_kms_rest_ffi_rustbuffer_alloc,
|
|
1502
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1503
|
+
RustBuffer.by_value
|
|
1504
|
+
attach_function :ffi_kibo_kms_rest_ffi_rustbuffer_from_bytes,
|
|
1505
|
+
[ForeignBytes, RustCallStatus.by_ref],
|
|
1506
|
+
RustBuffer.by_value
|
|
1507
|
+
attach_function :ffi_kibo_kms_rest_ffi_rustbuffer_free,
|
|
1508
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1509
|
+
:void
|
|
1510
|
+
attach_function :ffi_kibo_kms_rest_ffi_rustbuffer_reserve,
|
|
1511
|
+
[RustBuffer.by_value, :uint64, RustCallStatus.by_ref],
|
|
1512
|
+
RustBuffer.by_value
|
|
1513
|
+
attach_function :uniffi_kibo_kms_rest_ffi_checksum_func_zk_decrypt,
|
|
1514
|
+
[RustCallStatus.by_ref],
|
|
1515
|
+
:uint16
|
|
1516
|
+
attach_function :uniffi_kibo_kms_rest_ffi_checksum_func_zk_decrypt_blocking,
|
|
1517
|
+
[RustCallStatus.by_ref],
|
|
1518
|
+
:uint16
|
|
1519
|
+
attach_function :uniffi_kibo_kms_rest_ffi_checksum_func_zk_encrypt,
|
|
1520
|
+
[RustCallStatus.by_ref],
|
|
1521
|
+
:uint16
|
|
1522
|
+
attach_function :uniffi_kibo_kms_rest_ffi_checksum_func_zk_encrypt_blocking,
|
|
1523
|
+
[RustCallStatus.by_ref],
|
|
1524
|
+
:uint16
|
|
1525
|
+
attach_function :ffi_kibo_kms_rest_ffi_uniffi_contract_version,
|
|
1526
|
+
[RustCallStatus.by_ref],
|
|
1527
|
+
:uint32
|
|
1528
|
+
|
|
1529
|
+
end
|
|
1530
|
+
|
|
1531
|
+
# Public interface members begin here.
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
class FfiAttestationTier
|
|
1538
|
+
SOFTWARE = 1
|
|
1539
|
+
HARDWARE_BACKED = 2
|
|
1540
|
+
CONFIDENTIAL = 3
|
|
1541
|
+
|
|
1542
|
+
end
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
class FfiMinPosture
|
|
1550
|
+
PLATFORM_MANAGED = 1
|
|
1551
|
+
BYOK = 2
|
|
1552
|
+
HYOK = 3
|
|
1553
|
+
|
|
1554
|
+
end
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
class FfiOracleMode
|
|
1562
|
+
BROKERED = 1
|
|
1563
|
+
DIRECT = 2
|
|
1564
|
+
|
|
1565
|
+
end
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
class FfiPosture
|
|
1573
|
+
BYOK = 1
|
|
1574
|
+
HYOK = 2
|
|
1575
|
+
|
|
1576
|
+
end
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
class FfiStrategy
|
|
1584
|
+
LOCAL_ENVELOPE = 1
|
|
1585
|
+
CUSTOMER_KMS_ORACLE = 2
|
|
1586
|
+
|
|
1587
|
+
end
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
class KmsProvider
|
|
1595
|
+
AWS_KMS = 1
|
|
1596
|
+
GCP_KMS = 2
|
|
1597
|
+
AZURE_KV = 3
|
|
1598
|
+
HASHICORP_VAULT = 4
|
|
1599
|
+
|
|
1600
|
+
end
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
# Record type DecryptInput
|
|
1606
|
+
class DecryptInput
|
|
1607
|
+
attr_reader :kms_cred, :provider_config, :envelope, :strategy, :attestation_tier, :encryption_context
|
|
1608
|
+
|
|
1609
|
+
def initialize(kms_cred:, provider_config:, envelope:, strategy:, attestation_tier:, encryption_context:)
|
|
1610
|
+
@kms_cred = kms_cred
|
|
1611
|
+
@provider_config = provider_config
|
|
1612
|
+
@envelope = envelope
|
|
1613
|
+
@strategy = strategy
|
|
1614
|
+
@attestation_tier = attestation_tier
|
|
1615
|
+
@encryption_context = encryption_context
|
|
1616
|
+
end
|
|
1617
|
+
|
|
1618
|
+
def ==(other)
|
|
1619
|
+
if @kms_cred != other.kms_cred
|
|
1620
|
+
return false
|
|
1621
|
+
end
|
|
1622
|
+
if @provider_config != other.provider_config
|
|
1623
|
+
return false
|
|
1624
|
+
end
|
|
1625
|
+
if @envelope != other.envelope
|
|
1626
|
+
return false
|
|
1627
|
+
end
|
|
1628
|
+
if @strategy != other.strategy
|
|
1629
|
+
return false
|
|
1630
|
+
end
|
|
1631
|
+
if @attestation_tier != other.attestation_tier
|
|
1632
|
+
return false
|
|
1633
|
+
end
|
|
1634
|
+
if @encryption_context != other.encryption_context
|
|
1635
|
+
return false
|
|
1636
|
+
end
|
|
1637
|
+
|
|
1638
|
+
true
|
|
1639
|
+
end
|
|
1640
|
+
end
|
|
1641
|
+
|
|
1642
|
+
# Record type DecryptOutput
|
|
1643
|
+
class DecryptOutput
|
|
1644
|
+
attr_reader :plaintext
|
|
1645
|
+
|
|
1646
|
+
def initialize(plaintext:)
|
|
1647
|
+
@plaintext = plaintext
|
|
1648
|
+
end
|
|
1649
|
+
|
|
1650
|
+
def ==(other)
|
|
1651
|
+
if @plaintext != other.plaintext
|
|
1652
|
+
return false
|
|
1653
|
+
end
|
|
1654
|
+
|
|
1655
|
+
true
|
|
1656
|
+
end
|
|
1657
|
+
end
|
|
1658
|
+
|
|
1659
|
+
# Record type EncryptInput
|
|
1660
|
+
class EncryptInput
|
|
1661
|
+
attr_reader :provider, :posture, :strategy, :oracle_mode, :kms_cred, :key_ref, :provider_config, :attestation_tier, :encryption_context, :plaintext, :posture_policy
|
|
1662
|
+
|
|
1663
|
+
def initialize(provider:, posture:, strategy:, oracle_mode:, kms_cred:, key_ref:, provider_config:, attestation_tier:, encryption_context:, plaintext:, posture_policy:)
|
|
1664
|
+
@provider = provider
|
|
1665
|
+
@posture = posture
|
|
1666
|
+
@strategy = strategy
|
|
1667
|
+
@oracle_mode = oracle_mode
|
|
1668
|
+
@kms_cred = kms_cred
|
|
1669
|
+
@key_ref = key_ref
|
|
1670
|
+
@provider_config = provider_config
|
|
1671
|
+
@attestation_tier = attestation_tier
|
|
1672
|
+
@encryption_context = encryption_context
|
|
1673
|
+
@plaintext = plaintext
|
|
1674
|
+
@posture_policy = posture_policy
|
|
1675
|
+
end
|
|
1676
|
+
|
|
1677
|
+
def ==(other)
|
|
1678
|
+
if @provider != other.provider
|
|
1679
|
+
return false
|
|
1680
|
+
end
|
|
1681
|
+
if @posture != other.posture
|
|
1682
|
+
return false
|
|
1683
|
+
end
|
|
1684
|
+
if @strategy != other.strategy
|
|
1685
|
+
return false
|
|
1686
|
+
end
|
|
1687
|
+
if @oracle_mode != other.oracle_mode
|
|
1688
|
+
return false
|
|
1689
|
+
end
|
|
1690
|
+
if @kms_cred != other.kms_cred
|
|
1691
|
+
return false
|
|
1692
|
+
end
|
|
1693
|
+
if @key_ref != other.key_ref
|
|
1694
|
+
return false
|
|
1695
|
+
end
|
|
1696
|
+
if @provider_config != other.provider_config
|
|
1697
|
+
return false
|
|
1698
|
+
end
|
|
1699
|
+
if @attestation_tier != other.attestation_tier
|
|
1700
|
+
return false
|
|
1701
|
+
end
|
|
1702
|
+
if @encryption_context != other.encryption_context
|
|
1703
|
+
return false
|
|
1704
|
+
end
|
|
1705
|
+
if @plaintext != other.plaintext
|
|
1706
|
+
return false
|
|
1707
|
+
end
|
|
1708
|
+
if @posture_policy != other.posture_policy
|
|
1709
|
+
return false
|
|
1710
|
+
end
|
|
1711
|
+
|
|
1712
|
+
true
|
|
1713
|
+
end
|
|
1714
|
+
end
|
|
1715
|
+
|
|
1716
|
+
# Record type EncryptOutput
|
|
1717
|
+
class EncryptOutput
|
|
1718
|
+
attr_reader :envelope
|
|
1719
|
+
|
|
1720
|
+
def initialize(envelope:)
|
|
1721
|
+
@envelope = envelope
|
|
1722
|
+
end
|
|
1723
|
+
|
|
1724
|
+
def ==(other)
|
|
1725
|
+
if @envelope != other.envelope
|
|
1726
|
+
return false
|
|
1727
|
+
end
|
|
1728
|
+
|
|
1729
|
+
true
|
|
1730
|
+
end
|
|
1731
|
+
end
|
|
1732
|
+
|
|
1733
|
+
# Record type FfiAllowedOracleModes
|
|
1734
|
+
class FfiAllowedOracleModes
|
|
1735
|
+
attr_reader :brokered, :direct
|
|
1736
|
+
|
|
1737
|
+
def initialize(brokered:, direct:)
|
|
1738
|
+
@brokered = brokered
|
|
1739
|
+
@direct = direct
|
|
1740
|
+
end
|
|
1741
|
+
|
|
1742
|
+
def ==(other)
|
|
1743
|
+
if @brokered != other.brokered
|
|
1744
|
+
return false
|
|
1745
|
+
end
|
|
1746
|
+
if @direct != other.direct
|
|
1747
|
+
return false
|
|
1748
|
+
end
|
|
1749
|
+
|
|
1750
|
+
true
|
|
1751
|
+
end
|
|
1752
|
+
end
|
|
1753
|
+
|
|
1754
|
+
# Record type FfiCredential
|
|
1755
|
+
class FfiCredential
|
|
1756
|
+
attr_reader :secret, :expires_at_unix_secs
|
|
1757
|
+
|
|
1758
|
+
def initialize(secret:, expires_at_unix_secs:)
|
|
1759
|
+
@secret = secret
|
|
1760
|
+
@expires_at_unix_secs = expires_at_unix_secs
|
|
1761
|
+
end
|
|
1762
|
+
|
|
1763
|
+
def ==(other)
|
|
1764
|
+
if @secret != other.secret
|
|
1765
|
+
return false
|
|
1766
|
+
end
|
|
1767
|
+
if @expires_at_unix_secs != other.expires_at_unix_secs
|
|
1768
|
+
return false
|
|
1769
|
+
end
|
|
1770
|
+
|
|
1771
|
+
true
|
|
1772
|
+
end
|
|
1773
|
+
end
|
|
1774
|
+
|
|
1775
|
+
# Record type FfiKeyRef
|
|
1776
|
+
class FfiKeyRef
|
|
1777
|
+
attr_reader :version, :external_ref
|
|
1778
|
+
|
|
1779
|
+
def initialize(version:, external_ref:)
|
|
1780
|
+
@version = version
|
|
1781
|
+
@external_ref = external_ref
|
|
1782
|
+
end
|
|
1783
|
+
|
|
1784
|
+
def ==(other)
|
|
1785
|
+
if @version != other.version
|
|
1786
|
+
return false
|
|
1787
|
+
end
|
|
1788
|
+
if @external_ref != other.external_ref
|
|
1789
|
+
return false
|
|
1790
|
+
end
|
|
1791
|
+
|
|
1792
|
+
true
|
|
1793
|
+
end
|
|
1794
|
+
end
|
|
1795
|
+
|
|
1796
|
+
# Record type FfiKvPair
|
|
1797
|
+
class FfiKvPair
|
|
1798
|
+
attr_reader :key, :value
|
|
1799
|
+
|
|
1800
|
+
def initialize(key:, value:)
|
|
1801
|
+
@key = key
|
|
1802
|
+
@value = value
|
|
1803
|
+
end
|
|
1804
|
+
|
|
1805
|
+
def ==(other)
|
|
1806
|
+
if @key != other.key
|
|
1807
|
+
return false
|
|
1808
|
+
end
|
|
1809
|
+
if @value != other.value
|
|
1810
|
+
return false
|
|
1811
|
+
end
|
|
1812
|
+
|
|
1813
|
+
true
|
|
1814
|
+
end
|
|
1815
|
+
end
|
|
1816
|
+
|
|
1817
|
+
# Record type FfiPosturePolicy
|
|
1818
|
+
class FfiPosturePolicy
|
|
1819
|
+
attr_reader :min_custody_posture, :allowed_oracle_modes
|
|
1820
|
+
|
|
1821
|
+
def initialize(min_custody_posture:, allowed_oracle_modes:)
|
|
1822
|
+
@min_custody_posture = min_custody_posture
|
|
1823
|
+
@allowed_oracle_modes = allowed_oracle_modes
|
|
1824
|
+
end
|
|
1825
|
+
|
|
1826
|
+
def ==(other)
|
|
1827
|
+
if @min_custody_posture != other.min_custody_posture
|
|
1828
|
+
return false
|
|
1829
|
+
end
|
|
1830
|
+
if @allowed_oracle_modes != other.allowed_oracle_modes
|
|
1831
|
+
return false
|
|
1832
|
+
end
|
|
1833
|
+
|
|
1834
|
+
true
|
|
1835
|
+
end
|
|
1836
|
+
end
|
|
1837
|
+
|
|
1838
|
+
# Record type FfiProviderConfig
|
|
1839
|
+
class FfiProviderConfig
|
|
1840
|
+
attr_reader :aws_region, :vault_address
|
|
1841
|
+
|
|
1842
|
+
def initialize(aws_region:, vault_address:)
|
|
1843
|
+
@aws_region = aws_region
|
|
1844
|
+
@vault_address = vault_address
|
|
1845
|
+
end
|
|
1846
|
+
|
|
1847
|
+
def ==(other)
|
|
1848
|
+
if @aws_region != other.aws_region
|
|
1849
|
+
return false
|
|
1850
|
+
end
|
|
1851
|
+
if @vault_address != other.vault_address
|
|
1852
|
+
return false
|
|
1853
|
+
end
|
|
1854
|
+
|
|
1855
|
+
true
|
|
1856
|
+
end
|
|
1857
|
+
end
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
def self.zk_decrypt(input)
|
|
1864
|
+
input = input
|
|
1865
|
+
RustBuffer.check_lower_TypeDecryptInput(input)
|
|
1866
|
+
|
|
1867
|
+
result = KiboKmsRestFfi.rust_call_with_error(ZkFfiUniffiError,:uniffi_kibo_kms_rest_ffi_fn_func_zk_decrypt,RustBuffer.alloc_from_TypeDecryptInput(input))
|
|
1868
|
+
return result.consumeIntoTypeDecryptOutput
|
|
1869
|
+
end
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
|
|
1875
|
+
def self.zk_decrypt_blocking(input)
|
|
1876
|
+
input = input
|
|
1877
|
+
RustBuffer.check_lower_TypeDecryptInput(input)
|
|
1878
|
+
|
|
1879
|
+
result = KiboKmsRestFfi.rust_call_with_error(ZkFfiUniffiError,:uniffi_kibo_kms_rest_ffi_fn_func_zk_decrypt_blocking,RustBuffer.alloc_from_TypeDecryptInput(input))
|
|
1880
|
+
return result.consumeIntoTypeDecryptOutput
|
|
1881
|
+
end
|
|
1882
|
+
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
def self.zk_encrypt(input)
|
|
1888
|
+
input = input
|
|
1889
|
+
RustBuffer.check_lower_TypeEncryptInput(input)
|
|
1890
|
+
|
|
1891
|
+
result = KiboKmsRestFfi.rust_call_with_error(ZkFfiUniffiError,:uniffi_kibo_kms_rest_ffi_fn_func_zk_encrypt,RustBuffer.alloc_from_TypeEncryptInput(input))
|
|
1892
|
+
return result.consumeIntoTypeEncryptOutput
|
|
1893
|
+
end
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
def self.zk_encrypt_blocking(input)
|
|
1900
|
+
input = input
|
|
1901
|
+
RustBuffer.check_lower_TypeEncryptInput(input)
|
|
1902
|
+
|
|
1903
|
+
result = KiboKmsRestFfi.rust_call_with_error(ZkFfiUniffiError,:uniffi_kibo_kms_rest_ffi_fn_func_zk_encrypt_blocking,RustBuffer.alloc_from_TypeEncryptInput(input))
|
|
1904
|
+
return result.consumeIntoTypeEncryptOutput
|
|
1905
|
+
end
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
end
|
|
1912
|
+
|