krypt-core 0.0.1

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.
Files changed (73) hide show
  1. data/LICENSE +20 -0
  2. data/ext/krypt/core/Makefile +221 -0
  3. data/ext/krypt/core/binyo-error.h +40 -0
  4. data/ext/krypt/core/binyo-io-buffer.h +54 -0
  5. data/ext/krypt/core/binyo-io.h +131 -0
  6. data/ext/krypt/core/extconf.h +8 -0
  7. data/ext/krypt/core/extconf.rb +80 -0
  8. data/ext/krypt/core/krypt-core.c +110 -0
  9. data/ext/krypt/core/krypt-core.h +97 -0
  10. data/ext/krypt/core/krypt-core.o +0 -0
  11. data/ext/krypt/core/krypt-provider.h +86 -0
  12. data/ext/krypt/core/krypt_asn1-internal.c +681 -0
  13. data/ext/krypt/core/krypt_asn1-internal.h +117 -0
  14. data/ext/krypt/core/krypt_asn1-internal.o +0 -0
  15. data/ext/krypt/core/krypt_asn1.c +2109 -0
  16. data/ext/krypt/core/krypt_asn1.h +88 -0
  17. data/ext/krypt/core/krypt_asn1.o +0 -0
  18. data/ext/krypt/core/krypt_asn1_codec.c +973 -0
  19. data/ext/krypt/core/krypt_asn1_codec.o +0 -0
  20. data/ext/krypt/core/krypt_asn1_in_adapter.c +178 -0
  21. data/ext/krypt/core/krypt_asn1_in_adapter.o +0 -0
  22. data/ext/krypt/core/krypt_asn1_in_chunked.c +292 -0
  23. data/ext/krypt/core/krypt_asn1_in_chunked.o +0 -0
  24. data/ext/krypt/core/krypt_asn1_in_definite.c +156 -0
  25. data/ext/krypt/core/krypt_asn1_in_definite.o +0 -0
  26. data/ext/krypt/core/krypt_asn1_parser.c +592 -0
  27. data/ext/krypt/core/krypt_asn1_parser.o +0 -0
  28. data/ext/krypt/core/krypt_asn1_template-internal.h +185 -0
  29. data/ext/krypt/core/krypt_asn1_template.c +459 -0
  30. data/ext/krypt/core/krypt_asn1_template.h +56 -0
  31. data/ext/krypt/core/krypt_asn1_template.o +0 -0
  32. data/ext/krypt/core/krypt_asn1_template_encoder.c +76 -0
  33. data/ext/krypt/core/krypt_asn1_template_encoder.o +0 -0
  34. data/ext/krypt/core/krypt_asn1_template_parser.c +1176 -0
  35. data/ext/krypt/core/krypt_asn1_template_parser.o +0 -0
  36. data/ext/krypt/core/krypt_b64-internal.h +38 -0
  37. data/ext/krypt/core/krypt_b64.c +391 -0
  38. data/ext/krypt/core/krypt_b64.h +41 -0
  39. data/ext/krypt/core/krypt_b64.o +0 -0
  40. data/ext/krypt/core/krypt_digest.c +391 -0
  41. data/ext/krypt/core/krypt_digest.h +51 -0
  42. data/ext/krypt/core/krypt_digest.o +0 -0
  43. data/ext/krypt/core/krypt_error.c +221 -0
  44. data/ext/krypt/core/krypt_error.h +46 -0
  45. data/ext/krypt/core/krypt_error.o +0 -0
  46. data/ext/krypt/core/krypt_hex-internal.h +36 -0
  47. data/ext/krypt/core/krypt_hex.c +255 -0
  48. data/ext/krypt/core/krypt_hex.h +41 -0
  49. data/ext/krypt/core/krypt_hex.o +0 -0
  50. data/ext/krypt/core/krypt_io.c +65 -0
  51. data/ext/krypt/core/krypt_io.h +56 -0
  52. data/ext/krypt/core/krypt_io.o +0 -0
  53. data/ext/krypt/core/krypt_io_in_pem.c +397 -0
  54. data/ext/krypt/core/krypt_io_in_pem.o +0 -0
  55. data/ext/krypt/core/krypt_missing.c +238 -0
  56. data/ext/krypt/core/krypt_missing.h +62 -0
  57. data/ext/krypt/core/krypt_missing.o +0 -0
  58. data/ext/krypt/core/krypt_pem.c +171 -0
  59. data/ext/krypt/core/krypt_pem.o +0 -0
  60. data/ext/krypt/core/krypt_provider-internal.h +40 -0
  61. data/ext/krypt/core/krypt_provider.c +136 -0
  62. data/ext/krypt/core/krypt_provider.o +0 -0
  63. data/ext/krypt/core/kryptcore.so +0 -0
  64. data/ext/krypt/core/mkmf.log +130 -0
  65. data/lib/krypt-core/version.rb +3 -0
  66. data/lib/krypt-core.rb +35 -0
  67. data/lib/kryptcore.so +0 -0
  68. data/spec/README +2 -0
  69. data/test/README +2 -0
  70. data/test/res/certificate.cer +0 -0
  71. data/test/resources.rb +48 -0
  72. data/test/scratch.rb +17 -0
  73. metadata +150 -0
