Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bouncycastle.crypto.tls;
 
 
    protected Certificate certificate;
    protected BasicAgreement basicAgreement;
    protected boolean truncateAgreement;
    public DefaultTlsAgreementCredentials(Certificate certificateAsymmetricKeyParameter privateKey)
    {
        if (certificate == null)
        {
            throw new IllegalArgumentException("'certificate' cannot be null");
        }
        if (certificate.isEmpty())
        {
            throw new IllegalArgumentException("'certificate' cannot be empty");
        }
        if (privateKey == null)
        {
            throw new IllegalArgumentException("'privateKey' cannot be null");
        }
        if (!privateKey.isPrivate())
        {
            throw new IllegalArgumentException("'privateKey' must be private");
        }
        if (privateKey instanceof DHPrivateKeyParameters)
        {
             = new DHBasicAgreement();
             = true;
        }
        else if (privateKey instanceof ECPrivateKeyParameters)
        {
             = new ECDHBasicAgreement();
             = false;
        }
        else
        {
            throw new IllegalArgumentException("'privateKey' type not supported: "
                + privateKey.getClass().getName());
        }
        this. = certificate;
        this. = privateKey;
    }
    public Certificate getCertificate()
    {
        return ;
    }
    public byte[] generateAgreement(AsymmetricKeyParameter peerPublicKey)
    {
        .init();
        BigInteger agreementValue = .calculateAgreement(peerPublicKey);
        if ()
        {
            return BigIntegers.asUnsignedByteArray(agreementValue);
        }
        return BigIntegers.asUnsignedByteArray(.getFieldSize(), agreementValue);
    }
New to GrepCode? Check out our FAQ X