|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.RecipientInfo
public abstract class RecipientInfo
The CMS type RecipientInfo.
The Cryptographic Message Syntax (CMS) (RFC 5652)
specifies the RecipientInfo
type for collecting all recipient-related
information about some particular recipient a CMS EnvelopedData
or
CMS AuthenticatedData
shall be sent to:
RecipientInfo ::= CHOICE { ktri KeyTransRecipientInfo, kari [1] KeyAgreeRecipientInfo, kekri [2] KEKRecipientInfo, pwri [3] PasswordRecipientinfo, ori [4] OtherRecipientInfo }
The RecipientInfo type depends on the key management algorithm used for the
recipient of an EnvelopedData
or AuthenticatedData
.
CMS provides three alternatives:
KeyTransRecipientInfo
for the public key of the recipient
certificate, identified by IssuerAndSerialNumber
. CMS recommends to use RSA for encrypting
the content encryption key.
KeyAgreeRecipientInfo
may transfer the encrypted content
encryption key to one or more recipient using the same key
agreement algorithm and domain parameters for that algorithm.
CMS recommends to use ESDH with an ephemeral sender key.
KEKRecipientInfo
using a CMS key wrap algorithm like
AES key wrap.
PasswordRecipientInfo
using a key derivation algorithm like
PBKDF2 as specified by RFC 2898 (PKCS#5) and
a key encryption algorithm like PWRI-KEK as specified
by RFC 3211.
OtherRecipientInfo
Field Summary | |
---|---|
static int |
KEK_RECIPIENT_INFO
The CMS RecipientInfo type KEKRecipientInfo . |
static int |
KEY_AGREE_RECIPIENT_INFO
The CMS RecipientInfo type KeyAgreeRecipientInfo . |
static int |
KEY_TRANSPORT_RECIPIENT_INFO
The CMS RecipientInfo type KeyTransRecipientInfo . |
protected AlgorithmID |
keyEncryptionAlgorithm_
The algorithm used for encrypting the content encryption key. |
static int |
OTHER_RECIPIENT_INFO
The CMS RecipientInfo type OtherRecipientInfo . |
static int |
PASSWORD_RECIPIENT_INFO
The CMS RecipientInfo type PasswordRecipientInfo . |
protected SecurityProvider |
securityProvider_
The SecurityProvider providing the required cryptographic engines. |
protected int |
version_
The CMS version this RecipientInfo represents. |
Constructor Summary | |
---|---|
protected |
RecipientInfo()
Creates an empty RecipientInfo. |
Method Summary | |
---|---|
static SET |
createRecipientInfos(java.util.Vector recipients)
Creates a SET of the supplied RecipientInfos. |
javax.crypto.SecretKey |
decryptKey(java.security.Key kek)
Decrypts the encrypted content-encryption key this RecipientInfo holds for the given recipient. |
javax.crypto.SecretKey |
decryptKey(java.security.Key kek,
KeyIdentifier recipientIdentifier)
Decrypts the encrypted content-encryption key this RecipientInfo holds for the given recipient. |
abstract javax.crypto.SecretKey |
decryptKey(java.security.Key kek,
KeyIdentifier recipientIdentifier,
java.lang.String cekAlgName)
Decrypts the encrypted content-encryption key this RecipientInfo holds for the given recipient. |
javax.crypto.SecretKey |
decryptKey(java.security.Key kek,
java.lang.String cekAlgName)
Decrypts the encrypted content-encryption key this RecipientInfo holds for the given recipient. |
abstract void |
encryptKey(javax.crypto.SecretKey cek)
Encrypts the given secret content encryption key for the recipient(s) this RecipientInfo represents. |
abstract byte[] |
getEncryptedKey(KeyIdentifier recipientIdentifier)
Returns the encrypted content-encryption key for the recipient with the given keyIdentfier. |
AlgorithmID |
getKeyEncryptionAlgorithm()
Returns the key-encryption algorithm used for encrypting the content-encryption key with the recipient public key. |
abstract KeyIdentifier[] |
getRecipientIdentifiers()
Returns the key identifier(s) belonging to the recipient(s) of this RecipientInfo. |
int |
getRecipientInfoType()
Returns the type of the recipient info. |
SecurityProvider |
getSecurityProvider()
Gets the SecurityProvider installed for this RecipientInfo. |
int |
getVersion()
Returns the CMS version this RecipientInfo represents. |
abstract boolean |
isRecipientInfoFor(KeyIdentifier recipientIdentifier)
Checks if this is a RecipientInfo for the recipient identified by the given key identifier. |
abstract CertificateIdentifier |
isRecipientInfoFor(X509Certificate recipientCertificate)
Checks if this is a RecipientInfo for the given recipient certificate. |
static RecipientInfo |
parseRecipientInfo(ASN1Object obj)
Parses a RecipientInfo from the supplied ASN1Object. |
static RecipientInfo |
parseRecipientInfo(ASN1Object obj,
SecurityProvider securityProvider)
Parses a RecipientInfo from the supplied ASN1Object. |
static RecipientInfo |
parseRecipientInfo(java.io.InputStream is)
Parses a DER encoded RecipientInfo from the supplied input stream. |
static RecipientInfo |
parseRecipientInfo(java.io.InputStream is,
SecurityProvider securityProvider)
Parses a DER encoded RecipientInfo from the supplied input stream. |
static RecipientInfo[] |
parseRecipientInfos(java.io.InputStream is)
Parses a SET of DER encoded RecipientInfos from the supplied input stream. |
static RecipientInfo[] |
parseRecipientInfos(java.io.InputStream is,
SecurityProvider securityProvider)
Parses a SET of DER encoded RecipientInfos from the supplied input stream. |
void |
setSecurityProvider(SecurityProvider securityProvider)
Sets the SecurityProvider for this RecipientInfo. |
abstract java.lang.String |
toString()
Returns a string giving some information about this RecipientInfo object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface iaik.asn1.ASN1Type |
---|
decode, toASN1Object |
Field Detail |
---|
public static final int KEY_TRANSPORT_RECIPIENT_INFO
KeyTransRecipientInfo
.
public static final int KEY_AGREE_RECIPIENT_INFO
KeyAgreeRecipientInfo
.
public static final int KEK_RECIPIENT_INFO
KEKRecipientInfo
.
public static final int PASSWORD_RECIPIENT_INFO
PasswordRecipientInfo
.
public static final int OTHER_RECIPIENT_INFO
OtherRecipientInfo
.
protected int version_
protected AlgorithmID keyEncryptionAlgorithm_
protected SecurityProvider securityProvider_
Constructor Detail |
---|
protected RecipientInfo()
Method Detail |
---|
public int getVersion()
public abstract void encryptKey(javax.crypto.SecretKey cek) throws CMSException
cek
- the symmetric content encryption key to encrypt
CMSException
- if the key encryption process fails for some
reason (e.g. the key-encryption algortihm used
by this RecipientInfo
is not implemented,
or the recipient key is invalid, ...)public abstract javax.crypto.SecretKey decryptKey(java.security.Key kek, KeyIdentifier recipientIdentifier, java.lang.String cekAlgName) throws CMSException, java.security.InvalidKeyException
The recovered key is returned as SecretKey
.
kek
- the recipient key used to decrypt the encrypted content-encryption key.recipientIdentifier
- information to be used for getting the right encrypted content
encryption key for the right recipient; may be required if this
RecipientInfo holds content encryption keys for more than one
recipient (see KeyAgreeRecipientInfo
)cekAlgName
- the name of the content encryption key (e.g. "AES") to be set for the
SecretKey object created by this method
CMSException
- if the key-decryption process fails for some reason (e.g. the
key-encryption algorithm used by this RecipientInfo
is not supported, a padding error occurs during decryption...
java.security.InvalidKeyException
- if the specified private key is not validpublic javax.crypto.SecretKey decryptKey(java.security.Key kek, KeyIdentifier recipientIdentifier) throws CMSException, java.security.InvalidKeyException
The recovered key is returned as SecretKey
.
kek
- the recipient key used to decrypt the encrypted content-encryption key.recipientIdentifier
- information to be used for getting the right encrypted content
encryption key for the right recipient; may be required if this
RecipientInfo holds content encryption keys for more than one
recipient (see KeyAgreeRecipientInfo
)
CMSException
- if the key-decryption process fails for some reason (e.g. the
key-encryption algorithm used by this RecipientInfo
is not supported, a padding error occurs during decryption...
java.security.InvalidKeyException
- if the specified private key is not validpublic javax.crypto.SecretKey decryptKey(java.security.Key kek) throws CMSException, java.security.InvalidKeyException
The recovered key is returned as SecretKey
.
Note that a KeyAgreeRecipientInfo
may
hold recipient encrypted keys for more than only one recipient; so it may
be appropriate to specify a recipient identifier when decrypting
the encrypted content-encryption key. Otherwise
all included recipient encrypted keys may be tried to be decrypted with the
given key encryption key, which might give some overhead.
kek
- the recipient key used to decrypt the encrypted content-encryption key.
CMSException
- if the key-decryption process fails for some reason (e.g. the
key-encryption algorithm used by this RecipientInfo
is not supported, a padding error occurs during decryption...
java.security.InvalidKeyException
- if the specified private key is not validpublic javax.crypto.SecretKey decryptKey(java.security.Key kek, java.lang.String cekAlgName) throws CMSException, java.security.InvalidKeyException
The recovered key is returned as SecretKey
.
Note that a KeyAgreeRecipientInfo
may
hold recipient encrypted keys for more than only one recipient; so it may
be appropriate to specify a recipient identifier when decrypting
the encrypted content-encryption key. Otherwise
all included recipient encrypted keys may be tried to be decrypted with the
given key encryption key, which might give some overhead.
kek
- the recipient key used to decrypt the encrypted content-encryption key.cekAlgName
- the name of the content encryption key (e.g. "AES") to be set for the
SecretKey object created by this method
CMSException
- if the key-decryption process fails for some reason (e.g. the
key-encryption algorithm used by this RecipientInfo
is not supported, a padding error occurs during decryption...
java.security.InvalidKeyException
- if the specified private key is not validpublic abstract byte[] getEncryptedKey(KeyIdentifier recipientIdentifier) throws CMSException
A RecipientInfo only may hold one single encrypted content-encryption
key (e.g. KeyTransRecipientInfo
),
but may hold encrypted content-encryption keys for more than one
recipients (e.g. KeyAgreeRecipientInfo
),
each of them identified by its corresponding key identifier.
recipientIdentifier
- information to be used for getting the right encrypted content
encryption key for the right recipient; may be required if this
RecipientInfo holds content encryption keys for more than one
recipient (see KeyAgreeRecipientInfo
)
CMSException
- if no recipient with this key identifier is includedpublic abstract KeyIdentifier[] getRecipientIdentifiers()
A RecipientInfo only may represent only one single recipient
(e.g. KeyTransRecipientInfo
),
but may represent more than one recipients (e.g. KeyAgreeRecipientInfo
),
each of them identified by its corresponding key identifier.
public abstract boolean isRecipientInfoFor(KeyIdentifier recipientIdentifier)
recipientIdentifier
- the key identifier belonging to the recipient
we are searching for
true
if this RecipientInfo belongs to the particular
recipient in mind, false
if notpublic abstract CertificateIdentifier isRecipientInfoFor(X509Certificate recipientCertificate)
This method only may be used for asking if a KeyTransRecipientInfo
or KeyAgreeRecipientInfo
belongs to the recipient with the given
certificate. Class KEKRecipientInfo
has to implement this method, too, but always will return null
since the KEKRecipientInfo does not use certificates.
recipientCertificate
- the certificate of the recipient
null
if notpublic int getRecipientInfoType()
KEY_TRANSPORT_RECIPIENT_INFO
(0) or
KEY_AGREE_RECIPIENT_INFO
(1) or
KEK_RECIPIENT_INFO
(2) or
PASSWORD_RECIPIENT_INFO
(3) or
OTHER_RECIPIENT_INFO
(4)public AlgorithmID getKeyEncryptionAlgorithm()
public void setSecurityProvider(SecurityProvider securityProvider)
This method allows to explicitly set a SecurityProvider for this RecipientInfo. If no explicit SecurityProvider is set, the default system wide installed SecurityProvider will be used for the required cryptographic operations.
When parsing a KeyAgreeRecipientInfo
or a KEKRecipientInfo
, it might be preferable to supply the SecurityProvider immediately when creating
the RecipientInfo.
securityProvider
- the SecurityProvider to be setpublic SecurityProvider getSecurityProvider()
If no explicit SecurityProvider has been set
for this object,
the default system wide installed SecurityProvider will be used for the required cryptographic
operations. However, this method will return null
if it does not have its own
SecurityProvider.
null
if
this object does not have its own SecurityProviderpublic static RecipientInfo[] parseRecipientInfos(java.io.InputStream is) throws java.io.IOException, CMSParsingException
is
- the input stream supplying the SET of DER encoded RecipientInfo
KeyTransRecipientInfos
,
KeyAgreeRecipientInfos
KEKRecipientInfos
,
PasswordRecipientInfos
,
or OtherRecipientInfos
,
depending on the types of RecipientInfos contained in the SET
java.io.IOException
- if an I/O error occurs while reading from the stream
CMSParsingException
- if an error occurs while parsing the RecipientInfopublic static RecipientInfo[] parseRecipientInfos(java.io.InputStream is, SecurityProvider securityProvider) throws java.io.IOException, CMSParsingException
is
- the input stream supplying the SET of DER encoded RecipientInfosecurityProvider
- the securityProvider to be used, if null
use the
default system-wide installed SecurityProvider
KeyTransRecipientInfos
,
KeyAgreeRecipientInfos
KEKRecipientInfos
,
PasswordRecipientInfos
,
or OtherRecipientInfos
,
depending on the types of RecipientInfos contained in the SET
java.io.IOException
- if an I/O error occurs while reading from the stream
CMSParsingException
- if an error occurs while parsing the RecipientInfopublic static RecipientInfo parseRecipientInfo(java.io.InputStream is) throws java.io.IOException, CMSParsingException
is
- the input stream supplying the DER encoded RecipientInfo
KeyTransRecipientInfo
,
KeyAgreeRecipientInfo
KEKRecipientInfo
,
PasswordRecipientInfo
,
or OtherRecipientInfo
,
depending on the type of RecipientInfo
java.io.IOException
- if an I/O error occurs while reading from the stream
CMSParsingException
- if an error occurs while parsing the RecipientInfopublic static RecipientInfo parseRecipientInfo(java.io.InputStream is, SecurityProvider securityProvider) throws java.io.IOException, CMSParsingException
is
- the input stream supplying the DER encoded RecipientInfosecurityProvider
- the securityProvider to be used, if null
use the
default system-wide installed SecurityProvider
KeyTransRecipientInfo
,
KeyAgreeRecipientInfo
KEKRecipientInfo
,
PasswordRecipientInfo
,
or OtherRecipientInfo
,
depending on the type of RecipientInfo
java.io.IOException
- if an I/O error occurs while reading from the stream
CMSParsingException
- if an error occurs while parsing the RecipientInfopublic static RecipientInfo parseRecipientInfo(ASN1Object obj) throws CMSParsingException
obj
- the RecipientInfo as ASN1Object
KeyTransRecipientInfo
,
KeyAgreeRecipientInfo
KEKRecipientInfo
,
PasswordRecipientInfo
,
or OtherRecipientInfo
,
depending on the type of RecipientInfo
CMSParsingException
- if an error occurs while parsing the RecipientInfopublic static RecipientInfo parseRecipientInfo(ASN1Object obj, SecurityProvider securityProvider) throws CMSParsingException
obj
- the RecipientInfo as ASN1ObjectsecurityProvider
- the securityProvider to be used, if null
use the
default system-wide installed SecurityProvider
KeyTransRecipientInfo
,
KeyAgreeRecipientInfo
KEKRecipientInfo
,
PasswordRecipientInfo
,
or OtherRecipientInfo
,
depending on the type of RecipientInfo
CMSParsingException
- if an error occurs while parsing the RecipientInfopublic static SET createRecipientInfos(java.util.Vector recipients) throws CMSException
This method creates a SET OF the supplied RecipientInfos thereby using the right tags depending on the RecipientInfo version number:
RecipientInfo ::= CHOICE { ktri KeyTransRecipientInfo, kari [1] KeyAgreeRecipientInfo, kekri [2] KEKRecipientInfo, pwri [3] PasswordRecipientInfo, ori [4] OtherRecipientInfo }
recipients
- the recipientInfos to be processed
CMSException
- if an error occurs while creating the ASN.1 SETpublic abstract java.lang.String toString()
RecipientInfo
object.
toString
in class java.lang.Object
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |