API java : EncryptedPrivateKeyInfo


javax.crypto
Class EncryptedPrivateKeyInfo

java.lang.Object
  extended by javax.crypto.EncryptedPrivateKeyInfo

public class EncryptedPrivateKeyInfo
extends Object

This class implements the EncryptedPrivateKeyInfo type as defined in PKCS #8.

Its ASN.1 definition is as follows:

  1. EncryptedPrivateKeyInfo ::= SEQUENCE {
  2. encryptionAlgorithm AlgorithmIdentifier,
  3. encryptedData OCTET STRING }
  4.  
  5. AlgorithmIdentifier ::= SEQUENCE {
  6. algorithm OBJECT IDENTIFIER,
  7. parameters ANY DEFINED BY algorithm OPTIONAL }

Since:
1.4
See Also:
PKCS8EncodedKeySpec

Constructor Summary
EncryptedPrivateKeyInfo(AlgorithmParameters algParams, byte[] encryptedData)
          Constructs an EncryptedPrivateKeyInfo from the encryption algorithm parameters and the encrypted data.
EncryptedPrivateKeyInfo(byte[] encoded)
          Constructs (i.e., parses) an EncryptedPrivateKeyInfo from its ASN.1 encoding.
EncryptedPrivateKeyInfo(String algName, byte[] encryptedData)
          Constructs an EncryptedPrivateKeyInfo from the encryption algorithm name and the encrypted data.
 
Method Summary
 String getAlgName()
          Returns the encryption algorithm.
 AlgorithmParameters getAlgParameters()
          Returns the algorithm parameters used by the encryption algorithm.
 byte[] getEncoded()
          Returns the ASN.1 encoding of this object.
 byte[] getEncryptedData()
          Returns the encrypted data.
 PKCS8EncodedKeySpec getKeySpec(Cipher cipher)
          Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
 PKCS8EncodedKeySpec getKeySpec(Key decryptKey)
          Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
 PKCS8EncodedKeySpec getKeySpec(Key decryptKey, Provider provider)
          Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
 PKCS8EncodedKeySpec getKeySpec(Key decryptKey, String providerName)
          Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptedPrivateKeyInfo

public EncryptedPrivateKeyInfo(byte[] encoded)
                        throws IOException
Constructs (i.e., parses) an EncryptedPrivateKeyInfo from its ASN.1 encoding.

Parameters:
encoded - the ASN.1 encoding of this object. The contents of the array are copied to protect against subsequent modification.
Throws:
NullPointerException - if the encoded is null.
IOException - if error occurs when parsing the ASN.1 encoding.

EncryptedPrivateKeyInfo

public EncryptedPrivateKeyInfo(String algName,
                               byte[] encryptedData)
                        throws NoSuchAlgorithmException
Constructs an EncryptedPrivateKeyInfo from the encryption algorithm name and the encrypted data.

Note: This constructor will use null as the value of the algorithm parameters. If the encryption algorithm has parameters whose value is not null, a different constructor, e.g. EncryptedPrivateKeyInfo(AlgorithmParameters, byte[]), should be used.

Parameters:
algName - encryption algorithm name. See Appendix A in the Java Cryptography Extension Reference Guide for information about standard Cipher algorithm names.
encryptedData - encrypted data. The contents of encrypedData are copied to protect against subsequent modification when constructing this object.
Throws:
NullPointerException - if algName or encryptedData is null.
IllegalArgumentException - if encryptedData is empty, i.e. 0-length.
NoSuchAlgorithmException - if the specified algName is not supported.

EncryptedPrivateKeyInfo

public EncryptedPrivateKeyInfo(AlgorithmParameters algParams,
                               byte[] encryptedData)
                        throws NoSuchAlgorithmException
Constructs an EncryptedPrivateKeyInfo from the encryption algorithm parameters and the encrypted data.

