use of org.jruby.ext.openssl.impl.BIO in project jruby-openssl by jruby.
the class PKCS7 method decrypt.
@JRubyMethod(rest = true)
public IRubyObject decrypt(IRubyObject[] args) {
IRubyObject dflags;
if (Arity.checkArgumentCount(getRuntime(), args, 2, 3) == 3) {
dflags = args[2];
} else {
dflags = getRuntime().getNil();
}
PKey pkey = (PKey) args[0];
X509Cert cert = (X509Cert) args[1];
final PrivateKey privKey = pkey.getPrivateKey();
final X509AuxCertificate auxCert = cert.getAuxCert();
final int flg = dflags.isNil() ? 0 : RubyNumeric.fix2int(dflags);
final BIO out = BIO.mem();
try {
p7.decrypt(privKey, auxCert, out, flg);
} catch (PKCS7Exception pkcs7e) {
throw newPKCS7Error(getRuntime(), pkcs7e);
}
return membio2str(getRuntime(), out);
}
Aggregations