本文整理汇总了Java中java.security.spec.RSAPrivateKeySpec.getPrivateExponent方法的典型用法代码示例。如果您正苦于以下问题:Java RSAPrivateKeySpec.getPrivateExponent方法的具体用法?Java RSAPrivateKeySpec.getPrivateExponent怎么用?Java RSAPrivateKeySpec.getPrivateExponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.spec.RSAPrivateKeySpec
的用法示例。
在下文中一共展示了RSAPrivateKeySpec.getPrivateExponent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: JCERSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //导入方法依赖的package包/类
JCERSAPrivateKey(
RSAPrivateKeySpec spec)
{
this.modulus = spec.getModulus();
this.privateExponent = spec.getPrivateExponent();
}
示例4: BCRSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //导入方法依赖的package包/类
BCRSAPrivateKey(
RSAPrivateKeySpec spec)
{
this.modulus = spec.getModulus();
this.privateExponent = spec.getPrivateExponent();
}
示例5: TempJCERSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //导入方法依赖的package包/类
TempJCERSAPrivateKey(
RSAPrivateKeySpec spec)
{
this.modulus = spec.getModulus();
this.privateExponent = spec.getPrivateExponent();
}
示例6: IosRSAPrivateKey
import java.security.spec.RSAPrivateKeySpec; //导入方法依赖的package包/类
public IosRSAPrivateKey(RSAPrivateKeySpec spec) {
super(spec.getModulus());
this.privateExponent = spec.getPrivateExponent();
}