本文整理汇总了Java中java.security.spec.RSAPublicKeySpec.getModulus方法的典型用法代码示例。如果您正苦于以下问题:Java RSAPublicKeySpec.getModulus方法的具体用法?Java RSAPublicKeySpec.getModulus怎么用?Java RSAPublicKeySpec.getModulus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.spec.RSAPublicKeySpec
的用法示例。
在下文中一共展示了RSAPublicKeySpec.getModulus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BCRSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
BCRSAPublicKey(
RSAPublicKeySpec spec)
{
this.algorithmIdentifier = DEFAULT_ALGORITHM_IDENTIFIER;
this.modulus = spec.getModulus();
this.publicExponent = spec.getPublicExponent();
}
示例2: decodeRSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
/**
* @param spec an instance of {@link RSAPublicKeySpec} to decode.
* @return an instance of {@link GnuRSAPublicKey} constructed from the
* information in the designated key-specification.
*/
private GnuRSAPublicKey decodeRSAPublicKey(RSAPublicKeySpec spec)
{
BigInteger n = spec.getModulus();
BigInteger e = spec.getPublicExponent();
return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
}
示例3: testRSA
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的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: getRSAKeyLength
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
static int getRSAKeyLength(PublicKey key) {
BigInteger modulus;
if (key instanceof RSAPublicKey) {
modulus = ((RSAPublicKey)key).getModulus();
} else {
RSAPublicKeySpec spec = getRSAPublicKeySpec(key);
modulus = spec.getModulus();
}
return modulus.bitLength();
}
示例5: JCERSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
JCERSAPublicKey(
RSAPublicKeySpec spec)
{
this.modulus = spec.getModulus();
this.publicExponent = spec.getPublicExponent();
}
示例6: BCRSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
BCRSAPublicKey(
RSAPublicKeySpec spec)
{
this.modulus = spec.getModulus();
this.publicExponent = spec.getPublicExponent();
}
示例7: TempJCERSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
TempJCERSAPublicKey(
RSAPublicKeySpec spec)
{
this.modulus = spec.getModulus();
this.publicExponent = spec.getPublicExponent();
}
示例8: toRSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
public static RSAPublicKey toRSAPublicKey(RSAPublicKeySpec k)
{
return new RSAPublicKey(k.getModulus(), k.getPublicExponent());
}
示例9: IosRSAPublicKey
import java.security.spec.RSAPublicKeySpec; //导入方法依赖的package包/类
public IosRSAPublicKey(RSAPublicKeySpec spec) {
super(spec.getModulus());
this.publicExponent = spec.getPublicExponent();
}