SignedData signedData = SignedData.getInstance(contentInfo.getContent()); Enumeration certificates = signedData.getCertificates().getObjects();
public PKCS12SafeBagFactory(ContentInfo info) { if (info.getContentType().equals(PKCSObjectIdentifiers.encryptedData)) { throw new IllegalArgumentException("encryptedData requires constructor with decryptor."); } this.safeBagSeq = ASN1Sequence.getInstance(ASN1OctetString.getInstance(info.getContent()).getOctets()); }
public PKCS12SafeBagFactory(ContentInfo info) { if (info.getContentType().equals(PKCSObjectIdentifiers.encryptedData)) { throw new IllegalArgumentException("encryptedData requires constructor with decryptor."); } this.safeBagSeq = ASN1Sequence.getInstance(ASN1OctetString.getInstance(info.getContent()).getOctets()); }
CMSSignedData dataParser = new CMSSignedData(trustBundleByte); ContentInfo contentInfo = dataParser.getContentInfo(); SignedData signedData = SignedData.getInstance(contentInfo.getContent()); CMSSignedData encapInfoBundle = new CMSSignedData(new CMSProcessableByteArray(signedData.getEncapContentInfo().getContent().getDERObject().getEncoded()),contentInfo); SignedData encapMetaData = SignedData.getInstance(encapInfoBundle.getContentInfo().getContent()); CMSProcessableByteArray cin = new CMSProcessableByteArray(((ASN1OctetString)encapMetaData.getEncapContentInfo().getContent()).getOctets()); CertificateFactory ucf = CertificateFactory.getInstance("X.509"); CMSSignedData unsignedParser = new CMSSignedData(cin.getInputStream()); ContentInfo unsginedEncapInfo = unsignedParser.getContentInfo(); SignedData metaData = SignedData.getInstance(unsginedEncapInfo.getContent()); Enumeration certificates = metaData.getCertificates().getObjects(); // Build certificate path while (certificates.hasMoreElements()) { DERObject certObj = (DERObject) certificates.nextElement(); InputStream bin = new ByteArrayInputStream(certObj.getDEREncoded()); X509Certificate cert = (X509Certificate) ucf.generateCertificate(bin); X500Name x500name = new JcaX509CertificateHolder(cert).getSubject(); RDN cn = x500name.getRDNs(BCStyle.CN)[0]; }
ASN1OctetString content = ASN1OctetString.getInstance(info.getContent()); byte[] data = ASN1OctetString.getInstance(info.getContent()).getOctets(); byte[] res = calculatePbeMac(mData.getMac().getAlgorithmId().getAlgorithm(), mData.getSalt(), itCount, passwd, data, provider);
/** * Return the content infos in the AuthenticatedSafe contained in this Pfx. * * @return an array of ContentInfo. */ public ContentInfo[] getContentInfos() { ASN1Sequence seq = ASN1Sequence.getInstance(ASN1OctetString.getInstance(this.pfx.getAuthSafe().getContent()).getOctets()); ContentInfo[] content = new ContentInfo[seq.size()]; for (int i = 0; i != seq.size(); i++) { content[i] = ContentInfo.getInstance(seq.getObjectAt(i)); } return content; }
ASN1OctetString content = ASN1OctetString.getInstance(info.getContent()); byte[] data = ASN1OctetString.getInstance(info.getContent()).getOctets(); byte[] res = calculatePbeMac(mData.getMac().getAlgorithmId().getObjectId(), mData.getSalt(), itCount, passwd, data, provider);
/** * Return the content infos in the AuthenticatedSafe contained in this Pfx. * * @return an array of ContentInfo. */ public ContentInfo[] getContentInfos() { ASN1Sequence seq = ASN1Sequence.getInstance(ASN1OctetString.getInstance(this.pfx.getAuthSafe().getContent()).getOctets()); ContentInfo[] content = new ContentInfo[seq.size()]; for (int i = 0; i != seq.size(); i++) { content[i] = ContentInfo.getInstance(seq.getObjectAt(i)); } return content; }
int itCount = mData.getIterationCount().intValue(); byte[] data = ((ASN1OctetString)info.getContent()).getOctets(); bIn = new ASN1InputStream(((ASN1OctetString)info.getContent()).getOctets()); ASN1InputStream dIn = new ASN1InputStream(((ASN1OctetString)c[i].getContent()).getOctets()); ASN1Sequence seq = (ASN1Sequence)dIn.readObject(); EncryptedData d = EncryptedData.getInstance(c[i].getContent()); byte[] octets = cryptData(false, d.getEncryptionAlgorithm(), password, wrongPKCS12Zero, d.getContent().getOctets()); System.out.println("extra " + ASN1Dump.dumpAsString(c[i].getContent()));
/** * Verify the MacData attached to the PFX is consistent with what is expected. * * @param macCalcProviderBuilder provider builder for the calculator for the MAC * @param password password to use * @return true if mac data is valid, false otherwise. * @throws PKCSException if there is a problem evaluating the MAC. * @throws IllegalStateException if no MAC is actually present */ public boolean isMacValid(PKCS12MacCalculatorBuilderProvider macCalcProviderBuilder, char[] password) throws PKCSException { if (hasMac()) { MacData pfxmData = pfx.getMacData(); MacDataGenerator mdGen = new MacDataGenerator(macCalcProviderBuilder.get(new AlgorithmIdentifier(pfxmData.getMac().getAlgorithmId().getAlgorithm(), new PKCS12PBEParams(pfxmData.getSalt(), pfxmData.getIterationCount().intValue())))); try { MacData mData = mdGen.build( password, ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets()); return Arrays.constantTimeAreEqual(mData.getEncoded(), pfx.getMacData().getEncoded()); } catch (IOException e) { throw new PKCSException("unable to process AuthSafe: " + e.getMessage()); } } throw new IllegalStateException("no MAC present on PFX"); }
saltLength = salt.length; byte[] data = ((ASN1OctetString)info.getContent()).getOctets(); bIn = new ASN1InputStream(((ASN1OctetString)info.getContent()).getOctets()); ASN1InputStream dIn = new ASN1InputStream(((ASN1OctetString)c[i].getContent()).getOctets()); ASN1Sequence seq = (ASN1Sequence)dIn.readObject(); EncryptedData d = EncryptedData.getInstance(c[i].getContent()); byte[] octets = cryptData(false, d.getEncryptionAlgorithm(), password, wrongPKCS12Zero, d.getContent().getOctets()); System.out.println("extra " + ASN1Dump.dumpAsString(c[i].getContent()));
/** * Verify the MacData attached to the PFX is consistent with what is expected. * * @param macCalcProviderBuilder provider builder for the calculator for the MAC * @param password password to use * @return true if mac data is valid, false otherwise. * @throws PKCSException if there is a problem evaluating the MAC. * @throws IllegalStateException if no MAC is actually present */ public boolean isMacValid(PKCS12MacCalculatorBuilderProvider macCalcProviderBuilder, char[] password) throws PKCSException { if (hasMac()) { MacData pfxmData = pfx.getMacData(); MacDataGenerator mdGen = new MacDataGenerator(macCalcProviderBuilder.get(new AlgorithmIdentifier(pfxmData.getMac().getAlgorithmId().getAlgorithm(), new PKCS12PBEParams(pfxmData.getSalt(), pfxmData.getIterationCount().intValue())))); try { MacData mData = mdGen.build( password, ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets()); return Arrays.constantTimeAreEqual(mData.getEncoded(), pfx.getMacData().getEncoded()); } catch (IOException e) { throw new PKCSException("unable to process AuthSafe: " + e.getMessage()); } } throw new IllegalStateException("no MAC present on PFX"); }
byte[] data = ((ASN1OctetString)mainInfo.getContent()).getOctets();
byte[] data = ((ASN1OctetString)mainInfo.getContent()).getOctets();