Examples of RSAPrivateKey


Examples of ch.ethz.ssh2.signature.RSAPrivateKey

            "ssh-dss", pk_enc, ds_enc);
        tm.sendMessage(ua.getPayload());
      }
      else if (key instanceof RSAPrivateKey)
      {
        RSAPrivateKey pk = (RSAPrivateKey) key;

        byte[] pk_enc = RSASHA1Verify.encodeSSHRSAPublicKey(pk.getPublicKey());

        TypesWriter tw = new TypesWriter();
        {
          byte[] H = tm.getSessionIdentifier();
View Full Code Here

Examples of ch.ethz.ssh2.signature.RSAPrivateKey

      BigInteger n = dr.readInt();
      BigInteger e = dr.readInt();
      BigInteger d = dr.readInt();

      return new RSAPrivateKey(d, e, n);
    }

    throw new IOException("PEM problem: it is of unknown type");
  }
View Full Code Here

Examples of com.trilead.ssh2.signature.RSAPrivateKey

            "ssh-dss", pk_enc, ds_enc);
        tm.sendMessage(ua.getPayload());
      }
      else if (key instanceof RSAPrivateKey)
      {
        RSAPrivateKey pk = (RSAPrivateKey) key;

        byte[] pk_enc = RSASHA1Verify.encodeSSHRSAPublicKey(pk.getPublicKey());

        TypesWriter tw = new TypesWriter();
        {
          byte[] H = tm.getSessionIdentifier();
View Full Code Here

Examples of iaik.security.rsa.RSAPrivateKey

      System.out.println("Diffie-Hellman cipher-suites can not be used. " + ex);
    }

    try {
        // set the temporary RSA key pair for RSA_EXPORT cipher suites
      RSAPrivateKey tsk = new RSAPrivateKey(new FileInputStream(certDir + "/tempRSAPrivateKey.der"));
      PublicKey tpk = tsk.getPublicKey();
      KeyPair tempKeyPair = new KeyPair(tpk, tsk);
      serverContext.setRSATempKeyPair(tempKeyPair);
    } catch (Exception ex) {
      System.out.println("Unable to set 512 bit temporary RSA key pair.");
      System.out.println("RSA exportable cipher-suites can not be used.");
View Full Code Here

Examples of java.security.interfaces.RSAPrivateKey

            KeyFactory key_factory = KeyFactory.getInstance("RSA");
           
            RSAPrivateKeySpec   private_key_spec =
              new RSAPrivateKeySpec( new BigInteger(mod,16), new BigInteger(exp,16));
       
            RSAPrivateKey  key = (RSAPrivateKey)key_factory.generatePrivate( private_key_spec );
           
            byte[]  req = new byte[ 8 + 20 ];
           
            req[0= (byte)(add?0x01:0x00);
           
View Full Code Here

Examples of java.security.interfaces.RSAPrivateKey

        if (o == this)
        {
            return true;
        }

        RSAPrivateKey key = (RSAPrivateKey)o;

        return getModulus().equals(key.getModulus())
            && getPrivateExponent().equals(key.getPrivateExponent());
    }
View Full Code Here

Examples of java.security.interfaces.RSAPrivateKey

        KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA", "BC");

        gen.initialize(1024, new SecureRandom());

        KeyPair         pair = gen.generateKeyPair();
        RSAPrivateKey   privKey = (RSAPrivateKey)pair.getPrivate();
        RSAPublicKey    pubKey = (RSAPublicKey)pair.getPublic();
        BigInteger      modulus = privKey.getModulus();
        BigInteger      privateExponent = privKey.getPrivateExponent();


        //
        // distinguished name table.
        //
        Hashtable                   attrs = new Hashtable();
        Vector                      order = new Vector();

        attrs.put(X509Principal.C, "AU");
        attrs.put(X509Principal.O, "The Legion of the Bouncy Castle");
        attrs.put(X509Principal.L, "Melbourne");
        attrs.put(X509Principal.ST, "Victoria");
        attrs.put(X509Principal.EmailAddress, "feedback-crypto@bouncycastle.org");

        order.addElement(X509Principal.C);
        order.addElement(X509Principal.O);
        order.addElement(X509Principal.L);
        order.addElement(X509Principal.ST);
        order.addElement(X509Principal.EmailAddress);

        //
        // extensions
        //

        //
        // create the certificate.
        //
        X509V3CertificateGenerator  certGen = new X509V3CertificateGenerator();

        certGen.setSerialNumber(BigInteger.valueOf(1));
        certGen.setIssuerDN(new X509Principal(order, attrs));
        certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
        certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
        certGen.setSubjectDN(new X509Principal(order, attrs));
        certGen.setPublicKey(pubKey);
        certGen.setSignatureAlgorithm("MD5WithRSAEncryption");

        Certificate[]   chain = new Certificate[1];

        try
        {
            X509Certificate cert = certGen.generate(privKey);

            cert.checkValidity(new Date());

            cert.verify(pubKey);

            ByteArrayInputStream    bIn = new ByteArrayInputStream(cert.getEncoded());
            CertificateFactory      fact = CertificateFactory.getInstance("X.509", "BC");

            cert = (X509Certificate)fact.generateCertificate(bIn);

            chain[0] = cert;
        }
        catch (Exception e)
        {
            fail("error generating cert - " + e.toString());
        }

        store.setKeyEntry("private", privKey, passwd, chain);

        //
        // write out and read back store
        //
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();

        store.store(bOut, passwd);

        ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());

        //
        // start with a new key store
        //
        store = KeyStore.getInstance(storeName, "BC");

        store.load(bIn, passwd);

        //
        // verify public key
        //
        privKey = (RSAPrivateKey)store.getKey("private", passwd);

        if (!privKey.getModulus().equals(modulus))
        {
            fail("private key modulus wrong");
        }
        else if (!privKey.getPrivateExponent().equals(privateExponent))
        {
            fail("private key exponent wrong");
        }

        //
View Full Code Here

Examples of java.security.interfaces.RSAPrivateKey

                k.getPublicExponent(), k.getPrivateExponent(),
                k.getPrimeP(), k.getPrimeQ(), k.getPrimeExponentP(), k.getPrimeExponentQ(), k.getCrtCoefficient());
        }
        else
        {
            RSAPrivateKey k = key;

            return new RSAKeyParameters(true, k.getModulus(), k.getPrivateExponent());
        }
    }
View Full Code Here

Examples of java.security.interfaces.RSAPrivateKey

        if (o == this)
        {
            return true;
        }

        RSAPrivateKey key = (RSAPrivateKey)o;

        return getModulus().equals(key.getModulus())
            && getPrivateExponent().equals(key.getPrivateExponent());
    }
View Full Code Here

Examples of java.security.interfaces.RSAPrivateKey

    protected int engineGetKeySize(
        Key key)
    {
        if (key instanceof RSAPrivateKey)
        {
            RSAPrivateKey k = (RSAPrivateKey)key;

            return k.getModulus().bitLength();
        }
        else if (key instanceof RSAPublicKey)
        {
            RSAPublicKey k = (RSAPublicKey)key;

            return k.getModulus().bitLength();
        }

        throw new IllegalArgumentException("not an RSA key!");
    }
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.