Skip to content

Commit f23fc36

Browse files
committed
Document reversed MPI encoding / little-endian native encoding
1 parent 81eea49 commit f23fc36

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* This type is for use with {@link PublicKeyAlgorithmTags#ECDH} or {@link PublicKeyAlgorithmTags#ECDSA}.
99
* The specific curve is identified by providing an OID.
1010
* 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.
1114
* Modern implementations use dedicated key types {@link X25519SecretBCPGKey}, {@link X448SecretBCPGKey} along with
1215
* dedicated algorithm tags {@link PublicKeyAlgorithmTags#X25519}, {@link PublicKeyAlgorithmTags#X448}.
1316
* If you want to be compatible with legacy applications however, you should use this class instead.
@@ -17,6 +20,8 @@
1720
* Crypto-Refresh - Algorithm-Specific Parts for ECDH Keys</a>
1821
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-ec">
1922
* 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>
2025
*/
2126
public class ECSecretBCPGKey
2227
extends BCPGObject

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Note however, that legacy implementations might not understand this key type yet.
99
* For a key type compatible with legacy v4 implementations, see {@link ECDHPublicBCPGKey} with
1010
* {@link PublicKeyAlgorithmTags#ECDH}.
11+
* Note: Contrary to {@link ECSecretBCPGKey} using {@link PublicKeyAlgorithmTags#ECDH}, which uses big-endian
12+
* MPI encoding to encode the secret key material, {@link X25519SecretBCPGKey} uses native little-endian encoding.
1113
*
1214
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-algorithm-specific-part-for-x">
1315
* Crypto-Refresh - Algorithm-Specific Part for X25519 Keys</a>

0 commit comments

Comments
 (0)