View Javadoc
1   package civitas.crypto.rsakeypair;
2   
3   import java.security.PublicKey;
4   
5   import org.springframework.beans.factory.annotation.Autowired;
6   import org.springframework.stereotype.Controller;
7   
8   import civitas.crypto.CryptoBase;
9   import civitas.crypto.algorithms.CreateFreshNonceBase64;
10  
11  @Controller
12  public class GenerateKeyPair {
13  
14  	@Autowired
15  	CryptoBase cryptoBase;
16  
17  	@Autowired
18  	CreateFreshNonceBase64 createFreshNonceBase64;
19  
20  	public KeyPair apply(final int keyLength) {
21  		java.security.KeyPair kp = cryptoBase.getPublicKeyGenerator(keyLength).generateKeyPair();
22  		PublicKey pubk = kp.getPublic();
23  		java.security.PrivateKey prvk = kp.getPrivate();
24  
25  		return new KeyPair(pubk, prvk);
26  	}
27  }