java.security.spec.DSAPrivateKeySpec Java Examples
The following examples show how to use
java.security.spec.DSAPrivateKeySpec.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Ssh2DsaPrivateKey.java From j2ssh-maverick with GNU Lesser General Public License v3.0 | 6 votes |
public Ssh2DsaPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x, BigInteger y) throws SshException { try { KeyFactory kf = JCEProvider .getProviderForAlgorithm(JCEAlgorithms.JCE_DSA) == null ? KeyFactory .getInstance(JCEAlgorithms.JCE_DSA) : KeyFactory .getInstance(JCEAlgorithms.JCE_DSA, JCEProvider .getProviderForAlgorithm(JCEAlgorithms.JCE_DSA)); DSAPrivateKeySpec spec = new DSAPrivateKeySpec(x, p, q, g); prv = (DSAPrivateKey) kf.generatePrivate(spec); pub = new Ssh2DsaPublicKey(p, q, g, y); } catch (Throwable e) { throw new SshException(e); } }
Example #2
Source File: DSAKeyFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #3
Source File: DSAKeyFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #4
Source File: DSAKeyFactory.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #5
Source File: DSAKeyFactory.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #6
Source File: SoftKeymasterBlob.java From keystore-decryptor with Apache License 2.0 | 6 votes |
private void parseDsaKeyPair(byte[] blob) throws GeneralSecurityException, IOException { ASN1InputStream ain = new ASN1InputStream(new ByteArrayInputStream( blob)); ASN1Sequence seq = (ASN1Sequence) ain.readObject(); ain.close(); ASN1Integer p = (ASN1Integer) seq.getObjectAt(1); ASN1Integer q = (ASN1Integer) seq.getObjectAt(2); ASN1Integer g = (ASN1Integer) seq.getObjectAt(3); ASN1Integer y = (ASN1Integer) seq.getObjectAt(4); ASN1Integer x = (ASN1Integer) seq.getObjectAt(5); DSAPrivateKeySpec privSpec = new DSAPrivateKeySpec(x.getValue(), p.getValue(), q.getValue(), g.getValue()); DSAPublicKeySpec pubSpec = new DSAPublicKeySpec(y.getValue(), p.getValue(), q.getValue(), g.getValue()); KeyFactory kf = KeyFactory.getInstance("DSA"); privateKey = kf.generatePrivate(privSpec); publicKey = kf.generatePublic(pubSpec); }
Example #7
Source File: DSAKeyFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #8
Source File: DSAKeyFactory.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #9
Source File: DSAKeyFactory.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #10
Source File: DSAKeyFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #11
Source File: DSAKeyFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #12
Source File: DSAKeyFactory.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #13
Source File: DSAKeyFactory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #14
Source File: DSAKeyFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #15
Source File: DSAKeyFactory.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #16
Source File: DSAKeyFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates a private key object from the provided key specification * (key material). * * @param keySpec the specification (key material) of the private key * * @return the private key * * @exception InvalidKeySpecException if the given key specification * is inappropriate for this key factory to produce a private key. */ protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { try { if (keySpec instanceof DSAPrivateKeySpec) { DSAPrivateKeySpec dsaPrivKeySpec = (DSAPrivateKeySpec)keySpec; return new DSAPrivateKey(dsaPrivKeySpec.getX(), dsaPrivKeySpec.getP(), dsaPrivKeySpec.getQ(), dsaPrivKeySpec.getG()); } else if (keySpec instanceof PKCS8EncodedKeySpec) { return new DSAPrivateKey (((PKCS8EncodedKeySpec)keySpec).getEncoded()); } else { throw new InvalidKeySpecException ("Inappropriate key specification"); } } catch (InvalidKeyException e) { throw new InvalidKeySpecException ("Inappropriate key specification: " + e.getMessage()); } }
Example #17
Source File: DSAKeyFactory.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #18
Source File: DSAPrivateKeySpecTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Test for constructor */ public final void testDSAPrivateKeySpec() { KeySpec ks = new DSAPrivateKeySpec( new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4")); assertTrue(ks instanceof DSAPrivateKeySpec); }
Example #19
Source File: ConstantPasswords.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
public void bad10() throws Exception { BigInteger bigInteger = new BigInteger("12345", 5); new DSAPrivateKeySpec(bigInteger, null, null, null); new DSAPublicKeySpec(bigInteger, null, bigInteger, null); // report once new DHPrivateKeySpec(bigInteger, null, null); new DHPublicKeySpec(bigInteger, null, null); new ECPrivateKeySpec(bigInteger, null); new RSAPrivateKeySpec(bigInteger, null); new RSAMultiPrimePrivateCrtKeySpec(bigInteger, null, null, null, null, null, null, null, null); new RSAPrivateCrtKeySpec(bigInteger, null, null, null, null, null, null, null); new RSAPublicKeySpec(bigInteger, null); new DSAPublicKeyImpl(bigInteger, null, null, null); }
Example #20
Source File: DSAKeyFactory.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #21
Source File: DSAPrivateKeySpecTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * getP() test */ public final void testGetP() { DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4")); assertEquals(2, dpks.getP().intValue()); }
Example #22
Source File: DSAKeyFactory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #23
Source File: DSAKeyFactory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #24
Source File: DSAKeyFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #25
Source File: DSAKeyFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #26
Source File: DSAPrivateKeySpecTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * getG() test */ public final void testGetG() { DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4")); assertEquals(4, dpks.getG().intValue()); }
Example #27
Source File: DSAKeyFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #28
Source File: KeyFactorySpi.java From ripple-lib-java with ISC License | 5 votes |
protected PrivateKey engineGeneratePrivate( KeySpec keySpec) throws InvalidKeySpecException { if (keySpec instanceof DSAPrivateKeySpec) { return new BCDSAPrivateKey((DSAPrivateKeySpec)keySpec); } return super.engineGeneratePrivate(keySpec); }
Example #29
Source File: DSAKeyFactory.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }
Example #30
Source File: DSAKeyFactory.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Translates a key object, whose provider may be unknown or potentially * untrusted, into a corresponding key object of this key factory. * * @param key the key whose provider is unknown or untrusted * * @return the translated key * * @exception InvalidKeyException if the given key cannot be processed by * this key factory. */ protected Key engineTranslateKey(Key key) throws InvalidKeyException { try { if (key instanceof java.security.interfaces.DSAPublicKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPublicKey) { return key; } // Convert key to spec DSAPublicKeySpec dsaPubKeySpec = engineGetKeySpec(key, DSAPublicKeySpec.class); // Create key from spec, and return it return engineGeneratePublic(dsaPubKeySpec); } else if (key instanceof java.security.interfaces.DSAPrivateKey) { // Check if key originates from this factory if (key instanceof sun.security.provider.DSAPrivateKey) { return key; } // Convert key to spec DSAPrivateKeySpec dsaPrivKeySpec = engineGetKeySpec(key, DSAPrivateKeySpec.class); // Create key from spec, and return it return engineGeneratePrivate(dsaPrivKeySpec); } else { throw new InvalidKeyException("Wrong algorithm type"); } } catch (InvalidKeySpecException e) { throw new InvalidKeyException("Cannot translate key: " + e.getMessage()); } }