2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
28 #include <yaca_types.h>
35 * @defgroup Advanced-Digest Advanced API for the message digests.
42 * @brief Initializes a digest context.
46 * @remarks The @a ctx should be released using yaca_context_destroy()
48 * @param[out] ctx Newly created context
49 * @param[in] algo Digest algorithm that will be used
51 * @return #YACA_ERROR_NONE on success, negative on error
52 * @retval #YACA_ERROR_NONE Successful
53 * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
55 * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
56 * @retval #YACA_ERROR_INTERNAL Internal error
58 * @see #yaca_digest_algorithm_e
59 * @see yaca_digest_update()
60 * @see yaca_digest_finalize()
61 * @see yaca_context_destroy()
63 int yaca_digest_initialize(yaca_context_h *ctx, yaca_digest_algorithm_e algo);
66 * @brief Feeds the data into the message digest algorithm.
70 * @param[in,out] ctx Context created by yaca_digest_initialize()
71 * @param[in] data Data from which the digest is to be calculated
72 * @param[in] data_len Length of the data
74 * @return #YACA_ERROR_NONE on success, negative on error
75 * @retval #YACA_ERROR_NONE Successful
76 * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
78 * @retval #YACA_ERROR_INTERNAL Internal error
80 * @see yaca_digest_initialize()
81 * @see yaca_digest_finalize()
83 int yaca_digest_update(yaca_context_h ctx, const char *data, size_t data_len);
86 * @brief Calculates the final digest.
90 * @param[in,out] ctx A valid digest context
91 * @param[out] digest Buffer for the message digest
92 * (must be allocated by client, see yaca_context_get_output_length())
93 * @param[out] digest_len Length of the digest,
94 * actual number of bytes written will be returned here
96 * @return #YACA_ERROR_NONE on success, negative on error
97 * @retval #YACA_ERROR_NONE Successful
98 * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
100 * @retval #YACA_ERROR_INTERNAL Internal error
102 * @see yaca_digest_initialize()
103 * @see yaca_digest_update()
104 * @see yaca_context_get_output_length()
106 int yaca_digest_finalize(yaca_context_h ctx, char *digest, size_t *digest_len);
114 #endif /* YACA_DIGEST_H */