Bouncy Castle Cryptography Library 1.85

org.bouncycastle.cms.jcajce
Class JceKeyAgreeRecipient

java.lang.Object
  extended byorg.bouncycastle.cms.AbstractRecipient
      extended byorg.bouncycastle.cms.AbstractKeyAgreeRecipient
          extended byorg.bouncycastle.cms.jcajce.JceKeyAgreeRecipient
All Implemented Interfaces:
KeyAgreeRecipient, Recipient
Direct Known Subclasses:
JceKeyAgreeAuthenticatedRecipient, JceKeyAgreeAuthEnvelopedRecipient, JceKeyAgreeEnvelopedRecipient

public abstract class JceKeyAgreeRecipient
extends AbstractKeyAgreeRecipient


Field Summary
protected  EnvelopedDataHelper contentHelper
           
protected  EnvelopedDataHelper helper
           
protected  EnvelopedDataHelper unwrappingHelper
           
 
Constructor Summary
JceKeyAgreeRecipient(java.security.PrivateKey recipientKey)
           
 
Method Summary
protected  java.security.Key extractSecretKey(org.bouncycastle.asn1.x509.AlgorithmIdentifier keyEncryptionAlgorithm, org.bouncycastle.asn1.x509.AlgorithmIdentifier contentEncryptionAlgorithm, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo senderKey, org.bouncycastle.asn1.ASN1OctetString userKeyingMaterial, byte[] encryptedContentEncryptionKey)
           
 org.bouncycastle.asn1.x509.AlgorithmIdentifier getPrivateKeyAlgorithmIdentifier()
           
 JceKeyAgreeRecipient setAllowedContentAlgorithms(java.util.Set allowedContentAlgorithms)
          Set the content-encryption algorithms this recipient is willing to unwrap a key for.
 JceKeyAgreeRecipient setContentProvider(java.security.Provider provider)
          Set the provider to use for content processing.
 JceKeyAgreeRecipient setContentProvider(java.lang.String providerName)
          Set the provider to use for content processing.
 JceKeyAgreeRecipient setMinimumTagSize(int tagSizeInBits)
          Set the minimum AEAD authentication tag size (in bits) this recipient will accept.
 JceKeyAgreeRecipient setPrivateKeyAlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier privKeyAlgID)
          Set the algorithm identifier for the private key.
 JceKeyAgreeRecipient setProvider(java.security.Provider provider)
          Set the provider to use for key recovery and content processing.
 JceKeyAgreeRecipient setProvider(java.lang.String providerName)
          Set the provider to use for key recovery and content processing.
 JceKeyAgreeRecipient setUnwrappingProvider(java.security.Provider provider)
          Set the provider to use for unwrapping the content session key.
 JceKeyAgreeRecipient setUnwrappingProvider(java.lang.String providerName)
          Set the provider to use for unwrapping the content session key.
