@Override
    protected byte[] engineSign() throws SignatureException {
        if (key == null) {
            // This can't actually happen, but you never know...
            throw new SignatureException("No key provided");
        }

        int output_size = NativeCrypto.ECDSA_size(key.getNativeRef());
        byte[] outputBuffer = new byte[output_size];
        try {
            int bytes_written = NativeCrypto.ECDSA_sign(
                    buffer.array(), buffer.size(), outputBuffer, key.getNativeRef());
            if (bytes_written < 0) {
                throw new SignatureException("Could not compute signature.");
            }
            // There's no guarantee that the signature will be ECDSA_size bytes long,
            // that's just the maximum possible length of a signature.  Only return the bytes
            // that were actually produced.
            if (bytes_written != output_size) {
                byte[] newBuffer = new byte[bytes_written];
                System.arraycopy(outputBuffer, 0, newBuffer, 0, bytes_written);
                outputBuffer = newBuffer;
            }
            return outputBuffer;
        } catch (Exception ex) {
            throw new SignatureException(ex);
        } finally {
            buffer.reset();
        }
    }
Buffer to hold value to be signed or verified.
common/src/main/java/org/conscrypt/OpenSSLSignatureRawECDSA.java