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


Java DHKeyParameters类代码示例

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


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

示例1: getKeyLength

import org.bouncycastle.crypto.params.DHKeyParameters; //导入依赖的package包/类
/**
 * Get the key size of a key represented by key parameters.
 * 
 * @param keyParams The key parameters
 * @return The key size, {@link #UNKNOWN_KEY_SIZE} if not known
 */
public static int getKeyLength(AsymmetricKeyParameter keyParams)
{
	if (keyParams instanceof RSAKeyParameters)
	{
		return ((RSAKeyParameters) keyParams).getModulus().bitLength();
	}
	else if (keyParams instanceof DSAKeyParameters)
	{
		return ((DSAKeyParameters) keyParams).getParameters().getP().bitLength();
	}
	else if (keyParams instanceof DHKeyParameters)
	{
		return ((DHKeyParameters) keyParams).getParameters().getP().bitLength();
	}
	else if (keyParams instanceof ECKeyParameters)
	{
		// TODO: how to get key length from these?
		return UNKNOWN_KEY_SIZE;
	}

	LOG.warning("Don't know how to get key size from parameters " + keyParams);
	return UNKNOWN_KEY_SIZE;
}
 
开发者ID:gavioto,项目名称:portecle,代码行数:30,代码来源:KeyPairUtil.java

示例2: engineGetOutputSize

import org.bouncycastle.crypto.params.DHKeyParameters; //导入依赖的package包/类
public int engineGetOutputSize(int inputLen)
{
    int len1, len2, len3;

    if (key == null)
    {
        throw new IllegalStateException("cipher not initialised");
    }

    len1 = engine.getMac().getMacSize();

    if (otherKeyParameter == null)
    {
        len2 = 1 + 2 * (((DHKeyParameters)key).getParameters().getP().bitLength() + 7) / 8;
    }
    else
    {
        len2 = 0;
    }

    if (engine.getCipher() == null)
    {
        len3 = inputLen;
    }
    else if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen);
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen - len1 - len2);
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        return buffer.size() + len1 + len2 + len3;
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        return buffer.size() - len1 - len2 + len3;
    }
    else
    {
        throw new IllegalStateException("IESCipher not initialised");
    }

}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:52,代码来源:IESCipher.java


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