Examples of generatePrivate()


Examples of java.security.KeyFactory.generatePrivate()

            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.KeyFactory.generatePrivate()

            // Read the private key
            BigInteger p = bar.readBigInteger();
            RSAPrivateKeySpec prvSpec = new RSAPrivateKeySpec(n, p);
            RSAPublicKeySpec pubSpec = new RSAPublicKeySpec(n, e);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            prvKey = (RSAPrivateKey) kf.generatePrivate(prvSpec);
            pubKey = (RSAPublicKey) kf.generatePublic(pubSpec);
        } catch (Exception e) {
            throw new InvalidKeyException();
        }
    }
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

            BigInteger g = bar.readBigInteger();
            BigInteger x = bar.readBigInteger();
            dsaKey = new DSAPrivateKeySpec(x, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
            prvkey = (DSAPrivateKey) kf.generatePrivate(dsaKey);
        } catch (Exception e) {
            throw new InvalidKeyException();
        }
    }
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

            PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encKey);
            KeyFactory factory = KeyFactory.getInstance(SOSKeyGenerator.keyAlgorithmName,
                    SOSKeyGenerator.provider);

            priv = factory.generatePrivate(keySpec);
      
        } catch (NoClassDefFoundError e) {
            throw new Exception("no such Definition : " + e);
      
        } catch (java.security.spec.InvalidKeySpecException e) {
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

   
    final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
   
    final PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(privKeyBytes);
   
    final PrivateKey privateKey = keyFactory.generatePrivate(privSpec);
   
    this.digester = MessageDigest.getInstance("sha-256");
   
    this.signer = Signature.getInstance("SHA256withRSA");
    this.signer.initSign(privateKey);
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

        byte[] pkcs8Bytes = JavaUtils.getBytesFromFile(filename);
        PKCS8EncodedKeySpec pkcs8Spec = new PKCS8EncodedKeySpec(pkcs8Bytes);

        // Create a key factory
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        rsaKey = keyFactory.generatePrivate(pkcs8Spec);
    }

    @Test
    public void test_five_content_3des_cbc() throws Exception {
        // Read in document
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

            String identity = in.identity;
            String pem = in.credential;

            // extract private key
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            PrivateKey privateKey = keyFactory.generatePrivate(Pems.privateKeySpec(Payloads.newStringPayload(pem)));

            // extract certificate(s)
            Collection<X509Certificate> certs = x509Certificates(pem);

            return new FGCPCredentials.Builder().identity(identity).credential(pem)
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

            KeyFactory kf = KeyFactory.getInstance("DSA");
//            System.out.println("ssh-dsa " + new String(Base64.encode(DSASHA1Verify.encodeSSHDSAPublicKey(x.getPublicKey()))));

            return new KeyPair(
                    kf.generatePublic(new DSAPublicKeySpec(x.getY(), x.getP(), x.getQ(), x.getG())),
                    kf.generatePrivate(new DSAPrivateKeySpec(x.getX(), x.getP(), x.getQ(), x.getG())));
        }

        throw new UnsupportedOperationException("Unrecognizable key format: "+key);
    }
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

        PemObject pemObject = reader.readPemObject();
        reader.close();

        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pemObject.getContent());
        KeyFactory kf = KeyFactory.getInstance("RSA");
        PrivateKey privateKey = kf.generatePrivate(keySpec);
        if (privateKey instanceof RSAPrivateCrtKey) {
          RSAPrivateCrtKey rsaPrivateCrtKey = (RSAPrivateCrtKey) privateKey;
          RSAPublicKeySpec publicKeySpec = new java.security.spec.RSAPublicKeySpec(
              rsaPrivateCrtKey.getModulus(), rsaPrivateCrtKey.getPublicExponent());
          PublicKey publicKey = kf.generatePublic(publicKeySpec);
View Full Code Here

Examples of java.security.KeyFactory.generatePrivate()

  private PrivateKey tryParsePemFormat(String data) {
    try {
      byte[] encoded = Base64.decode(data);
      PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
      KeyFactory kf = KeyFactory.getInstance("RSA");
      PrivateKey privKey = kf.generatePrivate(keySpec);

      return privKey;
    } catch (Exception e) {
      log.debug("Error parsing pem data", e);
      return null;
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.