Skip to content

Commit 940bffa

Browse files
committed
add draft implementation of OpenSSL::PKCS7#finalize / PKCS7_final
1 parent 5571b7e commit 940bffa

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
@@ -889,6 +889,24 @@ ossl_pkcs7_to_pem(VALUE self)
889889
return str;
890890
}
891891

892+
static VALUE
893+
ossl_pkcs7_finalize(VALUE self, VALUE data, VALUE flags)
894+
{
895+
PKCS7 *pkcs7;
896+
BIO *in;
897+
898+
GetPKCS7(self, pkcs7);
899+
900+
int flg = NIL_P(flags) ? 0 : NUM2INT(flags);
901+
in = ossl_obj2bio(&data);
902+
903+
if (!PKCS7_final(pkcs7, in, flg)) {
904+
ossl_raise(ePKCS7Error, NULL);
905+
};
906+
907+
return self;
908+
}
909+
892910
/*
893911
* SIGNER INFO
894912
*/
@@ -1078,6 +1096,7 @@ Init_ossl_pkcs7(void)
10781096
rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0);
10791097
rb_define_alias(cPKCS7, "to_s", "to_pem");
10801098
rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);
1099+
rb_define_method(cPKCS7, "finalize", ossl_pkcs7_finalize, 2);
10811100

10821101
cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject);
10831102
rb_define_const(cPKCS7, "Signer", cPKCS7Signer);

0 commit comments

Comments
 (0)