Package org.bouncycastle.crypto.params

Examples of org.bouncycastle.crypto.params.RSAKeyParameters


           
            AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WITHRSAENCRYPTION");
            AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
            RSAPrivateKey privateRSAKey = (RSAPrivateKey)privateKey;
            RSAKeyParameters keyParams = new RSAKeyParameters(true, privateRSAKey.getModulus(), privateRSAKey.getPrivateExponent());
            ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(keyParams);

            gen.addSignerInfoGenerator(
                    new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider())
                        .build(sigGen, new X509CertificateHolder(certificate)));
View Full Code Here


  public MessageHeader(int size, int certainty) throws Exception{
    RSAKeyGenerationParameters param = new RSAKeyGenerationParameters(pubExp, sr, size, certainty);
    RSAKeyPairGenerator kpGen = new RSAKeyPairGenerator();
    kpGen.init(param);
    acKp = kpGen.generateKeyPair();
    RSAKeyParameters rsaParam = (RSAKeyParameters)acKp.getPublic();
    this.exp = rsaParam.getExponent();
    this.mod = rsaParam.getModulus();
    eng.init(false, acKp.getPrivate());
  }
View Full Code Here

  public BigInteger getMod() {
    return this.mod;
  }

  private String generate() throws Exception{
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod, exp);
    AsymmetricBlockCipher eng = new PKCS1Encoding(new RSAEngine());
    eng.init(true, pubParameters);
    byte[] data = Base16.fromHexString(this.sessionKey);
    data = eng.processBlock(data, 0, data.length);
    return Base16.toHexString(data);
View Full Code Here

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

        cipher.init(forSigning, kParam);

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

        block = new byte[(keyBits + 7) / 8];
        mBuf = new byte[block.length - 1];

        reset();
View Full Code Here

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

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

            kParam = (RSAKeyParameters)p.getParameters();
            random = p.getRandom();
        }
        else
        {
            kParam = (RSAKeyParameters)param;
            if (forSigning)
            {
                random = new SecureRandom();
            }
        }

        cipher.init(forSigning, kParam);

        emBits = kParam.getModulus().bitLength() - 1;

        block = new byte[(emBits + 7) / 8];

        reset();
    }
View Full Code Here

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

            catch (Exception e)
            {
                return new SimpleTestResult(false, getName() + ": exception - " + e.toString());
            }
   
            RSAKeyParameters    pubParameters = new RSAKeyParameters(
                                                        false,
                                                        pubStruct.getModulus(),
                                                        pubStruct.getPublicExponent());
   
            RSAKeyParameters    privParameters = new RSAPrivateCrtKeyParameters(
                                                        privStruct.getModulus(),
                                                        privStruct.getPublicExponent(),
                                                        privStruct.getPrivateExponent(),
                                                        privStruct.getPrime1(),
                                                        privStruct.getPrime2(),
View Full Code Here

        return true;
    }

    private TestResult doTest1()
    {
        RSAKeyParameters    pubParameters = new RSAKeyParameters(false, mod1, pub1);
        RSAKeyParameters    privParameters = new RSAKeyParameters(true, mod1, pri1);
        RSAEngine           rsa = new RSAEngine();
        byte[]              data;

        //
        // ISO 9796-1 - public encrypt, private decrypt
View Full Code Here

        return new SimpleTestResult(true, "ISO9796: Okay");
    }

    private TestResult doTest2()
    {
        RSAKeyParameters    pubParameters = new RSAKeyParameters(false, mod1, pub1);
        RSAKeyParameters    privParameters = new RSAKeyParameters(true, mod1, pri1);
        RSAEngine           rsa = new RSAEngine();
        byte[]              data;

        //
        // ISO 9796-1 - public encrypt, private decrypt
View Full Code Here

        return new SimpleTestResult(true, "ISO9796: Okay");
    }

    public TestResult doTest3()
    {
        RSAKeyParameters    pubParameters = new RSAKeyParameters(false, mod2, pub2);
        RSAKeyParameters    privParameters = new RSAKeyParameters(true, mod2, pri2);
        RSAEngine           rsa = new RSAEngine();
        byte[]              data;

        //
        // ISO 9796-1 - public encrypt, private decrypt
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.