1 /* Copyright 2015 OpenMarket Ltd
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 #include "olm/error.h"
24 struct _olm_ed25519_public_key;
32 OlmErrorCode last_error;
34 /** The length of a SHA-256 hash in bytes. */
35 std::size_t sha256_length() const;
37 /** Compute a SHA-256 hash. Returns the length of the SHA-256 hash in bytes
38 * on success. Returns std::size_t(-1) on failure. On failure last_error
39 * will be set with an error code. If the output buffer was too small then
40 * last error will be OUTPUT_BUFFER_TOO_SMALL. */
42 std::uint8_t const * input, std::size_t input_length,
43 std::uint8_t * output, std::size_t output_length
46 /** Verify a ed25519 signature. Returns std::size_t(0) on success. Returns
47 * std::size_t(-1) on failure or if the signature was invalid. On failure
48 * last_error will be set with an error code. If the signature was too short
49 * or was not a valid signature then last_error will be BAD_MESSAGE_MAC. */
50 std::size_t ed25519_verify(
51 _olm_ed25519_public_key const & key,
52 std::uint8_t const * message, std::size_t message_length,
53 std::uint8_t const * signature, std::size_t signature_length
61 #endif /* UTILITY_HH_ */