Skip to content

Commit

Permalink
feat: 1.为加载函数添加注释,触发 CI
Browse files Browse the repository at this point in the history
Signed-off-by: photowey <[email protected]>
  • Loading branch information
photowey committed Dec 7, 2023
1 parent 8cbae2c commit d418970
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/twgc/gm/sm2/SM2Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ public static PublicKey derivePublicFromPrivate(PrivateKey privateKey) {
BouncyCastleProvider.CONFIGURATION);
}

/**
* 加载私钥
*
* @param password 密码
* @param fx {@link Reader} 回调函数
* @return {@link PrivateKey}
* @throws IOException
* @throws OperatorCreationException
* @throws PKCSException
*/
public static PrivateKey loadPriv(String password, Supplier<Reader> fx) throws IOException, OperatorCreationException, PKCSException {
PrivateKey priv = null;
try (PEMParser pemParser = new PEMParser(fx.get())) {
Expand All @@ -283,6 +293,16 @@ public static PrivateKey loadPriv(String password, Supplier<Reader> fx) throws I
return priv;
}

/**
* 加载公钥
*
* @param fx {@link Reader} 回调函数
* @return {@link PublicKey}
* @throws IOException
* @throws NoSuchProviderException
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public static PublicKey loadPublic(Supplier<Reader> fx) throws IOException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException {
try (PemReader pemReader = new PemReader(fx.get())) {
PemObject spki = pemReader.readPemObject();
Expand Down

0 comments on commit d418970

Please sign in to comment.