# Uses of Class
java.security.InvalidKeyException

Packages that use InvalidKeyException
Package
Description
java.security
Provides the classes and interfaces for the security framework.
java.security.cert
Provides classes and interfaces for parsing and managing certificates, certificate revocation lists (CRLs), and certification paths.
javax.crypto
Provides the classes and interfaces for cryptographic operations.
javax.crypto.spec
Provides classes and interfaces for key specifications and algorithm parameter specifications.
javax.security.cert
Provides classes for public key certificates.

- ## Uses of InvalidKeyException in java.security

  Methods in java.security that throw InvalidKeyException
  Modifier and Type
  Method
  Description
  `protected abstract void`
  SignatureSpi.`engineInitSign(PrivateKey privateKey)`
  Initializes this `Signature` object with the specified private key for signing operations.
  `protected void`
  SignatureSpi.`engineInitSign(PrivateKey privateKey, SecureRandom random)`
  Initializes this `Signature` object with the specified private key and source of randomness for signing operations.
  `protected abstract void`
  SignatureSpi.`engineInitVerify(PublicKey publicKey)`
  Initializes this `Signature` object with the specified public key for verification operations.
  `protected abstract Key`
  KeyFactorySpi.`engineTranslateKey(Key key)`
  Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this key factory.
  `final void`
  Signature.`initSign(PrivateKey privateKey)`
  Initialize this object for signing.
  `final void`
  Signature.`initSign(PrivateKey privateKey, SecureRandom random)`
  Initialize this object for signing.
  `final void`
  Signature.`initVerify(Certificate certificate)`
  Initializes this object for verification, using the public key from the given certificate.
  `final void`
  Signature.`initVerify(PublicKey publicKey)`
  Initializes this object for verification.
  `final Key`
  KeyFactory.`translateKey(Key key)`
  Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this key factory.
  `boolean`
  SignedObject.`verify(PublicKey verificationKey, Signature verificationEngine)`
  Verifies that the signature in this `SignedObject` is the valid signature for the object stored inside, with the given verification key, using the designated verification engine.
  Constructors in java.security that throw InvalidKeyException
  Modifier
  Constructor
  Description
  ``
  `SignedObject(Serializable object, PrivateKey signingKey, Signature signingEngine)`
  Constructs a `SignedObject` from any Serializable object.

- ## Uses of InvalidKeyException in java.security.cert

  Methods in java.security.cert that throw InvalidKeyException
  Modifier and Type
  Method
  Description
  `abstract void`
  Certificate.`verify(PublicKey key)`
  Verifies that this certificate was signed using the private key that corresponds to the specified public key.
  `abstract void`
  Certificate.`verify(PublicKey key, String sigProvider)`
  Verifies that this certificate was signed using the private key that corresponds to the specified public key.
  `void`
  Certificate.`verify(PublicKey key, Provider sigProvider)`
  Verifies that this certificate was signed using the private key that corresponds to the specified public key.
  `void`
  X509Certificate.`verify(PublicKey key, Provider sigProvider)`
  Verifies that this certificate was signed using the private key that corresponds to the specified public key.
  `abstract void`
  X509CRL.`verify(PublicKey key)`
  Verifies that this CRL was signed using the private key that corresponds to the given public key.
  `abstract void`
  X509CRL.`verify(PublicKey key, String sigProvider)`
  Verifies that this CRL was signed using the private key that corresponds to the given public key.
  `void`
  X509CRL.`verify(PublicKey key, Provider sigProvider)`
  Verifies that this CRL was signed using the private key that corresponds to the given public key.

- ## Uses of InvalidKeyException in javax.crypto

  Methods in javax.crypto that throw InvalidKeyException
  Modifier and Type
  Method
  Description
  `final Key`
  KeyAgreement.`doPhase(Key key, boolean lastPhase)`
  Executes the next phase of this key agreement with the given key that was received from one of the other parties involved in this key agreement.
  `protected abstract Key`
  KeyAgreementSpi.`engineDoPhase(Key key, boolean lastPhase)`
  Executes the next phase of this key agreement with the given key that was received from one of the other parties involved in this key agreement.
  `protected abstract SecretKey`
  KeyAgreementSpi.`engineGenerateSecret(String algorithm)`
  Creates the shared secret and returns it as a secret key object of the requested algorithm type.
  `protected int`
  CipherSpi.`engineGetKeySize(Key key)`
  Returns the key size of the given key object in bits.
  `protected abstract void`
  CipherSpi.`engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random)`
  Initializes this `CipherSpi` object with a key, a set of algorithm parameters, and a source of randomness.
  `protected abstract void`
  CipherSpi.`engineInit(int opmode, Key key, SecureRandom random)`
  Initializes this `CipherSpi` object with a key and a source of randomness.
  `protected abstract void`
  CipherSpi.`engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)`
  Initializes this `CipherSpi` object with a key, a set of algorithm parameters, and a source of randomness.
  `protected abstract void`
  ExemptionMechanismSpi.`engineInit(Key key)`
  Initializes this exemption mechanism with a key.
  `protected abstract void`
  ExemptionMechanismSpi.`engineInit(Key key, AlgorithmParameters params)`
  Initializes this exemption mechanism with a key and a set of algorithm parameters.
  `protected abstract void`
  ExemptionMechanismSpi.`engineInit(Key key, AlgorithmParameterSpec params)`
  Initializes this exemption mechanism with a key and a set of algorithm parameters.
  `protected abstract void`
  KeyAgreementSpi.`engineInit(Key key, SecureRandom random)`
  Initializes this key agreement with the given key and source of randomness.
  `protected abstract void`
  KeyAgreementSpi.`engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random)`
  Initializes this key agreement with the given key, set of algorithm parameters, and source of randomness.
  `protected abstract void`
  MacSpi.`engineInit(Key key, AlgorithmParameterSpec params)`
  Initializes the MAC with the given (secret) key and algorithm parameters.
  `KEMSpi.DecapsulatorSpi`
  KEMSpi.`engineNewDecapsulator(PrivateKey privateKey, AlgorithmParameterSpec spec)`
  Creates a KEM decapsulator on the KEM receiver side.
  `KEMSpi.EncapsulatorSpi`
  KEMSpi.`engineNewEncapsulator(PublicKey publicKey, AlgorithmParameterSpec spec, SecureRandom secureRandom)`
  Creates a KEM encapsulator on the KEM sender side.
  `protected abstract SecretKey`
  SecretKeyFactorySpi.`engineTranslateKey(SecretKey key)`
  Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret key factory.
  `protected Key`
  CipherSpi.`engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)`
  Unwrap a previously wrapped key.
  `protected byte[]`
  CipherSpi.`engineWrap(Key key)`
  Wrap a key.
  `final SecretKey`
  KeyAgreement.`generateSecret(String algorithm)`
  Creates the shared secret and returns it as a `SecretKey` object of the specified algorithm.
  `PrivateKey`
  EncryptedPrivateKeyInfo.`getKey(char[] password)`
  Preview.
  Extracts and returns the enclosed `PrivateKey` using the specified password.
  `PrivateKey`
  EncryptedPrivateKeyInfo.`getKey(Key decryptKey, Provider provider)`
  Preview.
  Extracts and returns the enclosed `PrivateKey` using the specified decryption key and provider.
  `KeyPair`
  EncryptedPrivateKeyInfo.`getKeyPair(char[] password)`
  Preview.
  Extracts and returns the enclosed `KeyPair` using the specified password.
  `KeyPair`
  EncryptedPrivateKeyInfo.`getKeyPair(Key decryptKey, Provider provider)`
  Preview.
  Extracts and returns the enclosed `KeyPair` using the specified decryption key and provider.
  `PKCS8EncodedKeySpec`
  EncryptedPrivateKeyInfo.`getKeySpec(Key decryptKey)`
  Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
  `PKCS8EncodedKeySpec`
  EncryptedPrivateKeyInfo.`getKeySpec(Key decryptKey, String providerName)`
  Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
  `PKCS8EncodedKeySpec`
  EncryptedPrivateKeyInfo.`getKeySpec(Key decryptKey, Provider provider)`
  Extract the enclosed PKCS8EncodedKeySpec object from the encrypted data and return it.
  `final Object`
  SealedObject.`getObject(Key key)`
  Retrieves the original (encapsulated) object.
  `final Object`
  SealedObject.`getObject(Key key, String provider)`
  Retrieves the original (encapsulated) object.
  `final void`
  Cipher.`init(int opmode, Certificate certificate)`
  Initializes this `Cipher` object with the public key from the given certificate.
  `final void`
  Cipher.`init(int opmode, Certificate certificate, SecureRandom random)`
  Initializes this `Cipher` object with the public key from the given certificate and a source of randomness.
  `final void`
  Cipher.`init(int opmode, Key key)`
  Initializes this `Cipher` object with a key.
  `final void`
  Cipher.`init(int opmode, Key key, AlgorithmParameters params)`
  Initializes this `Cipher` object with a key and a set of algorithm parameters.
  `final void`
  Cipher.`init(int opmode, Key key, AlgorithmParameters params, SecureRandom random)`
  Initializes this `Cipher` object with a key, a set of algorithm parameters, and a source of randomness.
  `final void`
  Cipher.`init(int opmode, Key key, SecureRandom random)`
  Initializes this `Cipher` object with a key and a source of randomness.
  `final void`
  Cipher.`init(int opmode, Key key, AlgorithmParameterSpec params)`
  Initializes this `Cipher` object with a key and a set of algorithm parameters.
  `final void`
  Cipher.`init(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)`
  Initializes this `Cipher` object with a key, a set of algorithm parameters, and a source of randomness.
  `final void`
  ExemptionMechanism.`init(Key key)`
  Initializes this exemption mechanism with a key.
  `final void`
  ExemptionMechanism.`init(Key key, AlgorithmParameters params)`
  Initializes this exemption mechanism with a key and a set of algorithm parameters.
  `final void`
  ExemptionMechanism.`init(Key key, AlgorithmParameterSpec params)`
  Initializes this exemption mechanism with a key and a set of algorithm parameters.
  `final void`
  KeyAgreement.`init(Key key)`
  Initializes this key agreement with the given key, which is required to contain all the algorithm parameters required for this key agreement.
  `final void`
  KeyAgreement.`init(Key key, SecureRandom random)`
  Initializes this key agreement with the given key and source of randomness.
  `final void`
  KeyAgreement.`init(Key key, AlgorithmParameterSpec params)`
  Initializes this key agreement with the given key and set of algorithm parameters.
  `final void`
  KeyAgreement.`init(Key key, AlgorithmParameterSpec params, SecureRandom random)`
  Initializes this key agreement with the given key, set of algorithm parameters, and source of randomness.
  `final void`
  Mac.`init(Key key)`
  Initializes this `Mac` object with the given key.
  `final void`
  Mac.`init(Key key, AlgorithmParameterSpec params)`
  Initializes this `Mac` object with the given key and algorithm parameters.
  `KEM.Decapsulator`
  KEM.`newDecapsulator(PrivateKey privateKey)`
  Creates a KEM decapsulator on the KEM receiver side.
  `KEM.Decapsulator`
  KEM.`newDecapsulator(PrivateKey privateKey, AlgorithmParameterSpec spec)`
  Creates a KEM decapsulator on the KEM receiver side.
  `KEM.Encapsulator`
  KEM.`newEncapsulator(PublicKey publicKey)`
  Creates a KEM encapsulator on the KEM sender side.
  `KEM.Encapsulator`
  KEM.`newEncapsulator(PublicKey publicKey, SecureRandom secureRandom)`
  Creates a KEM encapsulator on the KEM sender side.
  `KEM.Encapsulator`
  KEM.`newEncapsulator(PublicKey publicKey, AlgorithmParameterSpec spec, SecureRandom secureRandom)`
  Creates a KEM encapsulator on the KEM sender side.
  `final SecretKey`
  SecretKeyFactory.`translateKey(SecretKey key)`
  Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret key factory.
  `final Key`
  Cipher.`unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)`
  Unwrap a previously wrapped key.
  `final byte[]`
  Cipher.`wrap(Key key)`
  Wrap a key.

