本文整理汇总了Java中org.bouncycastle.crypto.params.ECPublicKeyParameters类的典型用法代码示例。如果您正苦于以下问题:Java ECPublicKeyParameters类的具体用法?Java ECPublicKeyParameters怎么用?Java ECPublicKeyParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ECPublicKeyParameters类属于org.bouncycastle.crypto.params包,在下文中一共展示了ECPublicKeyParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verify
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
@Override
public boolean verify(byte[] hash, byte[] signature, byte[] publicKey) {
ASN1InputStream asn1 = new ASN1InputStream(signature);
try {
ECDSASigner signer = new ECDSASigner();
signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(publicKey), domain));
DLSequence seq = (DLSequence) asn1.readObject();
BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
return signer.verifySignature(hash, r, s);
} catch (Exception e) {
return false;
} finally {
try {
asn1.close();
} catch (IOException ignored) {
}
}
}
示例2: JCEECPublicKey
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public JCEECPublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = createSpec(ellipticCurve, dp);
}
else
{
this.ecSpec = spec;
}
}
示例3: generateClientKeyExchange
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public void generateClientKeyExchange(OutputStream output)
throws IOException
{
if (agreementCredentials != null)
{
return;
}
AsymmetricCipherKeyPair ecAgreeClientKeyPair = TlsECCUtils.generateECKeyPair(context.getSecureRandom(),
ecAgreeServerPublicKey.getParameters());
this.ecAgreeClientPrivateKey = (ECPrivateKeyParameters)ecAgreeClientKeyPair.getPrivate();
byte[] point = TlsECCUtils.serializeECPublicKey(serverECPointFormats,
(ECPublicKeyParameters)ecAgreeClientKeyPair.getPublic());
TlsUtils.writeOpaque8(point, output);
}
示例4: init
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
/**
* initialise the EC Elgamal engine.
*
* @param param the necessary EC key parameters.
*/
public void init(
CipherParameters param)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom p = (ParametersWithRandom)param;
if (!(p.getParameters() instanceof ECPublicKeyParameters))
{
throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
}
this.key = (ECPublicKeyParameters)p.getParameters();
this.random = p.getRandom();
}
else
{
if (!(param instanceof ECPublicKeyParameters))
{
throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
}
this.key = (ECPublicKeyParameters)param;
this.random = new SecureRandom();
}
}
示例5: init
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
/**
* initialise the encryptor.
*
* @param param the necessary EC key parameters.
*/
public void init(
CipherParameters param)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom p = (ParametersWithRandom)param;
if (!(p.getParameters() instanceof ECPublicKeyParameters))
{
throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
}
this.key = (ECPublicKeyParameters)p.getParameters();
this.random = p.getRandom();
}
else
{
if (!(param instanceof ECPublicKeyParameters))
{
throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
}
this.key = (ECPublicKeyParameters)param;
this.random = new SecureRandom();
}
}
示例6: init
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public void init(boolean forSigning, CipherParameters param)
{
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.random = rParam.getRandom();
param = rParam.getParameters();
}
else
{
this.random = new SecureRandom();
}
this.key = (ECPrivateKeyParameters)param;
}
else
{
this.key = (ECPublicKeyParameters)param;
}
}
示例7: init
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public void init(
boolean forSigning,
CipherParameters param)
{
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.random = rParam.getRandom();
this.key = (ECPrivateKeyParameters)rParam.getParameters();
}
else
{
this.random = new SecureRandom();
this.key = (ECPrivateKeyParameters)param;
}
}
else
{
this.key = (ECPublicKeyParameters)param;
}
}
示例8: init
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public void init(
boolean forSigning,
CipherParameters param)
{
this.forSigning = forSigning;
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.random = rParam.getRandom();
this.key = (ECPrivateKeyParameters)rParam.getParameters();
}
else
{
this.random = new SecureRandom();
this.key = (ECPrivateKeyParameters)param;
}
}
else
{
this.key = (ECPublicKeyParameters)param;
}
}
示例9: BCDSTU4145PublicKey
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public BCDSTU4145PublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = createSpec(ellipticCurve, dp);
}
else
{
this.ecSpec = spec;
}
}
示例10: BCECPublicKey
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public BCECPublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec,
ProviderConfiguration configuration)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = createSpec(ellipticCurve, dp);
}
else
{
this.ecSpec = spec;
}
this.configuration = configuration;
}
示例11: BCECGOST3410PublicKey
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public BCECGOST3410PublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = createSpec(ellipticCurve, dp);
}
else
{
this.ecSpec = spec;
}
}
示例12: JCEECPublicKey
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
JCEECPublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
this.ecSpec = new ECParameterSpec(
dp.getCurve(),
dp.getG(),
dp.getN(),
dp.getH(),
dp.getSeed());
}
else
{
this.ecSpec = spec;
}
}
示例13: init
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
public void init(
boolean forSigning,
CipherParameters param)
{
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.random = rParam.getRandom();
this.key = (ECPrivateKeyParameters)rParam.getParameters();
}
else
{
this.random = new SecureRandom();
this.key = (ECPrivateKeyParameters)param;
}
}
else
{
this.key = (ECPublicKeyParameters)param;
}
}
示例14: generateKeyPair
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
/**
* Given the domain parameters this routine generates an EC key
* pair in accordance with X9.62 section 5.2.1 pages 26, 27.
*/
public AsymmetricCipherKeyPair generateKeyPair()
{
BigInteger n = params.getN();
int nBitLength = n.bitLength();
BigInteger d;
do
{
d = new BigInteger(nBitLength, random);
}
while (d.equals(ZERO) || (d.compareTo(n) >= 0));
ECPoint Q = params.getG().multiply(d);
return new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(Q, params),
new ECPrivateKeyParameters(d, params));
}
示例15: prepareAfterParse
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
@Override
public void prepareAfterParse() {
try {
msg.prepareComputations();
List<ECPointFormat> pointFormatList = chooser.getServerSupportedPointFormats();
ECPointFormat[] formatArray = pointFormatList.toArray(new ECPointFormat[pointFormatList.size()]);
short[] pointFormats = ECCUtilsBCWrapper.convertPointFormats(formatArray);
ECPublicKeyParameters clientPublicKey = TlsECCUtils.deserializeECPublicKey(pointFormats,
getDomainParameters(chooser.getEcCurveType(), chooser.getSelectedCurve()), msg.getPublicKey()
.getValue());
CustomECPoint customClientKey = new CustomECPoint(clientPublicKey.getQ().getRawXCoord().toBigInteger(),
clientPublicKey.getQ().getRawYCoord().toBigInteger());
msg.getComputations().setClientPublicKey(customClientKey);
BigInteger privatekey = chooser.getServerEcPrivateKey();
computePremasterSecret(clientPublicKey,
new ECPrivateKeyParameters(privatekey, clientPublicKey.getParameters()));
preparePremasterSecret(msg);
prepareClientRandom(msg);
} catch (IOException ex) {
throw new PreparationException("Could prepare ECDHClientKeyExchange Message after Parse", ex);
}
}