本文整理匯總了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();
}