@Override
    protected int engineGenerateSecret(byte[] sharedSecret, int offset)
            throws ShortBufferException {
        checkCompleted();
        int available = sharedSecret.length - offset;
        if (mResult.length > available) {
            throw new ShortBufferWithoutStackTraceException(
                    "Needed: " + mResult.length + ", available: " + available);
        }

        System.arraycopy(mResult, 0, sharedSecret, offset, mResult.length);
        return mResult.length;
    }
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