File tree Expand file tree Collapse file tree
prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/sm9 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 * User identity keys are not standalone-decodable (their encoding omits the master
1818 * public key), so they are not serializable; their {@code writeReplace} throws
1919 * rather than routing through this proxy.
20+ * <p>
21+ * A deserialization filter sees both this class and the key readResolve returns; see the package
22+ * documentation for the allow-list that follows from that.
2023 */
2124class SM9KeyProxy
2225 implements Serializable
Original file line number Diff line number Diff line change 55 * {@code KeyGenerator.SM9-KEM} (and {@code KEM.SM9-KEM} on Java 21 and later). The public key
66 * interfaces these classes implement are in {@link org.bouncycastle.jcajce.interfaces}; the
77 * lightweight implementation they wrap is described in {@link org.bouncycastle.math.ec.sm9}.
8+ * <p>
9+ * <b>Serialization.</b> Only the master keys are serializable. Each is written as an
10+ * {@code SM9KeyProxy} holding its standard encoding, and rebuilt through the key factory by the
11+ * proxy's {@code readResolve}; the user keys and the key exchange's ephemeral keys refuse to be
12+ * written, and no key class accepts a stream that names it directly. A deserialization filter
13+ * ({@code java.io.ObjectInputFilter}) is also shown the object {@code readResolve} returns, so an
14+ * allow-list for SM9 master keys has to name the resolved class as well as the proxy and the byte
15+ * array it carries, for example:
16+ * <pre>
17+ * org.bouncycastle.jcajce.provider.asymmetric.sm9.SM9KeyProxy;
18+ * org.bouncycastle.jcajce.provider.asymmetric.sm9.BCSM9SigMasterPublicKey;
19+ * org.bouncycastle.jcajce.provider.asymmetric.sm9.BCSM9SigMasterPrivateKey;
20+ * org.bouncycastle.jcajce.provider.asymmetric.sm9.BCSM9EncMasterPublicKey;
21+ * org.bouncycastle.jcajce.provider.asymmetric.sm9.BCSM9EncMasterPrivateKey;
22+ * [B;!*
23+ * </pre>
24+ * (as one pattern string, without the line breaks). A filter naming the proxy alone rejects every
25+ * SM9 key. Serialization carries no integrity protection: a stream yields whatever well-formed
26+ * master key it encodes, so a stored key that must not be substituted or corrupted needs protecting
27+ * by the application.
828 */
929package org .bouncycastle .jcajce .provider .asymmetric .sm9 ;
You can’t perform that action at this time.
0 commit comments