|
|
|
@ -10628,9 +10628,10 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
// is not retained in EntityAttachment.type. Detect the actual CMS
|
|
|
|
// is not retained in EntityAttachment.type. Detect the actual CMS
|
|
|
|
// content type from the ContentInfo OID.
|
|
|
|
// content type from the ContentInfo OID.
|
|
|
|
ASN1ObjectIdentifier contentType = getCmsContentType(input);
|
|
|
|
ASN1ObjectIdentifier contentType = getCmsContentType(input);
|
|
|
|
|
|
|
|
boolean envelopedData = CMSObjectIdentifiers.envelopedData.equals(contentType);
|
|
|
|
boolean authEnveloped = CMSObjectIdentifiers.authEnvelopedData.equals(contentType);
|
|
|
|
boolean authEnveloped = CMSObjectIdentifiers.authEnvelopedData.equals(contentType);
|
|
|
|
|
|
|
|
|
|
|
|
if (!authEnveloped && !CMSObjectIdentifiers.envelopedData.equals(contentType))
|
|
|
|
if (!envelopedData && !authEnveloped)
|
|
|
|
throw new CMSException("Unsupported encrypted CMS content type: " + contentType);
|
|
|
|
throw new CMSException("Unsupported encrypted CMS content type: " + contentType);
|
|
|
|
|
|
|
|
|
|
|
|
int count = -1;
|
|
|
|
int count = -1;
|
|
|
|
@ -10646,18 +10647,18 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
|
|
|
|
|
|
|
|
JceKeyTransRecipient recipient;
|
|
|
|
JceKeyTransRecipient recipient;
|
|
|
|
if (authEnveloped) {
|
|
|
|
if (authEnveloped) {
|
|
|
|
CMSAuthEnvelopedDataParser authData = new CMSAuthEnvelopedDataParser(fis);
|
|
|
|
CMSAuthEnvelopedDataParser parser = new CMSAuthEnvelopedDataParser(fis);
|
|
|
|
recipientStore = authData.getRecipientInfos();
|
|
|
|
recipientStore = parser.getRecipientInfos();
|
|
|
|
contentAlgorithm = authData.getEncryptionAlgOID();
|
|
|
|
contentAlgorithm = parser.getEncryptionAlgOID();
|
|
|
|
contentAlgorithmOid = authData.getEncAlgOID();
|
|
|
|
contentAlgorithmOid = parser.getEncAlgOID();
|
|
|
|
parserClass = authData.getClass().getName();
|
|
|
|
parserClass = parser.getClass().getName();
|
|
|
|
recipient = new JceKeyTransAuthEnvelopedRecipient(privkey);
|
|
|
|
recipient = new JceKeyTransAuthEnvelopedRecipient(privkey);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
CMSEnvelopedDataParser envelopedData = new CMSEnvelopedDataParser(fis);
|
|
|
|
CMSEnvelopedDataParser parser = new CMSEnvelopedDataParser(fis);
|
|
|
|
recipientStore = envelopedData.getRecipientInfos();
|
|
|
|
recipientStore = parser.getRecipientInfos();
|
|
|
|
contentAlgorithm = envelopedData.getContentEncryptionAlgorithm();
|
|
|
|
contentAlgorithm = parser.getContentEncryptionAlgorithm();
|
|
|
|
contentAlgorithmOid = envelopedData.getEncryptionAlgOID();
|
|
|
|
contentAlgorithmOid = parser.getEncryptionAlgOID();
|
|
|
|
parserClass = envelopedData.getClass().getName();
|
|
|
|
parserClass = parser.getClass().getName();
|
|
|
|
recipient = new JceKeyTransEnvelopedRecipient(privkey);
|
|
|
|
recipient = new JceKeyTransEnvelopedRecipient(privkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -10989,16 +10990,12 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ASN1ObjectIdentifier getCmsContentType(File file)
|
|
|
|
private ASN1ObjectIdentifier getCmsContentType(File file) throws IOException, CMSException {
|
|
|
|
throws IOException, CMSException {
|
|
|
|
try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
|
|
|
|
try (InputStream is =
|
|
|
|
|
|
|
|
new BufferedInputStream(new FileInputStream(file))) {
|
|
|
|
|
|
|
|
ASN1Encodable object = new ASN1StreamParser(is).readObject();
|
|
|
|
ASN1Encodable object = new ASN1StreamParser(is).readObject();
|
|
|
|
if (!(object instanceof ASN1SequenceParser))
|
|
|
|
if (!(object instanceof ASN1SequenceParser))
|
|
|
|
throw new CMSException("Invalid CMS ContentInfo");
|
|
|
|
throw new CMSException("Invalid CMS ContentInfo");
|
|
|
|
|
|
|
|
ContentInfoParser contentInfo = new ContentInfoParser((ASN1SequenceParser) object);
|
|
|
|
ContentInfoParser contentInfo =
|
|
|
|
|
|
|
|
new ContentInfoParser((ASN1SequenceParser) object);
|
|
|
|
|
|
|
|
return contentInfo.getContentType();
|
|
|
|
return contentInfo.getContentType();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|