Examples of RSAPublicKey


Examples of ch.ethz.ssh2.signature.RSAPublicKey

  private boolean verifySignature(byte[] sig, byte[] hostkey) throws IOException
  {
    if (kxs.np.server_host_key_algo.equals("ssh-rsa"))
    {
      RSASignature rs = RSASHA1Verify.decodeSSHRSASignature(sig);
      RSAPublicKey rpk = RSASHA1Verify.decodeSSHRSAPublicKey(hostkey);

      log.log(50, "Verifying ssh-rsa signature");

      return RSASHA1Verify.verifySignature(kxs.H, rs, rpk);
    }
View Full Code Here

Examples of com.maverick.crypto.publickey.RsaPublicKey

                                blob[0] = 0;
                                System.arraycopy(x509.getSignature(), 0, blob, 1, x509.getSignature().length);
                            }

                            BigInteger input = new BigInteger(blob);
                            RsaPublicKey r = (RsaPublicKey) trusted.getPublicKey();
                            BigInteger decoded = Rsa.doPublic(input, r.getModulus(), r.getPublicExponent());
                            BigInteger result = Rsa.removePKCS1(decoded, 0x01);
                            byte[] sig = result.toByteArray();

                            MD5Digest digest = new MD5Digest();
                            digest.update(x509.getTBSCertificate(), 0, x509.getTBSCertificate().length);
                            byte[] hash = new byte[digest.getDigestSize()];
                            digest.doFinal(hash, 0);

                            DERInputStream der = new DERInputStream(new ByteArrayInputStream(sig));

                            ASN1Sequence o = (ASN1Sequence) der.readObject();

                            ASN1Sequence o1 = (ASN1Sequence) o.getObjectAt(0);

                            DERObjectIdentifier o2 = (DERObjectIdentifier) o1.getObjectAt(0);
                            ASN1OctetString o3 = (ASN1OctetString) o.getObjectAt(1);

                            byte[] actual = o3.getOctets();

                            for (int i = 0; i < actual.length; i++) {
                                if (actual[i] != hash[i]) {
                                    return false;
                                }
                            }

                        } catch (IOException ex1) {
                            throw new SSLException(SSLException.INTERNAL_ERROR, ex1.getMessage());
                        }

                    } else if (x509.getSigAlgName().equals("SHA1WithRSAEncryption")) { //$NON-NLS-1$

                        try {
                            byte[] blob = x509.getSignature();

                            // Check for signed bit
                            if ((blob[0] & 0x80) == 0x80) {
                                blob = new byte[x509.getSignature().length + 1];
                                blob[0] = 0;
                                System.arraycopy(x509.getSignature(), 0, blob, 1, x509.getSignature().length);
                            }

                            BigInteger input = new BigInteger(blob);
                            RsaPublicKey r = (RsaPublicKey) trusted.getPublicKey();

                            BigInteger decoded = Rsa.doPublic(input, r.getModulus(), r.getPublicExponent());

                            BigInteger result = Rsa.removePKCS1(decoded, 0x01);
                            byte[] sig = result.toByteArray();

                            SHA1Digest digest = new SHA1Digest();
View Full Code Here

Examples of com.sun.satsa.crypto.RSAPublicKey

     * @exception InvalidKeySpecException if the given key specification
     * is inappropriate for this key factory to produce a public key.
     */
    public final PublicKey generatePublic(KeySpec keySpec)
        throws InvalidKeySpecException {
        return new RSAPublicKey(keySpec);
    }
View Full Code Here

Examples of com.trilead.ssh2.signature.RSAPublicKey

  private boolean verifySignature(byte[] sig, byte[] hostkey) throws IOException
  {
    if (kxs.np.server_host_key_algo.equals("ssh-rsa"))
    {
      RSASignature rs = RSASHA1Verify.decodeSSHRSASignature(sig);
      RSAPublicKey rpk = RSASHA1Verify.decodeSSHRSAPublicKey(hostkey);

      log.log(50, "Verifying ssh-rsa signature");

      return RSASHA1Verify.verifySignature(kxs.H, rs, rpk);
    }
View Full Code Here

Examples of java.security.interfaces.RSAPublicKey

  {
    SecretKeySpec blowfishKey = null;
    try {
      X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(PUBLIC_KEY);
      KeyFactory keyFactory = KeyFactory.getInstance("RSA");
      RSAPublicKey publicKey = (RSAPublicKey)keyFactory.generatePublic(publicKeySpec);

      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.DECRYPT_MODE, publicKey);

      byte[] blowfishKeyByteArray = cipher.doFinal(encryptedKey);
View Full Code Here

Examples of java.security.interfaces.RSAPublicKey

  {
    byte[] returnByteArray = null;
    try {
      X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(PUBLIC_KEY);
      KeyFactory keyFactory = KeyFactory.getInstance("RSA");
      RSAPublicKey publicKey = (RSAPublicKey)keyFactory.generatePublic(publicKeySpec);

      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.ENCRYPT_MODE, publicKey);

      returnByteArray = cipher.doFinal(blowfishKey.getEncoded());
View Full Code Here

Examples of java.security.interfaces.RSAPublicKey

    KeyFactory key_factory = KeyFactory.getInstance("RSA");
   
    RSAPublicKeySpec   public_key_spec =
      new RSAPublicKeySpec( new BigInteger(modulus,16), new BigInteger(pub_exp,16));

    RSAPublicKey public_key   = (RSAPublicKey)key_factory.generatePublic( public_key_spec );

    verifyData( file, public_key );
  }
View Full Code Here

Examples of java.security.interfaces.RSAPublicKey

    KeyFactory key_factory = KeyFactory.getInstance("RSA");
   
    RSAPublicKeySpec   public_key_spec =
      new RSAPublicKeySpec( new BigInteger(modulus,16), new BigInteger(pub_exp,16));

    RSAPublicKey public_key   = (RSAPublicKey)key_factory.generatePublic( public_key_spec );
   
    Signature  sig = Signature.getInstance("MD5withRSA" );

    sig.initVerify( public_key );
   
View Full Code Here

Examples of java.security.interfaces.RSAPublicKey

           {
                   return new X509EncodedKeySpec(key.getEncoded());
           }
           else if (spec.isAssignableFrom(RSAPublicKeySpec.class) && key instanceof RSAPublicKey)
           {
                RSAPublicKey    k = (RSAPublicKey)key;

                return new RSAPublicKeySpec(k.getModulus(), k.getPublicExponent());
           }
           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;

                return new RSAPrivateCrtKeySpec(
                                k.getModulus(), k.getPublicExponent(),
                                k.getPrivateExponent(),
                                k.getPrimeP(), k.getPrimeQ(),
                                k.getPrimeExponentP(), k.getPrimeExponentQ(),
                                k.getCrtCoefficient());
           }


            throw new RuntimeException("not implemented yet " + key + " " + spec);
        }
View Full Code Here

Examples of java.security.interfaces.RSAPublicKey

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

    RSAPublicKey key = (RSAPublicKey)o;

    return getModulus().equals(key.getModulus())
      && getPublicExponent().equals(key.getPublicExponent());
  }
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.