@Override
    protected void engineInit(Key key, SecureRandom random) throws InvalidKeyException {
        if (key == null) {
            throw new InvalidKeyException("key == null");
        }
        if (!(key instanceof PrivateKey)) {
            throw new InvalidKeyException("Not a private key: " + key.getClass());
        }

        T privateKey = convertPrivateKey((PrivateKey) key);
        mExpectedResultLength = getOutputSize(privateKey);
        mPrivateKey = privateKey;
    }
Given the public key {@code theirPublicKey} and the private key {@code ourPrivateKey} write the shared secret
to {@code buffer} and return the actual output size.
common/src/main/java/org/conscrypt/OpenSSLBaseDHKeyAgreement.java