本文整理匯總了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);
}
}
示例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);
}
}
示例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);
}
示例4: JCERSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
JCERSAPrivateKey(
RSAPrivateKeySpec spec)
{
this.modulus = spec.getModulus();
this.privateExponent = spec.getPrivateExponent();
}
示例5: BCRSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
BCRSAPrivateKey(
RSAPrivateKeySpec spec)
{
this.modulus = spec.getModulus();
this.privateExponent = spec.getPrivateExponent();
}
示例6: TempJCERSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
TempJCERSAPrivateKey(
RSAPrivateKeySpec spec)
{
this.modulus = spec.getModulus();
this.privateExponent = spec.getPrivateExponent();
}
示例7: IosRSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //導入方法依賴的package包/類
public IosRSAPrivateKey(RSAPrivateKeySpec spec) {
super(spec.getModulus());
this.privateExponent = spec.getPrivateExponent();
}