java.lang.Object
java.security.spec.RSAPrivateKeySpec
- All Implemented Interfaces:
- KeySpec
- Direct Known Subclasses:
- RSAMultiPrimePrivateCrtKeySpec, RSAPrivateCrtKeySpec
- See Also:
- Top Examples, Source Code,
Key
,
KeyFactory
,
PKCS8EncodedKeySpec
,
RSAPublicKeySpec
public BigInteger getModulus()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public BigInteger getPrivateExponent()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[801]Keystore
By Anonymous on 2004/11/29 22:56:28 Rate
public static void kstore ( String algoName, Certificate cert ) throws KeyStoreException, InvalidKeyException, java.security.cert.CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, InvalidKeySpecException
{
//g?n?ration keystore
KeyStore ks = KeyStore.getInstance ( algoName ) ;
//verification du certificat du client
PublicKey pk = cert.getPublicKey ( ) ;
cert.verify ( pk ) ;
//generation cl? secrete ( mode DES )
KeyGenerator kg = KeyGenerator.getInstance ( "DES" ) ;
kg.init ( 56 ) ;
SecretKey key = kg.generateKey ( ) ;
//chiffrage RSA cl? secrete ? partir de la cl? publique
//k^e mod n = BigInteger
BigInteger m = ( ( RSAPrivateKey ) key ) .getPrivateExponent ( ) ;
BigInteger n = ( ( RSAPublicKey ) pk ) .getModulus ( ) ;
BigInteger e = ( ( RSAPublicKey ) pk ) .getPublicExponent ( ) ;
BigInteger keyChiff = m.modPow ( e,n ) ;
if ( keyChiff.compareTo ( BigInteger.ZERO ) < 0 )
keyChiff = keyChiff.add ( p ) ;
System.out.println ( keyChiff ) ;
}
public RSAPrivateKeySpec(BigInteger modulus,
BigInteger privateExponent)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples