/** * return a KeyTransRecipientInfo object from the given object. * * @param obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static KeyTransRecipientInfo getInstance( Object obj) { if (obj == null || obj instanceof KeyTransRecipientInfo) { return (KeyTransRecipientInfo)obj; } if(obj instanceof ASN1Sequence) { return new KeyTransRecipientInfo((ASN1Sequence)obj); } throw new IllegalArgumentException( "Illegal object in KeyTransRecipientInfo: " + obj.getClass().getName()); }
/** * Return a KeyTransRecipientInfo object from the given object. * <p> * Accepted inputs: * <ul> * <li> null → null * <li> {@link KeyTransRecipientInfo} object * <li> {@link org.spongycastle.asn1.ASN1Sequence#getInstance(java.lang.Object) ASN1Sequence} input formats with KeyTransRecipientInfo structure inside * </ul> * * @param obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static KeyTransRecipientInfo getInstance( Object obj) { if (obj instanceof KeyTransRecipientInfo) { return (KeyTransRecipientInfo)obj; } if(obj != null) { return new KeyTransRecipientInfo(ASN1Sequence.getInstance(obj)); } return null; }
private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0) throws GeneralSecurityException, IOException { ASN1InputStream asn1inputstream = new ASN1InputStream(new ByteArrayInputStream(x509certificate.getTBSCertificate())); TBSCertificateStructure tbscertificatestructure = TBSCertificateStructure.getInstance(asn1inputstream.readObject()); AlgorithmIdentifier algorithmidentifier = tbscertificatestructure.getSubjectPublicKeyInfo().getAlgorithm(); IssuerAndSerialNumber issuerandserialnumber = new IssuerAndSerialNumber( tbscertificatestructure.getIssuer(), tbscertificatestructure.getSerialNumber().getValue()); Cipher cipher = Cipher.getInstance(algorithmidentifier.getAlgorithm().getId()); try{ cipher.init(1, x509certificate); }catch(InvalidKeyException e){ cipher.init(1,x509certificate.getPublicKey()); } DEROctetString deroctetstring = new DEROctetString(cipher.doFinal(abyte0)); RecipientIdentifier recipId = new RecipientIdentifier(issuerandserialnumber); return new KeyTransRecipientInfo( recipId, algorithmidentifier, deroctetstring); } }
return new KeyTransRecipientInfo(recipientId, algorithmId, octets);
public final RecipientInfo generate(GenericKey contentEncryptionKey) throws CMSException { byte[] encryptedKeyBytes; try { encryptedKeyBytes = wrapper.generateWrappedKey(contentEncryptionKey); } catch (OperatorException e) { throw new CMSException("exception wrapping content key: " + e.getMessage(), e); } RecipientIdentifier recipId; if (issuerAndSerial != null) { recipId = new RecipientIdentifier(issuerAndSerial); } else { recipId = new RecipientIdentifier(new DEROctetString(subjectKeyIdentifier)); } return new RecipientInfo(new KeyTransRecipientInfo(recipId, wrapper.getAlgorithmIdentifier(), new DEROctetString(encryptedKeyBytes))); } }
public final RecipientInfo generate(GenericKey contentEncryptionKey) throws CMSException { byte[] encryptedKeyBytes; try { encryptedKeyBytes = wrapper.generateWrappedKey(contentEncryptionKey); } catch (OperatorException e) { throw new CMSException("exception wrapping content key: " + e.getMessage(), e); } RecipientIdentifier recipId; if (issuerAndSerial != null) { recipId = new RecipientIdentifier(issuerAndSerial); } else { recipId = new RecipientIdentifier(new DEROctetString(subjectKeyIdentifier)); } return new RecipientInfo(new KeyTransRecipientInfo(recipId, wrapper.getAlgorithmIdentifier(), new DEROctetString(encryptedKeyBytes))); } }
final KeyTransRecipientInfo keyTransRecipientInfo = new KeyTransRecipientInfo(