result = Bswabe.dec(pub, prv, cph); println("//demo for co.junwei.bswabe: end to dec"); if ((result.b == true) && (result.e.equals(crypted.key) == true)) result = Bswabe.dec(pub, prv_delegate_ok, cph); println("//demo for co.junwei.bswabe: end to dec with ok delegated key"); if ((result.b == true) && (result.e.equals(crypted.key) == true)) result = Bswabe.dec(pub, prv, cph); println("//demo for co.junwei.bswabe: end to dec"); if ((result.b == true) && (result.e.equals(crypted.key) == true)) result = Bswabe.dec(pub, prv_delegate_ko, cph); println("//demo for co.junwei.bswabe: end to dec with ko delegated key"); if ((result.b == true) && (result.e.equals(crypted.key) == true))
public void dec(String pubfile, String prvfile, String encfile, String decfile) throws Exception { byte[] aesBuf, cphBuf; byte[] plt; byte[] prv_byte; byte[] pub_byte; byte[][] tmp; BswabeCph cph; BswabePrv prv; BswabePub pub; /* get BswabePub from pubfile */ pub_byte = Common.suckFile(pubfile); pub = SerializeUtils.unserializeBswabePub(pub_byte); /* read ciphertext */ tmp = Common.readCpabeFile(encfile); aesBuf = tmp[0]; cphBuf = tmp[1]; cph = SerializeUtils.bswabeCphUnserialize(pub, cphBuf); /* get BswabePrv form prvfile */ prv_byte = Common.suckFile(prvfile); prv = SerializeUtils.unserializeBswabePrv(pub, prv_byte); BswabeElementBoolean beb = Bswabe.dec(pub, prv, cph); System.err.println("e = " + beb.e.toString()); if (beb.b) { plt = AESCoder.decrypt(beb.e.toBytes(), aesBuf); Common.spitFile(decfile, plt); } else { System.exit(0); } }