Parameters:
algParams - the algorithm parameters for the encryption algorithm. algParams.getEncoded() should return the ASN.1 encoded bytes of the parameters field of the AlgorithmIdentifer component of the EncryptedPrivateKeyInfo type.
encryptedData - encrypted data. The contents of encrypedData are copied to protect against subsequent modification when constructing this object.
Throws:
NullPointerException - if algParams or encryptedData is null.
IllegalArgumentException - if encryptedData is empty, i.e. 0-length.
NoSuchAlgorithmException - if the specified algName of the specified algParams parameter is not supported.
Method Detail

getAlgName

public String getAlgName()
Returns the encryption algorithm.

Note: Standard name is returned instead of the specified one in the constructor when such mapping is available. See Appendix A in the Java Cryptography Extension Reference Guide for information about standard Cipher algorithm names.

Returns:
the encryption algorithm name.

getAlgParameters

public AlgorithmParameters getAlgParameters()
Returns the algorithm parameters used by the encryption algorithm.

Returns:
the algorithm parameters.

getEncryptedData

public byte[] getEncryptedData()
Returns the encrypted data.

Returns:
the encrypted data. Returns a new array each time this method is called.

getKeySpec

public PKCS8EncodedKeySpec getKeySpec(Cipher cipher)
                               throws InvalidKeySpecException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
Note: In order to successfully retrieve the enclosed PKCS8EncodedKeySpec object, cipher needs to be initialized to either Cipher.DECRYPT_MODE or Cipher.UNWRAP_MODE, with the same key and parameters used for generating the encrypted data.

Parameters:
cipher - the initialized cipher object which will be used for decrypting the encrypted data.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
NullPointerException - if cipher is null.
InvalidKeySpecException - if the given cipher is inappropriate for the encrypted data or the encrypted data is corrupted and cannot be decrypted.

getKeySpec

public PKCS8EncodedKeySpec getKeySpec(Key decryptKey)
                               throws NoSuchAlgorithmException,
                                      InvalidKeyException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.

Parameters:
decryptKey - key used for decrypting the encrypted data.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
NullPointerException - if decryptKey is null.
NoSuchAlgorithmException - if cannot find appropriate cipher to decrypt the encrypted data.
InvalidKeyException - if decryptKey cannot be used to decrypt the encrypted data or the decryption result is not a valid PKCS8KeySpec.

getKeySpec

public PKCS8EncodedKeySpec getKeySpec(Key decryptKey,
                                      String providerName)
                               throws NoSuchProviderException,
                                      NoSuchAlgorithmException,
                                      InvalidKeyException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.

Parameters:
decryptKey - key used for decrypting the encrypted data.
providerName - the name of provider whose Cipher implementation will be used.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
NullPointerException - if decryptKey or providerName is null.
NoSuchProviderException - if no provider providerName is registered.
NoSuchAlgorithmException - if cannot find appropriate cipher to decrypt the encrypted data.
InvalidKeyException - if decryptKey cannot be used to decrypt the encrypted data or the decryption result is not a valid PKCS8KeySpec.

getKeySpec

public PKCS8EncodedKeySpec getKeySpec(Key decryptKey,
                                      Provider provider)
                               throws NoSuchAlgorithmException,
                                      InvalidKeyException
Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.

Parameters:
decryptKey - key used for decrypting the encrypted data.
provider - the name of provider whose Cipher implementation will be used.
Returns:
the PKCS8EncodedKeySpec object.
Throws:
NullPointerException - if decryptKey or provider is null.
NoSuchAlgorithmException - if cannot find appropriate cipher to decrypt the encrypted data in provider.
InvalidKeyException - if decryptKey cannot be used to decrypt the encrypted data or the decryption result is not a valid PKCS8KeySpec.

getEncoded

public byte[] getEncoded()
                  throws IOException
Returns the ASN.1 encoding of this object.

Returns:
the ASN.1 encoding. Returns a new array each time this method is called.
Throws:
IOException - if error occurs when constructing its ASN.1 encoding.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

6 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-2817
Document créé le 30/08/06 20:06, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/crypto/EncryptedPrivateKeyInfo.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,50 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Quand Google ne trouve pas quelque chose, il demande à Chuck Norris.

Anonyme [Chuck Norris fact]
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 00:13, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)