Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sha384.h « SHA384 « HASH « Inc « cryptographic « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 889a0ca4f47ae3bcd198a97a4cd7c085d3580808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
  ******************************************************************************
  * @file    sha384.h
  * @author  MCD Application Team
  * @brief   Provides SHA384 functions
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Image license SLA0044,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        http://www.st.com/SLA0044
  *
  ******************************************************************************
  */

/*! \page Tutorial_SHA384 SHA384 Tutorial
  *
  * Here follows an example of SHA384 functionality.
  * Please remember that before starting to call the Init function the context \b requires user
  * initialization. The mFlags and mTagSize member must be initialized prior to calling the
  *  init function. Look at the each function documentation to see what is needed prior of calling.
  *
  * The API functions to be used are:
  *  - \ref SHA384_Init initialize an \ref SHA384ctx_stt context with required digest size and flags.
  *  - \ref SHA384_Append process input buffers.
  *    It can be called multiple times.
  *  - \ref SHA384_Finish can be called only one time for the digest generation process.
  *
  * The following code performs a SHA384 hash of a buffer of size 1024 in a single Append call
  * \code
  * #include <stdio.h>
  * #include "crypto.h"
  * int32_t main()
  * {
  *   uint8_t message[1024]={...};
  *   uint8_t digest[CRL_SHA384_SIZE]; // 48 byte buffer
  *   // outSize is for digest output size, retval is for return value
  *   int32_t outSize, retval;
  *   SHA384ctx_stt context_st; // The SHA384 context
  *
  *   // Initialize Context Flag with default value
  *   context_st.mFlags = E_HASH_DEFAULT;
  *   // Set the required digest size to be only of 4 bytes (while the maximum allowed by SHA384 is 48)
  *   context_st.mTagSize = 4;
  *
  *   // call init function
  *   retval = SHA384_Init(&context_st);
  *   if (retval != HASH_SUCCESS)
  *   {  ... }
  *
  *   retval = SHA384_Append(&context_st, message, 1024);
  *   if (retval != HASH_SUCCESS)
  *   {  ... }
  *
  *   //Generate the message digest
  *   //Note that only the requested number of bytes of the digest will be written, in this case 4.
  *   retval = SHA384_Finish(&context_st, digest, &outSize );
  *   if (retval != HASH_SUCCESS)
  *   {  ... }
  * }
  * \endcode
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CRL_SHA384_H__
#define __CRL_SHA384_H__

#ifdef __cplusplus
extern "C"
{
#endif

  /* Includes ------------------------------------------------------------------*/

  /** @ingroup SHA384
    * @{
    */
#define CRL_SHA384_SIZE 48 /*!<  Number of bytes (uint8_t) to store a SHA-384 digest. */

  /**  Structure for the SHA-384 context */
  typedef HASHLctx_stt SHA384ctx_stt;
  /* Initialization of Context */
  int32_t SHA384_Init(SHA384ctx_stt *P_pSHA384ctx);
  /* Data processing function */
  int32_t SHA384_Append(SHA384ctx_stt *P_pSHA384ctx, const uint8_t *P_pInputBuffer, int32_t P_inputSize);
  /* Returns digest */
  int32_t SHA384_Finish(SHA384ctx_stt *P_pSHA384ctx, uint8_t *P_pOutputBuffer, int32_t *P_pOutputSize);

  /**
    * @}
    */

#ifdef __cplusplus
}
#endif

#endif   /*__CRL_SHA384_H__*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/