8 #define WrapPKCS12(klass, obj, p12) do { \
9 if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
10 (obj) = Data_Wrap_Struct((klass), 0, PKCS12_free, (p12)); \
13 #define GetPKCS12(obj, p12) do { \
14 Data_Get_Struct((obj), PKCS12, (p12)); \
15 if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
18 #define SafeGetPKCS12(obj, p12) do { \
19 OSSL_Check_Kind((obj), cPKCS12); \
20 GetPKCS12((obj), (p12)); \
23 #define ossl_pkcs12_set_key(o,v) rb_iv_set((o), "@key", (v))
24 #define ossl_pkcs12_set_cert(o,v) rb_iv_set((o), "@certificate", (v))
25 #define ossl_pkcs12_set_ca_certs(o,v) rb_iv_set((o), "@ca_certs", (v))
26 #define ossl_pkcs12_get_key(o) rb_iv_get((o), "@key")
27 #define ossl_pkcs12_get_cert(o) rb_iv_get((o), "@certificate")
28 #define ossl_pkcs12_get_ca_certs(o) rb_iv_get((o), "@ca_certs")
76 VALUE pass,
name, pkey, cert, ca, key_nid, cert_nid, key_iter, mac_iter, keytype;
78 char *passphrase, *friendlyname;
82 int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0;
85 rb_scan_args(argc, argv,
"46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype);
90 x509s =
NIL_P(ca) ?
NULL : ossl_x509_ary2sk(ca);
92 if (!
NIL_P(key_nid)) {
96 if (!
NIL_P(cert_nid)) {
100 if (!
NIL_P(key_iter))
102 if (!
NIL_P(mac_iter))
107 p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
108 nkey, ncert, kiter, miter, ktype);
109 sk_X509_pop_free(x509s, X509_free);
142 if(
rb_scan_args(argc, argv,
"02", &arg, &pass) == 0)
return self;
145 d2i_PKCS12_bio(in, &pkcs);
149 pkey = cert = ca =
Qnil;
150 if(!PKCS12_parse(pkcs, passphrase, &key, &x509, &x509s))
165 sk_X509_pop_free(x509s, X509_free);
183 if((len = i2d_PKCS12(p12,
NULL)) <= 0)
187 if(i2d_PKCS12(p12, &p) <= 0)