Examples of RSAKeyParameters


Examples of org.bouncycastle.crypto.params.RSAKeyParameters

      new RSAKeyParameters(false, new BigInteger(n), new BigInteger(e));
    digest.reset();
    cipher.init(false, pubKey);
  }
  public void setPrvKey(byte[] d, byte[] n) throws Exception{
    RSAKeyParameters prvKey=
      new RSAKeyParameters(true, new BigInteger(n), new BigInteger(d));
    digest.reset();
    cipher.init(true, prvKey);
  }
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

    kpgen.init(RSAKeyGenPara);
    AsymmetricCipherKeyPair keyPair=kpgen.generateKeyPair();

    RSAPrivateCrtKeyParameters prvKey=
      (RSAPrivateCrtKeyParameters) keyPair.getPrivate();
    RSAKeyParameters pubKey=
      (RSAKeyParameters) keyPair.getPublic();

    e=pubKey.getExponent().toByteArray();
    n=prvKey.getModulus().toByteArray();

    d=prvKey.getExponent().toByteArray();
    c=prvKey.getQInv().toByteArray();
    ep=prvKey.getDP().toByteArray();
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

      AsymmetricKeyParameter keyParam = PublicKeyFactory.createKey(subjectPublicKeyInfo);
     
      // TODO: handle other types of keys.
      if (keyParam instanceof RSAKeyParameters) {
        RSAKeyParameters rsaKeyParam = (RSAKeyParameters) keyParam;
        DefaultCertificate cert = new DefaultCertificate(this);
        cert.setDefaultSerialisation(new DERSerialisation(cert));
        cert.setSubjectPublicKey(new DefaultRSAPubKey(rsaKeyParam.getExponent(),rsaKeyParam.getModulus()));
        return cert;
      } else {
                log.warn("KeyParam is not an RSA Key but of type"+keyParam.getClass()+" need to implement this.");
            }
//          A lot of potentially useful code developed by Bruno, that shows one one
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

            }
        }

        cipher.init(forSigning, params);

        RSAKeyParameters kParam;

        if (params instanceof RSABlindingParameters)
        {
            kParam = ((RSABlindingParameters)params).getPublicKey();
        }
        else
        {
            kParam = (RSAKeyParameters)params;
        }
       
        emBits = kParam.getModulus().bitLength() - 1;

        if (emBits < (8 * hLen + 8 * sLen + 9))
        {
            throw new IllegalArgumentException("key too small for specified hash and salt lengths");
        }
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

   *             parameters.
   */
  public static PublicKey getPublicKey(PKCS10CertificationRequest csr)
      throws InvalidKeySpecException, IOException {
    SubjectPublicKeyInfo pubKeyInfo = csr.getSubjectPublicKeyInfo();
    RSAKeyParameters keyParams = (RSAKeyParameters) PublicKeyFactory
        .createKey(pubKeyInfo);
    KeySpec keySpec = new RSAPublicKeySpec(keyParams.getModulus(),
        keyParams.getExponent());

    KeyFactory kf;
    try {
      kf = KeyFactory.getInstance("RSA");
    } catch (NoSuchAlgorithmException e) {
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

public class RSAUtil
{
    static public RSAKeyParameters generatePublicKeyParameter(
        RSAPublicKey    key)
    {
        return new RSAKeyParameters(false, key.getModulus(), key.getPublicExponent());

    }
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

        }
        else
        {
            RSAPrivateKey    k = key;

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

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

     */
    public void init(
        boolean                 forSigning,
        CipherParameters        param)
    {
        RSAKeyParameters    kParam = null;
        int                    lengthOfSalt = saltLength;

        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    p = (ParametersWithRandom)param;

            kParam = (RSAKeyParameters)p.getParameters();
            random = p.getRandom();
        }
        else if (param instanceof ParametersWithSalt)
        {
            ParametersWithSalt    p = (ParametersWithSalt)param;

            kParam = (RSAKeyParameters)p.getParameters();
            standardSalt = p.getSalt();
            lengthOfSalt = standardSalt.length;
        }
        else
        {
            kParam = (RSAKeyParameters)param;
            if (forSigning)
            {
                random = new SecureRandom();
            }
        }
       
        cipher.init(forSigning, kParam);

        keyBits = kParam.getModulus().bitLength();

        block = new byte[(keyBits + 7) / 8];
       
        if (trailer == TRAILER_IMPLICIT)
        {
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

    public void init(
        boolean             forEncryption,
        CipherParameters    param)
    {
        RSAKeyParameters  kParam = null;

        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            kParam = (RSAKeyParameters)rParam.getParameters();
        }
        else
        {
            kParam = (RSAKeyParameters)param;
        }

        engine.init(forEncryption, kParam);

        bitSize = kParam.getModulus().bitLength();

        this.forEncryption = forEncryption;
    }
View Full Code Here

Examples of org.bouncycastle.crypto.params.RSAKeyParameters

                                    }

                                    /*
                                    * 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
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.