Examples of RSAPrivateKeySpec


Examples of java.security.spec.RSAPrivateKeySpec

    return algorithm;
  }

  private static RSAPrivateKey createPrivateKey(BigInteger n, BigInteger d) {
    try {
      return (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new RSAPrivateKeySpec(n, d));
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

                    "ae009d30cfdf6acb5b6a64cdc730bc630a39d946d08babffe62ea20a87e37c93b3b0e8a8e576045b" +
                    "bddfbde83ca9bfa180fe6a5f5eee60661936d728314e809201ef52cd71d9fa3c8ce83f9d30ab5e08" +
                    "1539219e7e45dd6a60be65ac95d2049b8f21", 16),
                new BigInteger("10001", 16));
       
        RSAPrivateKeySpec privKeySpec = new RSAPrivateKeySpec(
                new BigInteger(
                    "8710a2bcb2f3fdac177f0ae0461c2dd0ebf72e0d88a5400583a7d8bdabd" +
                    "6ae009d30cfdf6acb5b6a64cdc730bc630a39d946d08babffe62ea20a87e37c93b3b0e8a8e576045" +
                    "bbddfbde83ca9bfa180fe6a5f5eee60661936d728314e809201ef52cd71d9fa3c8ce83f9d30ab5e0" +
                    "81539219e7e45dd6a60be65ac95d2049b8f21", 16),
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

                                                      new BigInteger(dQ),
                                                      new BigInteger(qInv));
                        } else if (p==null) {
                            // only exponent
                            HBCIUtils.log("private "+type+" key is exponent-only",HBCIUtils.LOG_DEBUG);
                            RSAPrivateKeySpec spec=new RSAPrivateKeySpec(new BigInteger(modulus),
                                                                         new BigInteger(privexponent));
                            key=KeyFactory.getInstance("RSA").generatePrivate(spec);
                        } else {
                            // complete data
                            HBCIUtils.log("private "+type+" key is fully specified",HBCIUtils.LOG_DEBUG);
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

        }
    }

    public RSAPrivateKey privateKey(BigInteger modulus, BigInteger privateExponent) throws JoseException
    {
        RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(modulus, privateExponent);
        return getRsaPrivateKey(keySpec);
    }
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

                                         byte[] privateExponentBytes) {
        BigInteger modulus =  new BigInteger(1, modulusBytes);
        BigInteger privateExponent =  new BigInteger(1, privateExponentBytes);
        try {
            return (RSAPrivateKey)factory.generatePrivate(
                new RSAPrivateKeySpec(modulus, privateExponent));
        } catch (Exception ex) {
            throw new SecurityException(ex);
        }   
    }
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

                                         byte[] privateExponentBytes) {
        BigInteger modulus =  new BigInteger(1, modulusBytes);
        BigInteger privateExponent =  new BigInteger(1, privateExponentBytes);
        try {
            return (RSAPrivateKey)factory.generatePrivate(
                new RSAPrivateKeySpec(modulus, privateExponent));
        } catch (Exception ex) {
            throw new SecurityException(ex);
        }   
    }
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

       }
       else if (spec.isAssignableFrom(RSAPrivateKeySpec.class) && key instanceof RSAPrivateKey)
       {
            RSAPrivateKey    k = (RSAPrivateKey)key;

            return new RSAPrivateKeySpec(k.getModulus(), k.getPrivateExponent());
       }
       else if (spec.isAssignableFrom(RSAPrivateCrtKeySpec.class) && key instanceof RSAPrivateCrtKey)
       {
            RSAPrivateCrtKey    k = (RSAPrivateCrtKey)key;
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

       }
       else if (spec.isAssignableFrom(RSAPrivateKeySpec.class) && key instanceof RSAPrivateKey)
       {
            RSAPrivateKey    k = (RSAPrivateKey)key;

            return new RSAPrivateKeySpec(k.getModulus(), k.getPrivateExponent());
       }
       else if (spec.isAssignableFrom(RSAPrivateCrtKeySpec.class) && key instanceof RSAPrivateCrtKey)
       {
            RSAPrivateCrtKey    k = (RSAPrivateCrtKey)key;
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

                    "ae009d30cfdf6acb5b6a64cdc730bc630a39d946d08babffe62ea20a87e37c93b3b0e8a8e576045b" +
                    "bddfbde83ca9bfa180fe6a5f5eee60661936d728314e809201ef52cd71d9fa3c8ce83f9d30ab5e08" +
                    "1539219e7e45dd6a60be65ac95d2049b8f21", 16),
                new BigInteger("10001", 16));
       
        RSAPrivateKeySpec privKeySpec = new RSAPrivateKeySpec(
                new BigInteger(
                    "8710a2bcb2f3fdac177f0ae0461c2dd0ebf72e0d88a5400583a7d8bdabd" +
                    "6ae009d30cfdf6acb5b6a64cdc730bc630a39d946d08babffe62ea20a87e37c93b3b0e8a8e576045" +
                    "bbddfbde83ca9bfa180fe6a5f5eee60661936d728314e809201ef52cd71d9fa3c8ce83f9d30ab5e0" +
                    "81539219e7e45dd6a60be65ac95d2049b8f21", 16),
View Full Code Here

Examples of java.security.spec.RSAPrivateKeySpec

        MessageDigest sha1Digest;
        Cipher rsaCipher;
        try {
            sha1Digest = MessageDigest.getInstance("SHA1");

            RSAPrivateKeySpec privkey = new RSAPrivateKeySpec(publicKey, privateKey);
            KeyFactory factory = KeyFactory.getInstance("RSA");
            rsaCipher = Cipher.getInstance("RSA");
            rsaCipher.init(Cipher.ENCRYPT_MODE, factory.generatePrivate(privkey));

        } catch (Exception e) { // javax.security.* throws a lot of exceptions
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.