- ## Uses of InvalidKeyException in javax.crypto.spec

  Methods in javax.crypto.spec that throw InvalidKeyException
  Modifier and Type
  Method
  Description
  `static boolean`
  DESedeKeySpec.`isParityAdjusted(byte[] key, int offset)`
  Checks if the given DES-EDE key, starting at `offset` inclusive, is parity-adjusted.
  `static boolean`
  DESKeySpec.`isParityAdjusted(byte[] key, int offset)`
  Checks if the given DES key material, starting at `offset` inclusive, is parity-adjusted.
  `static boolean`
  DESKeySpec.`isWeak(byte[] key, int offset)`
  Checks if the given DES key material is weak or semi-weak.
  Constructors in javax.crypto.spec that throw InvalidKeyException
  Modifier
  Constructor
  Description
  ``
  `DESedeKeySpec(byte[] key)`
  Creates a DESedeKeySpec object using the first 24 bytes in `key` as the key material for the DES-EDE key.
  ``
  `DESedeKeySpec(byte[] key, int offset)`
  Creates a DESedeKeySpec object using the first 24 bytes in `key`, beginning at `offset` inclusive, as the key material for the DES-EDE key.
  ``
  `DESKeySpec(byte[] key)`
  Creates a DESKeySpec object using the first 8 bytes in `key` as the key material for the DES key.
  ``
  `DESKeySpec(byte[] key, int offset)`
  Creates a DESKeySpec object using the first 8 bytes in `key`, beginning at `offset` inclusive, as the key material for the DES key.

- ## Uses of InvalidKeyException in javax.security.cert

  Methods in javax.security.cert that throw InvalidKeyException
  Modifier and Type
  Method
  Description
  `abstract void`
  Certificate.`verify(PublicKey key)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Verifies that this certificate was signed using the private key that corresponds to the specified public key.
  `abstract void`
  Certificate.`verify(PublicKey key, String sigProvider)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Verifies that this certificate was signed using the private key that corresponds to the specified public key.