blob: 2c1210ca3e06b4bc8a295e57e5ff644292005749 [file] [log] [blame]
Vadim Bendebury56797522015-05-20 10:32:25 -07001// This file was extracted from the TCG Published
2// Trusted Platform Module Library
3// Part 4: Supporting Routines
4// Family "2.0"
5// Level 00 Revision 01.16
6// October 30, 2014
7
Vadim Bendeburyfea3a142015-05-28 18:53:22 -07008#include "CryptoEngine.h"
Vadim Bendebury56797522015-05-20 10:32:25 -07009#include "OsslCryptoEngine.h"
10static void Trap(const char *function, int line, int code);
11FAIL_FUNCTION TpmFailFunction = (FAIL_FUNCTION)&Trap;
12//
13//
14// Functions
15//
Vadim Bendebury56797522015-05-20 10:32:25 -070016// FAILURE_TRAP()
17//
18// This function is called if the caller to _cpri__InitCryptoUnits() doesn't provide a call back address.
19//
20static void
21Trap(
22 const char *function,
23 int line,
24 int code
25 )
26{
27 UNREFERENCED(function);
28 UNREFERENCED(line);
29 UNREFERENCED(code);
30 abort();
31}
32//
33//
34// _cpri__InitCryptoUnits()
35//
36// This function calls the initialization functions of the other crypto modules that are part of the crypto engine
37// for this implementation. This function should be called as a result of _TPM_Init(). The parameter to this
38// function is a call back function it TPM.lib that is called when the crypto engine has a failure.
39//
40LIB_EXPORT CRYPT_RESULT
41_cpri__InitCryptoUnits(
42 FAIL_FUNCTION failFunction
43 )
44{
45 TpmFailFunction = failFunction;
46 _cpri__RngStartup();
47 _cpri__HashStartup();
48 _cpri__SymStartup();
49#ifdef TPM_ALG_RSA
50 _cpri__RsaStartup();
51#endif
52#ifdef TPM_ALG_ECC
53 _cpri__EccStartup();
54#endif
55 return CRYPT_SUCCESS;
56}
57//
58//
59// _cpri__StopCryptoUnits()
60//
61// This function calls the shutdown functions of the other crypto modules that are part of the crypto engine
62// for this implementation.
63//
64LIB_EXPORT void
65_cpri__StopCryptoUnits(
66 void
67 )
68{
69 return;
70}
71//
72//
73// _cpri__Startup()
74//
75// This function calls the startup functions of the other crypto modules that are part of the crypto engine for
76// this implementation. This function should be called during processing of TPM2_Startup().
77//
78LIB_EXPORT BOOL
79_cpri__Startup(
80 void
81 )
82{
83 return( _cpri__HashStartup()
84 && _cpri__RngStartup()
85#ifdef TPM_ALG_RSA
86 && _cpri__RsaStartup()
87#endif // TPM_ALG_RSA
88#ifdef TPM_ALG_ECC
89 && _cpri__EccStartup()
90#endif // TPM_ALG_ECC
91 && _cpri__SymStartup());
92}