iodine 0.8.3 → 0.8.4
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 +4 -4
- data/CHANGELOG.md +7 -1
- data/ext/iodine/fio-stl.h +20409 -15729
- data/ext/iodine/fio-stl.md +6757 -915
- data/ext/iodine/iodine_connection.h +5 -3
- data/ext/iodine/iodine_crypto.h +42 -37
- data/ext/iodine/iodine_params.h +14 -7
- data/ext/iodine/iodine_utils.h +9 -2
- data/lib/iodine/version.rb +1 -1
- metadata +2 -2
|
@@ -2607,6 +2607,8 @@ static VALUE iodine_connection_initialize(int argc, VALUE *argv, VALUE self) {
|
|
|
2607
2607
|
(VALUE)h);
|
|
2608
2608
|
// args.settings.on_finish =
|
|
2609
2609
|
c->io = fio_http_connect FIO_NOOP(args.url.buf, h, args.settings);
|
|
2610
|
+
/* fio_http_connect duplicates its TLS reference; release our own. */
|
|
2611
|
+
fio_io_tls_free(args.settings.tls);
|
|
2610
2612
|
c->http = h;
|
|
2611
2613
|
fio_http_udata2_set(h, (void *)self);
|
|
2612
2614
|
|
|
@@ -2931,7 +2933,7 @@ static VALUE iodine_connection_peer_addr(VALUE self) {
|
|
|
2931
2933
|
fio_buf_info_s buf = FIO_BUF_INFO0;
|
|
2932
2934
|
iodine_connection_s *c = iodine_connection_ptr(self);
|
|
2933
2935
|
if (c->io)
|
|
2934
|
-
buf = fio_sock_peer_addr(fio_io_fd(c->io));
|
|
2936
|
+
buf = fio_sock_peer_addr(fio_io_fd(c->io), false);
|
|
2935
2937
|
if (!buf.len)
|
|
2936
2938
|
return Qnil;
|
|
2937
2939
|
return rb_str_new(buf.buf, buf.len);
|
|
@@ -2946,7 +2948,7 @@ static VALUE iodine_connection_from(VALUE self) {
|
|
|
2946
2948
|
fio_http_from(&addr, c->http);
|
|
2947
2949
|
buf = FIO_STR2BUF_INFO(addr);
|
|
2948
2950
|
} else if (c->io)
|
|
2949
|
-
buf = fio_sock_peer_addr(fio_io_fd(c->io));
|
|
2951
|
+
buf = fio_sock_peer_addr(fio_io_fd(c->io), false);
|
|
2950
2952
|
if (!buf.len)
|
|
2951
2953
|
return Qnil;
|
|
2952
2954
|
return rb_str_new(buf.buf, buf.len);
|
|
@@ -3311,7 +3313,7 @@ static void *iodine_tcp_listen(iodine_connection_args_s args) {
|
|
|
3311
3313
|
return fio_io_listen(.url = args.url.buf,
|
|
3312
3314
|
.protocol = protocol,
|
|
3313
3315
|
.udata = args.settings.udata,
|
|
3314
|
-
.tls = args.settings.tls,
|
|
3316
|
+
.tls = fio_io_tls_dup(args.settings.tls),
|
|
3315
3317
|
.on_stop = iodine_tcp_on_stop,
|
|
3316
3318
|
.queue_for_accept = 0);
|
|
3317
3319
|
}
|
data/ext/iodine/iodine_crypto.h
CHANGED
|
@@ -64,13 +64,14 @@ FIO_SFUNC VALUE iodine_crypto_chacha_encrypt(int argc,
|
|
|
64
64
|
VALUE ciphertext = rb_str_new(data.buf, data.len);
|
|
65
65
|
uint8_t mac[16];
|
|
66
66
|
|
|
67
|
-
fio_chacha20_poly1305_enc(mac,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
if (fio_chacha20_poly1305_enc(mac,
|
|
68
|
+
RSTRING_PTR(ciphertext),
|
|
69
|
+
data.len,
|
|
70
|
+
ad.buf,
|
|
71
|
+
ad.len,
|
|
72
|
+
(void *)key.buf,
|
|
73
|
+
(void *)nonce.buf))
|
|
74
|
+
rb_raise(rb_eRuntimeError, "Encryption failed");
|
|
74
75
|
|
|
75
76
|
VALUE mac_str = rb_str_new((const char *)mac, 16);
|
|
76
77
|
return rb_ary_new_from_args(2, ciphertext, mac_str);
|
|
@@ -172,13 +173,14 @@ FIO_SFUNC VALUE iodine_crypto_xchacha_encrypt(int argc,
|
|
|
172
173
|
VALUE ciphertext = rb_str_new(data.buf, data.len);
|
|
173
174
|
uint8_t mac[16];
|
|
174
175
|
|
|
175
|
-
fio_xchacha20_poly1305_enc(mac,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
if (fio_xchacha20_poly1305_enc(mac,
|
|
177
|
+
RSTRING_PTR(ciphertext),
|
|
178
|
+
data.len,
|
|
179
|
+
ad.buf,
|
|
180
|
+
ad.len,
|
|
181
|
+
(void *)key.buf,
|
|
182
|
+
(void *)nonce.buf))
|
|
183
|
+
rb_raise(rb_eRuntimeError, "Encryption failed");
|
|
182
184
|
|
|
183
185
|
VALUE mac_str = rb_str_new((const char *)mac, 16);
|
|
184
186
|
return rb_ary_new_from_args(2, ciphertext, mac_str);
|
|
@@ -277,13 +279,14 @@ FIO_SFUNC VALUE iodine_crypto_aes128gcm_encrypt(int argc,
|
|
|
277
279
|
VALUE ciphertext = rb_str_new(data.buf, data.len);
|
|
278
280
|
uint8_t mac[16];
|
|
279
281
|
|
|
280
|
-
fio_aes128_gcm_enc(mac,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
if (fio_aes128_gcm_enc(mac,
|
|
283
|
+
RSTRING_PTR(ciphertext),
|
|
284
|
+
data.len,
|
|
285
|
+
ad.buf,
|
|
286
|
+
ad.len,
|
|
287
|
+
(void *)key.buf,
|
|
288
|
+
(void *)nonce.buf))
|
|
289
|
+
rb_raise(rb_eRuntimeError, "Encryption failed");
|
|
287
290
|
|
|
288
291
|
VALUE mac_str = rb_str_new((const char *)mac, 16);
|
|
289
292
|
return rb_ary_new_from_args(2, ciphertext, mac_str);
|
|
@@ -382,13 +385,14 @@ FIO_SFUNC VALUE iodine_crypto_aes256gcm_encrypt(int argc,
|
|
|
382
385
|
VALUE ciphertext = rb_str_new(data.buf, data.len);
|
|
383
386
|
uint8_t mac[16];
|
|
384
387
|
|
|
385
|
-
fio_aes256_gcm_enc(mac,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
388
|
+
if (fio_aes256_gcm_enc(mac,
|
|
389
|
+
RSTRING_PTR(ciphertext),
|
|
390
|
+
data.len,
|
|
391
|
+
ad.buf,
|
|
392
|
+
ad.len,
|
|
393
|
+
(void *)key.buf,
|
|
394
|
+
(void *)nonce.buf))
|
|
395
|
+
rb_raise(rb_eRuntimeError, "Encryption failed");
|
|
392
396
|
|
|
393
397
|
VALUE mac_str = rb_str_new((const char *)mac, 16);
|
|
394
398
|
return rb_ary_new_from_args(2, ciphertext, mac_str);
|
|
@@ -1004,15 +1008,16 @@ FIO_SFUNC VALUE iodine_crypto_hkdf_derive(int argc, VALUE *argv, VALUE self) {
|
|
|
1004
1008
|
VALUE okm = rb_str_buf_new(length);
|
|
1005
1009
|
rb_str_set_len(okm, length);
|
|
1006
1010
|
|
|
1007
|
-
fio_hkdf(RSTRING_PTR(okm),
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1011
|
+
if (fio_hkdf(RSTRING_PTR(okm),
|
|
1012
|
+
(size_t)length,
|
|
1013
|
+
salt.buf,
|
|
1014
|
+
salt.len,
|
|
1015
|
+
ikm.buf,
|
|
1016
|
+
ikm.len,
|
|
1017
|
+
info.buf,
|
|
1018
|
+
info.len,
|
|
1019
|
+
(int)sha384))
|
|
1020
|
+
rb_raise(rb_eRuntimeError, "HKDF derivation failed");
|
|
1016
1021
|
|
|
1017
1022
|
return okm;
|
|
1018
1023
|
(void)self;
|
data/ext/iodine/iodine_params.h
CHANGED
|
@@ -795,6 +795,7 @@ typedef struct {
|
|
|
795
795
|
fio_str_info_s filename;
|
|
796
796
|
fio_str_info_s content_type;
|
|
797
797
|
fio_str_info_s headers;
|
|
798
|
+
fio_buf_info_s data;
|
|
798
799
|
} iodine___params_callback_args_s;
|
|
799
800
|
|
|
800
801
|
FIO_SFUNC VALUE iodine___params_callback_dispatch(VALUE args_) {
|
|
@@ -848,6 +849,10 @@ FIO_SFUNC VALUE iodine___params_callback_dispatch(VALUE args_) {
|
|
|
848
849
|
a->filename,
|
|
849
850
|
a->content_type,
|
|
850
851
|
a->headers);
|
|
852
|
+
if (iodine___params_on_file_data(a->u, a->result, a->data)) {
|
|
853
|
+
a->result = NULL;
|
|
854
|
+
a->status = -1;
|
|
855
|
+
}
|
|
851
856
|
break;
|
|
852
857
|
}
|
|
853
858
|
return Qnil;
|
|
@@ -963,11 +968,13 @@ FIO_SFUNC int iodine___params_cb_array_push(void *udata_,
|
|
|
963
968
|
return a.status;
|
|
964
969
|
}
|
|
965
970
|
|
|
966
|
-
FIO_SFUNC
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
+
FIO_SFUNC fio_json_obj_result_s iodine___params_cb_on_file(
|
|
972
|
+
void *udata_,
|
|
973
|
+
fio_str_info_s name,
|
|
974
|
+
fio_str_info_s filename,
|
|
975
|
+
fio_str_info_s content_type,
|
|
976
|
+
fio_str_info_s headers,
|
|
977
|
+
fio_buf_info_s data) {
|
|
971
978
|
iodine___params_callback_args_s a = {
|
|
972
979
|
.u = (iodine_params_udata_s *)udata_,
|
|
973
980
|
.op = IODINE_PARAMS_CB_FILE,
|
|
@@ -975,9 +982,10 @@ FIO_SFUNC void *iodine___params_cb_on_file(void *udata_,
|
|
|
975
982
|
.filename = filename,
|
|
976
983
|
.content_type = content_type,
|
|
977
984
|
.headers = headers,
|
|
985
|
+
.data = data,
|
|
978
986
|
};
|
|
979
987
|
iodine___params_callback_protect(&a);
|
|
980
|
-
return a.result;
|
|
988
|
+
return (fio_json_obj_result_s){.obj = a.result, .err = a.status};
|
|
981
989
|
}
|
|
982
990
|
|
|
983
991
|
/* The STL treats this callback table as read-only. */
|
|
@@ -997,7 +1005,6 @@ static fio_http_params_parse_callbacks_s IODINE_PARAMS_CALLBACKS = {
|
|
|
997
1005
|
.is_map = iodine___params_is_map,
|
|
998
1006
|
.free_unused_object = iodine___params_free_unused_object,
|
|
999
1007
|
.on_file = iodine___params_cb_on_file,
|
|
1000
|
-
.on_file_data = iodine___params_on_file_data,
|
|
1001
1008
|
};
|
|
1002
1009
|
|
|
1003
1010
|
/* *****************************************************************************
|
data/ext/iodine/iodine_utils.h
CHANGED
|
@@ -684,6 +684,8 @@ FIO_SFUNC VALUE iodine_utils_totp(int argc, VALUE *argv, VALUE self) {
|
|
|
684
684
|
interval = 30;
|
|
685
685
|
|
|
686
686
|
uint32_t otp = fio_otp(secret, .offset = offset, .interval = interval);
|
|
687
|
+
if (otp == FIO_OTP_ERROR)
|
|
688
|
+
otp = fio_otp(secret, .offset = offset, .interval = interval, .is_raw = 1);
|
|
687
689
|
return UINT2NUM(otp);
|
|
688
690
|
(void)self;
|
|
689
691
|
}
|
|
@@ -772,10 +774,15 @@ FIO_SFUNC VALUE iodine_utils_totp_verify(int argc, VALUE *argv, VALUE self) {
|
|
|
772
774
|
if (window < 0 || window > 10)
|
|
773
775
|
rb_raise(rb_eArgError, "window must be between 0 and 10");
|
|
774
776
|
|
|
775
|
-
/*
|
|
777
|
+
/* FIO_OTP_ERROR is not a valid code (including a caller's -1). */
|
|
778
|
+
if (code < 0 || code > 999999)
|
|
779
|
+
return Qfalse;
|
|
776
780
|
for (int64_t offset = -window; offset <= window; ++offset) {
|
|
777
781
|
uint32_t expected = fio_otp(secret, .offset = offset, .interval = interval);
|
|
778
|
-
if (expected ==
|
|
782
|
+
if (expected == FIO_OTP_ERROR)
|
|
783
|
+
expected = fio_otp(secret, .offset = offset, .interval = interval,
|
|
784
|
+
.is_raw = 1);
|
|
785
|
+
if (expected != FIO_OTP_ERROR && expected == (uint32_t)code)
|
|
779
786
|
return Qtrue;
|
|
780
787
|
}
|
|
781
788
|
|
data/lib/iodine/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iodine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Boaz Segev
|
|
@@ -134,7 +134,7 @@ metadata:
|
|
|
134
134
|
homepage_uri: https://github.com/boazsegev/iodine
|
|
135
135
|
source_code_uri: https://github.com/boazsegev/iodine
|
|
136
136
|
changelog_uri: https://github.com/boazsegev/iodine/blob/master/CHANGELOG.md
|
|
137
|
-
post_install_message: Thank you for installing Iodine 0.8.
|
|
137
|
+
post_install_message: Thank you for installing Iodine 0.8.4.
|
|
138
138
|
rdoc_options: []
|
|
139
139
|
require_paths:
|
|
140
140
|
- lib
|