src/main/java/cn/jiguang/common/utils/sm2/BCECUtil.java
public static BCECPrivateKey convertPKCS8ToECPrivateKey(byte[] pkcs8Key)
        throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {
        PKCS8EncodedKeySpec peks = new PKCS8EncodedKeySpec(pkcs8Key);
        KeyFactory kf = KeyFactory.getInstance(ALGO_NAME_EC, BouncyCastleProvider.PROVIDER_NAME);
        return (BCECPrivateKey) kf.generatePrivate(peks);
    }
public static BCECPrivateKey convertPKCS8ToECPrivateKey(byte[] pkcs8Key)
        throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {
        PKCS8EncodedKeySpec peks = new PKCS8EncodedKeySpec(pkcs8Key);
        KeyFactory kf = KeyFactory.getInstance(ALGO_NAME_EC, BouncyCastleProvider.PROVIDER_NAME);
        return (BCECPrivateKey) kf.generatePrivate(peks);
    }
public static BCECPrivateKey convertPKCS8ToECPrivateKey ( byte [ ] pkcs8Key ) throws NoSuchAlgorithmException , NoSuchProviderException , InvalidKeySpecException { PKCS8EncodedKeySpec peks = new PKCS8EncodedKeySpec ( pkcs8Key ) ; KeyFactory kf = KeyFactory . getInstance ( ALGO_NAME_EC , BouncyCastleProvider . PROVIDER_NAME ) ; return ( BCECPrivateKey ) kf . generatePrivate ( peks ) ; }
将PKCS8标准的私钥字节流转换为私钥对象

@param pkcs8Key
@return
@throws NoSuchAlgorithmException
@throws NoSuchProviderException
@throws InvalidKeySpecException
将PKCS8标准的私钥字节流转换为私钥对象