12 #define NewX509CRL(klass) \ 13 TypedData_Wrap_Struct((klass), &ossl_x509crl_type, 0) 14 #define SetX509CRL(obj, crl) do { \ 16 ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \ 18 RTYPEDDATA_DATA(obj) = (crl); \ 20 #define GetX509CRL(obj, crl) do { \ 21 TypedData_Get_Struct((obj), X509_CRL, &ossl_x509crl_type, (crl)); \ 23 ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \ 34 ossl_x509crl_free(
void *ptr)
67 tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
78 ossl_x509crl_alloc(
VALUE klass)
84 if (!(crl = X509_CRL_new())) {
104 crl = PEM_read_bio_X509_CRL(in, &x,
NULL,
NULL);
108 crl = d2i_X509_CRL_bio(in, &x);
120 X509_CRL *a, *b, *crl;
123 if (
self == other)
return self;
126 if (!(crl = X509_CRL_dup(b))) {
136 ossl_x509crl_get_version(
VALUE self)
142 ver = X509_CRL_get_version(crl);
148 ossl_x509crl_set_version(
VALUE self,
VALUE version)
153 if ((ver =
NUM2LONG(version)) < 0) {
157 if (!X509_CRL_set_version(crl, ver)) {
165 ossl_x509crl_get_signature_algorithm(
VALUE self)
168 const X509_ALGOR *alg;
172 if (!(out = BIO_new(BIO_s_mem()))) {
176 if (!i2a_ASN1_OBJECT(out, alg->algorithm)) {
185 ossl_x509crl_get_issuer(
VALUE self)
195 ossl_x509crl_set_issuer(
VALUE self,
VALUE issuer)
208 ossl_x509crl_get_last_update(
VALUE self)
211 const ASN1_TIME *time;
222 ossl_x509crl_set_last_update(
VALUE self,
VALUE time)
229 if (!X509_CRL_set_lastUpdate(crl, asn1time)) {
230 ASN1_TIME_free(asn1time);
233 ASN1_TIME_free(asn1time);
239 ossl_x509crl_get_next_update(
VALUE self)
242 const ASN1_TIME *time;
253 ossl_x509crl_set_next_update(
VALUE self,
VALUE time)
260 if (!X509_CRL_set_nextUpdate(crl, asn1time)) {
261 ASN1_TIME_free(asn1time);
264 ASN1_TIME_free(asn1time);
270 ossl_x509crl_get_revoked(
VALUE self)
278 num = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
284 for(i=0; i<num; i++) {
286 rev = sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), i);
295 ossl_x509crl_set_revoked(
VALUE self,
VALUE ary)
308 if ((sk = X509_CRL_get_REVOKED(crl))) {
309 while ((rev = sk_X509_REVOKED_pop(sk)))
310 X509_REVOKED_free(rev);
314 if (!X509_CRL_add0_revoked(crl, rev)) {
315 X509_REVOKED_free(rev);
325 ossl_x509crl_add_revoked(
VALUE self,
VALUE revoked)
332 if (!X509_CRL_add0_revoked(crl, rev)) {
333 X509_REVOKED_free(rev);
351 if (!X509_CRL_sign(crl, pkey, md)) {
364 switch (X509_CRL_verify(crl,
GetPKeyPtr(key))) {
376 ossl_x509crl_to_der(
VALUE self)
382 if (!(out = BIO_new(BIO_s_mem()))) {
385 if (!i2d_X509_CRL_bio(out, crl)) {
394 ossl_x509crl_to_pem(
VALUE self)
400 if (!(out = BIO_new(BIO_s_mem()))) {
403 if (!PEM_write_bio_X509_CRL(out, crl)) {
412 ossl_x509crl_to_text(
VALUE self)
418 if (!(out = BIO_new(BIO_s_mem()))) {
421 if (!X509_CRL_print(out, crl)) {
433 ossl_x509crl_get_extensions(
VALUE self)
441 count = X509_CRL_get_ext_count(crl);
447 for (i=0; i<
count; i++) {
448 ext = X509_CRL_get_ext(crl, i);
459 ossl_x509crl_set_extensions(
VALUE self,
VALUE ary)
471 while ((ext = X509_CRL_delete_ext(crl, 0)))
472 X509_EXTENSION_free(ext);
475 if (!X509_CRL_add_ext(crl, ext, -1)) {
484 ossl_x509crl_add_extension(
VALUE self,
VALUE extension)
491 if (!X509_CRL_add_ext(crl, ext, -1)) {
#define RUBY_TYPED_FREE_IMMEDIATELY
#define X509_CRL_get0_lastUpdate(x)
EVP_PKEY * GetPrivPKeyPtr(VALUE obj)
#define X509_CRL_get0_nextUpdate(x)
VALUE rb_ary_push(VALUE ary, VALUE item)
ASN1_TIME * ossl_x509_time_adjust(ASN1_TIME *s, VALUE time)
BIO * ossl_obj2bio(volatile VALUE *pobj)
#define X509_CRL_get0_signature
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE ossl_membio2str(BIO *bio)
X509_NAME * GetX509NamePtr(VALUE)
X509_REVOKED * DupX509RevokedPtr(VALUE)
#define GetX509CRL(obj, crl)
VALUE ossl_to_der_if_possible(VALUE obj)
void ossl_clear_error(void)
RUBY_EXTERN VALUE rb_cObject
STACK_OF(X509) *ossl_x509_ary2sk(VALUE)
#define OSSL_BIO_reset(bio)
#define NewX509CRL(klass)
#define SetX509CRL(obj, crl)
VALUE ossl_x509ext_new(X509_EXTENSION *)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE ossl_x509crl_new(X509_CRL *crl)
VALUE ossl_x509revoked_new(X509_REVOKED *)
VALUE rb_define_module_under(VALUE outer, const char *name)
X509_EXTENSION * GetX509ExtPtr(VALUE)
#define RARRAY_AREF(a, i)
void Init_ossl_x509crl(void)
VALUE asn1time_to_time(const ASN1_TIME *time)
#define OSSL_Check_Kind(obj, klass)
void ossl_raise(VALUE exc, const char *fmt,...)
EVP_PKEY * GetPKeyPtr(VALUE obj)
VALUE ossl_x509name_new(X509_NAME *)
#define rb_check_frozen(obj)
VALUE rb_define_module(const char *name)
X509_CRL * GetX509CRLPtr(VALUE obj)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)