Brainpool ECC curves support for Java

As of version 3.1.3.1 of DidiSoft OpenPGP Library for Java Elliptic Curve (ECC) OpenPGP keys can be created over the field of Brainpool curves.

Usage of keys based on the Brainpool curves was possible by older versions of the library, but it couldn’t create keys based on them.

These Elliptic Curves are not yet a part of the ECC OpenPGP standard, but were adopted by GnuPG/gpg, so we had to catch up in order to be able to provide functionality for creating OpenPGP based on them. The curves are available as enumeration members in the EcCurve.Enum type:

EcCurve.Enum.Brainpool256;
EcCurve.Enum.Brainpool384;
EcCurve.Enum.Brainpool512;

and as String values:

EcCurve.Brainpool256;
EcCurve.Brainpool384;
EcCurve.Brainpool512;

and can be used with the new method KeyStore.generateEccKeyPair that accepts EcCurve.Enum parameters, or the overloaded versions that accept the ECC curve by name.

Below is an example code that demonstrates this new functionality:

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
import com.didisoft.pgp.*;
 
public class GenerateKeyPairECC {
 
	public static void main(String[] args) throws Exception {
		// initialize the KeyStore where the key will be generated
		KeyStore ks = new KeyStore("examples/DataFiles/pgp.keystore", "changeit");
 
		// key primary user Id
		String userId = "<demo@didisoft.com>";
 
		// preferred hashing algorithms
		HashAlgorithm.Enum[] hashingAlgorithms = new HashAlgorithm.Enum[]
		                             {HashAlgorithm.Enum.SHA256,
						HashAlgorithm.Enum.SHA384,
						HashAlgorithm.Enum.SHA512};
 
		// preferred compression algorithms
		CompressionAlgorithm.Enum[] compressions = new CompressionAlgorithm.Enum[] 
		                            {CompressionAlgorithm.Enum.ZIP,
						CompressionAlgorithm.Enum.UNCOMPRESSED};
 
		// preferred symmetric key algorithms
		CypherAlgorithm.Enum[] cyphers = new CypherAlgorithm.Enum[] 
		                     {CypherAlgorithm.Enum.AES_128,
					CypherAlgorithm.Enum.AES_192,
					CypherAlgorithm.Enum.AES_256};
 
		String privateKeyPassword = "changeit";
 
		EcCurve.Enum masterEcCurve = EcCurve.Enum.Brainpool512;
		EcCurve.Enum encryptionEcCurve = EcCurve.Enum.Brainpool512;
 
		int expiresAfterDays = 0; // never expires
 
		KeyPairInformation key = ks.generateEccKeyPair(masterEcCurve,
							encryptionEcCurve,
							userId, 
							privateKeyPassword, 
							compressions, 
							hashingAlgorithms, 
							cyphers,
							expiresAfterDays);
 
		System.out.println("Generated a " + masterEcCurve.toString() + "/" + encryptionEcCurve.toString() + " ECC OpenPGP key");
	}
}

 

What’s Next?

In the upcoming months we are going to provide support for Curve25519 which is one of the fastest ECC curves and is not known to be part of any patent yet.