Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle Security Developer Tools PKI SDK CMP Java API Reference 10g Release 3 (10.1.3) B25373-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.security.crypto.cmp
Class EncryptedValue

`java.lang.Object
oracle.security.crypto.cmp.EncryptedValue`

All Implemented Interfaces:
  oracle.security.crypto.asn1.ASN1Object, oracle.security.crypto.util.Streamable

public class EncryptedValue
extends java.lang.Object
implements oracle.security.crypto.asn1.ASN1Object

Encrypted content for encrypted key value and encrypted certificate value for CertifiedKeyPair objects.

Constructor Summary
`EncryptedValue()` Create new, empty `EncryptedValue`.
`EncryptedValue(byte[] encValue)` Create a new `EncryptedValue` with the specified encypted value
`EncryptedValue(java.io.InputStream is)`

Method Summary
`static byte[]` | `decrypt(EncryptedValue encVal, oracle.security.crypto.core.PrivateKey recipKey)` Decrypt an `EncryptedValue` and return the bytes of the value.
`static EncryptedValue` | `encrypt(oracle.security.crypto.asn1.ASN1Object obj, oracle.security.crypto.core.SymmetricKey encrKey, oracle.security.crypto.core.PublicKey recipKey)` Creates a new `EncryptedValue` instance whose value is the DER encoding of the given `ASN1Object`.
`byte[]` | `getEncSymmKey()` Returns the encrypted symmetric key used to encrypt the value.
`byte[]` | `getEncValue()` Returns the encrypted value of this object.
`oracle.security.crypto.core.AlgorithmIdentifier` | `getIntendedAlg()` Returns the intended algorithm of the encrypted value.
`oracle.security.crypto.core.AlgorithmIdentifier` | `getKeyAlg()` Returns the algorithm used to encrypt the symmetric key.
`oracle.security.crypto.core.AlgorithmIdentifier` | `getSymmAlg()` Returns the symmetric algorithm used to encrypt the value.
`byte[]` | `getValueHint()` Returns the value hint of the encrypted value.
`void` | `input(java.io.InputStream is)`
`int` | `length()`
`void` | `output(java.io.OutputStream os)`
`void` | `setEncSymmKey(byte[] encSymmKey)` Sets the encrypted symmetric key used to encrypt the value.
`void` | `setIntendedAlg(oracle.security.crypto.core.AlgorithmIdentifier intendedAlg)` Sets the intended algorithm for the encrypted value.
`void` | `setKeyAlg(oracle.security.crypto.core.AlgorithmIdentifier keyAlg)` Sets the algorithm used to encrypt the symmetric key.
`void` | `setSymmAlg(oracle.security.crypto.core.AlgorithmIdentifier symmAlg)` Sets the symmetric algorithm used to encrypt the value.
`void` | `setValueHint(byte[] valueHint)` Sets the value hint for the encrypted value.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### EncryptedValue

    public EncryptedValue()

  Create new, empty `EncryptedValue`. Note that an instance created using this constructor is not valid, and is intended primarily for use in conjunction with the `input(java.io.InputStream)` method.

### EncryptedValue

    public EncryptedValue(byte[] encValue)

  Create a new `EncryptedValue` with the specified encypted value

### EncryptedValue

    public EncryptedValue(java.io.InputStream is)
                   throws java.io.IOException

Method Detail

### encrypt

    public static EncryptedValue encrypt(oracle.security.crypto.asn1.ASN1Object obj,
                                         oracle.security.crypto.core.SymmetricKey encrKey,
                                         oracle.security.crypto.core.PublicKey recipKey)
                                  throws oracle.security.crypto.core.AlgorithmIdentifierException,
                                         oracle.security.crypto.core.CipherException,
                                         oracle.security.crypto.core.InvalidKeyException

  Creates a new `EncryptedValue` instance whose value is the DER encoding of the given `ASN1Object`.

  For example, to encrypt a certificate:

                              // The certificate to be encrypted.
                              X509 cert = ... ;

                              // The public key of the recipient.
                              PublicKey pubKey = ... ;

                              // Generate a random triple-DES encryption key.
                              SymmetricKeyGenerator keyGen =
                                      SymmetricKeyGenerator.getInstance(AlgID.DES_EDE3_CBC);
                              SymmetricKey symmKey = keyGen.generateKey();

                              // Create the EncryptedValue.
                              EncryptedValue encCert = EncryptedValue.encrypt(cert, symmKey, pubKey);

  Parameters:
    `obj` - The `ASN1Object` to be encrypted.
    `encrKey` - The symmetric key that will be used to encrypt the object. Must have a valid algorithm identifer.
    `recipKey` - The public key that will be used to encrypt the symmetric key for the recipient.
  Throws:
    `oracle.security.crypto.core.AlgorithmIdentifierException`
    `oracle.security.crypto.core.CipherException`
    `oracle.security.crypto.core.InvalidKeyException`

