ACR: Modify remarks related to pointer/handle cleanup
[platform/core/security/yaca.git] / api / yaca / yaca_digest.h
1 /*
2  *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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
17  */
18
19 /**
20  * @file yaca_digest.h
21  * @brief
22  */
23
24 #ifndef YACA_DIGEST_H
25 #define YACA_DIGEST_H
26
27 #include <stddef.h>
28 #include <yaca_types.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /**
35  * @defgroup  Advanced-Digest  Advanced API for the message digests.
36  *
37  *
38  * @{
39  */
40
41 /**
42  * @brief  Initializes a digest context.
43  *
44  * @since_tizen 3.0
45  *
46  * @remarks  The @a ctx should be released using yaca_context_destroy()
47  *
48  * @param[out] ctx   Newly created context
49  * @param[in]  algo  Digest algorithm that will be used
50  *
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,
54  *                                       invalid algo)
55  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
56  * @retval #YACA_ERROR_INTERNAL Internal error
57  *
58  * @see #yaca_digest_algorithm_e
59  * @see yaca_digest_update()
60  * @see yaca_digest_finalize()
61  * @see yaca_context_destroy()
62  */
63 int yaca_digest_initialize(yaca_context_h *ctx, yaca_digest_algorithm_e algo);
64
65 /**
66  * @brief  Feeds the data into the message digest algorithm.
67  *
68  * @since_tizen 3.0
69  *
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
73  *
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,
77  *                                       invalid context)
78  * @retval #YACA_ERROR_INTERNAL Internal error
79  *
80  * @see yaca_digest_initialize()
81  * @see yaca_digest_finalize()
82  */
83 int yaca_digest_update(yaca_context_h ctx, const char *data, size_t data_len);
84
85 /**
86  * @brief  Calculates the final digest.
87  *
88  * @since_tizen 3.0
89  *
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
95  *
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,
99  *                                       invalid context)
100  * @retval #YACA_ERROR_INTERNAL Internal error
101  *
102  * @see yaca_digest_initialize()
103  * @see yaca_digest_update()
104  * @see yaca_context_get_output_length()
105  */
106 int yaca_digest_finalize(yaca_context_h ctx, char *digest, size_t *digest_len);
107
108 /**@}*/
109
110 #ifdef __cplusplus
111 } /* extern */
112 #endif
113
114 #endif /* YACA_DIGEST_H */