Skip to content

Commit 879c139

Browse files
committed
add draft implementation of OpenSSL::PKCS7#finalize / PKCS7_final
1 parent 0c18627 commit 879c139

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ext/openssl/ossl_pkcs7.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,24 @@ ossl_pkcs7_to_pem(VALUE self)
874874
return str;
875875
}
876876

877+
static VALUE
878+
ossl_pkcs7_finalize(VALUE self, VALUE data, VALUE flags)
879+
{
880+
PKCS7 *pkcs7;
881+
BIO *in;
882+
883+
GetPKCS7(self, pkcs7);
884+
885+
int flg = NIL_P(flags) ? 0 : NUM2INT(flags);
886+
in = ossl_obj2bio(&data);
887+
888+
if (!PKCS7_final(pkcs7, in, flg)) {
889+
ossl_raise(ePKCS7Error, NULL);
890+
};
891+
892+
return self;
893+
}
894+
877895
/*
878896
* SIGNER INFO
879897
*/
@@ -1063,6 +1081,7 @@ Init_ossl_pkcs7(void)
10631081
rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0);
10641082
rb_define_alias(cPKCS7, "to_s", "to_pem");
10651083
rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);
1084+
rb_define_method(cPKCS7, "finalize", ossl_pkcs7_finalize, 2);
10661085

10671086
cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject);
10681087
rb_define_const(cPKCS7, "Signer", cPKCS7Signer);

0 commit comments

Comments
 (0)