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


Java ECPrivateKey.getS方法代码示例

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


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

示例1: JCEECPrivateKey

import java.security.interfaces.ECPrivateKey; //导入方法依赖的package包/类
public JCEECPrivateKey(
    ECPrivateKey    key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:JCEECPrivateKey.java

示例2: BCDSTU4145PrivateKey

import java.security.interfaces.ECPrivateKey; //导入方法依赖的package包/类
public BCDSTU4145PrivateKey(
    ECPrivateKey key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:BCDSTU4145PrivateKey.java

示例3: BCECPrivateKey

import java.security.interfaces.ECPrivateKey; //导入方法依赖的package包/类
public BCECPrivateKey(
    ECPrivateKey key,
    ProviderConfiguration configuration)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
    this.configuration = configuration;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:BCECPrivateKey.java

示例4: BCECGOST3410PrivateKey

import java.security.interfaces.ECPrivateKey; //导入方法依赖的package包/类
public BCECGOST3410PrivateKey(
    ECPrivateKey key)
{
    this.d = key.getS();
    this.algorithm = key.getAlgorithm();
    this.ecSpec = key.getParams();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:BCECGOST3410PrivateKey.java

示例5: isPrivateKeyValid

import java.security.interfaces.ECPrivateKey; //导入方法依赖的package包/类
/**
 * Checks if the private key is a valid key (according to requirement [V2G2-823]) for the received contract 
 * certificate before saving it to the keystore.
 * @param privateKey The private key corresponding to the contract certificate
 * @param contractCertChain The received contract certificate chain 
 * @return True, if the private key is a valid key, false otherwise.
 */
private static boolean isPrivateKeyValid(ECPrivateKey privateKey, CertificateChainType contractCertChain) {
	AlgorithmParameters parameters;
	
	try {
		parameters = AlgorithmParameters.getInstance("EC");
		parameters.init(new ECGenParameterSpec("secp256r1"));
		
		ECParameterSpec ecParameterSpec = parameters.getParameterSpec(ECParameterSpec.class);
		
		// Now we need to check if the private key is correct (see requirement [V2G2-823]) 
		BigInteger order = ecParameterSpec.getOrder();
		ECPoint basePoint = ecParameterSpec.getGenerator();
		BigInteger privateKeyValue = privateKey.getS();
		X509Certificate contractCert = getCertificate(contractCertChain.getCertificate());
		ECPublicKey publicKey = (ECPublicKey) contractCert.getPublicKey();
		
		// 1. check
		if (privateKeyValue.compareTo(order) != -1) {
			getLogger().error("Validation of private key failed: its value is not strictly smaller than the "
							+ "order of the base point");
			return false;
		}
		
		// 2. check
		/*
		 * TODO: 
		 * No idea how to check for 
		 * "multiplication of the base point with this value must generate a key matching the public key of 
		 * the contract certificate"
		 * "this value" = value of private key
		 * -> some more expert knowledge on the arithmetic of elliptic curves is needed to tackle this!
		 */
		
	} catch (NoSuchAlgorithmException | InvalidParameterSpecException e) {
		getLogger().error(e.getClass().getSimpleName() + " occurred when trying to get private key from raw bytes", e);
		return false;
	}
	
	return true;
}
 
开发者ID:V2GClarity,项目名称:RISE-V2G,代码行数:48,代码来源:SecurityUtils.java


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