org.bouncycastle.crypto.params.ECKeyParameters Java Examples

The following examples show how to use org.bouncycastle.crypto.params.ECKeyParameters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyPairUtil.java    From portecle with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: KeyPairUtil.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
	}

	_logger.warn("Don't know how to get key size from parameters " + keyParams);
	return UNKNOWN_KEY_SIZE;
}
 
Example #3
Source File: BCECUtil.java    From gmhelper with Apache License 2.0 4 votes vote down vote up
public static int getCurveLength(ECKeyParameters ecKey) {
    return getCurveLength(ecKey.getParameters());
}
 
Example #4
Source File: BCECUtil.java    From littleca with Apache License 2.0 4 votes vote down vote up
public static int getCurveLength(ECKeyParameters ecKey) {
    return getCurveLength(ecKey.getParameters());
}
 
Example #5
Source File: BCECUtil.java    From jiguang-java-client-common with MIT License 4 votes vote down vote up
public static int getCurveLength(ECKeyParameters ecKey) {
    return getCurveLength(ecKey.getParameters());
}