當前位置: 首頁>>代碼示例>>Java>>正文


Java RSAPrivateKeySpec.getModulus方法代碼示例

本文整理匯總了Java中java.security.spec.RSAPrivateKeySpec.getModulus方法的典型用法代碼示例。如果您正苦於以下問題:Java RSAPrivateKeySpec.getModulus方法的具體用法?Java RSAPrivateKeySpec.getModulus怎麽用?Java RSAPrivateKeySpec.getModulus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.spec.RSAPrivateKeySpec的用法示例。


在下文中一共展示了RSAPrivateKeySpec.getModulus方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: BuildFromSecrets

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
public static RsaSha256Fulfillment BuildFromSecrets(String PEMEncodedPrivateKey, byte[] message, SecureRandom saltRandom) {
        ConditionType type = ConditionType.RSA_SHA256;
        
        try {
//            privKey = (RSAPrivateKeySpec)kf.generatePrivate(new PKCS8EncodedKeySpec(privateKey.payload));
            RSAPrivateKeySpec privKeySpec = RsaSha256Fulfillment.parsePEMEncodedPrivateKey(PEMEncodedPrivateKey);
            PrivateKey privKey = kf.generatePrivate(privKeySpec);
            Signature signatureEngine = RsaSha256Fulfillment.getSignEngine();
            signatureEngine.initSign(privKey /*, saltRandom */);
            signatureEngine.update(message);
            byte[] signature =  signatureEngine.sign();
            BigInteger modulus = privKeySpec.getModulus();
            FulfillmentPayload payload = RsaSha256Fulfillment.calculatePayload(modulus, signature);
    
            return new RsaSha256Fulfillment(type, payload, modulus, new SignaturePayload(signature));
        } catch (Exception e) {
            throw new RuntimeException(e.toString(), e);
        }
    }
 
開發者ID:mgrand,項目名稱:bigchaindb-java-driver,代碼行數:20,代碼來源:RsaSha256Fulfillment.java

示例2: init

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
private static OpenSSLKey init(RSAPrivateKeySpec rsaKeySpec) throws InvalidKeySpecException {
    final BigInteger modulus = rsaKeySpec.getModulus();
    final BigInteger privateExponent = rsaKeySpec.getPrivateExponent();

    if (modulus == null) {
        throw new InvalidKeySpecException("modulus == null");
    } else if (privateExponent == null) {
        throw new InvalidKeySpecException("privateExponent == null");
    }

    try {
        return new OpenSSLKey(NativeCrypto.EVP_PKEY_new_RSA(
                modulus.toByteArray(),
                null,
                privateExponent.toByteArray(),
                null,
                null,
                null,
                null,
                null));
    } catch (Exception e) {
        throw new InvalidKeySpecException(e);
    }
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:25,代碼來源:OpenSSLRSAPrivateKey.java

示例3: testRSA

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
@Test
public void testRSA() throws Exception {
	KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
	assertNotNull(keyPairGenerator);
	keyPairGenerator.initialize(1024);
	KeyPair keyPair = keyPairGenerator.genKeyPair();
	assertNotNull(keyPair);
	PublicKey publicKey = keyPair.getPublic();
	assertNotNull(publicKey);
	PrivateKey privateKey = keyPair.getPrivate();
	assertNotNull(privateKey);

	KeyFactory keyFactory = KeyFactory.getInstance("RSA");
	assertNotNull(keyFactory);
	RSAPrivateKeySpec privateKeySpec = keyFactory.getKeySpec(privateKey,
			RSAPrivateKeySpec.class);
	assertNotNull(privateKeySpec);
	RSAPublicKeySpec publicKeySpec = keyFactory.getKeySpec(publicKey,
			RSAPublicKeySpec.class);
	assertNotNull(publicKeySpec);

	BigInteger privateModulus = privateKeySpec.getModulus();
	assertNotNull(privateModulus);
	BigInteger privateExponent = privateKeySpec.getPrivateExponent();
	assertNotNull(privateExponent);

	BigInteger publicModulus = publicKeySpec.getModulus();
	assertNotNull(publicModulus);
	BigInteger publicExponent = publicKeySpec.getPublicExponent();
	assertNotNull(publicExponent);

	System.out.println("privateModulus: " + privateModulus);
	System.out.println("privateExponent: " + privateExponent);
	System.out.println("publicModulus: " + publicModulus);
	System.out.println("publicExponent: " + publicExponent);
}
 
開發者ID:PureSolTechnologies,項目名稱:Purifinity,代碼行數:37,代碼來源:CryptographyTest.java

示例4: JCERSAPrivateKey

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
JCERSAPrivateKey(
    RSAPrivateKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.privateExponent = spec.getPrivateExponent();
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:7,代碼來源:JCERSAPrivateKey.java

示例5: BCRSAPrivateKey

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
BCRSAPrivateKey(
    RSAPrivateKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.privateExponent = spec.getPrivateExponent();
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:7,代碼來源:BCRSAPrivateKey.java

示例6: TempJCERSAPrivateKey

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
TempJCERSAPrivateKey(
    RSAPrivateKeySpec spec)
{
    this.modulus = spec.getModulus();
    this.privateExponent = spec.getPrivateExponent();
}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:7,代碼來源:TempJCERSAPrivateKey.java

示例7: IosRSAPrivateKey

import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
public IosRSAPrivateKey(RSAPrivateKeySpec spec) {
  super(spec.getModulus());
  this.privateExponent = spec.getPrivateExponent();
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:5,代碼來源:IosRSAKey.java


注:本文中的java.security.spec.RSAPrivateKeySpec.getModulus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。