1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package org.bouncycastle.openpgp.operator.jcajce;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Date;
import org.bouncycastle.openpgp.PGPAlgorithmParameters;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
public class JcaPGPKeyPair
extends PGPKeyPair
{
private static PGPPublicKey getPublicKey(int algorithm, PublicKey pubKey, Date date)
throws PGPException
{
return new JcaPGPKeyConverter().getPGPPublicKey(algorithm, pubKey, date);
}
private static PGPPublicKey getPublicKey(int algorithm, PGPAlgorithmParameters algorithmParameters, PublicKey pubKey, Date date)
throws PGPException
{
return new JcaPGPKeyConverter().getPGPPublicKey(algorithm, algorithmParameters, pubKey, date);
}
private static PGPPrivateKey getPrivateKey(PGPPublicKey pub, PrivateKey privKey)
throws PGPException
{
return new JcaPGPKeyConverter().getPGPPrivateKey(pub, privKey);
}
public JcaPGPKeyPair(int algorithm, KeyPair keyPair, Date date)
throws PGPException
{
this.pub = getPublicKey(algorithm, keyPair.getPublic(), date);
this.priv = getPrivateKey(this.pub, keyPair.getPrivate());
}
public JcaPGPKeyPair(int algorithm, PGPAlgorithmParameters parameters, KeyPair keyPair, Date date)
throws PGPException
{
this.pub = getPublicKey(algorithm, parameters, keyPair.getPublic(), date);
this.priv = getPrivateKey(this.pub, keyPair.getPrivate());
}
}
|