public class BCECUtil
extends java.lang.Object
| Constructor and Description |
|---|
BCECUtil() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
convertECPrivateKeyPEMToPKCS8(java.lang.String pemString)
将PEM格式的私钥转换为PKCS8标准字节流
|
static java.lang.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(java.lang.String pemString)
将PEM格式的公钥转为X509标准的字节流
|
static byte[] |
convertECPublicKeyToX509(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
将ECC公钥对象转换为X509标准的字节流
|
static java.lang.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(java.math.BigInteger d,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters) |
static org.bouncycastle.crypto.params.ECPublicKeyParameters |
createECPublicKeyParameters(java.math.BigInteger x,
java.math.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(java.lang.String xHex,
java.lang.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 java.security.KeyPair |
generateKeyPair(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
java.security.SecureRandom random) |
static org.bouncycastle.crypto.AsymmetricCipherKeyPair |
generateKeyPairParameter(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
java.security.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(java.security.spec.ECGenParameterSpec genSpec)
copy from BC
|
static org.bouncycastle.asn1.x9.X962Parameters |
getDomainParametersFromName(java.security.spec.ECParameterSpec ecSpec,
boolean withCompression)
copy from BC
|
static org.bouncycastle.asn1.x9.X9ECParameters |
getDomainParametersFromName(java.lang.String curveName)
copy from BC
|
public static org.bouncycastle.crypto.AsymmetricCipherKeyPair generateKeyPairParameter(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
java.security.SecureRandom random)
public static java.security.KeyPair generateKeyPair(org.bouncycastle.crypto.params.ECDomainParameters domainParameters,
java.security.SecureRandom random)
throws java.security.NoSuchProviderException,
java.security.NoSuchAlgorithmException,
java.security.InvalidAlgorithmParameterException
java.security.NoSuchProviderExceptionjava.security.NoSuchAlgorithmExceptionjava.security.InvalidAlgorithmParameterExceptionpublic 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(java.math.BigInteger d,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters)
public static org.bouncycastle.crypto.params.ECPublicKeyParameters createECPublicKeyParameters(java.math.BigInteger x,
java.math.BigInteger y,
org.bouncycastle.math.ec.ECCurve curve,
org.bouncycastle.crypto.params.ECDomainParameters domainParameters)
public static org.bouncycastle.crypto.params.ECPublicKeyParameters createECPublicKeyParameters(java.lang.String xHex,
java.lang.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 java.security.NoSuchProviderException,
java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException,
java.io.IOException
java.security.NoSuchProviderExceptionjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecExceptionjava.io.IOExceptionpublic 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 java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
java.security.spec.InvalidKeySpecException
pkcs8Key - java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionjava.security.spec.InvalidKeySpecExceptionpublic static java.lang.String convertECPrivateKeyPKCS8ToPEM(byte[] encodedKey)
throws java.io.IOException
encodedKey - java.io.IOExceptionpublic static byte[] convertECPrivateKeyPEMToPKCS8(java.lang.String pemString)
throws java.io.IOException
pemString - java.io.IOExceptionpublic static byte[] convertECPrivateKeyToSEC1(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKey,
org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
throws java.io.IOException
priKey - pubKey - java.io.IOExceptionpublic static byte[] convertECPrivateKeySEC1ToPKCS8(byte[] sec1Key)
throws java.io.IOException
sec1Key - java.io.IOExceptionpublic static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey convertSEC1ToBCECPrivateKey(byte[] sec1Key)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
java.security.spec.InvalidKeySpecException,
java.io.IOException
sec1Key - java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionjava.security.spec.InvalidKeySpecExceptionjava.io.IOExceptionpublic static org.bouncycastle.crypto.params.ECPrivateKeyParameters convertSEC1ToECPrivateKey(byte[] sec1Key)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
java.security.spec.InvalidKeySpecException,
java.io.IOException
sec1Key - java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionjava.security.spec.InvalidKeySpecExceptionjava.io.IOExceptionpublic static byte[] convertECPublicKeyToX509(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKey)
pubKey - public static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey convertX509ToECPublicKey(byte[] x509Bytes)
throws java.security.NoSuchProviderException,
java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
x509Bytes - java.security.NoSuchProviderExceptionjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecExceptionpublic static java.lang.String convertECPublicKeyX509ToPEM(byte[] encodedKey)
throws java.io.IOException
encodedKey - java.io.IOExceptionpublic static byte[] convertECPublicKeyPEMToX509(java.lang.String pemString)
throws java.io.IOException
pemString - java.io.IOExceptionpublic static org.bouncycastle.asn1.x9.X9ECParameters getDomainParametersFromGenSpec(java.security.spec.ECGenParameterSpec genSpec)
genSpec - public static org.bouncycastle.asn1.x9.X9ECParameters getDomainParametersFromName(java.lang.String curveName)
curveName - public static org.bouncycastle.asn1.x9.X962Parameters getDomainParametersFromName(java.security.spec.ECParameterSpec ecSpec,
boolean withCompression)
ecSpec - withCompression - Copyright © 2019. All Rights Reserved.