Skip to content

Commit 1bae99b

Browse files
committed
Merge branch 'pgpainless-documentBCPGKeys'
2 parents 6d2e793 + 15b0d91 commit 1bae99b

14 files changed

+142
-6
lines changed

pg/src/main/java/org/bouncycastle/bcpg/ECDHPublicBCPGKey.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
import org.bouncycastle.math.ec.ECPoint;
88

99
/**
10-
* base class for an ECDH Public Key.
10+
* Base class for an ECDH Public Key.
11+
* This type is for use with {@link PublicKeyAlgorithmTags#ECDH}.
12+
* The specific curve is identified by providing an OID.
13+
* Regarding X25519, X448, consider the following:
14+
* Modern implementations use dedicated key types {@link X25519PublicBCPGKey}, {@link X448PublicBCPGKey} along with
15+
* dedicated algorithm tags {@link PublicKeyAlgorithmTags#X25519}, {@link PublicKeyAlgorithmTags#X448}.
16+
* If you want to be compatible with legacy applications however, you should use this class instead.
17+
* Note though, that for v6 keys, {@link X25519PublicBCPGKey} or {@link X448PublicBCPGKey} MUST be used for X25519, X448.
18+
*
19+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ecd">
20+
* Crypto-Refresh - Algorithm-Specific Parts for ECDH Keys</a>
1121
*/
1222
public class ECDHPublicBCPGKey
1323
extends ECPublicBCPGKey

pg/src/main/java/org/bouncycastle/bcpg/ECDSAPublicBCPGKey.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import org.bouncycastle.math.ec.ECPoint;
88

99
/**
10-
* base class for an ECDSA Public Key.
10+
* Base class for an ECDSA Public Key.
11+
* This type is used with {@link PublicKeyAlgorithmTags#ECDSA} and the curve is identified by providing an OID.
12+
*
13+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ec">
14+
* Crypto-Refresh - Algorithm-Specific Parts for ECDSA Keys</a>
1115
*/
1216
public class ECDSAPublicBCPGKey
1317
extends ECPublicBCPGKey

pg/src/main/java/org/bouncycastle/bcpg/ECPublicBCPGKey.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import org.bouncycastle.math.ec.ECPoint;
99

1010
/**
11-
* base class for an EC Public Key.
11+
* Base class for an EC Public Key.
12+
* For subclasses, see {@link ECDHPublicBCPGKey}, {@link ECDSAPublicBCPGKey} or {@link EdDSAPublicBCPGKey}.
1213
*/
1314
public abstract class ECPublicBCPGKey
1415
extends BCPGObject

pg/src/main/java/org/bouncycastle/bcpg/ECSecretBCPGKey.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@
44
import java.math.BigInteger;
55

66
/**
7-
* base class for an EC Secret Key.
7+
* Base class for an EC Secret Key.
8+
* This type is for use with {@link PublicKeyAlgorithmTags#ECDH} or {@link PublicKeyAlgorithmTags#ECDSA}.
9+
* The specific curve is identified by providing an OID.
10+
* Regarding X25519, X448, consider the following:
11+
* ECDH keys using curve448 are unspecified.
12+
* ECDH secret keys using curve25519 use big-endian MPI encoding, contrary to {@link X25519SecretBCPGKey} which uses
13+
* native encoding.
14+
* Modern implementations use dedicated key types {@link X25519SecretBCPGKey}, {@link X448SecretBCPGKey} along with
15+
* dedicated algorithm tags {@link PublicKeyAlgorithmTags#X25519}, {@link PublicKeyAlgorithmTags#X448}.
16+
* If you want to be compatible with legacy applications however, you should use this class instead.
17+
* Note though, that for v6 keys, {@link X25519SecretBCPGKey} or {@link X448SecretBCPGKey} MUST be used for X25519, X448.
18+
*
19+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ecd">
20+
* Crypto-Refresh - Algorithm-Specific Parts for ECDH Keys</a>
21+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ec">
22+
* Crypto-Refresh - Algorithm-Specific Parts for ECDSA Keys</a>
23+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-curve25519legacy-ecdh-secre">
24+
* Crypto-Refresh - Curve25519Legacy ECDH Secret Key Material (deprecated)</a>
825
*/
926
public class ECSecretBCPGKey
1027
extends BCPGObject

pg/src/main/java/org/bouncycastle/bcpg/Ed25519PublicBCPGKey.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
import java.io.IOException;
44

