Skip to content

Commit 5571b7e

Browse files
committed
add PKCS7 "partial" flag support to OpenSSL::PKCS7.sign
1 parent 0313e1b commit 5571b7e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

ext/openssl/ossl_pkcs7.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,16 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
251251
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
252252
flg = NIL_P(flags) ? 0 : NUM2INT(flags);
253253
ret = NewPKCS7(cPKCS7);
254-
in = ossl_obj2bio(&data);
254+
255+
if (!(flg & PKCS7_PARTIAL))
256+
in = ossl_obj2bio(&data);
257+
255258
if(NIL_P(certs)) x509s = NULL;
256259
else{
257260
x509s = ossl_protect_x509_ary2sk(certs, &status);
258261
if(status){
259-
BIO_free(in);
262+
if (!(flg & PKCS7_PARTIAL))
263+
BIO_free(in);
260264
rb_jump_tag(status);
261265
}
262266
}
@@ -265,10 +269,17 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
265269
sk_X509_pop_free(x509s, X509_free);
266270
ossl_raise(ePKCS7Error, NULL);
267271
}
272+
268273
SetPKCS7(ret, pkcs7);
269-
ossl_pkcs7_set_data(ret, data);
274+
275+
if (!(flg & PKCS7_PARTIAL))
276+
ossl_pkcs7_set_data(ret, data);
277+
270278
ossl_pkcs7_set_err_string(ret, Qnil);
271-
BIO_free(in);
279+
280+
if (!(flg & PKCS7_PARTIAL))
281+
BIO_free(in);
282+
272283
sk_X509_pop_free(x509s, X509_free);
273284

274285
return ret;
@@ -1095,4 +1106,5 @@ Init_ossl_pkcs7(void)
10951106
DefPKCS7Const(BINARY);
10961107
DefPKCS7Const(NOATTR);
10971108
DefPKCS7Const(NOSMIMECAP);
1109+
DefPKCS7Const(PARTIAL);
10981110
}

0 commit comments

Comments
 (0)