/* c: static multi_split * */ private List<BIO> multiSplit(BIO bio, byte[] bound) throws IOException { List<BIO> parts = new ArrayList<BIO>(); byte[] linebuf = new byte[MAX_SMLEN]; int blen = bound.length; boolean eol = false; int len = 0; int part = 0; int state = 0; boolean first = true; BIO bpart = null; while ((len = bio.gets(linebuf, MAX_SMLEN)) > 0) { state = boundCheck(linebuf, len, bound, blen); if (state == 1) { first = true; part++; } else if (state == 2) { parts.add(bpart); return parts; } else if (part != 0) { // strip CR+LF from linebuf int[] tmp = new int[] {len}; boolean nextEol = stripEol(linebuf, tmp); len = tmp[0]; if (first) { first = false; if (bpart != null) { parts.add(bpart); } bpart = BIO.mem(); bpart.setMemEofReturn(0); } else if (eol) { bpart.write(NEWLINE, 0, 2); } eol = nextEol; if (len != 0) { bpart.write(linebuf, 0, len); } } } return parts; }
/* c: B64_read_PKCS7 * */ public PKCS7 readPKCS7Base64(BIO bio) throws IOException, PKCS7Exception { BIO bio64 = BIO.base64Filter(bio); return PKCS7.fromASN1(bio64); }