2424static struct tpm_chip * chip ;
2525static struct tpm_digest * digests ;
2626
27+ /* implementation specific TPM constants */
28+ #define TPM_SIZE_OFFSET 2
29+ #define TPM_RETURN_OFFSET 6
30+ #define TPM_DATA_OFFSET 10
31+
32+ #define LOAD32 (buffer , offset ) (ntohl(*(uint32_t *)&buffer[offset]))
33+ #define LOAD32N (buffer , offset ) (*(uint32_t *)&buffer[offset])
34+ #define LOAD16 (buffer , offset ) (ntohs(*(uint16_t *)&buffer[offset]))
35+
36+ struct osapsess {
37+ uint32_t handle ;
38+ unsigned char secret [SHA1_DIGEST_SIZE ];
39+ unsigned char enonce [TPM_NONCE_SIZE ];
40+ };
41+
42+ /* discrete values, but have to store in uint16_t for TPM use */
43+ enum {
44+ SEAL_keytype = 1 ,
45+ SRK_keytype = 4
46+ };
47+
48+ #define TPM_DEBUG 0
49+
50+ #if TPM_DEBUG
51+ static inline void dump_options (struct trusted_key_options * o )
52+ {
53+ pr_info ("sealing key type %d\n" , o -> keytype );
54+ pr_info ("sealing key handle %0X\n" , o -> keyhandle );
55+ pr_info ("pcrlock %d\n" , o -> pcrlock );
56+ pr_info ("pcrinfo %d\n" , o -> pcrinfo_len );
57+ print_hex_dump (KERN_INFO , "pcrinfo " , DUMP_PREFIX_NONE ,
58+ 16 , 1 , o -> pcrinfo , o -> pcrinfo_len , 0 );
59+ }
60+
61+ static inline void dump_sess (struct osapsess * s )
62+ {
63+ print_hex_dump (KERN_INFO , "trusted-key: handle " , DUMP_PREFIX_NONE ,
64+ 16 , 1 , & s -> handle , 4 , 0 );
65+ pr_info ("secret:\n" );
66+ print_hex_dump (KERN_INFO , "" , DUMP_PREFIX_NONE ,
67+ 16 , 1 , & s -> secret , SHA1_DIGEST_SIZE , 0 );
68+ pr_info ("trusted-key: enonce:\n" );
69+ print_hex_dump (KERN_INFO , "" , DUMP_PREFIX_NONE ,
70+ 16 , 1 , & s -> enonce , SHA1_DIGEST_SIZE , 0 );
71+ }
72+
73+ static inline void dump_tpm_buf (unsigned char * buf )
74+ {
75+ int len ;
76+
77+ pr_info ("\ntpm buffer\n" );
78+ len = LOAD32 (buf , TPM_SIZE_OFFSET );
79+ print_hex_dump (KERN_INFO , "" , DUMP_PREFIX_NONE , 16 , 1 , buf , len , 0 );
80+ }
81+ #else
82+ static inline void dump_options (struct trusted_key_options * o )
83+ {
84+ }
85+
86+ static inline void dump_sess (struct osapsess * s )
87+ {
88+ }
89+
90+ static inline void dump_tpm_buf (unsigned char * buf )
91+ {
92+ }
93+ #endif
94+
2795static int TSS_rawhmac (unsigned char * digest , const unsigned char * key ,
2896 unsigned int keylen , ...)
2997{
@@ -56,7 +124,7 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key,
56124/*
57125 * calculate authorization info fields to send to TPM
58126 */
59- int TSS_authhmac (unsigned char * digest , const unsigned char * key ,
127+ static int TSS_authhmac (unsigned char * digest , const unsigned char * key ,
60128 unsigned int keylen , unsigned char * h1 ,
61129 unsigned char * h2 , unsigned int h3 , ...)
62130{
@@ -94,12 +162,11 @@ int TSS_authhmac(unsigned char *digest, const unsigned char *key,
94162 TPM_NONCE_SIZE , h2 , 1 , & c , 0 , 0 );
95163 return ret ;
96164}
97- EXPORT_SYMBOL_GPL (TSS_authhmac );
98165
99166/*
100167 * verify the AUTH1_COMMAND (Seal) result from TPM
101168 */
102- int TSS_checkhmac1 (unsigned char * buffer ,
169+ static int TSS_checkhmac1 (unsigned char * buffer ,
103170 const uint32_t command ,
104171 const unsigned char * ononce ,
105172 const unsigned char * key ,
@@ -159,7 +226,6 @@ int TSS_checkhmac1(unsigned char *buffer,
159226 return - EINVAL ;
160227 return 0 ;
161228}
162- EXPORT_SYMBOL_GPL (TSS_checkhmac1 );
163229
164230/*
165231 * verify the AUTH2_COMMAND (unseal) result from TPM
@@ -244,7 +310,7 @@ static int TSS_checkhmac2(unsigned char *buffer,
244310 * For key specific tpm requests, we will generate and send our
245311 * own TPM command packets using the drivers send function.
246312 */
247- int trusted_tpm_send (unsigned char * cmd , size_t buflen )
313+ static int trusted_tpm_send (unsigned char * cmd , size_t buflen )
248314{
249315 struct tpm_buf buf ;
250316 int rc ;
@@ -270,7 +336,6 @@ int trusted_tpm_send(unsigned char *cmd, size_t buflen)
270336 tpm_put_ops (chip );
271337 return rc ;
272338}
273- EXPORT_SYMBOL_GPL (trusted_tpm_send );
274339
275340/*
276341 * Lock a trusted key, by extending a selected PCR.
@@ -324,7 +389,7 @@ static int osap(struct tpm_buf *tb, struct osapsess *s,
324389/*
325390 * Create an object independent authorisation protocol (oiap) session
326391 */
327- int oiap (struct tpm_buf * tb , uint32_t * handle , unsigned char * nonce )
392+ static int oiap (struct tpm_buf * tb , uint32_t * handle , unsigned char * nonce )
328393{
329394 int ret ;
330395
@@ -341,7 +406,6 @@ int oiap(struct tpm_buf *tb, uint32_t *handle, unsigned char *nonce)
341406 TPM_NONCE_SIZE );
342407 return 0 ;
343408}
344- EXPORT_SYMBOL_GPL (oiap );
345409
346410struct tpm_digests {
347411 unsigned char encauth [SHA1_DIGEST_SIZE ];
0 commit comments