Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 1 | // 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 | |
Darren Krahn | 124ce14 | 2015-12-15 16:03:04 -0800 | [diff] [blame] | 8 | #include <stdlib.h> |
| 9 | |
Vadim Bendebury | fea3a14 | 2015-05-28 18:53:22 -0700 | [diff] [blame] | 10 | #include "CryptoEngine.h" |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 11 | #include "OsslCryptoEngine.h" |
| 12 | static void Trap(const char *function, int line, int code); |
| 13 | FAIL_FUNCTION TpmFailFunction = (FAIL_FUNCTION)&Trap; |
| 14 | // |
| 15 | // |
| 16 | // Functions |
| 17 | // |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 18 | // FAILURE_TRAP() |
| 19 | // |
| 20 | // This function is called if the caller to _cpri__InitCryptoUnits() doesn't provide a call back address. |
| 21 | // |
| 22 | static void |
| 23 | Trap( |
| 24 | const char *function, |
| 25 | int line, |
| 26 | int code |
| 27 | ) |
| 28 | { |
| 29 | UNREFERENCED(function); |
| 30 | UNREFERENCED(line); |
| 31 | UNREFERENCED(code); |
| 32 | abort(); |
| 33 | } |
| 34 | // |
| 35 | // |
| 36 | // _cpri__InitCryptoUnits() |
| 37 | // |
| 38 | // This function calls the initialization functions of the other crypto modules that are part of the crypto engine |
| 39 | // for this implementation. This function should be called as a result of _TPM_Init(). The parameter to this |
| 40 | // function is a call back function it TPM.lib that is called when the crypto engine has a failure. |
| 41 | // |
| 42 | LIB_EXPORT CRYPT_RESULT |
| 43 | _cpri__InitCryptoUnits( |
| 44 | FAIL_FUNCTION failFunction |
| 45 | ) |
| 46 | { |
| 47 | TpmFailFunction = failFunction; |
| 48 | _cpri__RngStartup(); |
| 49 | _cpri__HashStartup(); |
| 50 | _cpri__SymStartup(); |
| 51 | #ifdef TPM_ALG_RSA |
| 52 | _cpri__RsaStartup(); |
| 53 | #endif |
| 54 | #ifdef TPM_ALG_ECC |
| 55 | _cpri__EccStartup(); |
| 56 | #endif |
| 57 | return CRYPT_SUCCESS; |
| 58 | } |
| 59 | // |
| 60 | // |
| 61 | // _cpri__StopCryptoUnits() |
| 62 | // |
| 63 | // This function calls the shutdown functions of the other crypto modules that are part of the crypto engine |
| 64 | // for this implementation. |
| 65 | // |
| 66 | LIB_EXPORT void |
| 67 | _cpri__StopCryptoUnits( |
| 68 | void |
| 69 | ) |
| 70 | { |
| 71 | return; |
| 72 | } |
| 73 | // |
| 74 | // |
| 75 | // _cpri__Startup() |
| 76 | // |
| 77 | // This function calls the startup functions of the other crypto modules that are part of the crypto engine for |
| 78 | // this implementation. This function should be called during processing of TPM2_Startup(). |
| 79 | // |
| 80 | LIB_EXPORT BOOL |
| 81 | _cpri__Startup( |
| 82 | void |
| 83 | ) |
| 84 | { |
| 85 | return( _cpri__HashStartup() |
| 86 | && _cpri__RngStartup() |
| 87 | #ifdef TPM_ALG_RSA |
| 88 | && _cpri__RsaStartup() |
| 89 | #endif // TPM_ALG_RSA |
| 90 | #ifdef TPM_ALG_ECC |
| 91 | && _cpri__EccStartup() |
| 92 | #endif // TPM_ALG_ECC |
| 93 | && _cpri__SymStartup()); |
| 94 | } |