botan 0.1.0
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +219 -0
- data/lib/botan.rb +25 -0
- data/lib/botan/bcrypt.rb +49 -0
- data/lib/botan/cipher.rb +214 -0
- data/lib/botan/defaults.rb +21 -0
- data/lib/botan/digest.rb +145 -0
- data/lib/botan/error.rb +8 -0
- data/lib/botan/ffi/libbotan.rb +573 -0
- data/lib/botan/kdf.rb +87 -0
- data/lib/botan/mac.rb +90 -0
- data/lib/botan/pk/mceies.rb +62 -0
- data/lib/botan/pk/op/decrypt.rb +59 -0
- data/lib/botan/pk/op/encrypt.rb +62 -0
- data/lib/botan/pk/op/keyagreement.rb +59 -0
- data/lib/botan/pk/op/sign.rb +68 -0
- data/lib/botan/pk/op/verify.rb +71 -0
- data/lib/botan/pk/privatekey.rb +288 -0
- data/lib/botan/pk/publickey.rb +161 -0
- data/lib/botan/rng.rb +62 -0
- data/lib/botan/utils.rb +104 -0
- data/lib/botan/version.rb +8 -0
- data/lib/botan/x509/certificate.rb +139 -0
- data/lib/botan/x509/constraints.rb +20 -0
- metadata +197 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# (c) 2017 Ribose Inc.
|
4
|
+
|
5
|
+
module Botan
|
6
|
+
DEFAULT_KDF_ALGO = 'KDF2(SHA-256)'
|
7
|
+
DEFAULT_KDF_SALT_LENGTH = 16
|
8
|
+
DEFAULT_KDF_ITERATIONS = 100_000
|
9
|
+
DEFAULT_PBKDF_ALGO = 'PBKDF2(SHA-256)'
|
10
|
+
|
11
|
+
DEFAULT_EME = 'EME1(SHA-256)'
|
12
|
+
DEFAULT_EMSA = { 'RSA' => 'EMSA4(SHA-256)',
|
13
|
+
'DSA' => 'EMSA1(SHA-256)',
|
14
|
+
'ECDSA' => 'EMSA1(SHA-256)',
|
15
|
+
'ECKCDSA' => 'EMSA1(SHA-256)',
|
16
|
+
'ECGDSA' => 'EMSA1(SHA-256)',
|
17
|
+
'GOST-34.10' => 'EMSA1(SHA-256)' }.freeze
|
18
|
+
|
19
|
+
DEFAULT_AEAD = 'AES-256/OCB'
|
20
|
+
end # module
|
21
|
+
|
data/lib/botan/digest.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# (c) 2017 Ribose Inc.
|
4
|
+
|
5
|
+
require 'digest'
|
6
|
+
require 'ffi'
|
7
|
+
|
8
|
+
require 'botan/error'
|
9
|
+
require 'botan/ffi/libbotan'
|
10
|
+
require 'botan/utils'
|
11
|
+
|
12
|
+
module Botan
|
13
|
+
# Class for calculating message digests using Botan's hash functions.
|
14
|
+
#
|
15
|
+
# This should behave nearly identically to {::Digest} and {OpenSSL::Digest}.
|
16
|
+
# Some differences are:
|
17
|
+
#
|
18
|
+
# * Algorithm names. Example: OpenSSL expects `RIPEMD160`, Botan
|
19
|
+
# uses `RIPEMD-160`.
|
20
|
+
# * OIDs. Not currently supported.
|
21
|
+
#
|
22
|
+
# == Examples
|
23
|
+
# === examples/digest.rb
|
24
|
+
# {include:file:examples/digest.rb}
|
25
|
+
class Digest < ::Digest::Class
|
26
|
+
attr_reader :name
|
27
|
+
# @api private
|
28
|
+
attr_reader :ptr
|
29
|
+
|
30
|
+
def initialize(algo)
|
31
|
+
@name = algo
|
32
|
+
flags = 0
|
33
|
+
ptr = FFI::MemoryPointer.new(:pointer)
|
34
|
+
Botan.call_ffi(:botan_hash_init, ptr, algo, flags)
|
35
|
+
ptr = ptr.read_pointer
|
36
|
+
raise Botan::Error, 'botan_hash_init returned NULL' if ptr.null?
|
37
|
+
@ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy))
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize_copy(source)
|
41
|
+
@name = source.name
|
42
|
+
ptr = FFI::MemoryPointer.new(:pointer)
|
43
|
+
Botan.call_ffi(:botan_hash_copy_state, ptr, source.ptr)
|
44
|
+
ptr = ptr.read_pointer
|
45
|
+
@ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy))
|
46
|
+
end
|
47
|
+
|
48
|
+
# @api private
|
49
|
+
def self.destroy(ptr)
|
50
|
+
LibBotan.botan_hash_destroy(ptr)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.digest(name, data)
|
54
|
+
super(data, name)
|
55
|
+
end
|
56
|
+
|
57
|
+
{
|
58
|
+
SHA1: 'SHA-1',
|
59
|
+
SHA224: 'SHA-224',
|
60
|
+
SHA256: 'SHA-256',
|
61
|
+
SHA384: 'SHA-384',
|
62
|
+
SHA512: 'SHA-512',
|
63
|
+
SHA512_256: 'SHA-512-256',
|
64
|
+
RMD160: 'RIPEMD-160',
|
65
|
+
WHIRLPOOL: 'Whirlpool',
|
66
|
+
MD5: 'MD5',
|
67
|
+
MD4: 'MD4',
|
68
|
+
GOST3411: 'GOST-34.11',
|
69
|
+
ADLER32: 'Adler32',
|
70
|
+
CRC24: 'CRC24',
|
71
|
+
CRC32: 'CRC32',
|
72
|
+
SM3: 'SM3'
|
73
|
+
}.each do |class_name, algo|
|
74
|
+
klass = Class.new(self) do
|
75
|
+
define_method(:initialize, lambda do |data = nil|
|
76
|
+
super(algo)
|
77
|
+
update(data) if data
|
78
|
+
end)
|
79
|
+
end
|
80
|
+
singleton = (class << klass; self; end)
|
81
|
+
singleton.class_eval do
|
82
|
+
define_method(:digest) { |data| new.digest(data) }
|
83
|
+
define_method(:hexdigest) { |data| new.hexdigest(data) }
|
84
|
+
end
|
85
|
+
const_set(class_name, klass)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Retrieve the block length for the hash.
|
89
|
+
#
|
90
|
+
# @return [Integer]
|
91
|
+
def block_length
|
92
|
+
length_ptr = FFI::MemoryPointer.new(:size_t)
|
93
|
+
Botan.call_ffi(:botan_hash_block_size, @ptr, length_ptr)
|
94
|
+
length_ptr.read(:size_t)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Retrieve the length of the digest.
|
98
|
+
#
|
99
|
+
# @return [Integer]
|
100
|
+
def digest_length
|
101
|
+
length_ptr = FFI::MemoryPointer.new(:size_t)
|
102
|
+
Botan.call_ffi(:botan_hash_output_length, @ptr, length_ptr)
|
103
|
+
length_ptr.read(:size_t)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Adds input to the digest computation.
|
107
|
+
#
|
108
|
+
# @param [String] data
|
109
|
+
# @return [self]
|
110
|
+
def update(data)
|
111
|
+
Botan.call_ffi(:botan_hash_update, @ptr, data, data.bytesize)
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
# Resets the instace back to a clean state, as if no data has
|
116
|
+
# been supplied.
|
117
|
+
#
|
118
|
+
# @return [self]
|
119
|
+
def reset
|
120
|
+
Botan.call_ffi(:botan_hash_clear, @ptr)
|
121
|
+
self
|
122
|
+
end
|
123
|
+
|
124
|
+
alias << update
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def finish
|
129
|
+
out_buf = FFI::MemoryPointer.new(:uint8, digest_length)
|
130
|
+
Botan.call_ffi(:botan_hash_final, @ptr, out_buf)
|
131
|
+
out_buf.read_bytes(out_buf.size)
|
132
|
+
end
|
133
|
+
end # class
|
134
|
+
|
135
|
+
# Returns a Digest subclass by name.
|
136
|
+
#
|
137
|
+
# @param algo [String] the hash algorithm name
|
138
|
+
# @return [Class]
|
139
|
+
def Digest(algo)
|
140
|
+
Botan::Digest.const_get(algo)
|
141
|
+
end
|
142
|
+
|
143
|
+
module_function :Digest
|
144
|
+
end # module
|
145
|
+
|
data/lib/botan/error.rb
ADDED
@@ -0,0 +1,573 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# (c) 2017 Ribose Inc.
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
module LibBotan
|
9
|
+
extend FFI::Library
|
10
|
+
ffi_lib 'libbotan-2'
|
11
|
+
|
12
|
+
# Versioning
|
13
|
+
attach_function :botan_ffi_api_version,
|
14
|
+
[],
|
15
|
+
:uint32
|
16
|
+
attach_function :botan_ffi_supports_api,
|
17
|
+
[:uint32],
|
18
|
+
:int
|
19
|
+
attach_function :botan_version_string,
|
20
|
+
[],
|
21
|
+
:string
|
22
|
+
attach_function :botan_version_major,
|
23
|
+
[],
|
24
|
+
:uint32
|
25
|
+
attach_function :botan_version_minor,
|
26
|
+
[],
|
27
|
+
:uint32
|
28
|
+
attach_function :botan_version_patch,
|
29
|
+
[],
|
30
|
+
:uint32
|
31
|
+
attach_function :botan_version_datestamp,
|
32
|
+
[],
|
33
|
+
:uint32
|
34
|
+
|
35
|
+
if botan_ffi_supports_api(2017_03_27) != 0
|
36
|
+
raise 'The Botan library does not support the FFI API expected by this' \
|
37
|
+
' version of the Ruby module'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Utility Functions
|
41
|
+
attach_function :botan_same_mem,
|
42
|
+
%i[pointer pointer size_t],
|
43
|
+
:int
|
44
|
+
attach_function :botan_hex_encode,
|
45
|
+
%i[pointer size_t pointer uint32],
|
46
|
+
:int
|
47
|
+
|
48
|
+
# Random Number Generators
|
49
|
+
attach_function :botan_rng_init,
|
50
|
+
%i[pointer string],
|
51
|
+
:int
|
52
|
+
attach_function :botan_rng_get,
|
53
|
+
%i[pointer pointer size_t],
|
54
|
+
:int
|
55
|
+
attach_function :botan_rng_reseed,
|
56
|
+
%i[pointer size_t],
|
57
|
+
:int
|
58
|
+
attach_function :botan_rng_destroy,
|
59
|
+
[:pointer],
|
60
|
+
:int
|
61
|
+
|
62
|
+
# Hash Functions
|
63
|
+
attach_function :botan_hash_init,
|
64
|
+
%i[pointer string uint32],
|
65
|
+
:int
|
66
|
+
attach_function :botan_hash_copy_state,
|
67
|
+
%i[pointer pointer],
|
68
|
+
:int
|
69
|
+
attach_function :botan_hash_output_length,
|
70
|
+
%i[pointer pointer],
|
71
|
+
:int
|
72
|
+
attach_function :botan_hash_block_size,
|
73
|
+
%i[pointer pointer],
|
74
|
+
:int
|
75
|
+
attach_function :botan_hash_update,
|
76
|
+
%i[pointer pointer size_t],
|
77
|
+
:int
|
78
|
+
attach_function :botan_hash_final,
|
79
|
+
%i[pointer pointer],
|
80
|
+
:int
|
81
|
+
attach_function :botan_hash_clear,
|
82
|
+
[:pointer],
|
83
|
+
:int
|
84
|
+
attach_function :botan_hash_destroy,
|
85
|
+
[:pointer],
|
86
|
+
:int
|
87
|
+
# Missing implementation
|
88
|
+
# attach_function :botan_hash_name,
|
89
|
+
# [:pointer, :string, :size_t],
|
90
|
+
# :int
|
91
|
+
|
92
|
+
# Message Authentication Codes
|
93
|
+
attach_function :botan_mac_init,
|
94
|
+
%i[pointer string uint32],
|
95
|
+
:int
|
96
|
+
attach_function :botan_mac_output_length,
|
97
|
+
%i[pointer pointer],
|
98
|
+
:int
|
99
|
+
attach_function :botan_mac_set_key,
|
100
|
+
%i[pointer pointer size_t],
|
101
|
+
:int
|
102
|
+
attach_function :botan_mac_update,
|
103
|
+
%i[pointer pointer size_t],
|
104
|
+
:int
|
105
|
+
attach_function :botan_mac_final,
|
106
|
+
%i[pointer pointer],
|
107
|
+
:int
|
108
|
+
attach_function :botan_mac_clear,
|
109
|
+
[:pointer],
|
110
|
+
:int
|
111
|
+
attach_function :botan_mac_destroy,
|
112
|
+
[:pointer],
|
113
|
+
:int
|
114
|
+
|
115
|
+
# Ciphers
|
116
|
+
attach_function :botan_cipher_init,
|
117
|
+
%i[pointer string uint32],
|
118
|
+
:int
|
119
|
+
attach_function :botan_cipher_valid_nonce_length,
|
120
|
+
%i[pointer size_t],
|
121
|
+
:int
|
122
|
+
attach_function :botan_cipher_get_tag_length,
|
123
|
+
%i[pointer pointer],
|
124
|
+
:int
|
125
|
+
attach_function :botan_cipher_get_default_nonce_length,
|
126
|
+
%i[pointer pointer],
|
127
|
+
:int
|
128
|
+
attach_function :botan_cipher_get_update_granularity,
|
129
|
+
%i[pointer pointer],
|
130
|
+
:int
|
131
|
+
attach_function :botan_cipher_query_keylen,
|
132
|
+
%i[pointer pointer pointer],
|
133
|
+
:int
|
134
|
+
attach_function :botan_cipher_set_key,
|
135
|
+
%i[pointer pointer size_t],
|
136
|
+
:int
|
137
|
+
attach_function :botan_cipher_set_associated_data,
|
138
|
+
%i[pointer pointer size_t],
|
139
|
+
:int
|
140
|
+
attach_function :botan_cipher_start,
|
141
|
+
%i[pointer pointer size_t],
|
142
|
+
:int
|
143
|
+
attach_function :botan_cipher_update,
|
144
|
+
%i[pointer uint32 pointer size_t
|
145
|
+
pointer pointer size_t pointer],
|
146
|
+
:int
|
147
|
+
attach_function :botan_cipher_clear,
|
148
|
+
[:pointer],
|
149
|
+
:int
|
150
|
+
attach_function :botan_cipher_destroy,
|
151
|
+
[:pointer],
|
152
|
+
:int
|
153
|
+
|
154
|
+
# PBKDF
|
155
|
+
attach_function :botan_pbkdf,
|
156
|
+
%i[string pointer size_t string pointer size_t size_t],
|
157
|
+
:int
|
158
|
+
attach_function :botan_pbkdf_timed,
|
159
|
+
%i[string pointer size_t string
|
160
|
+
pointer size_t size_t pointer],
|
161
|
+
:int
|
162
|
+
|
163
|
+
# KDF
|
164
|
+
attach_function :botan_kdf,
|
165
|
+
%i[string pointer size_t pointer size_t
|
166
|
+
pointer size_t pointer size_t],
|
167
|
+
:int
|
168
|
+
|
169
|
+
# Password Hashing
|
170
|
+
attach_function :botan_bcrypt_generate,
|
171
|
+
%i[pointer pointer string pointer size_t uint32],
|
172
|
+
:int
|
173
|
+
attach_function :botan_bcrypt_is_valid,
|
174
|
+
%i[string pointer],
|
175
|
+
:int
|
176
|
+
|
177
|
+
# Block Ciphers
|
178
|
+
attach_function :botan_block_cipher_init,
|
179
|
+
%i[pointer string],
|
180
|
+
:int
|
181
|
+
attach_function :botan_block_cipher_destroy,
|
182
|
+
[:pointer],
|
183
|
+
:int
|
184
|
+
attach_function :botan_block_cipher_clear,
|
185
|
+
[:pointer],
|
186
|
+
:int
|
187
|
+
attach_function :botan_block_cipher_set_key,
|
188
|
+
%i[pointer pointer size_t],
|
189
|
+
:int
|
190
|
+
attach_function :botan_block_cipher_block_size,
|
191
|
+
[:pointer],
|
192
|
+
:int
|
193
|
+
attach_function :botan_block_cipher_encrypt_blocks,
|
194
|
+
%i[pointer pointer pointer size_t],
|
195
|
+
:int
|
196
|
+
attach_function :botan_block_cipher_decrypt_blocks,
|
197
|
+
%i[pointer pointer pointer size_t],
|
198
|
+
:int
|
199
|
+
|
200
|
+
# Multiple Precision Integers
|
201
|
+
attach_function :botan_mp_init,
|
202
|
+
[:pointer],
|
203
|
+
:int
|
204
|
+
attach_function :botan_mp_destroy,
|
205
|
+
[:pointer],
|
206
|
+
:int
|
207
|
+
attach_function :botan_mp_to_hex,
|
208
|
+
%i[pointer pointer],
|
209
|
+
:int
|
210
|
+
attach_function :botan_mp_to_str,
|
211
|
+
%i[pointer uint8 pointer pointer],
|
212
|
+
:int
|
213
|
+
attach_function :botan_mp_clear,
|
214
|
+
[:pointer],
|
215
|
+
:int
|
216
|
+
attach_function :botan_mp_set_from_int,
|
217
|
+
%i[pointer int],
|
218
|
+
:int
|
219
|
+
attach_function :botan_mp_set_from_mp,
|
220
|
+
%i[pointer pointer],
|
221
|
+
:int
|
222
|
+
attach_function :botan_mp_set_from_str,
|
223
|
+
%i[pointer string],
|
224
|
+
:int
|
225
|
+
attach_function :botan_mp_set_from_radix_str,
|
226
|
+
%i[pointer string size_t],
|
227
|
+
:int
|
228
|
+
attach_function :botan_mp_num_bits,
|
229
|
+
%i[pointer pointer],
|
230
|
+
:int
|
231
|
+
attach_function :botan_mp_num_bytes,
|
232
|
+
%i[pointer pointer],
|
233
|
+
:int
|
234
|
+
attach_function :botan_mp_to_bin,
|
235
|
+
%i[pointer pointer],
|
236
|
+
:int
|
237
|
+
attach_function :botan_mp_from_bin,
|
238
|
+
%i[pointer pointer size_t],
|
239
|
+
:int
|
240
|
+
attach_function :botan_mp_to_uint32,
|
241
|
+
%i[pointer pointer],
|
242
|
+
:int
|
243
|
+
attach_function :botan_mp_is_positive,
|
244
|
+
[:pointer],
|
245
|
+
:int
|
246
|
+
attach_function :botan_mp_is_negative,
|
247
|
+
[:pointer],
|
248
|
+
:int
|
249
|
+
attach_function :botan_mp_flip_sign,
|
250
|
+
[:pointer],
|
251
|
+
:int
|
252
|
+
attach_function :botan_mp_is_zero,
|
253
|
+
[:pointer],
|
254
|
+
:int
|
255
|
+
attach_function :botan_mp_is_odd,
|
256
|
+
[:pointer],
|
257
|
+
:int
|
258
|
+
attach_function :botan_mp_is_even,
|
259
|
+
[:pointer],
|
260
|
+
:int
|
261
|
+
attach_function :botan_mp_add,
|
262
|
+
%i[pointer pointer pointer],
|
263
|
+
:int
|
264
|
+
attach_function :botan_mp_sub,
|
265
|
+
%i[pointer pointer pointer],
|
266
|
+
:int
|
267
|
+
attach_function :botan_mp_mul,
|
268
|
+
%i[pointer pointer pointer],
|
269
|
+
:int
|
270
|
+
attach_function :botan_mp_div,
|
271
|
+
%i[pointer pointer pointer pointer],
|
272
|
+
:int
|
273
|
+
attach_function :botan_mp_mod_mul,
|
274
|
+
%i[pointer pointer pointer pointer],
|
275
|
+
:int
|
276
|
+
attach_function :botan_mp_equal,
|
277
|
+
%i[pointer pointer],
|
278
|
+
:int
|
279
|
+
attach_function :botan_mp_cmp,
|
280
|
+
%i[pointer pointer pointer],
|
281
|
+
:int
|
282
|
+
attach_function :botan_mp_swap,
|
283
|
+
%i[pointer pointer],
|
284
|
+
:int
|
285
|
+
attach_function :botan_mp_powmod,
|
286
|
+
%i[pointer pointer pointer pointer],
|
287
|
+
:int
|
288
|
+
attach_function :botan_mp_lshift,
|
289
|
+
%i[pointer pointer size_t],
|
290
|
+
:int
|
291
|
+
attach_function :botan_mp_rshift,
|
292
|
+
%i[pointer pointer size_t],
|
293
|
+
:int
|
294
|
+
attach_function :botan_mp_mod_inverse,
|
295
|
+
%i[pointer pointer pointer],
|
296
|
+
:int
|
297
|
+
attach_function :botan_mp_rand_bits,
|
298
|
+
%i[pointer pointer size_t],
|
299
|
+
:int
|
300
|
+
attach_function :botan_mp_rand_range,
|
301
|
+
%i[pointer pointer pointer pointer],
|
302
|
+
:int
|
303
|
+
attach_function :botan_mp_gcd,
|
304
|
+
%i[pointer pointer pointer],
|
305
|
+
:int
|
306
|
+
attach_function :botan_mp_is_prime,
|
307
|
+
%i[pointer pointer size_t],
|
308
|
+
:int
|
309
|
+
attach_function :botan_mp_get_bit,
|
310
|
+
%i[pointer size_t],
|
311
|
+
:int
|
312
|
+
attach_function :botan_mp_set_bit,
|
313
|
+
%i[pointer size_t],
|
314
|
+
:int
|
315
|
+
attach_function :botan_mp_clear_bit,
|
316
|
+
%i[pointer size_t],
|
317
|
+
:int
|
318
|
+
|
319
|
+
# Public Key Creation, Import and Export
|
320
|
+
attach_function :botan_privkey_create,
|
321
|
+
%i[pointer string string pointer],
|
322
|
+
:int
|
323
|
+
attach_function :botan_privkey_check_key,
|
324
|
+
%i[pointer pointer uint32],
|
325
|
+
:int
|
326
|
+
attach_function :botan_privkey_create_rsa,
|
327
|
+
%i[pointer pointer size_t],
|
328
|
+
:int
|
329
|
+
attach_function :botan_privkey_create_ecdsa,
|
330
|
+
%i[pointer pointer string],
|
331
|
+
:int
|
332
|
+
attach_function :botan_privkey_create_ecdh,
|
333
|
+
%i[pointer pointer string],
|
334
|
+
:int
|
335
|
+
attach_function :botan_privkey_create_mceliece,
|
336
|
+
%i[pointer pointer size_t size_t],
|
337
|
+
:int
|
338
|
+
attach_function :botan_privkey_load,
|
339
|
+
%i[pointer pointer pointer size_t string],
|
340
|
+
:int
|
341
|
+
attach_function :botan_privkey_destroy,
|
342
|
+
[:pointer],
|
343
|
+
:int
|
344
|
+
attach_function :botan_privkey_export,
|
345
|
+
%i[pointer pointer pointer uint32],
|
346
|
+
:int
|
347
|
+
# Note: botan_privkey_export_encrypted is deprecated
|
348
|
+
attach_function :botan_privkey_export_encrypted,
|
349
|
+
%i[pointer pointer pointer pointer string string uint32],
|
350
|
+
:int
|
351
|
+
attach_function :botan_privkey_export_encrypted_pbkdf_msec,
|
352
|
+
%i[pointer pointer pointer pointer string
|
353
|
+
uint32 pointer string string uint32],
|
354
|
+
:int
|
355
|
+
attach_function :botan_privkey_export_encrypted_pbkdf_iter,
|
356
|
+
%i[pointer pointer pointer pointer
|
357
|
+
string size_t string string uint32],
|
358
|
+
:int
|
359
|
+
attach_function :botan_pubkey_load,
|
360
|
+
%i[pointer pointer size_t],
|
361
|
+
:int
|
362
|
+
attach_function :botan_privkey_export_pubkey,
|
363
|
+
%i[pointer pointer],
|
364
|
+
:int
|
365
|
+
attach_function :botan_pubkey_export,
|
366
|
+
%i[pointer pointer pointer uint32],
|
367
|
+
:int
|
368
|
+
attach_function :botan_pubkey_algo_name,
|
369
|
+
%i[pointer pointer pointer],
|
370
|
+
:int
|
371
|
+
attach_function :botan_pubkey_check_key,
|
372
|
+
%i[pointer pointer uint32],
|
373
|
+
:int
|
374
|
+
attach_function :botan_pubkey_estimated_strength,
|
375
|
+
%i[pointer pointer],
|
376
|
+
:int
|
377
|
+
attach_function :botan_pubkey_fingerprint,
|
378
|
+
%i[pointer string pointer pointer],
|
379
|
+
:int
|
380
|
+
attach_function :botan_pubkey_destroy,
|
381
|
+
[:pointer],
|
382
|
+
:int
|
383
|
+
attach_function :botan_pubkey_get_field,
|
384
|
+
%i[pointer pointer string],
|
385
|
+
:int
|
386
|
+
attach_function :botan_privkey_get_field,
|
387
|
+
%i[pointer pointer string],
|
388
|
+
:int
|
389
|
+
|
390
|
+
# RSA specific functions
|
391
|
+
attach_function :botan_privkey_load_rsa,
|
392
|
+
%i[pointer pointer pointer pointer],
|
393
|
+
:int
|
394
|
+
attach_function :botan_privkey_rsa_get_p,
|
395
|
+
%i[pointer pointer],
|
396
|
+
:int
|
397
|
+
attach_function :botan_privkey_rsa_get_q,
|
398
|
+
%i[pointer pointer],
|
399
|
+
:int
|
400
|
+
attach_function :botan_privkey_rsa_get_d,
|
401
|
+
%i[pointer pointer],
|
402
|
+
:int
|
403
|
+
attach_function :botan_privkey_rsa_get_n,
|
404
|
+
%i[pointer pointer],
|
405
|
+
:int
|
406
|
+
attach_function :botan_privkey_rsa_get_e,
|
407
|
+
%i[pointer pointer],
|
408
|
+
:int
|
409
|
+
attach_function :botan_pubkey_load_rsa,
|
410
|
+
%i[pointer pointer pointer],
|
411
|
+
:int
|
412
|
+
attach_function :botan_pubkey_rsa_get_e,
|
413
|
+
%i[pointer pointer],
|
414
|
+
:int
|
415
|
+
attach_function :botan_pubkey_rsa_get_n,
|
416
|
+
%i[pointer pointer],
|
417
|
+
:int
|
418
|
+
|
419
|
+
# DSA specific functions
|
420
|
+
attach_function :botan_privkey_load_dsa,
|
421
|
+
%i[pointer pointer pointer pointer pointer],
|
422
|
+
:int
|
423
|
+
attach_function :botan_pubkey_load_dsa,
|
424
|
+
%i[pointer pointer pointer pointer pointer],
|
425
|
+
:int
|
426
|
+
attach_function :botan_privkey_dsa_get_x,
|
427
|
+
%i[pointer pointer],
|
428
|
+
:int
|
429
|
+
attach_function :botan_pubkey_dsa_get_p,
|
430
|
+
%i[pointer pointer],
|
431
|
+
:int
|
432
|
+
attach_function :botan_pubkey_dsa_get_q,
|
433
|
+
%i[pointer pointer],
|
434
|
+
:int
|
435
|
+
attach_function :botan_pubkey_dsa_get_g,
|
436
|
+
%i[pointer pointer],
|
437
|
+
:int
|
438
|
+
attach_function :botan_pubkey_dsa_get_y,
|
439
|
+
%i[pointer pointer],
|
440
|
+
:int
|
441
|
+
|
442
|
+
# ElGamal specific functions
|
443
|
+
attach_function :botan_privkey_load_elgamal,
|
444
|
+
%i[pointer pointer pointer pointer],
|
445
|
+
:int
|
446
|
+
attach_function :botan_pubkey_load_elgamal,
|
447
|
+
%i[pointer pointer pointer pointer],
|
448
|
+
:int
|
449
|
+
|
450
|
+
# Public Key Encryption/Decryption
|
451
|
+
attach_function :botan_pk_op_encrypt_create,
|
452
|
+
%i[pointer pointer pointer uint32],
|
453
|
+
:int
|
454
|
+
attach_function :botan_pk_op_encrypt_destroy,
|
455
|
+
[:pointer],
|
456
|
+
:int
|
457
|
+
attach_function :botan_pk_op_encrypt,
|
458
|
+
%i[pointer pointer pointer pointer pointer size_t],
|
459
|
+
:int
|
460
|
+
attach_function :botan_pk_op_decrypt_create,
|
461
|
+
%i[pointer pointer pointer uint32],
|
462
|
+
:int
|
463
|
+
attach_function :botan_pk_op_decrypt_destroy,
|
464
|
+
[:pointer],
|
465
|
+
:int
|
466
|
+
attach_function :botan_pk_op_decrypt,
|
467
|
+
%i[pointer pointer pointer pointer size_t],
|
468
|
+
:int
|
469
|
+
|
470
|
+
# Signatures
|
471
|
+
attach_function :botan_pk_op_sign_create,
|
472
|
+
%i[pointer pointer pointer uint32],
|
473
|
+
:int
|
474
|
+
attach_function :botan_pk_op_sign_destroy,
|
475
|
+
[:pointer],
|
476
|
+
:int
|
477
|
+
attach_function :botan_pk_op_sign_update,
|
478
|
+
%i[pointer pointer size_t],
|
479
|
+
:int
|
480
|
+
attach_function :botan_pk_op_sign_finish,
|
481
|
+
%i[pointer pointer pointer pointer],
|
482
|
+
:int
|
483
|
+
attach_function :botan_pk_op_verify_create,
|
484
|
+
%i[pointer pointer pointer uint32],
|
485
|
+
:int
|
486
|
+
attach_function :botan_pk_op_verify_destroy,
|
487
|
+
[:pointer],
|
488
|
+
:int
|
489
|
+
attach_function :botan_pk_op_verify_update,
|
490
|
+
%i[pointer pointer size_t],
|
491
|
+
:int
|
492
|
+
attach_function :botan_pk_op_verify_finish,
|
493
|
+
%i[pointer pointer size_t],
|
494
|
+
:int
|
495
|
+
|
496
|
+
# Key Agreement
|
497
|
+
attach_function :botan_pk_op_key_agreement_create,
|
498
|
+
%i[pointer pointer string uint32],
|
499
|
+
:int
|
500
|
+
attach_function :botan_pk_op_key_agreement_destroy,
|
501
|
+
[:pointer],
|
502
|
+
:int
|
503
|
+
attach_function :botan_pk_op_key_agreement_export_public,
|
504
|
+
%i[pointer pointer pointer],
|
505
|
+
:int
|
506
|
+
attach_function :botan_pk_op_key_agreement,
|
507
|
+
%i[pointer pointer pointer pointer size_t pointer size_t],
|
508
|
+
:int
|
509
|
+
attach_function :botan_mceies_encrypt,
|
510
|
+
%i[pointer pointer string pointer size_t
|
511
|
+
pointer size_t pointer pointer],
|
512
|
+
:int
|
513
|
+
attach_function :botan_mceies_decrypt,
|
514
|
+
%i[pointer string pointer size_t
|
515
|
+
pointer size_t pointer pointer],
|
516
|
+
:int
|
517
|
+
|
518
|
+
# X.509 Certificates
|
519
|
+
attach_function :botan_x509_cert_load,
|
520
|
+
%i[pointer pointer size_t],
|
521
|
+
:int
|
522
|
+
attach_function :botan_x509_cert_load_file,
|
523
|
+
%i[pointer string],
|
524
|
+
:int
|
525
|
+
attach_function :botan_x509_cert_destroy,
|
526
|
+
[:pointer],
|
527
|
+
:int
|
528
|
+
# Missing implementation
|
529
|
+
# attach_function :botan_x509_cert_gen_selfsigned,
|
530
|
+
# [:pointer, :pointer, :pointer, :string, :string],
|
531
|
+
# :int
|
532
|
+
attach_function :botan_x509_cert_get_time_starts,
|
533
|
+
%i[pointer pointer pointer],
|
534
|
+
:int
|
535
|
+
attach_function :botan_x509_cert_get_time_expires,
|
536
|
+
%i[pointer pointer pointer],
|
537
|
+
:int
|
538
|
+
attach_function :botan_x509_cert_get_fingerprint,
|
539
|
+
%i[pointer string pointer pointer],
|
540
|
+
:int
|
541
|
+
attach_function :botan_x509_cert_get_serial_number,
|
542
|
+
%i[pointer pointer pointer],
|
543
|
+
:int
|
544
|
+
attach_function :botan_x509_cert_get_authority_key_id,
|
545
|
+
%i[pointer pointer pointer],
|
546
|
+
:int
|
547
|
+
attach_function :botan_x509_cert_get_subject_key_id,
|
548
|
+
%i[pointer pointer pointer],
|
549
|
+
:int
|
550
|
+
# Missing implementation
|
551
|
+
# attach_function :botan_x509_cert_path_verify,
|
552
|
+
# [:pointer, :string],
|
553
|
+
# :int
|
554
|
+
attach_function :botan_x509_cert_get_public_key_bits,
|
555
|
+
%i[pointer pointer pointer],
|
556
|
+
:int
|
557
|
+
attach_function :botan_x509_cert_get_public_key,
|
558
|
+
%i[pointer pointer],
|
559
|
+
:int
|
560
|
+
attach_function :botan_x509_cert_get_issuer_dn,
|
561
|
+
%i[pointer string size_t pointer pointer],
|
562
|
+
:int
|
563
|
+
attach_function :botan_x509_cert_get_subject_dn,
|
564
|
+
%i[pointer string size_t pointer pointer],
|
565
|
+
:int
|
566
|
+
attach_function :botan_x509_cert_to_string,
|
567
|
+
%i[pointer pointer pointer],
|
568
|
+
:int
|
569
|
+
attach_function :botan_x509_cert_allowed_usage,
|
570
|
+
%i[pointer uint],
|
571
|
+
:int
|
572
|
+
end # module
|
573
|
+
|