当前位置: 首页>>代码示例>>Java>>正文


Java EphemeralKeyPair.getEncodedPublicKey方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.EphemeralKeyPair.getEncodedPublicKey方法的典型用法代码示例。如果您正苦于以下问题:Java EphemeralKeyPair.getEncodedPublicKey方法的具体用法?Java EphemeralKeyPair.getEncodedPublicKey怎么用?Java EphemeralKeyPair.getEncodedPublicKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.EphemeralKeyPair的用法示例。


在下文中一共展示了EphemeralKeyPair.getEncodedPublicKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processBlock

import org.bouncycastle.crypto.EphemeralKeyPair; //导入方法依赖的package包/类
public byte[] processBlock(
    byte[] in,
    int inOff,
    int inLen)
    throws InvalidCipherTextException
{
    if (forEncryption)
    {
        if (keyPairGenerator != null)
        {
            EphemeralKeyPair ephKeyPair = keyPairGenerator.generate();

            this.privParam = ephKeyPair.getKeyPair().getPrivate();
            this.V = ephKeyPair.getEncodedPublicKey();
        }
    }
    else
    {
        if (keyParser != null)
        {
            ByteArrayInputStream bIn = new ByteArrayInputStream(in, inOff, inLen);

            try
            {
                this.pubParam = keyParser.readKey(bIn);
            }
            catch (IOException e)
            {
                throw new InvalidCipherTextException("unable to recover ephemeral public key: " + e.getMessage(), e);
            }

            int encLength = (inLen - bIn.available());
            this.V = Arrays.copyOfRange(in, inOff, inOff + encLength);
        }
    }

    // Compute the common value and convert to byte array. 
    agree.init(privParam);
    BigInteger z = agree.calculateAgreement(pubParam);
    byte[] Z = BigIntegers.asUnsignedByteArray(agree.getFieldSize(), z);

    // Create input to KDF.  
    byte[] VZ;
    if (V.length != 0)
    {
        VZ = new byte[V.length + Z.length];
        System.arraycopy(V, 0, VZ, 0, V.length);
        System.arraycopy(Z, 0, VZ, V.length, Z.length);
    }
    else
    {
        VZ = Z;
    }

    // Initialise the KDF.
    KDFParameters kdfParam = new KDFParameters(VZ, param.getDerivationV());
    kdf.init(kdfParam);

    return forEncryption
        ? encryptBlock(in, inOff, inLen)
        : decryptBlock(in, inOff, inLen);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:63,代码来源:IESEngine.java

示例2: processBlock

import org.bouncycastle.crypto.EphemeralKeyPair; //导入方法依赖的package包/类
public byte[] processBlock(
    byte[] in,
    int inOff,
    int inLen)
    throws InvalidCipherTextException
{
    if (forEncryption)
    {
        if (keyPairGenerator != null)
        {
            EphemeralKeyPair ephKeyPair = keyPairGenerator.generate();

            this.privParam = ephKeyPair.getKeyPair().getPrivate();
            this.V = ephKeyPair.getEncodedPublicKey();
        }
    }
    else
    {
        if (keyParser != null)
        {
            ByteArrayInputStream bIn = new ByteArrayInputStream(in, inOff, inLen);

            try
            {
                this.pubParam = keyParser.readKey(bIn);
            }
            catch (IOException e)
            {
                throw new InvalidCipherTextException("unable to recover ephemeral public key: " + e.getMessage(), e);
            }

            int encLength = (inLen - bIn.available());
            this.V = Arrays.copyOfRange(in, inOff, inOff + encLength);
        }
    }

    // Compute the common value and convert to byte array. 
    agree.init(privParam);
    BigInteger z = agree.calculateAgreement(pubParam);
    byte[] Z = BigIntegers.asUnsignedByteArray(agree.getFieldSize(), z);

    // Create input to KDF.  
    if (V.length != 0)
    {
        byte[] VZ = Arrays.concatenate(V, Z);
        Arrays.fill(Z, (byte)0);
        Z = VZ;
    }

    try
    {
        // Initialise the KDF.
        KDFParameters kdfParam = new KDFParameters(Z, param.getDerivationV());
        kdf.init(kdfParam);

        return forEncryption
            ? encryptBlock(in, inOff, inLen)
            : decryptBlock(in, inOff, inLen);
    }
    finally
    {
        Arrays.fill(Z, (byte)0);
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:65,代码来源:IESEngine.java


注:本文中的org.bouncycastle.crypto.EphemeralKeyPair.getEncodedPublicKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。