Skip to content

Commit 003cb5a

Browse files
committed
docs: add javadoc
1 parent 4965a95 commit 003cb5a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

key-pair-loader/src/main/java/com/onixbyte/security/KeyLoader.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ default RSAPublicKey loadPublicKey(String modulus, String exponent) {
6868
throw new KeyLoadingException("This key loader does not support loading an RSA public key.");
6969
}
7070

71+
/**
72+
* Loads an EC public key using the provided x and y coordinates together with the curve name.
73+
* <p>
74+
* This default implementation throws a {@link KeyLoadingException} to signify that this key loader does not support
75+
* loading an EC public key. Implementing classes are expected to override this method to supply their own
76+
* loading logic.
77+
*
78+
* @param xHex the hexadecimal string representing the x coordinate of the EC point
79+
* @param yHex the hexadecimal string representing the y coordinate of the EC point
80+
* @param curveName the name of the elliptic curve
81+
* @return the loaded {@link ECPublicKey} instance
82+
* @throws KeyLoadingException if loading is not supported or fails
83+
*/
7184
default ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) {
7285
throw new KeyLoadingException("This key loader does not support loading an EC public key.");
7386
}

key-pair-loader/src/main/java/com/onixbyte/security/impl/ECKeyLoader.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ public ECPublicKey loadPublicKey(String pemKeyText) {
131131
}
132132
}
133133

134+
/**
135+
* Loads an EC public key from the given hexadecimal x and y coordinates alongside the curve name.
136+
* <p>
137+
* This method converts the hexadecimal string representations of the EC point coordinates into {@link BigInteger}
138+
* instances, then constructs an {@link ECPoint} and retrieves the corresponding {@link ECParameterSpec} for the
139+
* named curve. Subsequently, it utilises the {@link KeyFactory} to generate an {@link ECPublicKey}.
140+
* <p>
141+
* Only curves listed in {@link #SUPPORTED_CURVES} are supported. Should the specified curve name be unsupported,
142+
* or if key construction fails due to invalid parameters or unsupported algorithms, a {@link KeyLoadingException}
143+
* will be thrown.
144+
*
145+
* @param xHex the hexadecimal string representing the x-coordinate of the EC point
146+
* @param yHex the hexadecimal string representing the y-coordinate of the EC point
147+
* @param curveName the name of the elliptic curve
148+
* @return the {@link ECPublicKey} generated from the specified coordinates and curve
149+
* @throws KeyLoadingException if the curve is unsupported or key generation fails
150+
*/
134151
@Override
135152
public ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) {
136153
if (!SUPPORTED_CURVES.contains(curveName)) {

0 commit comments

Comments
 (0)