当前位置: 首页>>代码示例>>Java>>正文


Java PublicKeyFactory类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.util.PublicKeyFactory的典型用法代码示例。如果您正苦于以下问题:Java PublicKeyFactory类的具体用法?Java PublicKeyFactory怎么用?Java PublicKeyFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PublicKeyFactory类属于org.bouncycastle.crypto.util包,在下文中一共展示了PublicKeyFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receiveCertificateVerifyMessage

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
protected void receiveCertificateVerifyMessage(ByteArrayInputStream buf)
    throws IOException
{

    byte[] clientCertificateSignature = TlsUtils.readOpaque16(buf);

    assertEmpty(buf);

    // Verify the CertificateVerify message contains a correct signature.
    try
    {
        TlsSigner tlsSigner = TlsUtils.createTlsSigner(this.clientCertificateType);
        tlsSigner.init(getContext());

        org.bouncycastle.asn1.x509.Certificate x509Cert = this.clientCertificate.getCertificateAt(0);
        SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
        AsymmetricKeyParameter publicKey = PublicKeyFactory.createKey(keyInfo);

        tlsSigner.verifyRawSignature(clientCertificateSignature, publicKey, this.certificateVerifyHash);
    }
    catch (Exception e)
    {
        throw new TlsFatalAlert(AlertDescription.decrypt_error);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:TlsServerProtocol.java

示例2: getPublicKey

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public PublicKey getPublicKey() {
	try {
		SubjectPublicKeyInfo subjectPublicKeyInfo = getCertificate().getSubjectPublicKeyInfo();
		RSAKeyParameters rsa = (RSAKeyParameters) PublicKeyFactory.createKey(subjectPublicKeyInfo);

		RSAPublicKeySpec rsaSpec = new RSAPublicKeySpec(rsa.getModulus(), rsa.getExponent());

		KeyFactory kf = KeyFactory.getInstance(DEFAULT_KEY_ALG);
		PublicKey rsaPub = kf.generatePublic(rsaSpec);

		return rsaPub;

	} catch (Exception e) {
		throw new RuntimeException("Error while getting Public Key: " + e.getMessage(), e);
	}
}
 
开发者ID:fabiusks,项目名称:cert-services,代码行数:17,代码来源:IdentityContainer.java

示例3: testSampleWitnesses

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
@Test
public void testSampleWitnesses()
    throws Exception
{
    ECPublicKeyParameters pubKey = (ECPublicKeyParameters)PublicKeyFactory.createKey(encKey);
    ECShuffledTranscriptVerifier verifier = new ECShuffledTranscriptVerifier(pubKey, new ByteArrayInputStream(getSequence(witnessTranscript, new MessageChooser()
    {
        @Override
        public boolean chooseMessage(int index)
        {
            if (index % 2 == 0)
            {
                return false;
            }

            return true;
        }
    })), new ByteArrayInputStream(initialTranscript), new ByteArrayInputStream(finalTranscript));

    verifier.verify();
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:22,代码来源:VerifierTest.java

示例4: testCorruptWitnesses

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
@Test
public void testCorruptWitnesses()
    throws Exception
{
    ECPublicKeyParameters pubKey = (ECPublicKeyParameters)PublicKeyFactory.createKey(encKey);
    try
    {
        ECShuffledTranscriptVerifier verifier = new ECShuffledTranscriptVerifier(pubKey, new ByteArrayInputStream(initialTranscript), new ByteArrayInputStream(initialTranscript), new ByteArrayInputStream(finalTranscript));

        verifier.verify();

        TestCase.fail("corrupt messages not noticed");
    }
    catch (TranscriptVerificationException e)
    {
        TestCase.assertEquals("illegal object in getInstance: org.bouncycastle.asn1.DLSequence", e.getCause().getMessage());
    }
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:19,代码来源:VerifierTest.java

示例5: processCertificateVerify

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
protected void processCertificateVerify(ServerHandshakeState state, byte[] body, byte[] certificateVerifyHash)
    throws IOException
{
    ByteArrayInputStream buf = new ByteArrayInputStream(body);

    DigitallySigned clientCertificateVerify = DigitallySigned.parse(state.serverContext, buf);

    TlsProtocol.assertEmpty(buf);

    // Verify the CertificateVerify message contains a correct signature.
    try
    {
        org.bouncycastle.asn1.x509.Certificate x509Cert = state.clientCertificate.getCertificateAt(0);
        SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
        AsymmetricKeyParameter publicKey = PublicKeyFactory.createKey(keyInfo);

        TlsSigner tlsSigner = TlsUtils.createTlsSigner(state.clientCertificateType);
        tlsSigner.init(state.serverContext);
        tlsSigner.verifyRawSignature(clientCertificateVerify.getAlgorithm(),
            clientCertificateVerify.getSignature(), publicKey, certificateVerifyHash);
    }
    catch (Exception e)
    {
        throw new TlsFatalAlert(AlertDescription.decrypt_error);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:27,代码来源:DTLSServerProtocol.java

示例6: receiveCertificateVerifyMessage

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
protected void receiveCertificateVerifyMessage(ByteArrayInputStream buf)
    throws IOException
{
    DigitallySigned clientCertificateVerify = DigitallySigned.parse(getContext(), buf);

    assertEmpty(buf);

    // Verify the CertificateVerify message contains a correct signature.
    try
    {
        org.bouncycastle.asn1.x509.Certificate x509Cert = this.peerCertificate.getCertificateAt(0);
        SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
        AsymmetricKeyParameter publicKey = PublicKeyFactory.createKey(keyInfo);

        TlsSigner tlsSigner = TlsUtils.createTlsSigner(this.clientCertificateType);
        tlsSigner.init(getContext());
        tlsSigner.verifyRawSignature(clientCertificateVerify.getAlgorithm(),
            clientCertificateVerify.getSignature(), publicKey, this.certificateVerifyHash);
    }
    catch (Exception e)
    {
        throw new TlsFatalAlert(AlertDescription.decrypt_error);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:25,代码来源:TlsServerProtocol.java

示例7: getPublicKey

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public AsymmetricKeyParameter getPublicKey()
    throws PKCSException
{
    try
    {
        return PublicKeyFactory.createKey(this.getSubjectPublicKeyInfo());
    }
    catch (IOException e)
    {
        throw new PKCSException("error extracting key encoding: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:13,代码来源:BcPKCS10CertificationRequest.java

示例8: processServerCertificate

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public void processServerCertificate(Certificate serverCertificate)
    throws IOException
{

    if (serverCertificate.isEmpty())
    {
        throw new TlsFatalAlert(AlertDescription.bad_certificate);
    }

    org.bouncycastle.asn1.x509.Certificate x509Cert = serverCertificate.getCertificateAt(0);

    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        throw new TlsFatalAlert(AlertDescription.unsupported_certificate);
    }

    // Sanity check the PublicKeyFactory
    if (this.serverPublicKey.isPrivate())
    {
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }

    this.rsaServerPublicKey = validateRSAPublicKey((RSAKeyParameters)this.serverPublicKey);

    TlsUtils.validateKeyUsage(x509Cert, KeyUsage.keyEncipherment);

    super.processServerCertificate(serverCertificate);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:TlsRSAKeyExchange.java

示例9: processServerCertificate

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public void processServerCertificate(Certificate serverCertificate)
    throws IOException
{

    if (keyExchange != KeyExchangeAlgorithm.RSA_PSK)
    {
        throw new TlsFatalAlert(AlertDescription.unexpected_message);
    }
    if (serverCertificate.isEmpty())
    {
        throw new TlsFatalAlert(AlertDescription.bad_certificate);
    }

    org.bouncycastle.asn1.x509.Certificate x509Cert = serverCertificate.getCertificateAt(0);

    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        throw new TlsFatalAlert(AlertDescription.unsupported_certificate);
    }

    // Sanity check the PublicKeyFactory
    if (this.serverPublicKey.isPrivate())
    {
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }

    this.rsaServerPublicKey = validateRSAPublicKey((RSAKeyParameters)this.serverPublicKey);

    TlsUtils.validateKeyUsage(x509Cert, KeyUsage.keyEncipherment);

    super.processServerCertificate(serverCertificate);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:38,代码来源:TlsPSKKeyExchange.java

示例10: processCertificateVerify

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
protected void processCertificateVerify(ServerHandshakeState state, byte[] body, byte[] certificateVerifyHash)
    throws IOException
{

    ByteArrayInputStream buf = new ByteArrayInputStream(body);

    byte[] clientCertificateSignature = TlsUtils.readOpaque16(buf);

    TlsProtocol.assertEmpty(buf);

    // Verify the CertificateVerify message contains a correct signature.
    try
    {
        TlsSigner tlsSigner = TlsUtils.createTlsSigner(state.clientCertificateType);
        tlsSigner.init(state.serverContext);

        org.bouncycastle.asn1.x509.Certificate x509Cert = state.clientCertificate.getCertificateAt(0);
        SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
        AsymmetricKeyParameter publicKey = PublicKeyFactory.createKey(keyInfo);

        tlsSigner.verifyRawSignature(clientCertificateSignature, publicKey, certificateVerifyHash);
    }
    catch (Exception e)
    {
        throw new TlsFatalAlert(AlertDescription.decrypt_error);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:28,代码来源:DTLSServerProtocol.java

示例11: processServerCertificate

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public void processServerCertificate(Certificate serverCertificate)
    throws IOException
{

    if (tlsSigner == null)
    {
        throw new TlsFatalAlert(AlertDescription.unexpected_message);
    }
    if (serverCertificate.isEmpty())
    {
        throw new TlsFatalAlert(AlertDescription.bad_certificate);
    }

    org.bouncycastle.asn1.x509.Certificate x509Cert = serverCertificate.getCertificateAt(0);

    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        throw new TlsFatalAlert(AlertDescription.unsupported_certificate);
    }

    if (!tlsSigner.isValidPublicKey(this.serverPublicKey))
    {
        throw new TlsFatalAlert(AlertDescription.certificate_unknown);
    }

    TlsUtils.validateKeyUsage(x509Cert, KeyUsage.digitalSignature);

    super.processServerCertificate(serverCertificate);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:35,代码来源:TlsSRPKeyExchange.java

示例12: extractDHPublicKeyParameters

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public static DHPublicKeyParameters extractDHPublicKeyParameters(Certificate cert) throws IOException {
    if (hasDHParameters(cert)) {
        SubjectPublicKeyInfo keyInfo = cert.getCertificateAt(0).getSubjectPublicKeyInfo();
        return (DHPublicKeyParameters) PublicKeyFactory.createKey(keyInfo);
    } else {
        throw new IOException();
    }
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:9,代码来源:CertificateUtils.java

示例13: extractECPublicKeyParameters

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public static ECPublicKeyParameters extractECPublicKeyParameters(Certificate cert) throws IOException {
    if (hasECParameters(cert)) {
        SubjectPublicKeyInfo keyInfo = cert.getCertificateAt(0).getSubjectPublicKeyInfo();
        return (ECPublicKeyParameters) PublicKeyFactory.createKey(keyInfo);
    } else {
        throw new IOException();
    }
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:9,代码来源:CertificateUtils.java

示例14: processServerCertificate

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public void processServerCertificate(Certificate serverCertificate)
    throws IOException
{
    if (serverCertificate.isEmpty())
    {
        throw new TlsFatalAlert(AlertDescription.bad_certificate);
    }

    org.bouncycastle.asn1.x509.Certificate x509Cert = serverCertificate.getCertificateAt(0);

    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        throw new TlsFatalAlert(AlertDescription.unsupported_certificate, e);
    }

    // Sanity check the PublicKeyFactory
    if (this.serverPublicKey.isPrivate())
    {
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }

    this.rsaServerPublicKey = validateRSAPublicKey((RSAKeyParameters)this.serverPublicKey);

    TlsUtils.validateKeyUsage(x509Cert, KeyUsage.keyEncipherment);

    super.processServerCertificate(serverCertificate);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:33,代码来源:TlsRSAKeyExchange.java

示例15: processServerCertificate

import org.bouncycastle.crypto.util.PublicKeyFactory; //导入依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
{
    if (keyExchange != KeyExchangeAlgorithm.RSA_PSK)
    {
        throw new TlsFatalAlert(AlertDescription.unexpected_message);
    }
    if (serverCertificate.isEmpty())
    {
        throw new TlsFatalAlert(AlertDescription.bad_certificate);
    }

    org.bouncycastle.asn1.x509.Certificate x509Cert = serverCertificate.getCertificateAt(0);

    SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
    try
    {
        this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
    }
    catch (RuntimeException e)
    {
        throw new TlsFatalAlert(AlertDescription.unsupported_certificate, e);
    }

    // Sanity check the PublicKeyFactory
    if (this.serverPublicKey.isPrivate())
    {
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }

    this.rsaServerPublicKey = validateRSAPublicKey((RSAKeyParameters)this.serverPublicKey);

    TlsUtils.validateKeyUsage(x509Cert, KeyUsage.keyEncipherment);

    super.processServerCertificate(serverCertificate);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:36,代码来源:TlsPSKKeyExchange.java


注:本文中的org.bouncycastle.crypto.util.PublicKeyFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。