Java 类org.bouncycastle.crypto.agreement.kdf.DHKDFParameters 实例源码

项目:ipack    文件:KeyAgreementSpi.java   
protected SecretKey engineGenerateSecret(
    String algorithm)
    throws NoSuchAlgorithmException
{
    byte[] secret = bigIntToBytes(result);

    if (kdf != null)
    {
        if (!algorithms.containsKey(algorithm))
        {
            throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
        }

        int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

        DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);

        byte[] keyBytes = new byte[keySize / 8];
        kdf.init(params);
        kdf.generateBytes(keyBytes, 0, keyBytes.length);
        secret = keyBytes;
    }
    else
    {
        // TODO Should we be ensuring the key is the right length?
    }

    return new SecretKeySpec(secret, algorithm);
}
项目:CryptMeme    文件:KeyAgreementSpi.java   
protected SecretKey engineGenerateSecret(
    String algorithm)
    throws NoSuchAlgorithmException
{
    byte[] secret = bigIntToBytes(result);

    if (kdf != null)
    {
        if (!algorithms.containsKey(algorithm))
        {
            throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
        }

        int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

        DHKDFParameters params = new DHKDFParameters(new ASN1ObjectIdentifier(algorithm), keySize, secret);

        byte[] keyBytes = new byte[keySize / 8];
        kdf.init(params);
        kdf.generateBytes(keyBytes, 0, keyBytes.length);
        secret = keyBytes;
    }
    else
    {
        // TODO Should we be ensuring the key is the right length?
    }

    return new SecretKeySpec(secret, algorithm);
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
protected SecretKey engineGenerateSecret(
    String algorithm)
    throws NoSuchAlgorithmException
{
    byte[] secret = bigIntToBytes(result);

    if (kdf != null)
    {
        if (!algorithms.containsKey(algorithm))
        {
            throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
        }

        int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

        DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);

        byte[] keyBytes = new byte[keySize / 8];
        kdf.init(params);
        kdf.generateBytes(keyBytes, 0, keyBytes.length);
        secret = keyBytes;
    }
    else
    {
        // TODO Should we be ensuring the key is the right length?
    }

    return new SecretKeySpec(secret, algorithm);
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
protected SecretKey engineGenerateSecret(
    String algorithm)
    throws NoSuchAlgorithmException
{
    byte[] secret = bigIntToBytes(result);

    if (kdf != null)
    {
        if (!algorithms.containsKey(algorithm))
        {
            throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
        }

        int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

        DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);

        byte[] keyBytes = new byte[keySize / 8];
        kdf.init(params);
        kdf.generateBytes(keyBytes, 0, keyBytes.length);
        secret = keyBytes;
    }
    else
    {
        // TODO Should we be ensuring the key is the right length?
    }

    return new SecretKeySpec(secret, algorithm);
}
项目:bc-java    文件:KeyAgreementSpi.java   
protected SecretKey engineGenerateSecret(
    String algorithm)
    throws NoSuchAlgorithmException
{
    byte[] secret = bigIntToBytes(result);

    if (kdf != null)
    {
        if (!algorithms.containsKey(algorithm))
        {
            throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
        }

        int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

        DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);

        byte[] keyBytes = new byte[keySize / 8];
        kdf.init(params);
        kdf.generateBytes(keyBytes, 0, keyBytes.length);
        secret = keyBytes;
    }
    else
    {
        // TODO Should we be ensuring the key is the right length?
    }

    return new SecretKeySpec(secret, algorithm);
}
项目:bc-java    文件:KeyAgreementSpi.java   
protected SecretKey engineGenerateSecret(
    String algorithm)
    throws NoSuchAlgorithmException
{
    byte[] secret = bigIntToBytes(result);

    if (kdf != null)
    {
        if (!algorithms.containsKey(algorithm))
        {
            throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
        }

        int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

        DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);

        byte[] keyBytes = new byte[keySize / 8];
        kdf.init(params);
        kdf.generateBytes(keyBytes, 0, keyBytes.length);
        secret = keyBytes;
    }
    else
    {
        // TODO Should we be ensuring the key is the right length?
    }

    return new SecretKeySpec(secret, algorithm);
}
项目:gwt-crypto    文件:DHKEKGeneratorTest.java   
public void performTest()
{
    checkMask(1, new DHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg1, 192, seed1), result1);
    checkMask(2, new DHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg2, 128, seed2, partyAInfo), result2);
}
项目:gwt-crypto    文件:ECDHKEKGeneratorTest.java   
public void performTest()
{
    checkMask(1, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg1, 256, seed1), result1);
    checkMask(2, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg2, 128, seed2), result2);
    checkMask(3, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg3, 192, seed3), result3);
}
项目:irma_future_id    文件:DHKEKGeneratorTest.java   
public void performTest()
{
    checkMask(1, new DHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg1, 192, seed1), result1);
    checkMask(2, new DHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg2, 128, seed2, partyAInfo), result2);
}
项目:irma_future_id    文件:ECDHKEKGeneratorTest.java   
public void performTest()
{
    checkMask(1, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg1, 256, seed1), result1);
    checkMask(2, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg2, 128, seed2), result2);
    checkMask(3, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg3, 192, seed3), result3);
}
项目:bc-java    文件:DHKEKGeneratorTest.java   
public void performTest()
{
    checkMask(1, new DHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg1, 192, seed1), result1);
    checkMask(2, new DHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg2, 128, seed2, partyAInfo), result2);
}
项目:bc-java    文件:ECDHKEKGeneratorTest.java   
public void performTest()
{
    checkMask(1, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg1, 256, seed1), result1);
    checkMask(2, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg2, 128, seed2), result2);
    checkMask(3, new ECDHKEKGenerator(new SHA1Digest()), new DHKDFParameters(alg3, 192, seed3), result3);
}