Module: Krypt::ASN1::Template
- Defined in:
- ext/krypt/core/krypt_asn1_template.c
Defined Under Namespace
Modules: Parser
Classes: Value
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
._mod_included_callback(klass) ⇒ Object
253
254
255
256
257
258
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 253
static VALUE
krypt_asn1_template_mod_included_callback(VALUE self, VALUE klass)
{
rb_define_alloc_func(klass, krypt_asn1_template_alloc);
return Qnil;
}
|
Instance Method Details
#<=>(other) ⇒ Object
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 312
VALUE
krypt_asn1_template_cmp(VALUE self, VALUE other)
{
VALUE vs1, vs2;
int result;
vs1 = krypt_asn1_template_to_der(self);
if (!rb_respond_to(other, sKrypt_ID_TO_DER)) return Qnil;
vs2 = krypt_to_der(other);
if (krypt_asn1_cmp_set_of((uint8_t *) RSTRING_PTR(vs1), (size_t) RSTRING_LEN(vs1),
(uint8_t *) RSTRING_PTR(vs2), (size_t) RSTRING_LEN(vs2), &result) == KRYPT_ERR) {
krypt_error_raise(eKryptASN1Error, "Error while comparing values");
}
return INT2NUM(result);
}
|
#__inspect__ ⇒ Object
380
381
382
383
384
385
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 380
static VALUE
krypt_asn1_template_inspect(VALUE self)
{
VALUE name = rb_str_new2("ROOT");
return int_traverse_template(self, name, int_inspect_i, NULL);
}
|
#_get_callback(name) ⇒ Object
271
272
273
274
275
276
277
278
279
280
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 271
VALUE
krypt_asn1_template_get_callback(VALUE self, VALUE name)
{
VALUE ret = Qnil;
ID ivname = SYM2ID(name);
if (krypt_asn1_template_get_cb_value(self, ivname, &ret) == KRYPT_ERR)
krypt_error_raise(eKryptASN1Error, "Could not access %s", rb_id2name(ivname));
return ret;
}
|
#_get_callback_choice(name) ⇒ Object
282
283
284
285
286
287
288
289
290
291
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 282
VALUE
krypt_asn1_template_get_callback_choice(VALUE self, VALUE name)
{
ID ivname = SYM2ID(name);
if (ivname == sKrypt_IV_TAG || ivname == sKrypt_IV_TYPE)
return int_return_choice_attr(self, ivname);
return krypt_asn1_template_get_callback(self, name);
}
|
#_set_callback(name, value) ⇒ Object
293
294
295
296
297
298
299
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 293
VALUE
krypt_asn1_template_set_callback(VALUE self, VALUE name, VALUE value)
{
ID ivname = SYM2ID(name);
krypt_asn1_template_set_cb_value(self, ivname, value);
return value;
}
|
#_set_callback_choice(name, value) ⇒ Object
301
302
303
304
305
306
307
308
309
310
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 301
VALUE
krypt_asn1_template_set_callback_choice(VALUE self, VALUE name, VALUE value)
{
ID ivname = SYM2ID(name);
if (ivname == sKrypt_IV_TAG || ivname == sKrypt_IV_TYPE)
return rb_ivar_set(self, ivname, value);
return krypt_asn1_template_set_callback(self, name, value);
}
|
#initialize ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 161
static VALUE
krypt_asn1_template_initialize(VALUE self)
{
krypt_asn1_template *template;
VALUE definition, klass;
if (DATA_PTR(self))
rb_raise(eKryptASN1Error, "Template already initialized");
klass = CLASS_OF(self);
if (NIL_P((definition = krypt_definition_get(klass)))) {
krypt_error_add("%s has no ASN.1 definition", rb_class2name(klass));
return Qnil;
}
template = krypt_asn1_template_new(NULL, definition, krypt_hash_get_options(definition));
krypt_asn1_template_set_parsed(template, 1);
krypt_asn1_template_set_decoded(template, 1);
DATA_PTR(self) = template;
if (rb_block_given_p()) {
VALUE blk = rb_block_proc();
rb_funcall(blk, rb_intern("call"), 1, self);
}
return self;
}
|
#to_der ⇒ DER-/BER-encoded String
Behaves the same way that Krypt::ASN1#to_der does.
393
394
395
396
397
398
399
400
401
|
# File 'ext/krypt/core/krypt_asn1_template.c', line 393
VALUE
krypt_asn1_template_to_der(VALUE template)
{
VALUE ret;
if (krypt_asn1_template_encode(template, &ret) == KRYPT_ERR)
krypt_error_raise(eKryptASN1Error, "Error while encoding value");
return ret;
}
|