|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--iaik.pkcs.pkcs7.RecipientInfo
This class implements the PKCS#7 RecipientInfo type.
The PKCS#7
Cryptographic Message Standard specifies the RecipientInfo
type for collecting all recipient-related information about some particular
recipient a PKCS#7 EnvelopedData or PKCS#7
SignedAndEnvelopedData object shall be sent to:
RecipientInfo ::= SEQUENCE {
version Version,
issuerAndSerialNumber IssuerAndSerialNumber,
keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
encryptedKey EncryptedKey }
EncryptedKey ::= OCTET STRING
The issuerAndSerialNumber field specifies the recipientīs
certificate by issuer distinguished name and issuer-specific serial number.
The keyEncryptionAlgorithm identifies the public-key algorithm
used for encrypting the randomly generated content-encryption key with
a recipient-specific public key. At this time only the PKCS#1
rsaEncryption method is supported. The encrypted content-encryption
key (used for encrypting the content) is stored in the encryptedKey
field.
For more information consult the RSA PKCS#7 specification.
This class provides several constructors and methods for creating a
RecipientInfo object, obtaining the component values,
and encrypting (respectively decrypting) the content-encryption key.
Assuming that cert represents the X509v3 certificate
of some intended recipient, a RecipientInfo object may be
created by supplying the certificate issuer distinguished name and the
issuer-specific serial number (through the certificate), and the recipientīs
key-encryption algorithm ID for encrypting the content-encryption key, e.g:
RecipientInfo recipient = new RecipientInfo(cert, AlgorithmID.rsaEncryption);
Note, that currently this class only supports the rsa(Encryption) key-encryption algorithm!
EnvelopedData,
EnvelopedDataStream,
SignedAndEnvelopedData,
SignedAndEnvelopedDataStream,
IssuerAndSerialNumber| Constructor Summary | |
RecipientInfo()
Default Constructor. |
|
RecipientInfo(ASN1Object obj)
Creates a RecipientInfo from an ASN1Object. |
|
RecipientInfo(IssuerAndSerialNumber issuer,
AlgorithmID keyEA,
byte[] encryptedKey)
Creates a RecipientInfo object with given
IssuerAndSerialNumber, key-encryption algorithm, and already
encrypted content encryption key. |
|
RecipientInfo(X509Certificate recipientCertificate,
AlgorithmID keyEA)
Creates a RecipientInfo object from a given certificate. |
|
| Method Summary | |
void |
decode(ASN1Object obj)
Decodes the given ASN.1 RecipientInfo object for parsing
the internal structure. |
SecretKey |
decryptKey(PrivateKey privateKey)
Uses a RSAPrivateKey to decrypt the encrypted content-encryption key. |
void |
encryptKey(SecretKey key)
Finishes the creation of a RecipientInfo object by encrypting
the given secret key.. |
byte[] |
getEncryptedKey()
Returns the encrypted content-encryption key. |
IssuerAndSerialNumber |
getIssuerAndSerialNumber()
Returns a specification of the recipient's certificate by issuer distinguished name and issuer-specific serial number. |
AlgorithmID |
getKeyEncryptionAlgorithm()
Returns the key-encryption algorithm used for encrypting the content-encryption key with the recipient's public key. |
int |
getVersion()
Returns the version of this RecipientInfo. |
ASN1Object |
toASN1Object()
Returns this RecipientInfo as ASN1Object. |
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 |
| Constructor Detail |
public RecipientInfo()
RecipientInfo
object and sets the version number to 0.
public RecipientInfo(IssuerAndSerialNumber issuer,
AlgorithmID keyEA,
byte[] encryptedKey)
RecipientInfo object with given
IssuerAndSerialNumber, key-encryption algorithm, and already
encrypted content encryption key. The already encrypted secret key
is supplied in a byte array and has been encrypted using the given
key-encryption algorithm.issuer - the IssuerAndSerialNumber specifying the
recipientīs certificate (and thereby the recipientīs
distinguished name and issuer-specific serial number)keyEncAlg - the ID of the key-encryption algorithm that has been
used for encrypting the content-encryption keyencryptedKey - the already encrypted secret key
public RecipientInfo(X509Certificate recipientCertificate,
AlgorithmID keyEA)
throws NoSuchAlgorithmException
IssuerAndSerialNumber
is obtained.
The public key from the given certificate will be used to encrypt the
symmetric content-encryption key with the given key-encryption algorithm
when calling the encryptKey method.recipientCertificate - the certificate of the recipientkeyEA - the algorithm for encrypting the symmetric key
public RecipientInfo(ASN1Object obj)
throws CodingException
RecipientInfo from an ASN1Object.
The ASN1Object supplied to this constructor represents an
already exisiting RecipientInfo object that may
have been created by calling toASN1Object.
obj - the RecipientInfo as ASN1Object| Method Detail |
public void decode(ASN1Object obj)
throws CodingException
RecipientInfo object for parsing
the internal structure.
This method internally is called when creating a PKCS#7 RecipientInfo
object from an already existing RecipientInfo object,
supplied as ASN1Object.
obj - the PKCS#7 RecipientInfo as ASN1Objectpublic ASN1Object toASN1Object()
RecipientInfo as ASN1Object.
Creates an ASN1 SEQUENCE object supplied with all the component values as
defined in the
PKCS#7 Cryptographic Message Standard specification. The ASN1Object returned
by this method may be used as parameter value when creating a
RecipientInfo object using the RecipientInfo(ASN1Object obj) constructor.
RecipientInfo as ASN1Object.
public SecretKey decryptKey(PrivateKey privateKey)
throws PKCSException,
InvalidKeyException
SecretKey.sk - the RSAPrivateKey to decrypt the encrypted content-encryption key.RecipientInfo
is not implemented, or the given private key is not a RSAPrivateKey)
public void encryptKey(SecretKey key)
throws PKCSException
RecipientInfo object by encrypting
the given secret key..
The public key from the recipientīs certificate is used to encrypt the given content-encryption key with the rsaEncryption method. The public key must be a RSAPublicKey.
key - the symmetric key to encryptRecipientInfo is not implemented,
or the recipientīs public key is not a RSAPublicKey)public int getVersion()
RecipientInfo.
This class implements version 0.public IssuerAndSerialNumber getIssuerAndSerialNumber()
IssuerAndSerialNumberpublic AlgorithmID getKeyEncryptionAlgorithm()
public byte[] getEncryptedKey()
public java.lang.String toString()
RecipientInfo object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||