Methods Summary |
---|
private byte[] | encodeObj(org.bouncycastle.asn1.DEREncodable obj)
if (obj != null)
{
return obj.getDERObject().getEncoded();
}
return null;
|
public byte[] | getContent(java.security.Key key, java.lang.String provider)
try
{
if (_data instanceof ByteArrayInputStream)
{
_data.reset();
}
return CMSUtils.streamToByteArray(getContentStream(key, provider).getContentStream());
}
catch (IOException e)
{
throw new RuntimeException("unable to parse internal stream: " + e);
}
|
protected CMSTypedStream | getContentFromSessionKey(java.security.Key sKey, java.security.Provider provider)
String encAlg = _encAlg.getObjectId().getId();
try
{
Cipher cipher;
cipher = CMSEnvelopedHelper.INSTANCE.getSymmetricCipher(encAlg, provider);
ASN1Object sParams = (ASN1Object)_encAlg.getParameters();
if (sParams != null && !(sParams instanceof ASN1Null))
{
AlgorithmParameters params = CMSEnvelopedHelper.INSTANCE.createAlgorithmParameters(encAlg, cipher.getProvider());
params.init(sParams.getEncoded(), "ASN.1");
cipher.init(Cipher.DECRYPT_MODE, sKey, params);
}
else
{
if (encAlg.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)
|| encAlg.equals(CMSEnvelopedDataGenerator.IDEA_CBC)
|| encAlg.equals(CMSEnvelopedDataGenerator.CAST5_CBC))
{
cipher.init(Cipher.DECRYPT_MODE, sKey, new IvParameterSpec(new byte[8]));
}
else
{
cipher.init(Cipher.DECRYPT_MODE, sKey);
}
}
return new CMSTypedStream(new CipherInputStream(_data, cipher));
}
catch (NoSuchAlgorithmException e)
{
throw new CMSException("can't find algorithm.", e);
}
catch (InvalidKeyException e)
{
throw new CMSException("key invalid in message.", e);
}
catch (NoSuchPaddingException e)
{
throw new CMSException("required padding not supported.", e);
}
catch (InvalidAlgorithmParameterException e)
{
throw new CMSException("algorithm parameters invalid.", e);
}
catch (IOException e)
{
throw new CMSException("error decoding algorithm parameters.", e);
}
|
public abstract CMSTypedStream | getContentStream(java.security.Key key, java.lang.String provider)
|
public java.lang.String | getKeyEncryptionAlgOID()return the object identifier for the key encryption algorithm.
return _keyEncAlg.getObjectId().getId();
|
public byte[] | getKeyEncryptionAlgParams()return the ASN.1 encoded key encryption algorithm parameters, or null if
there aren't any.
try
{
return encodeObj(_keyEncAlg.getParameters());
}
catch (Exception e)
{
throw new RuntimeException("exception getting encryption parameters " + e);
}
|
public java.security.AlgorithmParameters | getKeyEncryptionAlgorithmParameters(java.lang.String provider)Return an AlgorithmParameters object giving the encryption parameters
used to encrypt the key this recipient holds.
return getKeyEncryptionAlgorithmParameters(CMSUtils.getProvider(provider));
|
public java.security.AlgorithmParameters | getKeyEncryptionAlgorithmParameters(java.security.Provider provider)Return an AlgorithmParameters object giving the encryption parameters
used to encrypt the key this recipient holds.
try
{
byte[] enc = this.encodeObj(_keyEncAlg.getParameters());
if (enc == null)
{
return null;
}
AlgorithmParameters params = CMSEnvelopedHelper.INSTANCE.createAlgorithmParameters(getKeyEncryptionAlgOID(), provider);
params.init(enc, "ASN.1");
return params;
}
catch (NoSuchAlgorithmException e)
{
throw new CMSException("can't find parameters for algorithm", e);
}
catch (IOException e)
{
throw new CMSException("can't find parse parameters", e);
}
|
public RecipientId | getRID()
return _rid;
|