### decrypt

    public static byte[] decrypt(EncryptedValue encVal,
                                 oracle.security.crypto.core.PrivateKey recipKey)
                          throws oracle.security.crypto.core.AlgorithmIdentifierException,
                                 oracle.security.crypto.core.CipherException,
                                 oracle.security.crypto.core.InvalidKeyException

  Decrypt an `EncryptedValue` and return the bytes of the value.

  For example, to decrypt an `EncryptedValue` containing a certificate:

                              // The EncryptedValue.
                              EncryptedValue encVal = ... ;

                              // The recipient's private key.
                              PrivateKey privKey = ... ;

                              // Decrypt and construct the resulting certificate from
                              // its DER encoding.
                              byte[] val = EncryptedValue.decrypt(encVal, privKey);
                              X509 cert = new X509(val);

  Parameters:
    `encVal` - The `EncryptedValue` to be decrypted.
    `recipKey` - The private key of the recipient, corresponding to the public key used by the sender to encrypt.
  Throws:
    `oracle.security.crypto.core.AlgorithmIdentifierException`
    `oracle.security.crypto.core.CipherException`
    `oracle.security.crypto.core.InvalidKeyException`

### getEncValue

    public byte[] getEncValue()

  Returns the encrypted value of this object.

### setIntendedAlg

    public void setIntendedAlg(oracle.security.crypto.core.AlgorithmIdentifier intendedAlg)

  Sets the intended algorithm for the encrypted value.

### getIntendedAlg

    public oracle.security.crypto.core.AlgorithmIdentifier getIntendedAlg()

  Returns the intended algorithm of the encrypted value.

### setSymmAlg

    public void setSymmAlg(oracle.security.crypto.core.AlgorithmIdentifier symmAlg)

  Sets the symmetric algorithm used to encrypt the value.

### getSymmAlg

    public oracle.security.crypto.core.AlgorithmIdentifier getSymmAlg()

  Returns the symmetric algorithm used to encrypt the value.

### setEncSymmKey

    public void setEncSymmKey(byte[] encSymmKey)

  Sets the encrypted symmetric key used to encrypt the value.

### getEncSymmKey

    public byte[] getEncSymmKey()

  Returns the encrypted symmetric key used to encrypt the value.

### setKeyAlg

    public void setKeyAlg(oracle.security.crypto.core.AlgorithmIdentifier keyAlg)

  Sets the algorithm used to encrypt the symmetric key.

### getKeyAlg

    public oracle.security.crypto.core.AlgorithmIdentifier getKeyAlg()

  Returns the algorithm used to encrypt the symmetric key.

### setValueHint

    public void setValueHint(byte[] valueHint)

  Sets the value hint for the encrypted value.

### getValueHint

    public byte[] getValueHint()

  Returns the value hint of the encrypted value.

### toString

    public java.lang.String toString()

### input

    public void input(java.io.InputStream is)
               throws java.io.IOException

  Specified by:
    `input` in interface `oracle.security.crypto.util.Streamable`
  Throws:
    `java.io.IOException`

### output

    public void output(java.io.OutputStream os)
                throws java.io.IOException

  Specified by:
    `output` in interface `oracle.security.crypto.util.Streamable`
  Throws:
    `java.io.IOException`

### length

    public int length()

  Specified by:
    `length` in interface `oracle.security.crypto.util.Streamable`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle Security Developer Tools PKI SDK CMP Java API Reference 10g Release 3 (10.1.3) B25373-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005, 2006 , Oracle. All rights reserved.