@@ -0,0 +1,36 @@
1
+ /*
2
+ * krypt-core API - C implementation
3
+ *
4
+ * Copyright (c) 2011-2013
5
+ * Hiroshi Nakamura <nahi@ruby-lang.org>
6
+ * Martin Bosslet <martin.bosslet@gmail.com>
7
+ * All rights reserved.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining
10
+ * a copy of this software and associated documentation files (the
11
+ * "Software"), to deal in the Software without restriction, including
12
+ * without limitation the rights to use, copy, modify, merge, publish,
13
+ * distribute, sublicense, and/or sell copies of the Software, and to
14
+ * permit persons to whom the Software is furnished to do so, subject to
15
+ * the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+
29
+ #ifndef _KRYPT_HEX_INTERNAL_H
30
+ #define _KRYPT_HEX_INTERNAL_H_
31
+
32
+ int krypt_hex_encode(uint8_t *bytes, size_t len, uint8_t **out, size_t *outlen);
33
+ int krypt_hex_decode(uint8_t *bytes, size_t len, uint8_t **out, size_t *outlen);
34
+
35
+ #endif /* _KRYPT_HEX_INTERNAL_H_ */
36
+
@@ -0,0 +1,255 @@
1
+ /*
2
+ * krypt-core API - C implementation
3
+ *
4
+ * Copyright (c) 2011-2013
5
+ * Hiroshi Nakamura <nahi@ruby-lang.org>
6
+ * Martin Bosslet <martin.bosslet@gmail.com>
7
+ * All rights reserved.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining
10
+ * a copy of this software and associated documentation files (the
11
+ * "Software"), to deal in the Software without restriction, including
12
+ * without limitation the rights to use, copy, modify, merge, publish,
13
+ * distribute, sublicense, and/or sell copies of the Software, and to
14
+ * permit persons to whom the Software is furnished to do so, subject to
15
+ * the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+
29
+ #include "krypt-core.h"
30
+
31
+ VALUE mKryptHex;
32
+ VALUE cKryptHexEncoder;
33
+ VALUE cKryptHexDecoder;
34
+ VALUE eKryptHexError;
35
+
36
+ static const char krypt_hex_table[] = "0123456789abcdef";
37
+ static const char krypt_hex_table_inv[] = {
38
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
39
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
40
+ -1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,
41
+ -1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
42
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,12,
43
+ 13,14,15
44
+ };
45
+
46
+ #define KRYPT_HEX_INV_MAX 102
47
+ #define KRYPT_HEX_DECODE 0
48
+ #define KRYPT_HEX_ENCODE 1
49
+
50
+ static int
51
+ int_hex_encode(uint8_t *bytes, size_t len, uint8_t *out)
52
+ {
53
+ size_t i;
54
+ uint8_t b;
55
+ size_t j;
56
+
57
+ for (i=0; i < len; i++) {
58
+ b = bytes[i];
59
+ j = i * 2;
60
+ out[j] = krypt_hex_table[b >> 4];
61
+ out[j + 1] = krypt_hex_table[b & 0x0f];
62
+ }
63
+ return KRYPT_OK;
64
+ }
65
+
66
+ static int
67
+ int_hex_decode(uint8_t *bytes, size_t len, uint8_t *out)
68
+ {
69
+ size_t i;
70
+ char b;
71
+ uint8_t c, d;
72
+
73
+ for (i=0; i < len / 2; i++) {
74
+ c = (uint8_t) bytes[i*2];
75
+ d = (uint8_t) bytes[i*2+1];
76
+ if (c > KRYPT_HEX_INV_MAX || d > KRYPT_HEX_INV_MAX) {
77
+ krypt_error_add("Illegal hex character detected: %x or %x", c, d);
78
+ return KRYPT_ERR;
79
+ }
80
+ b = krypt_hex_table_inv[c];
81
+ if (b < 0) {
82
+ krypt_error_add("Illegal hex character detected: %x", c);
83
+ return KRYPT_ERR;
84
+ }
85
+ out[i] = b << 4;
86
+ b = krypt_hex_table_inv[d];
87
+ if (b < 0) {
88
+ krypt_error_add("Illegal hex character detected: %x", d);
89
+ return KRYPT_ERR;
90
+ }
91
+ out[i] |= b;
92
+ }
93
+ return KRYPT_OK;
94
+ }
95
+
96
+ #define int_hex_encode_tests(bytes, len, tmp) \
97
+ do { \
98
+ if (!(bytes)) { \
99
+ (tmp) = KRYPT_ERR; \
100
+ } \
101
+ if ((len) > SSIZE_MAX / 2) { \
102
+ krypt_error_add("Buffer too large: %ld", (len)); \
103
+ (tmp) = KRYPT_ERR; \
104
+ } \
105
+ } while (0)
106
+
107
+ int
108
+ krypt_hex_encode(uint8_t *bytes, size_t len, uint8_t **out, size_t *outlen)
109
+ {
110
+ size_t ret;
111
+ uint8_t *retval;
112
+ int tmp = 0;
113
+
114
+ int_hex_encode_tests(bytes, len, tmp);
115
+ if (tmp == KRYPT_ERR) return KRYPT_ERR;
116
+
117
+ ret = 2 * len;
118
+ retval = ALLOC_N(uint8_t, ret);
119
+ if (int_hex_encode(bytes, len, retval) == KRYPT_ERR) {
120
+ xfree(retval);
121
+ return KRYPT_ERR;
122
+ }
123
+
124
+ *out = retval;
125
+ *outlen = ret;
126
+ return KRYPT_OK;
127
+ }
128
+
129
+ #define int_hex_decode_tests(bytes, len, tmp) \
130
+ do { \
131
+ if (!(bytes)) { \
132
+ (tmp) = KRYPT_ERR; \
133
+ } \
134
+ if ((len) % 2) { \
135
+ krypt_error_add("Buffer length must be a multiple of 2"); \
136
+ (tmp) = KRYPT_ERR; \
137
+ } \
138
+ if ((len) / 2 > SSIZE_MAX) { \
139
+ krypt_error_add("Buffer too large: %ld", (len)); \
140
+ (tmp) = KRYPT_ERR; \
141
+ } \
142
+ } while (0)
143
+
144
+ int
145
+ krypt_hex_decode(uint8_t *bytes, size_t len, uint8_t **out, size_t *outlen)
146
+ {
147
+ size_t ret;
148
+ uint8_t *retval;
149
+ int tmp = 0;
150
+
151
+ int_hex_decode_tests(bytes, len, tmp);
152
+ if (tmp == KRYPT_ERR) return KRYPT_ERR;
153
+
154
+ ret = len / 2;
155
+ retval = ALLOC_N(uint8_t, ret);
156
+ if (int_hex_decode(bytes, len, retval) == KRYPT_ERR) {
157
+ xfree(retval);
158
+ return KRYPT_ERR;
159
+ }
160
+ *out = retval;
161
+ *outlen = ret;
162
+ return KRYPT_OK;
163
+ }
164
+
165
+ /* Krypt::Hex */
166
+
167
+ #define int_hex_process(bytes, len, mode, ret) \
168
+ do { \
169
+ ssize_t result_len; \
170
+ uint8_t *result; \
171
+ int tmp = 0; \
172
+ if (!(bytes)) \
173
+ krypt_error_raise(eKryptHexError, "Bytes null"); \
174
+ if ((mode) == KRYPT_HEX_DECODE) { \
175
+ int_hex_decode_tests((bytes), (len), tmp); \
176
+ if (tmp == KRYPT_ERR) \
177
+ krypt_error_raise(eKryptHexError, "Decoding the value failed"); \
178
+ result_len = (len) / 2; \
179
+ result = ALLOCA_N(uint8_t, result_len); \
180
+ tmp = int_hex_decode((bytes), (len), result); \
181
+ } else if ((mode) == KRYPT_HEX_ENCODE) { \
182
+ int_hex_encode_tests((bytes), (len), tmp); \
183
+ if (tmp == KRYPT_ERR) \
184
+ krypt_error_raise(eKryptHexError, "Encoding the value failed"); \
185
+ result_len = (len) * 2; \
186
+ result = ALLOCA_N(uint8_t, result_len); \
187
+ tmp = int_hex_encode((bytes), (len), result); \
188
+ } else { \
189
+ krypt_error_raise(rb_eRuntimeError, "Internal error"); \
190
+ } \
191
+ if (tmp == KRYPT_ERR) \
192
+ krypt_error_raise(eKryptHexError, "Processing the hex value failed."); \
193
+ (ret) = rb_str_new((const char *) result, result_len); \
194
+ } while (0)
195
+
196
+ /**
197
+ * call-seq:
198
+ * Krypt::Hex.decode(data) -> String
199
+ *
200
+ * Decodes a hex-encoded string of +data+, which need not necessarily be
201
+ * a String, but must allow a conversion with to_str.
202
+ */
203
+ static VALUE
204
+ krypt_hex_module_decode(VALUE self, VALUE data)
205
+ {
206
+ VALUE ret;
207
+ uint8_t *bytes;
208
+ size_t len;
209
+
210
+ StringValue(data);
211
+ len = (size_t) RSTRING_LEN((data));
212
+ bytes = (uint8_t *) RSTRING_PTR((data));
213
+ int_hex_process(bytes, len, KRYPT_HEX_DECODE, ret);
214
+ return ret;
215
+ }
216
+
217
+ /**
218
+ * call-seq:
219
+ * Krypt::Hex.encode(data) -> String
220
+ *
221
+ * Encodes +data+, a String, or an object allowing conversion with to_str,
222
+ * in hex encoding.
223
+ */
224
+ static VALUE
225
+ krypt_hex_module_encode(VALUE self, VALUE data)
226
+ {
227
+ VALUE ret;
228
+ uint8_t *bytes;
229
+ size_t len;
230
+
231
+ StringValue(data);
232
+ len = (size_t) RSTRING_LEN((data));
233
+ bytes = (uint8_t *) RSTRING_PTR((data));
234
+ int_hex_process(bytes, len, KRYPT_HEX_ENCODE, ret);
235
+ rb_enc_associate(ret, rb_usascii_encoding());
236
+ return ret;
237
+ }
238
+
239
+ /* End Krypt::Hex */
240
+
241
+ void
242
+ Init_krypt_hex(void)
243
+ {
244
+ #if 0
245
+ mKrypt = rb_define_module("Krypt"); /* Let RDoc know */
246
+ #endif
247
+
248
+ mKryptHex = rb_define_module_under(mKrypt, "Hex");
249
+
250
+ eKryptHexError = rb_define_class_under(mKryptHex, "HexError", eKryptError);
251
+
252
+ rb_define_module_function(mKryptHex, "decode", krypt_hex_module_decode, 1);
253
+ rb_define_module_function(mKryptHex, "encode", krypt_hex_module_encode, 1);
254
+ }
255
+
@@ -0,0 +1,41 @@
1
+ /*
2
+ * krypt-core API - C implementation
3
+ *
4
+ * Copyright (c) 2011-2013
5
+ * Hiroshi Nakamura <nahi@ruby-lang.org>
6
+ * Martin Bosslet <martin.bosslet@gmail.com>
7
+ * All rights reserved.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining
10
+ * a copy of this software and associated documentation files (the
11
+ * "Software"), to deal in the Software without restriction, including
12
+ * without limitation the rights to use, copy, modify, merge, publish,
13
+ * distribute, sublicense, and/or sell copies of the Software, and to
14
+ * permit persons to whom the Software is furnished to do so, subject to
15
+ * the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+
29
+ #ifndef _KRYPT_HEX_H
30
+ #define _KRYPT_HEX_H_
31
+
32
+ extern VALUE mKryptHex;
33
+ extern VALUE cKryptHexEncoder;
34
+ extern VALUE cKryptHexDecoder;
35
+
36
+ extern VALUE eKryptHexError;
37
+
38
+ void Init_krypt_hex(void);
39
+
40
+ #endif /* _KRYPT_HEX_H_ */
41
+
Binary file
@@ -0,0 +1,65 @@
1
+ /*
2
+ * krypt-core API - C implementation
3
+ *
4
+ * Copyright (c) 2011-2013
5
+ * Hiroshi Nakamura <nahi@ruby-lang.org>
6
+ * Martin Bosslet <martin.bosslet@gmail.com>
7
+ * All rights reserved.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining
10
+ * a copy of this software and associated documentation files (the
11
+ * "Software"), to deal in the Software without restriction, including
12
+ * without limitation the rights to use, copy, modify, merge, publish,
13
+ * distribute, sublicense, and/or sell copies of the Software, and to
14
+ * permit persons to whom the Software is furnished to do so, subject to
15
+ * the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+
29
+ #include "krypt-core.h"
30
+
31
+ binyo_instream *
32
+ krypt_instream_new_value_der(VALUE value)
33
+ {
34
+ binyo_instream *in;
35
+
36
+ if (!(in = binyo_instream_new_value(value))) {
37
+ value = krypt_to_der_if_possible(value);
38
+ StringValue(value);
39
+ in = binyo_instream_new_bytes((uint8_t *)RSTRING_PTR(value), RSTRING_LEN(value));
40
+ }
41
+
42
+ return in;
43
+ }
44
+
45
+ binyo_instream *
46
+ krypt_instream_new_value_pem(VALUE value)
47
+ {
48
+ binyo_instream *in;
49
+
50
+ if (!(in = binyo_instream_new_value(value))) {
51
+ value = krypt_to_pem_if_possible(value);
52
+ StringValue(value);
53
+ in = binyo_instream_new_bytes((uint8_t *)RSTRING_PTR(value), RSTRING_LEN(value));
54
+ }
55
+
56
+ return in;
57
+ }
58
+
59
+ void
60
+ Init_krypt_io(void)
61
+ {
62
+ Init_krypt_base64();
63
+ Init_krypt_hex();
64
+ }
65
+
@@ -0,0 +1,56 @@
1
+ /*
2
+ * krypt-core API - C implementation
3
+ *
4
+ * Copyright (c) 2011-2013
5
+ * Hiroshi Nakamura <nahi@ruby-lang.org>
6
+ * Martin Bosslet <martin.bosslet@gmail.com>
7
+ * All rights reserved.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining
10
+ * a copy of this software and associated documentation files (the
11
+ * "Software"), to deal in the Software without restriction, including
12
+ * without limitation the rights to use, copy, modify, merge, publish,
13
+ * distribute, sublicense, and/or sell copies of the Software, and to
14
+ * permit persons to whom the Software is furnished to do so, subject to
15
+ * the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+
29
+ #if !defined(_KRYPT_IO_H_)
30
+ #define _KRYPT_IO_H_
31
+
32
+ #include "binyo-error.h"
33
+ #include "binyo-io.h"
34
+ #include "binyo-io-buffer.h"
35
+
36
+ #include "krypt_hex.h"
37
+ #include "krypt_b64.h"
38
+
39
+ #define KRYPT_INSTREAM_TYPE_DEFINITE 100
40
+ #define KRYPT_INSTREAM_TYPE_CHUNKED 101
41
+ #define KRYPT_INSTREAM_TYPE_PEM 102
42
+
43
+ binyo_instream *krypt_instream_new_value_der(VALUE value);
44
+ binyo_instream *krypt_instream_new_value_pem(VALUE value);
45
+ binyo_instream *krypt_instream_new_chunked(binyo_instream *in, int values_only);
46
+ binyo_instream *krypt_instream_new_definite(binyo_instream *in, size_t length);
47
+ binyo_instream *krypt_instream_new_pem(binyo_instream *original);
48
+ void krypt_instream_pem_free_wrapper(binyo_instream *instream);
49
+
50
+ int krypt_pem_get_last_name(binyo_instream *instream, uint8_t **out, size_t *outlen);
51
+ void krypt_pem_continue_stream(binyo_instream *instream);
52
+
53
+ void Init_krypt_io(void);
54
+
55
+ #endif /* _KRYPT_IO_H_ */
56
+
Binary file