protected  java.security.Key unwrapSessionKey(org.bouncycastle.asn1.ASN1ObjectIdentifier wrapAlg, javax.crypto.SecretKey agreedKey, org.bouncycastle.asn1.ASN1ObjectIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
           
 
Methods inherited from class org.bouncycastle.cms.AbstractKeyAgreeRecipient
isEC, isGOST, isMQV, isRFC2631
 
Methods inherited from class org.bouncycastle.cms.AbstractRecipient
checkTagSize, isContentAlgorithmAllowed, setAllowedContentAlgorithmSet, setMinimumTagSizeInBits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.bouncycastle.cms.KeyAgreeRecipient
getRecipientOperator
 

Field Detail

helper

protected EnvelopedDataHelper helper

contentHelper

protected EnvelopedDataHelper contentHelper

unwrappingHelper

protected EnvelopedDataHelper unwrappingHelper
Constructor Detail

JceKeyAgreeRecipient

public JceKeyAgreeRecipient(java.security.PrivateKey recipientKey)
Method Detail

setProvider

public JceKeyAgreeRecipient setProvider(java.security.Provider provider)
Set the provider to use for key recovery and content processing.

Parameters:
provider - provider to use.
Returns:
this recipient.

setProvider

public JceKeyAgreeRecipient setProvider(java.lang.String providerName)
Set the provider to use for key recovery and content processing.

Parameters:
providerName - the name of the provider to use.
Returns:
this recipient.

setUnwrappingProvider

public JceKeyAgreeRecipient setUnwrappingProvider(java.security.Provider provider)
Set the provider to use for unwrapping the content session key.

Parameters:
provider - provider to use.
Returns:
this recipient.

setUnwrappingProvider

public JceKeyAgreeRecipient setUnwrappingProvider(java.lang.String providerName)
Set the provider to use for unwrapping the content session key.

Parameters:
providerName - the name of the provider to use.
Returns:
this recipient.

setContentProvider

public JceKeyAgreeRecipient setContentProvider(java.security.Provider provider)
Set the provider to use for content processing. If providerName is null a "no provider" search will be used to satisfy getInstance calls.

Parameters:
provider - the provider to use.
Returns:
this recipient.

setContentProvider

public JceKeyAgreeRecipient setContentProvider(java.lang.String providerName)
Set the provider to use for content processing. If providerName is null a "no provider" search will be used to satisfy getInstance calls.

Parameters:
providerName - the name of the provider to use.
Returns:
this recipient.

setPrivateKeyAlgorithmIdentifier

public JceKeyAgreeRecipient setPrivateKeyAlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier privKeyAlgID)
Set the algorithm identifier for the private key. You'll want to use this if you are dealing with a HSM and it is not possible to get the encoding of the private key.

Parameters:
privKeyAlgID - the algorithm identifier for the private key.
Returns:
this recipient.

setAllowedContentAlgorithms

public JceKeyAgreeRecipient setAllowedContentAlgorithms(java.util.Set allowedContentAlgorithms)
Set the content-encryption algorithms this recipient is willing to unwrap a key for. When set, an attempt to recover content protected under any other algorithm is rejected, mitigating an attacker substituting a weaker content-encryption algorithm into the recipient info.

Parameters:
allowedContentAlgorithms - the set of permitted content-encryption algorithm OIDs.
Returns:
this recipient.

setMinimumTagSize

public JceKeyAgreeRecipient setMinimumTagSize(int tagSizeInBits)
Set the minimum AEAD authentication tag size (in bits) this recipient will accept. When set, an attempt to recover AuthEnvelopedData whose content algorithm carries a shorter tag is rejected, mitigating an attacker downgrading the tag to a weaker length.

Parameters:
tagSizeInBits - the minimum acceptable AEAD tag size, in bits.
Returns:
this recipient.

unwrapSessionKey

protected java.security.Key unwrapSessionKey(org.bouncycastle.asn1.ASN1ObjectIdentifier wrapAlg,
                                             javax.crypto.SecretKey agreedKey,
                                             org.bouncycastle.asn1.ASN1ObjectIdentifier contentEncryptionAlgorithm,
                                             byte[] encryptedContentEncryptionKey)
                                      throws CMSException,
                                             java.security.InvalidKeyException,
                                             java.security.NoSuchAlgorithmException
Throws:
CMSException
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException

extractSecretKey

protected java.security.Key extractSecretKey(org.bouncycastle.asn1.x509.AlgorithmIdentifier keyEncryptionAlgorithm,
                                             org.bouncycastle.asn1.x509.AlgorithmIdentifier contentEncryptionAlgorithm,
                                             org.bouncycastle.asn1.x509.SubjectPublicKeyInfo senderKey,
                                             org.bouncycastle.asn1.ASN1OctetString userKeyingMaterial,
                                             byte[] encryptedContentEncryptionKey)
                                      throws CMSException
Throws:
CMSException

getPrivateKeyAlgorithmIdentifier

public org.bouncycastle.asn1.x509.AlgorithmIdentifier getPrivateKeyAlgorithmIdentifier()

Bouncy Castle Cryptography Library 1.85