Java 类org.bouncycastle.crypto.params.NaccacheSternKeyParameters 实例源码

项目:ipack    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}
项目:gwt-crypto    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}
项目:Aki-SSL    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}
项目:TinyTravelTracker    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}
项目:CryptMeme    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}
项目:irma_future_id    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}
项目:bc-java    文件:NaccacheSternEngine.java   
/**
 * Initializes this algorithm. Must be called before all other Functions.
 * 
 * @see org.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean,
 *      org.bouncycastle.crypto.CipherParameters)
 */
public void init(boolean forEncryption, CipherParameters param)
{
    this.forEncryption = forEncryption;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    key = (NaccacheSternKeyParameters)param;

    // construct lookup table for faster decryption if necessary
    if (!this.forEncryption)
    {
        if (debug)
        {
            System.out.println("Constructing lookup Array");
        }
        NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key;
        Vector primes = priv.getSmallPrimes();
        lookup = new Vector[primes.size()];
        for (int i = 0; i < primes.size(); i++)
        {
            BigInteger actualPrime = (BigInteger)primes.elementAt(i);
            int actualPrimeValue = actualPrime.intValue();

            lookup[i] = new Vector();
            lookup[i].addElement(ONE);

            if (debug)
            {
                System.out.println("Constructing lookup ArrayList for " + actualPrimeValue);
            }

            BigInteger accJ = ZERO;

            for (int j = 1; j < actualPrimeValue; j++)
            {
                accJ = accJ.add(priv.getPhi_n());
                BigInteger comp = accJ.divide(actualPrime);
                lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus()));
            }
        }
    }
}