1 2 29 30 package com.jcraft.jsch.jce; 31 32 import java.security.*; 33 import java.security.interfaces.*; 34 35 public class KeyPairGenDSA implements com.jcraft.jsch.KeyPairGenDSA{ 36 byte[] x; byte[] y; byte[] p; 39 byte[] q; 40 byte[] g; 41 42 public void init(int key_size) throws Exception { 43 KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA"); 44 keyGen.initialize(key_size, new SecureRandom()); 45 KeyPair pair = keyGen.generateKeyPair(); 46 PublicKey pubKey=pair.getPublic(); 47 PrivateKey prvKey=pair.getPrivate(); 48 49 x=((DSAPrivateKey)prvKey).getX().toByteArray(); 50 y=((DSAPublicKey)pubKey).getY().toByteArray(); 51 52 DSAParams params=((DSAKey)prvKey).getParams(); 53 p=params.getP().toByteArray(); 54 q=params.getQ().toByteArray(); 55 g=params.getG().toByteArray(); 56 } 57 public byte[] getX(){return x;} 58 public byte[] getY(){return y;} 59 public byte[] getP(){return p;} 60 public byte[] getQ(){return q;} 61 public byte[] getG(){return g;} 62 } 63 | Popular Tags |