Examples of DSAPrivateKey


Examples of java.security.interfaces.DSAPrivateKey

        pubKeyFactoryBean.setLocation(pubKeyResource);
        privKeyFactoryBean.setLocation(privKeyResource);
        pubKeyFactoryBean.afterPropertiesSet();
        privKeyFactoryBean.afterPropertiesSet();
       
        final DSAPrivateKey privateKey = (DSAPrivateKey) privKeyFactoryBean.getObject();
        final DSAPublicKey publicKey = (DSAPublicKey) pubKeyFactoryBean.getObject();
       
        final MockHttpServletRequest request = new MockHttpServletRequest();
       
        final String SAMLRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><samlp:AuthnRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"5545454455\" Version=\"2.0\" IssueInstant=\"Value\" ProtocolBinding=\"urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect\" ProviderName=\"https://localhost:8443/myRutgers\" AssertionConsumerServiceURL=\"https://localhost:8443/myRutgers\"/>";
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

            RSAPrivateCrtKey    rsK = (RSAPrivateCrtKey)privKey.getKey();
           
            secKey = new RSASecretBCPGKey(rsK.getPrivateExponent(), rsK.getPrimeP(), rsK.getPrimeQ());
            break;
        case PGPPublicKey.DSA:
            DSAPrivateKey       dsK = (DSAPrivateKey)privKey.getKey();
           
            secKey = new DSASecretBCPGKey(dsK.getX());
            break;
        case PGPPublicKey.ELGAMAL_ENCRYPT:
        case PGPPublicKey.ELGAMAL_GENERAL:
            ElGamalPrivateKey   esK = (ElGamalPrivateKey)privKey.getKey();
           
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

                {
                    return new SimpleTestResult(false, this.getName() + ": public q value not decoded properly");
                }
               
                PKCS8EncodedKeySpec  pkcs8 = new PKCS8EncodedKeySpec(sKey.getEncoded());
                DSAPrivateKey        k2 = (DSAPrivateKey)f.generatePrivate(pkcs8);

                if (!k2.getX().equals(((DSAPrivateKey)sKey).getX()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private number not decoded properly");
                }

                if (!k2.getParams().getG().equals(((DSAPrivateKey)sKey).getParams().getG()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private generator not decoded properly");
                }

                if (!k2.getParams().getP().equals(((DSAPrivateKey)sKey).getParams().getP()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private p value not decoded properly");
                }

                if (!k2.getParams().getQ().equals(((DSAPrivateKey)sKey).getParams().getQ()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private q value not decoded properly");
                }
               
                //
                // key decoding test - SUN decoding BC keys
                //
                f = KeyFactory.getInstance("DSA", "SUN");
                x509s = new X509EncodedKeySpec(k1.getEncoded());

                vKey = (DSAPublicKey)f.generatePublic(x509s);

                if (!k1.getY().equals(((DSAPublicKey)vKey).getY()))
                {
                    return new SimpleTestResult(false, this.getName() + ": public number not decoded properly");
                }

                if (!k1.getParams().getG().equals(((DSAPublicKey)vKey).getParams().getG()))
                {
                    return new SimpleTestResult(false, this.getName() + ": public generator not decoded properly");
                }

                if (!k1.getParams().getP().equals(((DSAPublicKey)vKey).getParams().getP()))
                {
                    return new SimpleTestResult(false, this.getName() + ": public p value not decoded properly");
                }

                if (!k1.getParams().getQ().equals(((DSAPublicKey)vKey).getParams().getQ()))
                {
                    return new SimpleTestResult(false, this.getName() + ": public q value not decoded properly");
                }

                pkcs8 = new PKCS8EncodedKeySpec(k2.getEncoded());
                sKey = (DSAPrivateKey)f.generatePrivate(pkcs8);

                if (!k2.getX().equals(((DSAPrivateKey)sKey).getX()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private number not decoded properly");
                }

                if (!k2.getParams().getG().equals(((DSAPrivateKey)sKey).getParams().getG()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private generator not decoded properly");
                }

                if (!k2.getParams().getP().equals(((DSAPrivateKey)sKey).getParams().getP()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private p value not decoded properly");
                }

                if (!k2.getParams().getQ().equals(((DSAPrivateKey)sKey).getParams().getQ()))
                {
                    return new SimpleTestResult(false, this.getName() + ": private q value not decoded properly");
                }
               
                //
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

        if (!(o instanceof DSAPrivateKey))
        {
            return false;
        }
       
        DSAPrivateKey other = (DSAPrivateKey)o;
       
        return this.getX().equals(other.getX())
            && this.getParams().getG().equals(other.getParams().getG())
            && this.getParams().getP().equals(other.getParams().getP())
            && this.getParams().getQ().equals(other.getParams().getQ());
    }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

        PrivateKey    key)
        throws InvalidKeyException
    {
        if (key instanceof DSAPrivateKey)
        {
            DSAPrivateKey    k = (DSAPrivateKey)key;

            return new DSAPrivateKeyParameters(k.getX(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        }
                       
        throw new InvalidKeyException("can't identify DSA private key.");
    }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

     * if KeySpec argument contains incorrect ASN.1 syntax
     */
    public final void testGeneratePrivateKeySpec04() throws Exception {

        PKCS8EncodedKeySpec ks;
        DSAPrivateKey prKey;

        final BigInteger x = privateX;
        final BigInteger p = privateP;
        final BigInteger q = privateQ;
        final BigInteger g = privateG;

        final byte enc1[] = new byte[20];
        System.arraycopy(privateEncoding, 0, enc1, 0, 20);
        final byte[] enc2 = enc1;

        prKey = new DSAPrivateKey () {

                  public BigInteger getX() { return x; }
                  public DSAParams getParams() {
                      return  (DSAParams)(new DSAParameterSpec(p, q, g));
                  }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

     * whose algorithm is neither null nor "DSA".
     */
    public final void testGeneratePrivateKeySpec05() throws Exception {

        PKCS8EncodedKeySpec ks;
        DSAPrivateKey prKey;

        final BigInteger x = privateX;
        final BigInteger p = privateP;
        final BigInteger q = privateQ;
        final BigInteger g = privateG;

        final byte enc1[] = new byte[privateEncoding.length];
        System.arraycopy(privateEncoding, 0, enc1, 0, privateEncoding.length);
        enc1[13] = 0;
        final byte[] enc2 = enc1;

        prKey = new DSAPrivateKey () {

                  public BigInteger getX() { return x; }
                  public DSAParams getParams() {
                      return  (DSAParams)(new DSAParameterSpec(p, q, g));
                  }
                  public String getAlgorithm() { return "DSA"; }
                  public byte[] getEncoded()   { return enc2; }
                  public String getFormat()    { return "PKCS8"; }
              };

        ks = kf.getKeySpec(prKey, PKCS8EncodedKeySpec.class);
        prKey = (DSAPrivateKey) kf.generatePrivate((KeySpec)ks);

        String alg = prKey.getAlgorithm();
        assertNotNull(alg);
        assertFalse("DSA".equals(alg));
    }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

        final BigInteger g = privateG;

        final byte enc1[] = new byte[lng];
        System.arraycopy(privateEncoding, 0, enc1, 0, lng)// enc1 contains incorrect encoding

        DSAPrivateKey prKey = new DSAPrivateKey () {

                  public BigInteger getX() { return x; }
                  public DSAParams getParams() {
                      return  (DSAParams)(new DSAParameterSpec(p, q, g));
                  }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

        final byte enc1[] = new byte[privateEncoding.length];
        System.arraycopy(privateEncoding, 0, enc1, 0, privateEncoding.length);
        enc1[13] = 0;
        final byte[] enc2 = enc1;

        DSAPrivateKey prKey = new DSAPrivateKey () {

                  public BigInteger getX() { return x; }
                  public DSAParams getParams() {
                      return  (DSAParams)(new DSAParameterSpec(p, q, g));
                  }
                  public String getAlgorithm() { return "DSA"; }
                  public byte[] getEncoded()   { return enc2; }
                  public String getFormat()    { return "PKCS8"; }
              };

        PKCS8EncodedKeySpec ks = kf.getKeySpec(prKey, PKCS8EncodedKeySpec.class);

        prKey = (DSAPrivateKey) kf.generatePrivate((KeySpec)ks);
        prKey = (DSAPrivateKey) kf.translateKey( (Key)prKey );

        String alg = prKey.getAlgorithm();
        assertNotNull(alg);
        assertFalse("PKCS8".equals(alg));
    }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

          && dsa1.getParams().getP().equals(dsa2.getParams().getP())
          && dsa1.getParams().getQ().equals(dsa2.getParams().getQ());

    } else if (key1 instanceof DSAPrivateKey
        && key2 instanceof DSAPrivateKey) {
      DSAPrivateKey dsa1 = ((DSAPrivateKey) key1);
      DSAPrivateKey dsa2 = ((DSAPrivateKey) key2);
      return dsa1.getX().equals(dsa2.getX())
          && dsa1.getParams().getG().equals(dsa2.getParams().getG())
          && dsa1.getParams().getP().equals(dsa2.getParams().getP())
          && dsa1.getParams().getQ().equals(dsa2.getParams().getQ());
    } else {
      return false;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.