- fix Building without Nagra not possible at Nagra_Merlin https://trac.streamboard...
[oscam.git] / cscrypt / sha256.h
blob2ed95cd3d12cf38ef6ff0e2acf00ac0c673d1786
1 /**
2 * \file mbedtls_sha256.h
4 * \brief SHA-224 and SHA-256 cryptographic hash function
6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: Apache-2.0
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * This file is part of mbed TLS (https://tls.mbed.org)
23 #ifndef MBEDTLS_SHA256_H
24 #define MBEDTLS_SHA256_H
26 #include <stddef.h>
27 #include <stdint.h>
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 /**
34 * \brief SHA-256 context structure
36 typedef struct
38 uint32_t total[2]; /*!< number of bytes processed */
39 uint32_t state[8]; /*!< intermediate digest state */
40 unsigned char buffer[64]; /*!< data block being processed */
41 int is224; /*!< 0 => SHA-256, else SHA-224 */
43 mbedtls_sha256_context;
45 /**
46 * \brief Initialize SHA-256 context
48 * \param ctx SHA-256 context to be initialized
50 void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
52 /**
53 * \brief Clear SHA-256 context
55 * \param ctx SHA-256 context to be cleared
57 void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
59 /**
60 * \brief Clone (the state of) a SHA-256 context
62 * \param dst The destination context
63 * \param src The context to be cloned
65 void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
66 const mbedtls_sha256_context *src );
68 /**
69 * \brief SHA-256 context setup
71 * \param ctx context to be initialized
72 * \param is224 0 = use SHA256, 1 = use SHA224
74 void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 );
76 /**
77 * \brief SHA-256 process buffer
79 * \param ctx SHA-256 context
80 * \param input buffer holding the data
81 * \param ilen length of the input data
83 void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen );
85 /**
86 * \brief SHA-256 final digest
88 * \param ctx SHA-256 context
89 * \param output SHA-224/256 checksum result
91 void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] );
93 /* Internal use */
94 void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] );
96 #ifdef __cplusplus
98 #endif
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
105 * \brief Output = SHA-256( input buffer )
107 * \param input buffer holding the data
108 * \param ilen length of the input data
109 * \param output SHA-224/256 checksum result
110 * \param is224 0 = use SHA256, 1 = use SHA224
112 void mbedtls_sha256( const unsigned char *input, size_t ilen, unsigned char output[32], int is224 );
115 * \brief Checkup routine
117 * \return 0 if successful, or 1 if the test failed
119 int mbedtls_sha256_self_test( int verbose );
121 #ifdef __cplusplus
123 #endif
125 #endif /* mbedtls_sha256.h */