Package org.bouncycastle.crypto.params

Examples of org.bouncycastle.crypto.params.RSAKeyParameters


        }

        public KeyPair generateKeyPair()
        {
            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            RSAKeyParameters            pub = (RSAKeyParameters)pair.getPublic();
            RSAPrivateCrtKeyParameters  priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();

            return new KeyPair(new JCERSAPublicKey(pub),
                               new JCERSAPrivateCrtKey(priv));
        }
View Full Code Here


            case PublicKeyAlgorithmTags.RSA_ENCRYPT:
            case PublicKeyAlgorithmTags.RSA_GENERAL:
            case PublicKeyAlgorithmTags.RSA_SIGN:
                RSAPublicBCPGKey rsaK = (RSAPublicBCPGKey)publicPk.getKey();

                return new RSAKeyParameters(false, rsaK.getModulus(), rsaK.getPublicExponent());
            case PublicKeyAlgorithmTags.DSA:
                DSAPublicBCPGKey dsaK = (DSAPublicBCPGKey)publicPk.getKey();

                return new DSAPublicKeyParameters(dsaK.getY(), new DSAParameters(dsaK.getP(), dsaK.getQ(), dsaK.getG()));
            case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT:
View Full Code Here

        } else {
            issuerName = new X500Name(subjectDn);
        }
       
        RSAPublicKey rsaPubKey = (RSAPublicKey)subjectPublicKey;
        RSAKeyParameters rsaSpec = new RSAKeyParameters(false, rsaPubKey.getModulus(), rsaPubKey.getPublicExponent());

        SubjectPublicKeyInfo subjectPublicKeyInfo =
            SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(rsaSpec);

        DigestCalculator digestCalc = new JcaDigestCalculatorProviderBuilder()
View Full Code Here

        if (algId.getObjectId().equals(PKCSObjectIdentifiers.rsaEncryption)
            || algId.getObjectId().equals(X509ObjectIdentifiers.id_ea_rsa))
        {
            RSAPublicKeyStructure   pubKey = new RSAPublicKeyStructure((ASN1Sequence)keyInfo.getPublicKey());

            return new RSAKeyParameters(false, pubKey.getModulus(), pubKey.getPublicExponent());
        }
        else if (algId.getObjectId().equals(PKCSObjectIdentifiers.dhKeyAgreement)
                 || algId.getObjectId().equals(X9ObjectIdentifiers.dhpublicnumber))
        {
            DHParameter params = new DHParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
View Full Code Here

        }

        public KeyPair generateKeyPair()
        {
            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            RSAKeyParameters            pub = (RSAKeyParameters)pair.getPublic();
            RSAPrivateCrtKeyParameters  priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();

            return new KeyPair(new JCERSAPublicKey(pub),
                               new JCERSAPrivateCrtKey(priv));
        }
View Full Code Here

  {
    String encString = null;

    BigInteger intModulus = new BigInteger(modulus);
    BigInteger intExponent = new BigInteger(exponent);
    RSAKeyParameters RSApubKey = new RSAKeyParameters(false, intModulus, intExponent);
    byte[] toEncrypt = input.getBytes();
    cipher = new PKCS1Encoding(new RSAEngine());
    cipher.init(true, RSApubKey);
    byte[] encByte = cipher.processBlock(toEncrypt, 0, toEncrypt.length);
    byte[] encValue = Hex.encode(encByte);
View Full Code Here

      // JCA identifier RSA/ECB/OAEPWithSHA-1AndMGF1Padding ?
      OAEPEncoding cipher = new OAEPEncoding(engine);

      BigInteger mod = pub.getModulus();
      BigInteger exp = pub.getPublicExponent();
      RSAKeyParameters keyParams = new RSAKeyParameters(false, mod, exp);
      cipher.init(true, keyParams);

      int inputBlockSize = cipher.getInputBlockSize();
      int outputBlockSize = cipher.getOutputBlockSize();
View Full Code Here

      OAEPEncoding cipher = new OAEPEncoding(engine);
     
      BigInteger mod = priv.getModulus();
      BigInteger exp = priv.getPrivateExponent();

      RSAKeyParameters keyParams = new RSAKeyParameters(true, mod, exp);
      cipher.init(false, keyParams);
      byte[] secretKeyBytes = cipher.processBlock(encryptedCEK, 0, encryptedCEK.length);
      return new SecretKeySpec(secretKeyBytes, "AES");

    } catch (Exception e) {
View Full Code Here

        }

        public KeyPair generateKeyPair()
        {
            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            RSAKeyParameters            pub = (RSAKeyParameters)pair.getPublic();
            RSAPrivateCrtKeyParameters  priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();

            return new KeyPair(new JCERSAPublicKey(pub),
                               new JCERSAPrivateCrtKey(priv));
        }
View Full Code Here

                                    }

                                    /*
                                    * Parse the servers public RSA key.
                                    */
                                    this.serverRsaKey = new RSAKeyParameters(
                                        false,
                                        rsaKey.getModulus(),
                                        rsaKey.getPublicExponent());

                                    connection_state = CS_SERVER_CERTIFICATE_RECEIVED;
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.params.RSAKeyParameters

Copyright © 2018 www.massapicom. 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.