/** * 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()); }
protected RecipientOperator getRecipientOperator(Recipient recipient) throws CMSException { return ((KeyTransRecipient)recipient).getRecipientOperator(keyEncAlg, messageAlgorithm, info.getEncryptedKey().getOctets()); } }
final KeyTransRecipientInfo kri = KeyTransRecipientInfo.getInstance(reci.toASN1Primitive()); final IssuerAndSerialNumber actual = IssuerAndSerialNumber.getInstance(kri.getRecipientIdentifier().toASN1Primitive()); encryptedKey = kri.getEncryptedKey().getOctets(); algEncryptedKey = kri.getKeyEncryptionAlgorithm();
KeyTransRecipientInformation( KeyTransRecipientInfo info, AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData) { super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData); this.info = info; RecipientIdentifier r = info.getRecipientIdentifier(); if (r.isTagged()) { ASN1OctetString octs = ASN1OctetString.getInstance(r.getId()); rid = new KeyTransRecipientId(octs.getOctets()); } else { IssuerAndSerialNumber iAnds = IssuerAndSerialNumber.getInstance(r.getId()); rid = new KeyTransRecipientId(iAnds.getName(), iAnds.getSerialNumber().getValue()); } }
public ASN1Integer getVersion() { if (info instanceof ASN1TaggedObject) { ASN1TaggedObject o = (ASN1TaggedObject)info; switch (o.getTagNo()) { case 1: return KeyAgreeRecipientInfo.getInstance(o, false).getVersion(); case 2: return getKEKInfo(o).getVersion(); case 3: return PasswordRecipientInfo.getInstance(o, false).getVersion(); case 4: return new ASN1Integer(0); // no syntax version for OtherRecipientInfo default: throw new IllegalStateException("unknown tag"); } } return KeyTransRecipientInfo.getInstance(info).getVersion(); }
public ASN1Encodable getInfo() { if (info instanceof ASN1TaggedObject) { ASN1TaggedObject o = (ASN1TaggedObject)info; switch (o.getTagNo()) { case 1: return KeyAgreeRecipientInfo.getInstance(o, false); case 2: return getKEKInfo(o); case 3: return PasswordRecipientInfo.getInstance(o, false); case 4: return OtherRecipientInfo.getInstance(o, false); default: throw new IllegalStateException("unknown tag"); } } return KeyTransRecipientInfo.getInstance(info); }
KeyTransRecipientInformation( KeyTransRecipientInfo info, AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData) { super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData); this.info = info; RecipientIdentifier r = info.getRecipientIdentifier(); if (r.isTagged()) { ASN1OctetString octs = ASN1OctetString.getInstance(r.getId()); rid = new KeyTransRecipientId(octs.getOctets()); } else { IssuerAndSerialNumber iAnds = IssuerAndSerialNumber.getInstance(r.getId()); rid = new KeyTransRecipientId(iAnds.getName(), iAnds.getSerialNumber().getValue()); } }
public ASN1Integer getVersion() { if (info instanceof ASN1TaggedObject) { ASN1TaggedObject o = (ASN1TaggedObject)info; switch (o.getTagNo()) { case 1: return KeyAgreeRecipientInfo.getInstance(o, false).getVersion(); case 2: return getKEKInfo(o).getVersion(); case 3: return PasswordRecipientInfo.getInstance(o, false).getVersion(); case 4: return new ASN1Integer(0); // no syntax version for OtherRecipientInfo default: throw new IllegalStateException("unknown tag"); } } return KeyTransRecipientInfo.getInstance(info).getVersion(); }
public ASN1Encodable getInfo() { if (info instanceof ASN1TaggedObject) { ASN1TaggedObject o = (ASN1TaggedObject)info; switch (o.getTagNo()) { case 1: return KeyAgreeRecipientInfo.getInstance(o, false); case 2: return getKEKInfo(o); case 3: return PasswordRecipientInfo.getInstance(o, false); case 4: return OtherRecipientInfo.getInstance(o, false); default: throw new IllegalStateException("unknown tag"); } } return KeyTransRecipientInfo.getInstance(info); }
/** * 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; }
protected RecipientOperator getRecipientOperator(Recipient recipient) throws CMSException { return ((KeyTransRecipient)recipient).getRecipientOperator(keyEncAlg, messageAlgorithm, info.getEncryptedKey().getOctets()); } }
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(