5+
/**
6+
* Public key of type {@link PublicKeyAlgorithmTags#Ed25519}.
7+
* This type was introduced with Crypto-Refresh and can be used with v4, v6 keys.
8+
* Note however, that legacy implementations might not understand this key type yet.
9+
* For a key type compatible with legacy v4 implementations, see {@link EdDSAPublicBCPGKey} with
10+
* {@link PublicKeyAlgorithmTags#EDDSA_LEGACY}.
11+
*
12+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ed2">
13+
* Crypto-Refresh - Algorithm-Specific Part for Ed25519 Keys</a>
14+
*/
515
public class Ed25519PublicBCPGKey
616
extends OctetArrayBCPGKey
717
{
18+
// 32 octets of the native public key
819
public static final int LENGTH = 32;
920

1021
public Ed25519PublicBCPGKey(BCPGInputStream in)

pg/src/main/java/org/bouncycastle/bcpg/Ed25519SecretBCPGKey.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
import java.io.IOException;
44

5+
/**
6+
* Secret key of type {@link PublicKeyAlgorithmTags#Ed25519}.
7+
* This type was introduced with Crypto-Refresh and can be used with v4, v6 keys.
8+
* Note however, that legacy implementations might not understand this key type yet.
9+
* For a key type compatible with legacy v4 implementations, see {@link EdDSAPublicBCPGKey} with
10+
* {@link PublicKeyAlgorithmTags#EDDSA_LEGACY}.
11+
*
12+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ed2">
13+
* Crypto-Refresh - Algorithm-Specific Part for Ed25519 Keys</a>
14+
*/
515
public class Ed25519SecretBCPGKey
616
extends OctetArrayBCPGKey
717
{
18+
// 32 octets of the native secret key
819
public static final int LENGTH = 32;
920

1021
public Ed25519SecretBCPGKey(BCPGInputStream in)

pg/src/main/java/org/bouncycastle/bcpg/Ed448PublicBCPGKey.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
import java.io.IOException;
44

5+
/**
6+
* Public key of type {@link PublicKeyAlgorithmTags#Ed448}.
7+
* This type was introduced with Crypto-Refresh and can be used with v4, v6 keys.
8+
* Note however, that legacy implementations might not understand this key type yet.
9+
* For a key type compatible with legacy v4 implementations, see {@link EdDSAPublicBCPGKey} with
10+
* {@link PublicKeyAlgorithmTags#EDDSA_LEGACY}.
11+
*
12+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ed4">
13+
* Crypto-Refresh - Algorithm-Specific Part for Ed448 Keys</a>
14+
*/
515
public class Ed448PublicBCPGKey
616
extends OctetArrayBCPGKey
717
{
18+
// 57 octets of the native public key
819
public static final int LENGTH = 57;
920

1021
public Ed448PublicBCPGKey(BCPGInputStream in)

pg/src/main/java/org/bouncycastle/bcpg/Ed448SecretBCPGKey.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
import java.io.IOException;
44

5+
/**
6+
* Secret key of type {@link PublicKeyAlgorithmTags#Ed448}.
7+
* This type was introduced with Crypto-Refresh and can be used with v4, v6 keys.
8+
* Note however, that legacy implementations might not understand this key type yet.
9+
* For a key type compatible with legacy v4 implementations, see {@link EdDSAPublicBCPGKey} with
10+
* {@link PublicKeyAlgorithmTags#EDDSA_LEGACY}.
11+
*
12+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ed4">
13+
* Crypto-Refresh - Algorithm-Specific Part for Ed448 Keys</a>
14+
*/
515
public class Ed448SecretBCPGKey
616
extends OctetArrayBCPGKey
717
{
18+
// 57 octets of the native secret key
819
public static final int LENGTH = 57;
920

1021
public Ed448SecretBCPGKey(BCPGInputStream in)

pg/src/main/java/org/bouncycastle/bcpg/EdDSAPublicBCPGKey.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
import org.bouncycastle.math.ec.ECPoint;
88

99
/**
10-
* base class for an EdDSA Public Key.
10+
* Base class for an EdDSA Public Key.
11+
* Here, the curve is identified by an OID and the key is MPI encoded.
12+
* This class is used with {@link PublicKeyAlgorithmTags#EDDSA_LEGACY} only and MUST NOT be used with v6 keys.
13+
* Modern OpenPGP uses dedicated key types:
14+
* For {@link PublicKeyAlgorithmTags#Ed25519} see {@link Ed25519PublicBCPGKey} instead.
15+
* For {@link PublicKeyAlgorithmTags#Ed448} see {@link Ed448PublicBCPGKey} instead.
16+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ed">
17+
* Crypto-Refresh - Algorithm-Specific Parts for EdDSALegacy Keys (deprecated)</a>
1118
*/
1219
public class EdDSAPublicBCPGKey
1320
extends ECPublicBCPGKey

pg/src/main/java/org/bouncycastle/bcpg/EdSecretBCPGKey.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
import java.math.BigInteger;
55

66
/**
7-
* base class for an Edwards Curve Secret Key.
7+
* Base class for an Edwards Curve (EdDSA) Secret Key.
8+
* This class is used with {@link PublicKeyAlgorithmTags#EDDSA_LEGACY} only and MUST NOT be used with v6 keys.
9+
* Modern OpenPGP uses dedicated key types:
10+
* For {@link PublicKeyAlgorithmTags#Ed25519} see {@link Ed25519SecretBCPGKey} instead.
11+
* For {@link PublicKeyAlgorithmTags#Ed448} see {@link Ed448SecretBCPGKey} instead.
12+
*
13+
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ed">
14+
* Crypto-Refresh - Algorithm-Specific Parts for EdDSALegacy Keys (deprecated)</a>
815
*/
916
public class EdSecretBCPGKey
1017
extends BCPGObject

0 commit comments

Comments
 (0)