aboutsummaryrefslogtreecommitdiff
path: root/CpriCryptPri.c
blob: 6926808acd465126404e127dc380d8529ab0bad8 (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
// This file was extracted from the TCG Published
// Trusted Platform Module Library
// Part 4: Supporting Routines
// Family "2.0"
// Level 00 Revision 01.16
// October 30, 2014

#include <stdlib.h>

#include "CryptoEngine.h"
#include "OsslCryptoEngine.h"
static void Trap(const char *function, int line, int code);
FAIL_FUNCTION       TpmFailFunction = (FAIL_FUNCTION)&Trap;
//
//
//          Functions
//
//          FAILURE_TRAP()
//
//     This function is called if the caller to _cpri__InitCryptoUnits() doesn't provide a call back address.
//
static void
Trap(
     const char          *function,
     int                  line,
     int                  code
     )
{
     UNREFERENCED(function);
     UNREFERENCED(line);
     UNREFERENCED(code);
     abort();
}
//
//
//          _cpri__InitCryptoUnits()
//
//     This function calls the initialization functions of the other crypto modules that are part of the crypto engine
//     for this implementation. This function should be called as a result of _TPM_Init(). The parameter to this
//     function is a call back function it TPM.lib that is called when the crypto engine has a failure.
//
LIB_EXPORT CRYPT_RESULT
_cpri__InitCryptoUnits(
     FAIL_FUNCTION        failFunction
     )
{
   TpmFailFunction = failFunction;
   _cpri__RngStartup();
   _cpri__HashStartup();
   _cpri__SymStartup();
#ifdef TPM_ALG_RSA
   _cpri__RsaStartup();
#endif
#ifdef TPM_ALG_ECC
   _cpri__EccStartup();
#endif
   return CRYPT_SUCCESS;
}
//
//
//          _cpri__StopCryptoUnits()
//
//     This function calls the shutdown functions of the other crypto modules that are part of the crypto engine
//     for this implementation.
//
LIB_EXPORT void
_cpri__StopCryptoUnits(
   void
   )
{
   return;
}
//
//
//          _cpri__Startup()
//
//     This function calls the startup functions of the other crypto modules that are part of the crypto engine for
//     this implementation. This function should be called during processing of TPM2_Startup().
//
LIB_EXPORT BOOL
_cpri__Startup(
   void
   )
{
   return(       _cpri__HashStartup()
              && _cpri__RngStartup()
#ifdef     TPM_ALG_RSA
              && _cpri__RsaStartup()
#endif     // TPM_ALG_RSA
#ifdef     TPM_ALG_ECC
              && _cpri__EccStartup()
#endif     // TPM_ALG_ECC
              && _cpri__SymStartup());
}