當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。