7#define NewPKCS12(klass) \
8 TypedData_Wrap_Struct((klass), &ossl_pkcs12_type, 0)
10#define SetPKCS12(obj, p12) do { \
11 if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
12 RTYPEDDATA_DATA(obj) = (p12); \
15#define GetPKCS12(obj, p12) do { \
16 TypedData_Get_Struct((obj), PKCS12, &ossl_pkcs12_type, (p12)); \
17 if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
20#define ossl_pkcs12_set_key(o,v) rb_iv_set((o), "@key", (v))
21#define ossl_pkcs12_set_cert(o,v) rb_iv_set((o), "@certificate", (v))
22#define ossl_pkcs12_set_ca_certs(o,v) rb_iv_set((o), "@ca_certs", (v))
23#define ossl_pkcs12_get_key(o) rb_iv_get((o), "@key")
24#define ossl_pkcs12_get_cert(o) rb_iv_get((o), "@certificate")
25#define ossl_pkcs12_get_ca_certs(o) rb_iv_get((o), "@ca_certs")
37ossl_pkcs12_free(
void *
ptr)
64ossl_pkcs12_initialize_copy(
VALUE self,
VALUE other)
66 PKCS12 *p12, *p12_old, *p12_new;
72 p12_new = ASN1_dup((i2d_of_void *)i2d_PKCS12, (d2i_of_void *)d2i_PKCS12, (
char *)p12);
107 VALUE pass,
name, pkey, cert, ca, key_nid, cert_nid, key_iter, mac_iter, keytype;
109 char *passphrase, *friendlyname;
113 int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0;
116 rb_scan_args(
argc,
argv,
"46", &pass, &
name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype);
122 if (!
NIL_P(key_nid)) {
126 if (!
NIL_P(cert_nid)) {
130 if (!
NIL_P(key_iter))
132 if (!
NIL_P(mac_iter))
138 x509s =
NIL_P(ca) ?
NULL : ossl_x509_ary2sk(ca);
139 p12 = PKCS12_create(passphrase, friendlyname,
key, x509, x509s,
140 nkey, ncert, kiter, miter, ktype);
141 sk_X509_pop_free(x509s, X509_free);
177 d2i_PKCS12_bio(in, &pkcs);
181 pkey = cert = ca =
Qnil;
185 if(!PKCS12_parse(pkcs, passphrase, &
key, &x509, &x509s))
203 sk_X509_pop_free(x509s, X509_free);
213ossl_pkcs12_to_der(
VALUE self)
221 if((
len = i2d_PKCS12(p12,
NULL)) <= 0)
225 if(i2d_PKCS12(p12, &p) <= 0)
char str[HTML_ESCAPE_MAX_LEN+1]
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
VALUE rb_define_module(const char *)
VALUE rb_cObject
Object class.
VALUE rb_protect(VALUE(*)(VALUE), VALUE, int *)
Protects a function call from potential global escapes from the function.
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
void ossl_raise(VALUE exc, const char *fmt,...)
#define ossl_str_adjust(str, p)
int *VALUE ossl_x509_sk2ary(const STACK_OF(X509) *certs)
STACK_OF(X509) *ossl_x509_ary2sk(VALUE)
BIO * ossl_obj2bio(volatile VALUE *pobj)
#define GetPKCS12(obj, p12)
#define ossl_pkcs12_set_ca_certs(o, v)
#define ossl_pkcs12_set_cert(o, v)
void Init_ossl_pkcs12(void)
#define SetPKCS12(obj, p12)
#define ossl_pkcs12_set_key(o, v)
EVP_PKEY * GetPKeyPtr(VALUE obj)
VALUE ossl_pkey_new(EVP_PKEY *pkey)
VALUE ossl_x509_new(X509 *)
X509 * GetX509CertPtr(VALUE)