public class BCECUtil extends Object
| Constructor and Description |
|---|
BCECUtil() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
convertECPrivateKeyPEMToPKCS8(String pemString)
将PEM格式的私钥转换为PKCS8标准字节流
|
static String |
convertECPrivateKeyPKCS8ToPEM(byte[] encodedKey)
将PKCS8标准的私钥字节流转换为PEM
|
static byte[] |
convertECPrivateKeySEC1ToPKCS8(byte[] sec1Key)
将SEC1标准的私钥字节流恢复为PKCS8标准的字节流
|
static byte[] |
convertECPrivateKeyToPKCS8(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKey,
org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
将ECC私钥转换为PKCS8标准的字节流
|
static byte[] |
convertECPrivateKeyToSEC1(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKey,
org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
将ECC私钥转换为SEC1标准的字节流
openssl d2i_ECPrivateKey函数要求的DER编码的私钥也是SEC1标准的,
这个工具函数的主要目的就是为了能生成一个openssl可以直接“识别”的ECC私钥.
|
static byte[] |
convertECPublicKeyPEMToX509(String pemString)
将PEM格式的公钥转为X509标准的字节流
|
static byte[] |
convertECPublicKeyToX509(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
将ECC公钥对象转换为X509标准的字节流
|
static String |
convertECPublicKeyX509ToPEM(byte[] encodedKey)
将X509标准的公钥字节流转为PEM
|
static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey |
convertPKCS8ToECPrivateKey(byte[] pkcs8Key)
将PKCS8标准的私钥字节流转换为私钥对象
|
static org.bouncycastle.crypto.params.ECPrivateKeyParameters |
convertPrivateKeyToParameters(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey ecPriKey) |
static org.bouncycastle.crypto.params.ECPublicKeyParameters |
convertPublicKeyToParameters(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey ecPubKey) |
static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey |
convertSEC1ToBCECPrivateKey(byte[] sec1Key)
将SEC1标准的私钥字节流转为BCECPrivateKey对象
|
static org.bouncycastle.crypto.params.ECPrivateKeyParameters |
convertSEC1ToECPrivateKey(byte[] sec1Key)
将SEC1标准的私钥字节流转为ECPrivateKeyParameters对象
openssl i2d_ECPrivateKey函数生成的DER编码的ecc私钥是:SEC1标准的、带有EC_GROUP、带有公钥的,
这个工具函数的主要目的就是为了使Java程序能够“识别”openssl生成的ECC私钥
|
static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey |
convertX509ToECPublicKey(byte[] x509Bytes)
将X509标准的公钥字节流转为公钥对象
|
static org.bouncycastle.crypto.params.ECPrivateKeyParameters |
createECPrivateKeyParameters(BigInteger d,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters) |
static org.bouncycastle.crypto.params.ECPublicKeyParameters |
createECPublicKeyParameters(BigInteger x,
BigInteger y,
org.bouncycastle.math.ec.ECCurve curve,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters) |
static org.bouncycastle.crypto.params.ECPublicKeyParameters |
createECPublicKeyParameters(byte[] xBytes,
byte[] yBytes,
org.bouncycastle.math.ec.ECCurve curve,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters) |
static org.bouncycastle.crypto.params.ECPublicKeyParameters |
createECPublicKeyParameters(String xHex,
String yHex,
org.bouncycastle.math.ec.ECCurve curve,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters) |
static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey |
createPublicKeyFromSubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo subPubInfo) |
static byte[] |
fixToCurveLengthBytes(int curveLength,
byte[] src) |
static KeyPair |
generateKeyPair(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
SecureRandom random) |
static org.bouncycastle.crypto.AsymmetricCipherKeyPair |
generateKeyPairParameter(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
SecureRandom random)
生成ECC密钥对
|
static int |
getCurveLength(org.bouncycastle.crypto.params.ECDomainParameters domainParams) |
static int |
getCurveLength(org.bouncycastle.crypto.params.ECKeyParameters ecKey) |
static org.bouncycastle.asn1.x9.X9ECParameters |
getDomainParametersFromGenSpec(ECGenParameterSpec genSpec)
copy from BC
|
static org.bouncycastle.asn1.x9.X962Parameters |
getDomainParametersFromName(ECParameterSpec ecSpec,
boolean withCompression)
copy from BC
|
static org.bouncycastle.asn1.x9.X9ECParameters |
getDomainParametersFromName(String curveName)
copy from BC
|
public static org.bouncycastle.crypto.AsymmetricCipherKeyPair generateKeyPairParameter(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
SecureRandom random)
public static KeyPair generateKeyPair(org.bouncycastle.crypto.params.ECDomainParameters domainParameters, SecureRandom random) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static int getCurveLength(org.bouncycastle.crypto.params.ECKeyParameters ecKey)
public static int getCurveLength(org.bouncycastle.crypto.params.ECDomainParameters domainParams)
public static byte[] fixToCurveLengthBytes(int curveLength,
byte[] src)
public static org.bouncycastle.crypto.params.ECPrivateKeyParameters createECPrivateKeyParameters(BigInteger d, org.bouncycastle.crypto.params.ECDomainParameters domainParameters)
public static org.bouncycastle.crypto.params.ECPublicKeyParameters createECPublicKeyParameters(BigInteger x, BigInteger y, org.bouncycastle.math.ec.ECCurve curve, org.bouncycastle.crypto.params.ECDomainParameters domainParameters)
public static org.bouncycastle.crypto.params.ECPublicKeyParameters createECPublicKeyParameters(String xHex, String yHex, org.bouncycastle.math.ec.ECCurve curve, org.bouncycastle.crypto.params.ECDomainParameters domainParameters)
public static org.bouncycastle.crypto.params.ECPublicKeyParameters createECPublicKeyParameters(byte[] xBytes,
byte[] yBytes,
org.bouncycastle.math.ec.ECCurve curve,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters)
public static org.bouncycastle.crypto.params.ECPrivateKeyParameters convertPrivateKeyToParameters(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey ecPriKey)
public static org.bouncycastle.crypto.params.ECPublicKeyParameters convertPublicKeyToParameters(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey ecPubKey)
public static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey createPublicKeyFromSubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo subPubInfo)
throws NoSuchProviderException,
NoSuchAlgorithmException,
InvalidKeySpecException,
IOException
public static byte[] convertECPrivateKeyToPKCS8(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKey,
org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
priKey - pubKey - 可以为空,但是如果为空的话得到的结果OpenSSL可能解析不了public static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey convertPKCS8ToECPrivateKey(byte[] pkcs8Key)
throws NoSuchAlgorithmException,
NoSuchProviderException,
InvalidKeySpecException
pkcs8Key - NoSuchAlgorithmExceptionNoSuchProviderExceptionInvalidKeySpecExceptionpublic static String convertECPrivateKeyPKCS8ToPEM(byte[] encodedKey) throws IOException
encodedKey - IOExceptionpublic static byte[] convertECPrivateKeyPEMToPKCS8(String pemString) throws IOException
pemString - IOExceptionpublic static byte[] convertECPrivateKeyToSEC1(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKey,
org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
throws IOException
priKey - pubKey - IOExceptionpublic static byte[] convertECPrivateKeySEC1ToPKCS8(byte[] sec1Key)
throws IOException
sec1Key - IOExceptionpublic static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey convertSEC1ToBCECPrivateKey(byte[] sec1Key)
throws NoSuchAlgorithmException,
NoSuchProviderException,
InvalidKeySpecException,
IOException
sec1Key - NoSuchAlgorithmExceptionNoSuchProviderExceptionInvalidKeySpecExceptionIOExceptionpublic static org.bouncycastle.crypto.params.ECPrivateKeyParameters convertSEC1ToECPrivateKey(byte[] sec1Key)
throws NoSuchAlgorithmException,
NoSuchProviderException,
InvalidKeySpecException,
IOException
sec1Key - NoSuchAlgorithmExceptionNoSuchProviderExceptionInvalidKeySpecExceptionIOExceptionpublic static byte[] convertECPublicKeyToX509(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
pubKey - public static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey convertX509ToECPublicKey(byte[] x509Bytes)
throws NoSuchProviderException,
NoSuchAlgorithmException,
InvalidKeySpecException
x509Bytes - NoSuchProviderExceptionNoSuchAlgorithmExceptionInvalidKeySpecExceptionpublic static String convertECPublicKeyX509ToPEM(byte[] encodedKey) throws IOException
encodedKey - IOExceptionpublic static byte[] convertECPublicKeyPEMToX509(String pemString) throws IOException
pemString - IOExceptionpublic static org.bouncycastle.asn1.x9.X9ECParameters getDomainParametersFromGenSpec(ECGenParameterSpec genSpec)
genSpec - public static org.bouncycastle.asn1.x9.X9ECParameters getDomainParametersFromName(String curveName)
curveName - public static org.bouncycastle.asn1.x9.X962Parameters getDomainParametersFromName(ECParameterSpec ecSpec, boolean withCompression)
ecSpec - withCompression - Copyright © 2021. All rights reserved.