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

项目:gwt-crypto    文件:MGF1GeneratorTest.java   
private void checkMask(
    int                count,
    DerivationFunction kdf,
    byte[]             seed,
    byte[]             result)
{
    byte[]             data = new byte[result.length];

    kdf.init(new MGFParameters(seed));

    kdf.generateBytes(data, 0, data.length);

    if (!areEqual(result, data))
    {
        fail("MGF1 failed generator test " + count);
    }
}
项目:irma_future_id    文件:MGF1GeneratorTest.java   
private void checkMask(
    int                count,
    DerivationFunction kdf,
    byte[]             seed,
    byte[]             result)
{
    byte[]             data = new byte[result.length];

    kdf.init(new MGFParameters(seed));

    kdf.generateBytes(data, 0, data.length);

    if (!areEqual(result, data))
    {
        fail("MGF1 failed generator test " + count);
    }
}
项目:bc-java    文件:MGF1GeneratorTest.java   
private void checkMask(
    int                count,
    DerivationFunction kdf,
    byte[]             seed,
    byte[]             result)
{
    byte[]             data = new byte[result.length];

    kdf.init(new MGFParameters(seed));

    kdf.generateBytes(data, 0, data.length);

    if (!areEqual(result, data))
    {
        fail("MGF1 failed generator test " + count);
    }
}
项目:ipack    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:ipack    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:Direct-File-Downloader    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:gwt-crypto    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 | (random.nextInt() & 0xff));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:gwt-crypto    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:gwt-crypto    文件:BcFixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 + random.nextInt(255));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:gwt-crypto    文件:BcFixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:gwt-crypto    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:Aki-SSL    文件:BcFixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 + random.nextInt(255));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:Aki-SSL    文件:BcFixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:Aki-SSL    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:TinyTravelTracker    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:AcademicTorrents-Downloader    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:CryptMeme    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:irma_future_id    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 | (random.nextInt() & 0xff));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:irma_future_id    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:irma_future_id    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 + random.nextInt(255));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:irma_future_id    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:irma_future_id    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 + Math.abs(random.nextInt()) % 254);
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:irma_future_id    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:irma_future_id    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:bc-java    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 | (random.nextInt() & 0xff));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:bc-java    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:bc-java    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 + random.nextInt(255));
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:bc-java    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:bc-java    文件:FixedLengthMGF1Padder.java   
public byte[] getPaddedData(byte[] data)
{
    byte[] bytes = new byte[length];
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    if (random == null)
    {
        random = new SecureRandom();
    }

    random.nextBytes(seed);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    System.arraycopy(seed, 0, bytes, 0, seed.length);
    System.arraycopy(data, 0, bytes, seed.length, data.length);

    for (int i = seed.length + data.length + 1; i != bytes.length; i++)
    {
        bytes[i] = (byte)(1 + Math.abs(random.nextInt()) % 254);
    }

    for (int i = 0; i != mask.length; i++)
    {
        bytes[i + seed.length] ^= mask[i];
    }

    return bytes;
}
项目:bc-java    文件:FixedLengthMGF1Padder.java   
public byte[] getUnpaddedData(byte[] paddedData)
{
    byte[] seed = new byte[dig.getDigestSize()];
    byte[] mask = new byte[length - dig.getDigestSize()];

    System.arraycopy(paddedData, 0, seed, 0, seed.length);

    MGF1BytesGenerator maskGen = new MGF1BytesGenerator(dig);

    maskGen.init(new MGFParameters(seed));

    maskGen.generateBytes(mask, 0, mask.length);

    for (int i = 0; i != mask.length; i++)
    {
        paddedData[i + seed.length] ^= mask[i];
    }

    int end = 0;

    for (int i = paddedData.length - 1; i != seed.length; i--)
    {
        if (paddedData[i] == 0)
        {
            end = i;
            break;
        }
    }

    if (end == 0)
    {
        throw new IllegalStateException("bad padding in encoding");
    }

    byte[] data = new byte[end - seed.length];

    System.arraycopy(paddedData, seed.length, data, 0, data.length);

    return data;
}
项目:bc-java    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}