├── NEWS ├── man ├── Makefile.am ├── man8 │ └── Makefile.am ├── man5 │ └── Makefile.am └── man3 │ ├── Tspi_Context_Create.3 │ ├── Tspi_Context_Close.3 │ ├── Tspi_Policy_FlushSecret.3 │ ├── Tspi_Key_UnloadKey.3 │ ├── Tspi_Context_CloseObject.3 │ ├── Tspi_Key_LoadKey.3 │ ├── Tspi_Context_Connect.3 │ ├── Tspi_TPM_KillMaintenanceFeature.3 │ ├── Tspi_Context_FreeMemory.3 │ ├── Tspi_Context_GetDefaultPolicy.3 │ ├── Tspi_TPM_GetEvent.3 │ ├── Tspi_TPM_GetTestResult.3 │ ├── Tspi_TPM_SelfTestFull.3 │ ├── Tspi_TPM_GetStatus.3 │ ├── Tspi_TPM_GetEventLog.3 │ ├── Tspi_Key_GetPubKey.3 │ ├── Tspi_ChangeAuth.3 │ ├── Tspi_PcrComposite_SelectPcrIndex.3 │ ├── Tspi_TPM_GetRandom.3 │ ├── Tspi_TPM_OwnerGetSRKPubKey.3 │ ├── Tspi_TPM_PcrRead.3 │ ├── Tspi_TPM_SetStatus.3 │ ├── Tspi_Key_CertifyKey.3 │ ├── Tspi_TPM_CertifySelfTest.3 │ ├── Tspi_TPM_StirRandom.3 │ ├── Tspi_Key_CreateKey.3 │ ├── Tspi_TPM_ClearOwner.3 │ ├── Tspi_TPM_Quote.3 │ └── Tspi_Policy_AssignToObject.3 ├── src ├── trspi │ ├── crypto │ │ └── Makefile.am │ └── Makefile.am ├── Makefile.am ├── tddl │ └── Makefile.am ├── include │ ├── tss │ │ ├── tcpa_error.h │ │ ├── tcpa_struct.h │ │ ├── tcpa_defines.h │ │ ├── tcpa_typedef.h │ │ ├── tcs_typedef.h │ │ ├── tcs_defines.h │ │ ├── tcs_structs.h │ │ ├── platform.h │ │ ├── tddl_error.h │ │ ├── tddlapi_error.h │ │ ├── tss_error_basics.h │ │ ├── tss_typedef.h │ │ └── tcs_error.h │ ├── tcs_aik.h │ ├── tsp_seal.h │ ├── tsp_audit.h │ ├── req_mgr.h │ ├── tcs_int_literals.h │ ├── daa │ │ ├── key_correct.h │ │ ├── list.h │ │ ├── anonymity_revocation.h │ │ ├── issuer.h │ │ └── daa_parameter.h │ ├── trousers │ │ └── tss.h │ ├── tddl.h │ ├── tcs_context.h │ ├── rpc_tcstp.h │ ├── biosem.h │ ├── memmgr.h │ ├── tsp_delegate.h │ ├── imaem.h │ ├── hosttable.h │ ├── tcs_key_ps.h │ ├── linux │ │ └── tpm.h │ ├── auth_mgr.h │ ├── Makefile.am │ ├── obj_daa.h │ ├── obj_hash.h │ ├── tsplog.h │ ├── authsess.h │ ├── threads.h │ ├── obj_daacred.h │ ├── tcsem.h │ ├── obj_daaarakey.h │ ├── obj_daaissuerkey.h │ ├── capabilities.h │ ├── obj_delfamily.h │ ├── obj_pcrs.h │ └── obj_encdata.h ├── tspi │ ├── daa │ │ ├── big_integer │ │ │ └── test │ │ │ │ ├── Makefile.am │ │ │ │ └── multi_exp.c │ │ ├── daa_verifier │ │ │ ├── test │ │ │ │ └── Makefile.am │ │ │ └── verifier.c │ │ ├── Makefile.am │ │ ├── utils │ │ │ └── list.c │ │ └── daa_debug.h │ ├── gtk │ │ ├── interface.h │ │ ├── callbacks.h │ │ └── support.h │ ├── tspi_counter.c │ ├── rpc │ │ └── tcstp │ │ │ ├── rpc_oper.c │ │ │ ├── rpc_context.c │ │ │ └── rpc_caps.c │ ├── tsp_oper.c │ ├── tspi_oper.c │ ├── ps │ │ └── ps_utils.c │ ├── log.c │ ├── tsp_counter.c │ ├── tspi_hash.c │ ├── tspi_pcr_comp.c │ ├── tspi_random.c │ ├── tspi_pcr_comp12.c │ ├── tsp_get_flags.c │ ├── tsp_dir.c │ ├── ssl_ui.c │ └── tsp_random.c ├── tcsd │ └── Makefile.am └── tcs │ ├── tcsi_oper.c │ ├── tcs_migration.c │ ├── tcs_counter.c │ ├── tcsi_context.c │ ├── rpc │ └── tcstp │ │ ├── rpc_oper.c │ │ ├── rpc_context.c │ │ └── rpc_caps.c │ ├── crypto │ └── openssl │ │ └── crypto.c │ ├── tcs_req_mgr.c │ ├── tcsi_sign.c │ ├── tcs_quote2.c │ ├── tcsi_bind.c │ ├── tcs_seal.c │ ├── tcsi_quote.c │ ├── log.c │ └── tcsi_quote2.c ├── doc ├── LTC-TSS_LLD_08_r2.pdf ├── LTC-TSS_LLD_08_r2.sxw └── TSS_programming_SNAFUs.txt ├── TODO ├── bootstrap.sh ├── dist ├── fedora │ ├── trousers.fc │ └── trousers.te ├── system.data.auth ├── system.data.noauth └── Makefile.am ├── Makefile.am ├── NICETOHAVES ├── tools └── Makefile.am ├── .gitignore ├── AUTHORS └── README.selinux /NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = man3 man5 man8 2 | -------------------------------------------------------------------------------- /src/trspi/crypto/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = openssl 2 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = trspi tddl tcs tspi tcsd include 2 | -------------------------------------------------------------------------------- /man/man8/Makefile.am: -------------------------------------------------------------------------------- 1 | man8_MANS = tcsd.8 2 | EXTRA_DIST = $(man8_MANS) 3 | -------------------------------------------------------------------------------- /man/man5/Makefile.am: -------------------------------------------------------------------------------- 1 | man5_MANS = tcsd.conf.5 2 | EXTRA_DIST = $(man5_MANS) 3 | -------------------------------------------------------------------------------- /doc/LTC-TSS_LLD_08_r2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srajiv/trousers/HEAD/doc/LTC-TSS_LLD_08_r2.pdf -------------------------------------------------------------------------------- /doc/LTC-TSS_LLD_08_r2.sxw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srajiv/trousers/HEAD/doc/LTC-TSS_LLD_08_r2.sxw -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Please see http://sourceforge.net/tracker/?group_id=126012&atid=704361 2 | for TrouSerS TODOs. 3 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | set -x 2 | aclocal || exit 1 3 | libtoolize --force -c || exit 1 4 | automake --add-missing -c --foreign || exit 1 5 | autoconf || exit 1 6 | -------------------------------------------------------------------------------- /src/tddl/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LIBRARIES=libtddl.a 2 | 3 | libtddl_a_SOURCES=tddl.c 4 | libtddl_a_CFLAGS=-DAPPID=\"TCSD\ TDDL\" -I${top_srcdir}/src/include 5 | -------------------------------------------------------------------------------- /src/include/tss/tcpa_error.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TCPA_ERROR_H__ 3 | #define __TCPA_ERROR_H__ 4 | 5 | #warning including deprecated header file tcpa_error.h 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/include/tss/tcpa_struct.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TCPA_STRUCT_H__ 3 | #define __TCPA_STRUCT_H__ 4 | 5 | #warning including deprecated header file tcpa_struct.h 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/include/tss/tcpa_defines.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TCPA_DEFINES_H__ 3 | #define __TCPA_DEFINES_H__ 4 | 5 | #warning including deprecated header file tcpa_defines.h 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/include/tss/tcpa_typedef.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TCPA_TYPEDEF_H__ 3 | #define __TCPA_TYPEDEF_H__ 4 | 5 | #warning including deprecated header file tcpa_typedef.h 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /dist/fedora/trousers.fc: -------------------------------------------------------------------------------- 1 | /usr/sbin/tcsd system_u:object_r:tcsd_exec_t 2 | /etc/tcsd.conf system_u:object_r:tcsd_config_t 3 | /var/lib/tpm(/.*)? system_u:object_r:tcsd_readwrite_t 4 | /dev/tpm(.*) system_u:object_r:tcsd_device_t 5 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src man dist tools 2 | EXTRA_DIST = AUTHORS LICENSE NEWS NICETOHAVES README \ 3 | README.selinux TODO ChangeLog \ 4 | doc/LTC-TSS_LLD_08_r2.pdf \ 5 | doc/LTC-TSS_LLD_08_r2.sxw \ 6 | doc/TSS_programming_SNAFUs.txt 7 | -------------------------------------------------------------------------------- /NICETOHAVES: -------------------------------------------------------------------------------- 1 | 2 | These items are of lower priority than the TODO list. If any of these become 3 | actual TODO's, they will move to that list. 4 | 5 | 1. Test Suite Design Document 6 | 7 | 2. State machine diagram of the TSS internal workings 8 | 9 | -------------------------------------------------------------------------------- /src/tspi/daa/big_integer/test/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = test 2 | 3 | 4 | test_SOURCES=test.c multi_exp.c ../bi_gmp.c ../bi_openssl.c ../bi.c \ 5 | ../../../include/bi.h ../../../include/bi_openssl.h ../../../include/bi_gmp.h 6 | test_CFLAGS=-G 7 | 8 | # test_CFLAGS=-I../../../include -DBI_OPENSSL 9 | 10 | -------------------------------------------------------------------------------- /tools/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS=ps_inspect ps_convert 2 | 3 | ps_inspect_SOURCES=ps_inspect.c 4 | ps_inspect_LDADD=${top_builddir}/src/tspi/libtspi.la 5 | ps_inspect_CFLAGS=-I${top_srcdir}/src/include 6 | 7 | ps_convert_SOURCES=ps_convert.c 8 | ps_convert_LDADD=${top_builddir}/src/tspi/libtspi.la 9 | ps_convert_CFLAGS=-I${top_srcdir}/src/include 10 | -------------------------------------------------------------------------------- /src/include/tcs_aik.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006-2007 8 | * 9 | */ 10 | 11 | #ifndef _TCS_AIK_H_ 12 | #define _TCS_AIK_H_ 13 | 14 | void get_credential(UINT32, UINT32 *, BYTE **); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/include/tsp_seal.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #ifndef _TSP_SEAL_H_ 12 | #define _TSP_SEAL_H_ 13 | 14 | TSS_RESULT sealx_mask_cb(UINT32, BYTE *, UINT32, BYTE *, BYTE *, UINT32, BYTE *, BYTE *); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/include/tsp_audit.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #ifndef _TSP_AUDIT_H_ 12 | #define _TSP_AUDIT_H_ 13 | 14 | TSS_RESULT __tspi_audit_set_ordinal_audit_status(TSS_HTPM, TSS_FLAG, TSS_FLAG, UINT32); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/trspi/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES=libtrousers.la 2 | 3 | libtrousers_la_SOURCES=trousers.c crypto/@CRYPTO_PACKAGE@/hash.c 4 | libtrousers_la_CFLAGS=-DAPPID=\"TSPI\" -I${top_srcdir}/src/include 5 | 6 | if TSS_BUILD_ASYM_CRYPTO 7 | libtrousers_la_SOURCES+=crypto/@CRYPTO_PACKAGE@/rsa.c 8 | endif 9 | if TSS_BUILD_SYM_CRYPTO 10 | libtrousers_la_SOURCES+=crypto/@CRYPTO_PACKAGE@/symmetric.c 11 | endif 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.deps 2 | *.o 3 | *.la 4 | *.libs 5 | *.lo 6 | *.a 7 | *.spec 8 | *~ 9 | *Makefile 10 | *Makefile.in 11 | /.pc 12 | /ltmain.sh 13 | /aclocal.m4 14 | /autom4te.cache 15 | /config.guess 16 | /config.log 17 | /config.status 18 | /config.sub 19 | /configure 20 | /depcomp 21 | /install-sh 22 | /libtool 23 | /missing 24 | /dist/tcsd.conf 25 | /man/man5/*.5 26 | /man/man8/*.8 27 | /src/tcsd/tcsd 28 | /tools/ps_convert 29 | /tools/ps_inspect 30 | -------------------------------------------------------------------------------- /src/tspi/daa/daa_verifier/test/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = verifier_transaction 2 | 3 | verifier_transaction_SOURCES = ../verifier_transaction.c ../../daa_structs.c \ 4 | ../../big_integer/bi_gmp.c ../../big_integer/bi_openssl.c ../../big_integer/bi.c \ 5 | ../../../include/bi.h ../../../include/bi_openssl.h ../../../include/bi_gmp.h \ 6 | ../../../include/list_.h ../../utils/list.c ../../../include/tss/tss.h ../../../include/daa_parameter.h \ 7 | ../../../include/daa_structs.h 8 | -------------------------------------------------------------------------------- /src/tcsd/Makefile.am: -------------------------------------------------------------------------------- 1 | sbin_PROGRAMS=tcsd 2 | 3 | tcsd_CFLAGS=-DAPPID=\"TCSD\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" -I${top_srcdir}/src/include 4 | tcsd_LDADD=${top_builddir}/src/tcs/libtcs.a ${top_builddir}/src/tddl/libtddl.a -lpthread @CRYPTOLIB@ 5 | 6 | tcsd_SOURCES=svrside.c tcsd_conf.c tcsd_threads.c platform.c 7 | 8 | if TSS_BUILD_PS 9 | tcsd_CFLAGS+=-DTSS_BUILD_PS 10 | endif 11 | if TSS_BUILD_PCR_EVENTS 12 | tcsd_CFLAGS+=-DTSS_BUILD_PCR_EVENTS 13 | endif 14 | -------------------------------------------------------------------------------- /src/include/req_mgr.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | 12 | #ifndef _REQ_MGR_H_ 13 | #define _REQ_MGR_H_ 14 | 15 | #include "threads.h" 16 | 17 | struct tpm_req_mgr 18 | { 19 | MUTEX_DECLARE(queue_lock); 20 | }; 21 | 22 | TSS_RESULT req_mgr_init(); 23 | TSS_RESULT req_mgr_final(); 24 | TSS_RESULT req_mgr_submit_req(BYTE *); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /doc/TSS_programming_SNAFUs.txt: -------------------------------------------------------------------------------- 1 | 2 | Tspi_TPM_GetEvents 3 | 4 | Events in the TCS event log are 0 indexed. So, a call such as: 5 | 6 | UINT32 five = 5; 7 | Tspi_TPM_GetEvents(hTPM, ulPcrIndex, 1, &five, &prgbPcrEvents); 8 | 9 | will get you 5 events (assuming at least 6 events have happened on the PCR) which 10 | will be the 2nd through 6th events on the PCR. (Since the 1st event is at index 0). 11 | This is probably what you want: 12 | 13 | UINT32 five = 5; 14 | Tspi_TPM_GetEvents(hTPM, ulPcrIndex, 0, &five, &prgbPcrEvents); 15 | 16 | -------------------------------------------------------------------------------- /dist/system.data.auth: -------------------------------------------------------------------------------- 1 | /  -------------------------------------------------------------------------------- /dist/system.data.noauth: -------------------------------------------------------------------------------- 1 | /  -------------------------------------------------------------------------------- /src/tspi/gtk/interface.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | /* 12 | * DO NOT EDIT THIS FILE - it is generated by Glade. 13 | */ 14 | 15 | #ifndef _INTERFACE_H_ 16 | #define _INTERFACE_H_ 17 | 18 | struct userdata { 19 | char *string; 20 | unsigned string_len; 21 | GtkWidget *window; 22 | GtkWidget *entry; 23 | GtkWidget *entryPass; 24 | GtkWidget *entryConf; 25 | }; 26 | 27 | GtkWidget* create_password_dialog (struct userdata *, char *); 28 | GtkWidget* create_new_password_dialog (struct userdata *, char *); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | All authors of this TSS have been funded by IBM. 3 | 4 | The TSS code was originally written for WIN32 by Ryan Catherman and ported to 5 | Linux initially by Seiji Munetoh and Taiga Nakamura as well as Ryan. 6 | 7 | The code has since been modified by Seiji Munetoh and Kent Yoder. 8 | 9 | The code is currently maintained by Kent Yoder . 10 | 11 | The manpages were originally written by Megan Schneider and Kathy Robertson 12 | and have been modified by Kent Yoder. 13 | 14 | Other contributors to the TSS 1.2 functionality: 15 | Tom Lendacky 16 | Loulwa Salem 17 | Ramon Brandao 18 | Klaus Kiwi 19 | 20 | Specifically the NVRAM implementation: 21 | James Xu 22 | Rossey Liu 23 | Jacfee Liu 24 | -------------------------------------------------------------------------------- /src/include/tcs_int_literals.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _TCS_INT_LITERALS_H_ 12 | #define _TCS_INT_LITERALS_H_ 13 | 14 | #define TPM_VENDOR_UNKNOWN 0 15 | #define TPM_VENDOR_ATMEL 1 16 | #define TPM_VENDOR_IFX 2 17 | #define TPM_VENDOR_NATL 3 18 | 19 | #define TPM_PARAMSIZE_OFFSET 0x02 20 | 21 | #define NULL_TPM_HANDLE ((TCPA_KEY_HANDLE)-1) 22 | #define NULL_TCS_HANDLE ((TCS_KEY_HANDLE)-1) 23 | #define SRK_TPM_HANDLE (0x40000000) 24 | #define EK_TPM_HANDLE (0x40000001) 25 | 26 | #define FIXED_TCS_MANUFACTURER "IBM " 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/tspi/daa/big_integer/test/multi_exp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // use standard C definition to avoid .h 6 | int test_exp_multi(void) { 7 | bi_t result; 8 | bi_t g[3]; 9 | unsigned long e[3]; 10 | 11 | bi_new( result); 12 | bi_new( g[0]); 13 | bi_new( g[1]); 14 | bi_new( g[2]); 15 | // result = (2^2 * 5^4 * 7^7) mod 56 -> should give 28 16 | bi_set_as_dec( g[0], "2"); 17 | bi_set_as_dec( g[1], "5"); 18 | bi_set_as_dec( g[2], "7"); 19 | e[0] = 2L; 20 | e[1] = 4L; 21 | e[2] = 7L; 22 | bi_multi_mod_exp( result, 3, g, e, 56); 23 | printf("multi-exponentiation =%s\n", bi_2_dec_char(result)); 24 | bi_free( g[0]); 25 | bi_free( g[1]); 26 | bi_free( g[2]); 27 | bi_free( result); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/include/daa/key_correct.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | #ifndef KEY_CORRECT_H_ 12 | #define KEY_CORRECT_H_ 13 | 14 | #include "daa/daa_structs.h" 15 | #include "daa/daa_parameter.h" 16 | #include "tsplog.h" 17 | 18 | /** 19 | * Verifies if the parameters Z,R0,R1,RReceiver and RIssuer of the public key 20 | * were correctly computed. 21 | * 22 | * @param pk 23 | * the public key, which one wants to verfy. 24 | */ 25 | TSS_RESULT 26 | is_pk_correct( TSS_DAA_PK_internal *public_key, 27 | TSS_DAA_PK_PROOF_internal *proof, 28 | int *isCorrect 29 | ); 30 | 31 | #endif /*KEY_CORRECTNESS_PROOF_H_*/ 32 | -------------------------------------------------------------------------------- /src/include/trousers/tss.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #ifndef _TSS_H_ 12 | #define _TSS_H_ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/include/tddl.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004, 2005 8 | * 9 | */ 10 | 11 | 12 | #ifndef _TDDL_H_ 13 | #define _TDDL_H_ 14 | 15 | #include 16 | #include "tcsd_wrap.h" 17 | #include "tcsd.h" 18 | 19 | struct tpm_device_node { 20 | char *path; 21 | #define TDDL_TRANSMIT_IOCTL 1 22 | #define TDDL_TRANSMIT_RW 2 23 | int transmit; 24 | int fd; 25 | }; 26 | 27 | #define TDDL_TXBUF_SIZE 2048 28 | #define TDDL_UNDEF -1 29 | 30 | TSS_RESULT Tddli_Open(void); 31 | 32 | TSS_RESULT Tddli_TransmitData(BYTE *pTransmitBuf, 33 | UINT32 TransmitBufLen, 34 | BYTE *pReceiveBuf, 35 | UINT32 *pReceiveBufLen); 36 | 37 | TSS_RESULT Tddli_Close(void); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /dist/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = system.data.auth system.data.noauth \ 2 | fedora/fedora.initrd.tcsd 3 | install: install-exec-hook 4 | if test ! -e ${DESTDIR}/@sysconfdir@/tcsd.conf; then mkdir -p ${DESTDIR}/@sysconfdir@ && cp tcsd.conf ${DESTDIR}/@sysconfdir@; fi 5 | /bin/chown tss:tss ${DESTDIR}/@sysconfdir@/tcsd.conf || true 6 | /bin/chmod 0600 ${DESTDIR}/@sysconfdir@/tcsd.conf 7 | 8 | install-exec-hook: 9 | /usr/sbin/groupadd tss || true 10 | /usr/sbin/useradd -r tss -g tss || true 11 | /bin/sh -c 'if [ ! -e ${DESTDIR}/@localstatedir@/lib/tpm ];then mkdir -p ${DESTDIR}/@localstatedir@/lib/tpm; fi' 12 | /bin/chown tss:tss ${DESTDIR}/@localstatedir@/lib/tpm || true 13 | /bin/chmod 0700 ${DESTDIR}/@localstatedir@/lib/tpm 14 | 15 | uninstall-hook: 16 | /usr/sbin/userdel tss || true 17 | /usr/sbin/groupdel tss || true 18 | -------------------------------------------------------------------------------- /src/include/tcs_context.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _TCS_CONTEXT_H_ 12 | #define _TCS_CONTEXT_H_ 13 | 14 | #include "threads.h" 15 | 16 | struct keys_loaded 17 | { 18 | TCS_KEY_HANDLE key_handle; 19 | struct keys_loaded *next; 20 | }; 21 | 22 | #define TSS_CONTEXT_FLAG_TRANSPORT_EXCLUSIVE 0x1 23 | #define TSS_CONTEXT_FLAG_TRANSPORT_ENCRYPTED 0x2 24 | #define TSS_CONTEXT_FLAG_TRANSPORT_ENABLED 0x4 25 | 26 | struct tcs_context { 27 | TSS_FLAG flags; 28 | TPM_TRANSHANDLE transHandle; 29 | TCS_CONTEXT_HANDLE handle; 30 | COND_VAR cond; /* used in waiting for an auth ctx to become available */ 31 | struct keys_loaded *keys; 32 | struct tcs_context *next; 33 | }; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /src/include/daa/list.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef LIST_H_ 12 | #define LIST_H_ 13 | 14 | /* simple linked list template */ 15 | struct _list_t { 16 | void *obj; 17 | struct _list_t *next; // pointer to next node 18 | }; 19 | 20 | typedef struct _list_t node_t; // each link is a list "node" 21 | 22 | typedef struct { 23 | node_t *head; // pointer to first node 24 | node_t *current; 25 | node_t *previous; 26 | } list_struct; 27 | 28 | typedef list_struct* list_ptr; 29 | typedef list_struct list_t[1]; 30 | 31 | 32 | list_ptr list_new(); 33 | 34 | void list_add(list_ptr list, void * obj); 35 | 36 | void list_dump(list_ptr list); 37 | 38 | void list_freeall(list_ptr list); 39 | 40 | #endif /*LIST_H_*/ 41 | -------------------------------------------------------------------------------- /src/include/rpc_tcstp.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #ifndef _RPC_TCSTP_H_ 12 | #define _RPC_TCSTP_H_ 13 | 14 | #include "tcs_tsp.h" 15 | 16 | typedef unsigned char TCSD_PACKET_TYPE; 17 | 18 | /* Packet header used for TCSD communication */ 19 | struct tcsd_packet_hdr { 20 | UINT32 packet_size; 21 | union { 22 | UINT32 ordinal; 23 | UINT32 result; 24 | } u; 25 | UINT32 num_parms; 26 | UINT32 type_size; 27 | UINT32 type_offset; 28 | UINT32 parm_size; 29 | UINT32 parm_offset; 30 | } STRUCTURE_PACKING_ATTRIBUTE; 31 | 32 | struct tcsd_comm_data { 33 | BYTE *buf; 34 | UINT32 buf_size; 35 | struct tcsd_packet_hdr hdr; 36 | } STRUCTURE_PACKING_ATTRIBUTE; 37 | 38 | #define TCSD_INIT_TXBUF_SIZE 1024 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/include/biosem.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | #ifndef _BIOSEM_H_ 12 | #define _BIOSEM_H_ 13 | 14 | int bios_open(void *, FILE **); 15 | TSS_RESULT bios_get_entries_by_pcr(FILE *, UINT32, UINT32, UINT32 *, TSS_PCR_EVENT **); 16 | TSS_RESULT bios_get_entry(FILE *, UINT32, UINT32 *, TSS_PCR_EVENT **); 17 | int bios_close(FILE *); 18 | 19 | extern struct ext_log_source bios_source; 20 | 21 | /* this should be large if we're reading out of /proc */ 22 | #define BIOS_READ_SIZE 4096 23 | 24 | typedef struct { 25 | UINT32 pcrIndex; 26 | UINT32 eventType; 27 | BYTE digest[20]; 28 | UINT32 eventDataSize; 29 | BYTE event[0];/* (eventSize) bytes of event data follows */ 30 | } TCG_PCClientPCREventStruc; 31 | 32 | #define EVLOG_SOURCE_BIOS 1 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/include/memmgr.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _MEMMGR_H_ 12 | #define _MEMMGR_H_ 13 | 14 | /* 15 | * For each TSP context, there is one memTable, which holds a list of memEntry's, 16 | * each of which holds a pointer to some malloc'd memory that's been returned to 17 | * the user. The memTable also can point to other memTable's which would be 18 | * created if multiple TSP contexts were opened. 19 | * 20 | */ 21 | 22 | struct memEntry { 23 | void *memPointer; 24 | struct memEntry *nextEntry; 25 | }; 26 | 27 | struct memTable { 28 | TSS_HCONTEXT tspContext; 29 | struct memEntry *entries; 30 | struct memTable *nextTable; 31 | }; 32 | 33 | MUTEX_DECLARE_INIT(memtable_lock); 34 | 35 | struct memTable *SpiMemoryTable = NULL; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/include/tsp_delegate.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #ifndef _TSP_DELEGATE_H_ 12 | #define _TSP_DELEGATE_H_ 13 | 14 | TSS_RESULT do_delegate_manage(TSS_HTPM hTpm, UINT32 familyID, UINT32 opFlag, 15 | UINT32 opDataSize, BYTE *opData, UINT32 *outDataSize, BYTE **outData); 16 | TSS_RESULT create_key_delegation(TSS_HKEY, BYTE, UINT32, TSS_HPCRS, TSS_HDELFAMILY, TSS_HPOLICY); 17 | TSS_RESULT create_owner_delegation(TSS_HTPM, BYTE, UINT32, TSS_HPCRS, TSS_HDELFAMILY, TSS_HPOLICY); 18 | 19 | TSS_RESULT update_delfamily_object(TSS_HTPM, UINT32); 20 | TSS_RESULT get_delegate_index(TSS_HCONTEXT, UINT32, TPM_DELEGATE_PUBLIC *); 21 | TSS_RESULT __tspi_build_delegate_public_info(BYTE, TSS_HPCRS, TSS_HDELFAMILY, TSS_HPOLICY, UINT32 *, BYTE **); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/include/tss/tcs_typedef.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Global typedefs for TSS Core Service 4 | 5 | */ 6 | 7 | #ifndef __TCS_TYPEDEF_H__ 8 | #define __TCS_TYPEDEF_H__ 9 | 10 | #include 11 | #include 12 | 13 | typedef UINT32 TCS_AUTHHANDLE; 14 | typedef UINT32 TCS_CONTEXT_HANDLE; 15 | typedef UINT32 TCS_KEY_HANDLE; 16 | typedef UINT32 TCS_HANDLE; 17 | 18 | 19 | // Substitution definitions for TCS-IDL 20 | typedef TPM_ENCAUTH TCG_ENCAUTH; 21 | typedef TPM_NONCE TCG_NONCE; 22 | typedef TPM_ENTITY_TYPE TCG_ENTITY_TYPE; 23 | typedef TPM_PCRINDEX TCG_PCRINDEX; 24 | typedef TPM_DIGEST TCG_DIGEST; 25 | typedef TPM_PCRVALUE TCG_PCRVALUE; 26 | typedef TPM_DIRVALUE TCG_DIRVALUE; 27 | typedef TPM_DIRINDEX TCG_DIRINDEX; 28 | 29 | 30 | 31 | #endif // __TCS_TYPEDEF_H__ 32 | 33 | -------------------------------------------------------------------------------- /src/include/imaem.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _IMAEM_H_ 12 | #define _IMAEM_H_ 13 | 14 | int ima_open(void *, FILE **); 15 | TSS_RESULT ima_get_entries_by_pcr(FILE *, UINT32, UINT32, UINT32 *, TSS_PCR_EVENT **); 16 | TSS_RESULT ima_get_entry(FILE *, UINT32, UINT32 *, TSS_PCR_EVENT **); 17 | int ima_close(FILE *); 18 | 19 | extern struct ext_log_source ima_source; 20 | 21 | /* 4 bytes binary [PCR value] 22 | * 20 bytes binary [SHA1 value] 23 | * 4 bytes binary [event type] 24 | * 255 bytes of ascii (MAX) [event name] 25 | * 1 byte -> '\0' [separator ] 26 | */ 27 | #define IMA_MIN_EVENT_SIZE 29 28 | #define IMA_MAX_EVENT_SIZE 284 29 | 30 | /* this should be large if we're reading out of /proc */ 31 | #define IMA_READ_SIZE (4096 + IMA_MAX_EVENT_SIZE) 32 | 33 | #define EVLOG_SOURCE_IMA 1 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/include/tss/tcs_defines.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | TSS Core Service structures 4 | 5 | */ 6 | 7 | #ifndef __TCS_DEFINES_H__ 8 | #define __TCS_DEFINES_H__ 9 | 10 | #define TSS_TCSATTRIB_TRANSPORT_DEFAULT ((UINT32)(0x00000000)) 11 | #define TSS_TCSATTRIB_TRANSPORT_EXCLUSIVE ((UINT32)(0x00000001)) 12 | 13 | 14 | // Values for the ulCredentialType parameter to Tcsi_GetCredential 15 | #define TSS_TCS_CREDENTIAL_EKCERT ((UINT32)0x00000001) 16 | #define TSS_TCS_CREDENTIAL_TPM_CC ((UINT32)0x00000002) 17 | #define TSS_TCS_CREDENTIAL_PLATFORMCERT ((UINT32)0x00000003) 18 | 19 | 20 | // Values for the ulCredentialAccessMode parameter to Tcsi_GetCredential 21 | // TSS_TCS_CERT_ACCESS_AUTO triggers the default behavior. 22 | // Values with TSS_TCS_CERT_VENDOR_SPECIFIC_BIT set trigger 23 | // vendor specific behavior. 24 | #define TSS_TCS_CERT_ACCESS_AUTO ((UINT32)0x00000001) 25 | 26 | #define TSS_TCS_CERT_VENDOR_SPECIFIC_BIT ((UINT32)0x80000000) 27 | 28 | #endif // __TCS_DEFINES_H__ 29 | -------------------------------------------------------------------------------- /src/include/hosttable.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #ifndef _HOSTTABLE_H_ 12 | #define _HOSTTABLE_H_ 13 | 14 | #include "rpc_tcstp.h" 15 | #include "threads.h" 16 | 17 | 18 | #define CONNECTION_TYPE_TCP_PERSISTANT 1 19 | 20 | struct host_table_entry { 21 | struct host_table_entry *next; 22 | TSS_HCONTEXT tspContext; 23 | TCS_CONTEXT_HANDLE tcsContext; 24 | BYTE *hostname; 25 | int type; 26 | int socket; 27 | struct tcsd_comm_data comm; 28 | MUTEX_DECLARE(lock); 29 | }; 30 | 31 | struct host_table { 32 | struct host_table_entry *entries; 33 | MUTEX_DECLARE(lock); 34 | }; 35 | 36 | extern struct host_table *ht; 37 | struct host_table_entry *get_table_entry(TCS_CONTEXT_HANDLE); 38 | void put_table_entry(struct host_table_entry *); 39 | TSS_RESULT __tspi_add_table_entry(TSS_HCONTEXT, BYTE *, int, struct host_table_entry **); 40 | void remove_table_entry(TCS_CONTEXT_HANDLE); 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/include/tcs_key_ps.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #ifndef _TCS_KEY_PS_H_ 12 | #define _TCS_KEY_PS_H_ 13 | 14 | TSS_RESULT ps_init_disk_cache(); 15 | void ps_close_disk_cache(); 16 | TSS_BOOL ps_is_key_registered(TCPA_STORE_PUBKEY *); 17 | TSS_RESULT getParentUUIDByUUID(TSS_UUID *, TSS_UUID *); 18 | TSS_RESULT isUUIDRegistered(TSS_UUID *, TSS_BOOL *); 19 | void disk_cache_shift(struct key_disk_cache *); 20 | TSS_RESULT ps_remove_key(TSS_UUID *); 21 | TSS_RESULT clean_disk_cache(int); 22 | TSS_RESULT ps_get_key_by_uuid(TSS_UUID *, BYTE *, UINT16 *); 23 | TSS_RESULT ps_get_key_by_cache_entry(struct key_disk_cache *, BYTE *, UINT16 *); 24 | TSS_RESULT ps_is_pub_registered(TCPA_STORE_PUBKEY *); 25 | TSS_RESULT ps_get_uuid_by_pub(TCPA_STORE_PUBKEY *, TSS_UUID **); 26 | TSS_RESULT ps_get_key_by_pub(TCPA_STORE_PUBKEY *, UINT32 *, BYTE **); 27 | TSS_RESULT ps_write_key(TSS_UUID *, TSS_UUID *, BYTE *, UINT32, BYTE *, UINT32); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/include/tss/tcs_structs.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | TSS Core Service structures 4 | 5 | */ 6 | 7 | #ifndef __TCS_STRUCT_H__ 8 | #define __TCS_STRUCT_H__ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | typedef struct tdTCS_AUTH 15 | { 16 | TCS_AUTHHANDLE AuthHandle; 17 | TPM_NONCE NonceOdd; // system 18 | TPM_NONCE NonceEven; // TPM 19 | TSS_BOOL fContinueAuthSession; 20 | TPM_AUTHDATA HMAC; 21 | } TCS_AUTH; 22 | 23 | // This is kept for legacy compatibility 24 | typedef TCS_AUTH TPM_AUTH; 25 | 26 | 27 | typedef struct tdTCS_LOADKEY_INFO 28 | { 29 | TSS_UUID keyUUID; 30 | TSS_UUID parentKeyUUID; 31 | TPM_DIGEST paramDigest; // SHA1 digest of the TPM_LoadKey 32 | // Command input parameters 33 | // As defined in TPM Main Specification 34 | TPM_AUTH authData; // Data regarding a valid auth 35 | // Session including the 36 | // HMAC digest 37 | } TCS_LOADKEY_INFO; 38 | 39 | #endif // __TCS_STRUCT_H__ 40 | 41 | -------------------------------------------------------------------------------- /src/tcs/tcsi_oper.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers_types.h" 18 | #include "tcs_utils.h" 19 | #include "tcslog.h" 20 | #include "req_mgr.h" 21 | 22 | TSS_RESULT 23 | TCSP_SetOperatorAuth_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 24 | TCPA_SECRET *operatorAuth) /* in */ 25 | { 26 | TSS_RESULT result; 27 | UINT64 offset = 0; 28 | UINT32 paramSize; 29 | BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 30 | 31 | LogDebugFn("Enter"); 32 | 33 | if ((result = ctx_verify_context(hContext))) 34 | return result; 35 | 36 | if ((result = tpm_rqu_build(TPM_ORD_SetOperatorAuth, &offset, txBlob, TPM_AUTHDATA_SIZE, 37 | operatorAuth->authdata))) 38 | return result; 39 | 40 | if ((result = req_mgr_submit_req(txBlob))) 41 | goto done; 42 | 43 | result = UnloadBlob_Header(txBlob, ¶mSize); 44 | 45 | LogResult("SetOperatorAuth", result); 46 | done: 47 | return result; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/tspi/tspi_counter.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "trousers/trousers.h" 17 | #include "trousers_types.h" 18 | #include "spi_utils.h" 19 | #include "capabilities.h" 20 | #include "tsplog.h" 21 | #include "obj.h" 22 | 23 | 24 | TSS_RESULT 25 | Tspi_TPM_ReadCounter(TSS_HTPM hTPM, /* in */ 26 | UINT32* counterValue) /* out */ 27 | { 28 | TSS_HCONTEXT tspContext; 29 | TCPA_RESULT result; 30 | TSS_COUNTER_ID counterID; 31 | TPM_COUNTER_VALUE counter_value; 32 | 33 | if (counterValue == NULL) 34 | return TSPERR(TSS_E_BAD_PARAMETER); 35 | 36 | if ((result = obj_tpm_get_tsp_context(hTPM, &tspContext))) 37 | return result; 38 | 39 | if ((result = obj_tpm_get_current_counter(hTPM, &counterID))) 40 | return result; 41 | 42 | if ((result = TCS_API(tspContext)->ReadCounter(tspContext, counterID, &counter_value))) 43 | return result; 44 | 45 | *counterValue = counter_value.counter; 46 | 47 | return TSS_SUCCESS; 48 | } 49 | -------------------------------------------------------------------------------- /src/include/linux/tpm.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | /* 12 | * include/linux/tpm.h 13 | * 14 | * Device driver for TCPA TPM (trusted platform module). 15 | */ 16 | #ifndef _TPM_H_ 17 | #define _TPM_H_ 18 | 19 | #if (defined (__linux) || defined (linux)) 20 | #include 21 | #elif (defined (__OpenBSD__) || defined (__FreeBSD__)) 22 | #include 23 | #endif 24 | 25 | /* ioctl commands */ 26 | #define TPMIOC_CANCEL _IO('T', 0x00) 27 | #define TPMIOC_TRANSMIT _IO('T', 0x01) 28 | 29 | #if defined(__KERNEL__) 30 | extern ssize_t tpm_transmit(const char *buf, size_t bufsiz); 31 | extern ssize_t tpm_extend(int index, u8 *digest); 32 | extern ssize_t tpm_pcrread(int index, u8 *hash); 33 | extern ssize_t tpm_dirread(int index, u8 *hash); 34 | extern ssize_t tpm_cap_version(int *maj, int *min, int *ver, int *rev); 35 | extern ssize_t tpm_cap_pcr(int *pcrs); 36 | extern ssize_t tpm_cap_dir(int *dirs); 37 | extern ssize_t tpm_cap_manufacturer(int *manufacturer); 38 | extern ssize_t tpm_cap_slot(int *slots); 39 | #endif /* __KERNEL__ */ 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/tspi/rpc/tcstp/rpc_oper.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "tsplog.h" 20 | #include "hosttable.h" 21 | #include "tcsd_wrap.h" 22 | #include "rpc_tcstp_tsp.h" 23 | 24 | 25 | TSS_RESULT 26 | RPC_SetOperatorAuth_TP(struct host_table_entry *hte, 27 | TCPA_SECRET *operatorAuth) /* in */ 28 | { 29 | TSS_RESULT result; 30 | 31 | initData(&hte->comm, 2); 32 | hte->comm.hdr.u.ordinal = TCSD_ORD_SETOPERATORAUTH; 33 | LogDebugFn("TCS Context: 0x%x", hte->tcsContext); 34 | 35 | if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm)) 36 | return TSPERR(TSS_E_INTERNAL_ERROR); 37 | if (setData(TCSD_PACKET_TYPE_SECRET, 1, operatorAuth, 0, &hte->comm)) 38 | return TSPERR(TSS_E_INTERNAL_ERROR); 39 | 40 | result = sendTCSDPacket(hte); 41 | 42 | if (result == TSS_SUCCESS) 43 | result = hte->comm.hdr.u.result; 44 | 45 | return result; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/tspi/tsp_oper.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "trousers/tss.h" 19 | #include "trousers/trousers.h" 20 | #include "trousers_types.h" 21 | #include "spi_utils.h" 22 | #include "capabilities.h" 23 | #include "tsplog.h" 24 | #include "obj.h" 25 | 26 | 27 | #ifdef TSS_BUILD_TRANSPORT 28 | TSS_RESULT 29 | Transport_SetOperatorAuth(TSS_HCONTEXT tspContext, /* in */ 30 | TCPA_SECRET *operatorAuth) /* in */ 31 | { 32 | TSS_RESULT result; 33 | UINT64 offset; 34 | TCS_HANDLE handlesLen = 0; 35 | BYTE data[sizeof(TCPA_SECRET)]; 36 | 37 | if ((result = obj_context_transport_init(tspContext))) 38 | return result; 39 | 40 | LogDebugFn("Executing in a transport session"); 41 | 42 | offset = 0; 43 | Trspi_LoadBlob(&offset, TPM_SHA1_160_HASH_LEN, data, operatorAuth->authdata); 44 | 45 | return obj_context_transport_execute(tspContext, TPM_ORD_SetOperatorAuth, sizeof(data), 46 | data, NULL, &handlesLen, NULL, NULL, NULL, NULL, NULL); 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/tcs/tcs_migration.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcsps.h" 21 | #include "tcs_utils.h" 22 | #include "tcs_int_literals.h" 23 | #include "capabilities.h" 24 | #include "tcslog.h" 25 | #include "req_mgr.h" 26 | #include "tcsd_wrap.h" 27 | #include "tcsd.h" 28 | 29 | TSS_RESULT 30 | UnloadBlob_MIGRATIONKEYAUTH(UINT64 *offset, BYTE *blob, TCPA_MIGRATIONKEYAUTH *mkAuth) 31 | { 32 | TSS_RESULT result; 33 | 34 | if (!mkAuth) { 35 | if ((result = UnloadBlob_PUBKEY(offset, blob, NULL))) 36 | return result; 37 | 38 | UnloadBlob_UINT16(offset, NULL, blob); 39 | UnloadBlob(offset, 20, blob, NULL); 40 | 41 | return TSS_SUCCESS; 42 | } 43 | 44 | if ((result = UnloadBlob_PUBKEY(offset, blob, &mkAuth->migrationKey))) 45 | return result; 46 | 47 | UnloadBlob_UINT16(offset, &mkAuth->migrationScheme, blob); 48 | UnloadBlob(offset, 20, blob, mkAuth->digest.digest); 49 | 50 | return result; 51 | } 52 | -------------------------------------------------------------------------------- /src/tspi/tspi_oper.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "spi_utils.h" 20 | #include "obj.h" 21 | #include "tsplog.h" 22 | 23 | 24 | TSS_RESULT 25 | Tspi_TPM_SetOperatorAuth(TSS_HTPM hTpm, /* in */ 26 | TSS_HPOLICY hOperatorPolicy) /* in */ 27 | { 28 | TSS_HCONTEXT tspContext; 29 | UINT32 type; 30 | TCPA_SECRET operatorAuth; 31 | TSS_RESULT result = TSS_SUCCESS; 32 | 33 | if ((result = obj_tpm_get_tsp_context(hTpm, &tspContext))) 34 | return result; 35 | 36 | if ((result = obj_policy_get_type(hOperatorPolicy, &type))) 37 | return result; 38 | 39 | if (type != TSS_POLICY_OPERATOR) 40 | return TSPERR(TSS_E_BAD_PARAMETER); 41 | 42 | if ((result = obj_policy_get_secret(hOperatorPolicy, TR_SECRET_CTX_NEW, &operatorAuth))) 43 | return result; 44 | 45 | if ((result = TCS_API(tspContext)->SetOperatorAuth(tspContext, &operatorAuth))) 46 | return result; 47 | 48 | if ((result = obj_tpm_set_policy(hTpm, hOperatorPolicy))) 49 | return result; 50 | 51 | return result; 52 | } 53 | -------------------------------------------------------------------------------- /src/include/tss/platform.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | There are platform dependent and general defines. 4 | 5 | --*/ 6 | 7 | #ifndef TSS_PLATFORM_H 8 | #define TSS_PLATFORM_H 9 | 10 | 11 | /* The default implementation is to use stdint.h, a part of the C99 standard. 12 | * Systems that don't support this are handled on a case-by-case basis. 13 | */ 14 | 15 | #if !defined(WIN32) 16 | #include 17 | typedef uint8_t BYTE; 18 | typedef int8_t TSS_BOOL; 19 | typedef uint16_t UINT16; 20 | typedef uint32_t UINT32; 21 | typedef uint64_t UINT64; 22 | 23 | typedef uint16_t TSS_UNICODE; 24 | typedef void* PVOID; 25 | 26 | #elif defined(WIN32) 27 | #include 28 | typedef unsigned char BYTE; 29 | typedef signed char TSS_BOOL; 30 | #ifndef _BASETSD_H_ 31 | // basetsd.h provides definitions of UINT16, UINT32 and UINT64. 32 | typedef unsigned short UINT16; 33 | typedef unsigned long UINT32; 34 | typedef unsigned __int64 UINT64; 35 | #endif 36 | typedef unsigned short TSS_UNICODE; 37 | typedef void* PVOID; 38 | #endif 39 | 40 | 41 | /* Include this so that applications that use names as defined in the 42 | * 1.1 TSS specification can still compile 43 | */ 44 | #include 45 | 46 | #endif // TSS_PLATFORM_H 47 | -------------------------------------------------------------------------------- /src/tcs/tcs_counter.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "trousers/tss.h" 23 | #include "trousers_types.h" 24 | #include "trousers_types.h" 25 | #include "tcs_tsp.h" 26 | #include "tcs_utils.h" 27 | #include "tcs_int_literals.h" 28 | #include "capabilities.h" 29 | #include "tcsps.h" 30 | #include "tcslog.h" 31 | 32 | 33 | void 34 | UnloadBlob_COUNTER_VALUE(UINT64 *offset, BYTE *blob, TPM_COUNTER_VALUE *ctr) 35 | { 36 | if (!ctr) { 37 | UnloadBlob_UINT16(offset, NULL, blob); 38 | UnloadBlob(offset, 4, blob, NULL); 39 | UnloadBlob_UINT32(offset, NULL, blob); 40 | return; 41 | } 42 | 43 | UnloadBlob_UINT16(offset, &ctr->tag, blob); 44 | UnloadBlob(offset, 4, blob, (BYTE *)&ctr->label); 45 | UnloadBlob_UINT32(offset, &ctr->counter, blob); 46 | } 47 | 48 | void 49 | LoadBlob_COUNTER_VALUE(UINT64 *offset, BYTE *blob, TPM_COUNTER_VALUE *ctr) 50 | { 51 | LoadBlob_UINT16(offset, ctr->tag, blob); 52 | LoadBlob(offset, 4, blob, (BYTE *)&ctr->label); 53 | LoadBlob_UINT32(offset, ctr->counter, blob); 54 | } 55 | -------------------------------------------------------------------------------- /src/tcs/tcsi_context.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "trousers_types.h" 17 | #include "tcs_tsp.h" 18 | #include "tcs_utils.h" 19 | #include "tcs_int_literals.h" 20 | #include "capabilities.h" 21 | #include "tcslog.h" 22 | 23 | 24 | TSS_RESULT 25 | TCS_OpenContext_Internal(TCS_CONTEXT_HANDLE * hContext) /* out */ 26 | { 27 | *hContext = make_context(); 28 | if (*hContext == 0) 29 | return TCSERR(TSS_E_OUTOFMEMORY); 30 | 31 | return TSS_SUCCESS; 32 | } 33 | 34 | TSS_RESULT 35 | TCS_CloseContext_Internal(TCS_CONTEXT_HANDLE hContext) /* in */ 36 | { 37 | TSS_RESULT result; 38 | 39 | LogDebug("Closing context %.8X", hContext); 40 | 41 | if ((result = ctx_verify_context(hContext))) 42 | return result; 43 | 44 | destroy_context(hContext); 45 | 46 | /* close all auth handles associated with hContext */ 47 | auth_mgr_close_context(hContext); 48 | 49 | KEY_MGR_ref_count(); 50 | 51 | LogDebug("Context %.8X closed", hContext); 52 | return TSS_SUCCESS; 53 | } 54 | 55 | TSS_RESULT 56 | TCS_FreeMemory_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 57 | BYTE *pMemory) /* in */ 58 | { 59 | free(pMemory); 60 | 61 | return TSS_SUCCESS; 62 | } 63 | -------------------------------------------------------------------------------- /src/tspi/ps/ps_utils.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "trousers/tss.h" 19 | #include "trousers_types.h" 20 | #include "tcs_tsp.h" 21 | #include "spi_utils.h" 22 | #include "tspps.h" 23 | #include "tsplog.h" 24 | 25 | inline TSS_RESULT 26 | read_data(int fd, void *data, UINT32 size) 27 | { 28 | int rc; 29 | 30 | rc = read(fd, data, size); 31 | if (rc == -1) { 32 | LogError("read of %d bytes: %s", size, strerror(errno)); 33 | return TSPERR(TSS_E_INTERNAL_ERROR); 34 | } else if ((unsigned)rc != size) { 35 | LogError("read of %d bytes (only %d read)", size, rc); 36 | return TSPERR(TSS_E_INTERNAL_ERROR); 37 | } 38 | 39 | return TSS_SUCCESS; 40 | } 41 | 42 | inline TSS_RESULT 43 | write_data(int fd, void *data, UINT32 size) 44 | { 45 | int rc; 46 | 47 | rc = write(fd, data, size); 48 | if (rc == -1) { 49 | LogError("write of %d bytes: %s", size, strerror(errno)); 50 | return TSPERR(TSS_E_INTERNAL_ERROR); 51 | } else if ((unsigned)rc != size) { 52 | LogError("write of %d bytes (only %d written)", size, rc); 53 | return TSPERR(TSS_E_INTERNAL_ERROR); 54 | } 55 | 56 | return TSS_SUCCESS; 57 | } 58 | -------------------------------------------------------------------------------- /src/tcs/rpc/tcstp/rpc_oper.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcs_utils.h" 21 | #include "tcs_int_literals.h" 22 | #include "capabilities.h" 23 | #include "tcslog.h" 24 | #include "tcsd_wrap.h" 25 | #include "tcsd.h" 26 | #include "tcs_utils.h" 27 | #include "rpc_tcstp_tcs.h" 28 | 29 | 30 | TSS_RESULT 31 | tcs_wrap_SetOperatorAuth(struct tcsd_thread_data *data) 32 | { 33 | TCS_CONTEXT_HANDLE hContext; 34 | TCPA_SECRET operatorAuth; 35 | TSS_RESULT result; 36 | 37 | if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) 38 | return TCSERR(TSS_E_INTERNAL_ERROR); 39 | 40 | LogDebugFn("thread %ld context %x", THREAD_ID, hContext); 41 | 42 | if (getData(TCSD_PACKET_TYPE_SECRET, 1, &operatorAuth, 0, &data->comm)) 43 | return TCSERR(TSS_E_INTERNAL_ERROR); 44 | 45 | MUTEX_LOCK(tcsp_lock); 46 | 47 | result = TCSP_SetOperatorAuth_Internal(hContext, &operatorAuth); 48 | 49 | MUTEX_UNLOCK(tcsp_lock); 50 | 51 | initData(&data->comm, 0); 52 | 53 | data->comm.hdr.u.result = result; 54 | 55 | return TSS_SUCCESS; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/tspi/log.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004, 2005 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "tsplog.h" 17 | 18 | #ifdef TSS_DEBUG 19 | 20 | /* 21 | * LogBlobData() 22 | * 23 | * Log a blob's data to the debugging stream 24 | * 25 | * szDescriptor - The APPID tag found in the caller's environment at build time 26 | * sizeOfBlob - The size of the data to log 27 | * blob - the data to log 28 | * 29 | */ 30 | 31 | 32 | void 33 | LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob) 34 | { 35 | char temp[64]; 36 | int i; 37 | 38 | if (getenv("TSS_DEBUG_OFF")) 39 | return; 40 | 41 | memset(temp, 0, sizeof(temp)); 42 | 43 | for (i = 0; (unsigned long)i < sizeOfBlob; i++) { 44 | if ((i > 0) && ((i % 16) == 0)) { 45 | fprintf(stdout, "%s\n", temp); 46 | memset(temp, 0, sizeof(temp)); 47 | } 48 | snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]); 49 | } 50 | fprintf(stdout, "%s\n", temp); 51 | } 52 | 53 | TSS_RESULT 54 | LogTSPERR(TSS_RESULT result, char *file, int line) 55 | { 56 | if (getenv("TSS_DEBUG_OFF") == NULL) 57 | fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result); 58 | 59 | return (result | TSS_LAYER_TSP); 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/tspi/tsp_counter.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "trousers/trousers.h" 17 | #include "trousers_types.h" 18 | #include "spi_utils.h" 19 | #include "capabilities.h" 20 | #include "tsplog.h" 21 | #include "obj.h" 22 | 23 | 24 | #ifdef TSS_BUILD_TRANSPORT 25 | TSS_RESULT 26 | Transport_ReadCounter(TSS_HCONTEXT tspContext, /* in */ 27 | TSS_COUNTER_ID idCounter, /* in */ 28 | TPM_COUNTER_VALUE* counterValue) /* out */ 29 | { 30 | TSS_RESULT result; 31 | UINT32 decLen = 0; 32 | BYTE *dec = NULL; 33 | UINT64 offset; 34 | TCS_HANDLE handlesLen = 0; 35 | BYTE data[sizeof(UINT32)]; 36 | 37 | if ((result = obj_context_transport_init(tspContext))) 38 | return result; 39 | 40 | LogDebugFn("Executing in a transport session"); 41 | 42 | offset = 0; 43 | Trspi_LoadBlob_UINT32(&offset, idCounter, data); 44 | 45 | if ((result = obj_context_transport_execute(tspContext, TPM_ORD_ReadCounter, sizeof(data), 46 | data, NULL, &handlesLen, NULL, NULL, NULL, 47 | &decLen, &dec))) 48 | return result; 49 | 50 | offset = 0; 51 | Trspi_UnloadBlob_COUNTER_VALUE(&offset, dec, counterValue); 52 | 53 | free(dec); 54 | 55 | return TSS_SUCCESS; 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /src/include/auth_mgr.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _AUTH_MGR_H_ 12 | #define _AUTH_MGR_H_ 13 | 14 | struct auth_map 15 | { 16 | TSS_BOOL full; 17 | TPM_AUTHHANDLE tpm_handle; 18 | TCS_CONTEXT_HANDLE tcs_ctx; 19 | BYTE *swap; /* These 'swap' variables manage blobs received from TPM_SaveAuthContext */ 20 | UINT32 swap_size; 21 | }; 22 | 23 | /* 24 | * it appears that there's no way to query a v1.1 TPM for the 25 | * max number of simultaneous auth sessions. We'll make the 26 | * default relatively large and let the TPM return 27 | * TCPA_RESOURCES to tell us when we cross the line. 28 | */ 29 | #define TSS_DEFAULT_AUTH_TABLE_SIZE 16 30 | #define TSS_DEFAULT_OVERFLOW_AUTHS 16 31 | 32 | struct _auth_mgr 33 | { 34 | short max_auth_sessions; 35 | short open_auth_sessions; 36 | UINT32 sleeping_threads; 37 | COND_VAR **overflow; /* queue of TCS contexts waiting for an auth session to become 38 | * available */ 39 | unsigned int of_head, of_tail; /* head and tail of the overflow queue */ 40 | struct auth_map *auth_mapper; /* table of currently tracked auth sessions */ 41 | UINT32 auth_mapper_size, overflow_size; 42 | } auth_mgr; 43 | 44 | MUTEX_DECLARE_INIT(auth_mgr_lock); 45 | 46 | TSS_RESULT TPM_SaveAuthContext(TPM_AUTHHANDLE, UINT32 *, BYTE **); 47 | TSS_RESULT TPM_LoadAuthContext(UINT32, BYTE *, TPM_AUTHHANDLE *); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/tcs/crypto/openssl/crypto.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include "trousers/tss.h" 21 | #include "trousers_types.h" 22 | #include "tcs_tsp.h" 23 | #include "tcslog.h" 24 | 25 | /* 26 | * Hopefully this will make the code clearer since 27 | * OpenSSL returns 1 on success 28 | */ 29 | #define EVP_SUCCESS 1 30 | 31 | TSS_RESULT 32 | Hash(UINT32 HashType, UINT32 BufSize, BYTE* Buf, BYTE* Digest) 33 | { 34 | EVP_MD_CTX md_ctx; 35 | unsigned int result_size; 36 | int rv; 37 | 38 | switch (HashType) { 39 | case TSS_HASH_SHA1: 40 | rv = EVP_DigestInit(&md_ctx, EVP_sha1()); 41 | break; 42 | default: 43 | rv = TCSERR(TSS_E_BAD_PARAMETER); 44 | goto out; 45 | break; 46 | } 47 | 48 | if (rv != EVP_SUCCESS) { 49 | rv = TCSERR(TSS_E_INTERNAL_ERROR); 50 | goto out; 51 | } 52 | 53 | rv = EVP_DigestUpdate(&md_ctx, Buf, BufSize); 54 | if (rv != EVP_SUCCESS) { 55 | rv = TCSERR(TSS_E_INTERNAL_ERROR); 56 | goto out; 57 | } 58 | 59 | result_size = EVP_MD_CTX_size(&md_ctx); 60 | rv = EVP_DigestFinal(&md_ctx, Digest, &result_size); 61 | if (rv != EVP_SUCCESS) { 62 | rv = TCSERR(TSS_E_INTERNAL_ERROR); 63 | } else 64 | rv = TSS_SUCCESS; 65 | 66 | out: 67 | return rv; 68 | } 69 | -------------------------------------------------------------------------------- /src/tspi/daa/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS=issuer_setup key_verification test test_tpm test_join test_sign 2 | #todel 3 | 4 | test_SOURCES=big_integer/bi_gmp.c big_integer/bi_openssl.c big_integer/bi.c utils/list.c big_integer/test/test.c big_integer/test/multi_exp.c 5 | test_CFLAGS=-I../../include/daa -I../../include -DBI_DEBUG -g -DAPPID=\"BI\" 6 | test_LDFLAGS=-lcrypto 7 | 8 | issuer_setup_SOURCES = daa_issuer/issuer_setup.c 9 | issuer_setup_CFLAGS=-I../../include/daa -I../../include -DBI_DEBUG -DAPPID=\"DAA_ISSUER_SETUP\" 10 | issuer_setup_LDFLAGS=-lcrypto ../libtspi.la ../libdaa.la 11 | 12 | key_verification_SOURCES=daa_issuer/key_verification.c 13 | key_verification_CFLAGS=-I../../include/daa -I../../include -DBI_DEBUG -DAPPID=\"DAA_KEY_VERIFICATION\" 14 | key_verification_LDFLAGS=-lcrypto ../libtspi.la ../libdaa.la 15 | 16 | test_tpm_SOURCES = daa_platform/test.c 17 | test_tpm_CFLAGS=-I../../include/daa -I../../include 18 | test_tpm_LDFLAGS=-lcrypto ../libtspi.la ../libdaa.la 19 | 20 | test_join_SOURCES = daa_platform/test_join.c 21 | test_join_CFLAGS=-I../../include/daa -I../../include -DBI_DEBUG -DAPPID=\"DAA_JOIN\" 22 | test_join_LDFLAGS=-lcrypto ../libtspi.la ../libdaa.la 23 | 24 | test_sign_SOURCES = test_sign.c 25 | test_sign_CFLAGS=-I../../include/daa -I../../include -DBI_DEBUG -DAPPID=\"DAA_JOIN\" 26 | test_sign_LDFLAGS=-lcrypto ../libtspi.la ../libdaa.la 27 | 28 | #todel_SOURCES = todel.c 29 | #todel_CFLAGS=-I../../include/daa -I../../include -DBI_DEBUG -DAPPID=\"DAA_JOIN\" 30 | #todel_LDFLAGS=-lcrypto ../libtspi.la ../libdaa.la 31 | 32 | -------------------------------------------------------------------------------- /src/include/Makefile.am: -------------------------------------------------------------------------------- 1 | tssincludedir = $(includedir)/tss 2 | trousersincludedir = $(includedir)/trousers 3 | 4 | tssinclude_HEADERS = tss/tcpa_error.h \ 5 | tss/tcs_error.h \ 6 | tss/tcs_defines.h \ 7 | tss/tcs.h \ 8 | tss/tddlapi_error.h \ 9 | tss/tspi.h \ 10 | tss/tss_error.h \ 11 | tss/platform.h \ 12 | tss/tcpa_struct.h \ 13 | tss/tcs_structs.h \ 14 | tss/tddl_error.h \ 15 | tss/tss_defines.h \ 16 | tss/tss_structs.h \ 17 | tss/tcpa_defines.h \ 18 | tss/tcpa_typedef.h \ 19 | tss/tcs_typedef.h \ 20 | tss/tddli.h \ 21 | tss/tss_error_basics.h \ 22 | tss/tss_typedef.h \ 23 | tss/compat11b.h \ 24 | tss/tpm.h \ 25 | tss/tpm_error.h \ 26 | tss/tpm_ordinal.h 27 | trousersinclude_HEADERS = trousers/tss.h trousers/trousers.h 28 | 29 | noinst_HEADERS = auth_mgr.h authsess.h biosem.h capabilities.h \ 30 | hosttable.h imaem.h memmgr.h obj_context.h \ 31 | obj_daaarakey.h obj_daacred.h obj_daa.h \ 32 | obj_daaissuerkey.h obj_delfamily.h obj_encdata.h \ 33 | obj.h obj_hash.h obj_migdata.h obj_nv.h \ 34 | obj_pcrs.h obj_policy.h obj_rsakey.h \ 35 | obj_tpm.h req_mgr.h rpc_tcstp.h rpc_tcstp_tcs.h \ 36 | rpc_tcstp_tsp.h spi_utils.h tcs_aik.h \ 37 | tcs_context.h tcsd.h tcsd_ops.h tcsd_wrap.h \ 38 | tcsem.h tcs_int_literals.h tcs_key_ps.h \ 39 | tcslog.h tcsps.h tcs_tsp.h tcs_utils.h \ 40 | tddl.h threads.h trousers_types.h tsp_audit.h \ 41 | tsp_delegate.h tsplog.h tspps.h tsp_seal.h \ 42 | linux/tpm.h 43 | 44 | -------------------------------------------------------------------------------- /src/tspi/gtk/callbacks.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _CALLBACKS_H_ 12 | #define _CALLBACKS_H_ 13 | 14 | #include 15 | 16 | #include "interface.h" 17 | 18 | /* Callbacks for the simple text imput dialog */ 19 | 20 | void 21 | on_dialog1_close (GtkDialog *dialog, 22 | struct userdata *user_data); 23 | 24 | void 25 | on_cancelbutton1_clicked (GtkButton *button, 26 | struct userdata *user_data); 27 | 28 | void 29 | on_okbutton1_clicked (GtkButton *button, 30 | struct userdata *user_data); 31 | 32 | gboolean 33 | enter_event (GtkWidget *widget, 34 | struct userdata *user_data); 35 | 36 | void 37 | on_inputdialog1_destroy (GtkObject *object, 38 | struct userdata *user_data); 39 | 40 | /* Callbacks for the new password dialog */ 41 | 42 | void 43 | on_entryPassword_activate (GtkEntry *entry, 44 | struct userdata *user_data); 45 | 46 | void 47 | on_entryConfirm_activate (GtkEntry *entry, 48 | struct userdata *user_data); 49 | 50 | void 51 | on_cancelbutton2_clicked (GtkButton *button, 52 | struct userdata *user_data); 53 | 54 | void 55 | on_okbutton2_clicked (GtkButton *button, 56 | struct userdata *user_data); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/include/tss/tddl_error.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | TPM Device Driver Library error return codes 4 | 5 | --*/ 6 | 7 | #ifndef __TDDL_ERROR_H__ 8 | #define __TDDL_ERROR_H__ 9 | 10 | #include 11 | #include 12 | 13 | 14 | #ifndef TSS_E_BASE 15 | #define TSS_E_BASE 0x00000000L 16 | #endif // TSS_E_BASE 17 | 18 | 19 | // 20 | // specific error codes returned by the TPM device driver library 21 | // offset TSS_TDDL_OFFSET 22 | // 23 | #define TDDL_E_FAIL TSS_E_FAIL 24 | #define TDDL_E_TIMEOUT TSS_E_TIMEOUT 25 | 26 | // The connection was already established. 27 | #define TDDL_E_ALREADY_OPENED (UINT32)(TSS_E_BASE + 0x081L) 28 | 29 | // The device was not connected. 30 | #define TDDL_E_ALREADY_CLOSED (UINT32)(TSS_E_BASE + 0x082L) 31 | 32 | // The receive buffer is too small. 33 | #define TDDL_E_INSUFFICIENT_BUFFER (UINT32)(TSS_E_BASE + 0x083L) 34 | 35 | // The command has already completed. 36 | #define TDDL_E_COMMAND_COMPLETED (UINT32)(TSS_E_BASE + 0x084L) 37 | 38 | // TPM aborted processing of command. 39 | #define TDDL_E_COMMAND_ABORTED (UINT32)(TSS_E_BASE + 0x085L) 40 | 41 | // The request could not be performed because of an I/O device error. 42 | #define TDDL_E_IOERROR (UINT32)(TSS_E_BASE + 0x087L) 43 | 44 | // Unsupported TAG is requested 45 | #define TDDL_E_BADTAG (UINT32)(TSS_E_BASE + 0x088L) 46 | 47 | // the requested TPM component was not found 48 | #define TDDL_E_COMPONENT_NOT_FOUND (UINT32)(TSS_E_BASE + 0x089L) 49 | 50 | #endif // __TDDL_ERROR_H__ 51 | 52 | -------------------------------------------------------------------------------- /src/include/obj_daa.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_DAA_H_ 12 | #define _OBJ_DAA_H_ 13 | 14 | #ifdef TSS_BUILD_DAA 15 | 16 | /* structures */ 17 | struct tr_daa_obj { 18 | UINT32 session_handle; // set by [join|sign] stage 0. 19 | TPM_HANDLE tpm_handle; 20 | }; 21 | 22 | /* obj_daa.c */ 23 | void daa_free(void *data); 24 | TSS_RESULT obj_daa_add(TSS_HCONTEXT tspContext, TSS_HOBJECT *phObject); 25 | TSS_RESULT obj_daa_remove(TSS_HOBJECT, TSS_HCONTEXT); 26 | TSS_BOOL obj_is_daa(TSS_HOBJECT); 27 | TSS_RESULT obj_daa_get_tsp_context(TSS_HDAA, TSS_HCONTEXT *); 28 | TSS_RESULT obj_daa_get_handle_tpm(TSS_HDAA, TPM_HANDLE *); 29 | TSS_RESULT obj_daa_set_handle_tpm(TSS_HDAA, TPM_HANDLE); 30 | TSS_RESULT obj_daa_get_session_handle(TSS_HDAA, UINT32 *); 31 | TSS_RESULT obj_daa_set_session_handle(TSS_HDAA, UINT32); 32 | 33 | #define DAA_LIST_DECLARE struct obj_list daa_list 34 | #define DAA_LIST_DECLARE_EXTERN extern struct obj_list daa_list 35 | #define DAA_LIST_INIT() list_init(&daa_list) 36 | #define DAA_LIST_CONNECT(a,b) obj_connectContext_list(&daa_list, a, b) 37 | #define DAA_LIST_CLOSE(a) obj_list_close(&daa_list, &daa_free, a) 38 | 39 | #else 40 | 41 | #define obj_is_daa(a) FALSE 42 | 43 | #define DAA_LIST_DECLARE 44 | #define DAA_LIST_DECLARE_EXTERN 45 | #define DAA_LIST_INIT() 46 | #define DAA_LIST_CONNECT(a,b) 47 | #define DAA_LIST_CLOSE(a) 48 | 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/include/obj_hash.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_HASH_H_ 12 | #define _OBJ_HASH_H_ 13 | 14 | #ifdef TSS_BUILD_HASH_LIST 15 | 16 | /* structures */ 17 | struct tr_hash_obj { 18 | UINT32 type; 19 | BYTE *hashData; 20 | UINT32 hashSize; 21 | UINT32 hashUpdateSize; 22 | BYTE *hashUpdateBuffer; 23 | }; 24 | 25 | /* obj_hash.c */ 26 | void __tspi_hash_free(void *data); 27 | TSS_RESULT obj_hash_add(TSS_HCONTEXT, UINT32, TSS_HOBJECT *); 28 | TSS_BOOL obj_is_hash(TSS_HOBJECT); 29 | TSS_RESULT obj_hash_remove(TSS_HOBJECT, TSS_HCONTEXT); 30 | TSS_RESULT obj_hash_get_tsp_context(TSS_HHASH, TSS_HCONTEXT *); 31 | TSS_RESULT obj_hash_set_value(TSS_HHASH, UINT32, BYTE *); 32 | TSS_RESULT obj_hash_get_value(TSS_HHASH, UINT32 *, BYTE **); 33 | TSS_RESULT obj_hash_update_value(TSS_HHASH, UINT32, BYTE *); 34 | 35 | #define HASH_LIST_DECLARE struct obj_list hash_list 36 | #define HASH_LIST_DECLARE_EXTERN extern struct obj_list hash_list 37 | #define HASH_LIST_INIT() list_init(&hash_list) 38 | #define HASH_LIST_CONNECT(a,b) obj_connectContext_list(&hash_list, a, b) 39 | #define HASH_LIST_CLOSE(a) obj_list_close(&hash_list, &__tspi_hash_free, a) 40 | 41 | #else 42 | 43 | #define obj_is_hash(a) FALSE 44 | 45 | #define HASH_LIST_DECLARE 46 | #define HASH_LIST_DECLARE_EXTERN 47 | #define HASH_LIST_INIT() 48 | #define HASH_LIST_CONNECT(a,b) 49 | #define HASH_LIST_CLOSE(a) 50 | 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/tspi/tspi_hash.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "spi_utils.h" 20 | #include "capabilities.h" 21 | #include "tsplog.h" 22 | #include "obj.h" 23 | 24 | 25 | TSS_RESULT 26 | Tspi_Hash_SetHashValue(TSS_HHASH hHash, /* in */ 27 | UINT32 ulHashValueLength, /* in */ 28 | BYTE * rgbHashValue) /* in */ 29 | { 30 | if (ulHashValueLength == 0 || rgbHashValue == NULL) 31 | return TSPERR(TSS_E_BAD_PARAMETER); 32 | 33 | return obj_hash_set_value(hHash, ulHashValueLength, rgbHashValue); 34 | } 35 | 36 | TSS_RESULT 37 | Tspi_Hash_GetHashValue(TSS_HHASH hHash, /* in */ 38 | UINT32 * pulHashValueLength, /* out */ 39 | BYTE ** prgbHashValue) /* out */ 40 | { 41 | if (pulHashValueLength == NULL || prgbHashValue == NULL) 42 | return TSPERR(TSS_E_BAD_PARAMETER); 43 | 44 | return obj_hash_get_value(hHash, pulHashValueLength, prgbHashValue); 45 | } 46 | 47 | TSS_RESULT 48 | Tspi_Hash_UpdateHashValue(TSS_HHASH hHash, /* in */ 49 | UINT32 ulDataLength, /* in */ 50 | BYTE *rgbData) /* in */ 51 | { 52 | if (rgbData == NULL && ulDataLength != 0) 53 | return TSPERR(TSS_E_BAD_PARAMETER); 54 | 55 | if (ulDataLength == 0) 56 | return TSS_SUCCESS; 57 | 58 | return obj_hash_update_value(hHash, ulDataLength, rgbData); 59 | } 60 | -------------------------------------------------------------------------------- /src/tspi/tspi_pcr_comp.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "trousers_types.h" 17 | #include "spi_utils.h" 18 | #include "capabilities.h" 19 | #include "tsplog.h" 20 | #include "obj.h" 21 | 22 | TSS_RESULT 23 | Tspi_PcrComposite_SetPcrValue(TSS_HPCRS hPcrComposite, /* in */ 24 | UINT32 ulPcrIndex, /* in */ 25 | UINT32 ulPcrValueLength, /* in */ 26 | BYTE * rgbPcrValue) /* in */ 27 | { 28 | if (ulPcrValueLength == 0 || rgbPcrValue == NULL) 29 | return TSPERR(TSS_E_BAD_PARAMETER); 30 | 31 | if (ulPcrValueLength != TCPA_SHA1_160_HASH_LEN) 32 | return TSPERR(TSS_E_BAD_PARAMETER); 33 | 34 | return obj_pcrs_set_value(hPcrComposite, ulPcrIndex, ulPcrValueLength, rgbPcrValue); 35 | } 36 | 37 | TSS_RESULT 38 | Tspi_PcrComposite_GetPcrValue(TSS_HPCRS hPcrComposite, /* in */ 39 | UINT32 ulPcrIndex, /* in */ 40 | UINT32 * pulPcrValueLength, /* out */ 41 | BYTE ** prgbPcrValue) /* out */ 42 | { 43 | if (pulPcrValueLength == NULL || prgbPcrValue == NULL) 44 | return TSPERR(TSS_E_BAD_PARAMETER); 45 | 46 | return obj_pcrs_get_value(hPcrComposite, ulPcrIndex, pulPcrValueLength, 47 | prgbPcrValue); 48 | 49 | } 50 | 51 | TSS_RESULT 52 | Tspi_PcrComposite_SelectPcrIndex(TSS_HPCRS hPcrComposite, /* in */ 53 | UINT32 ulPcrIndex) /* in */ 54 | { 55 | return obj_pcrs_select_index(hPcrComposite, ulPcrIndex); 56 | } 57 | -------------------------------------------------------------------------------- /src/tspi/daa/daa_verifier/verifier.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "bi.h" 17 | #include "daa_parameter.h" 18 | #include "trousers/tss.h" 19 | #include "spi_internal_types.h" 20 | #include "spi_utils.h" 21 | #include 22 | #include 23 | #include "tsplog.h" 24 | #include "tss/tcs.h" 25 | #include "platform.h" 26 | 27 | #include "verifier.h" 28 | 29 | TSPICALL Tspi_DAA_VerifyInit_internal 30 | ( 31 | TSS_HDAA hDAA, // in 32 | UINT32* nonceVerifierLength, // out 33 | BYTE** nonceVerifier, // out 34 | UINT32 baseNameLength, // out 35 | BYTE ** baseName // out 36 | ) { 37 | TSS_RESULT result = TSS_SUCCESS; 38 | TCS_CONTEXT_HANDLE tcsContext; 39 | bi_ptr nounce = NULL; 40 | 41 | //TODO how to setup the baseName & baseNameLength 42 | if( (result = obj_daa_get_tsp_context( hDAA, &tcsContext)) != TSS_SUCCESS) 43 | goto close; 44 | *nonceVerifierLength = DAA_PARAM_LENGTH_MESSAGE_DIGEST; 45 | *nonceVerifier = calloc_tspi( tcsContext, DAA_PARAM_LENGTH_MESSAGE_DIGEST); 46 | if (*nonceVerifier == NULL) { 47 | LogError("malloc of %d bytes failed", DAA_PARAM_LENGTH_MESSAGE_DIGEST); 48 | result = TSPERR(TSS_E_OUTOFMEMORY); 49 | goto close; 50 | } 51 | nounce = bi_new_ptr(); 52 | bi_urandom( nounce, DAA_PARAM_LENGTH_MESSAGE_DIGEST * 8); 53 | bi_2_byte_array( *nonceVerifier, DAA_PARAM_LENGTH_MESSAGE_DIGEST, nounce); 54 | close: 55 | FREE_BI( nounce); 56 | return result; 57 | } 58 | -------------------------------------------------------------------------------- /dist/fedora/trousers.te: -------------------------------------------------------------------------------- 1 | type tcsd_device_t, device_type, dev_fs; 2 | type tcsd_readwrite_t, file_type; 3 | type tcsd_config_t, file_type, sysadmfile; 4 | daemon_domain(tcsd, `') 5 | general_domain_access(tcsd_t) 6 | allow unconfined_t tcsd_t:process transition; 7 | type_transition unconfined_t tcsd_exec_t:process tcsd_t; 8 | allow tcsd_t tcsd_exec_t:dir r_dir_perms; 9 | allow tcsd_t etc_t:file { read getattr lock ioctl }; 10 | allow tcsd_t etc_t:lnk_file { read getattr }; 11 | allow tcsd_t devtty_t:chr_file { ioctl read getattr lock write append }; 12 | allow tcsd_t devpts_t:chr_file { ioctl read getattr lock write append }; 13 | can_network(tcsd_t) 14 | read_sysctl(tcsd_t, full) 15 | r_dir_file(tcsd_t, usr_t) 16 | r_dir_file(tcsd_t, tcsd_config_t) 17 | rw_dir_file(tcsd_t, tcsd_readwrite_t) 18 | allow tcsd_t tcsd_readwrite_t:file { setattr }; 19 | allow tcsd_t tcsd_readwrite_t:dir { setattr }; 20 | allow tcsd_t tcsd_device_t:chr_file { ioctl read getattr lock write append }; 21 | allow tcsd_t { random_device_t }:chr_file { read getattr }; 22 | allow tcsd_t lib_t:dir r_dir_perms; 23 | allow tcsd_t lib_t:file { rx_file_perms execmod }; 24 | allow tcsd_t lib_t:lnk_file r_file_perms; 25 | allow tcsd_t lib_t:file { rx_file_perms execmod }; 26 | allow tcsd_t lib_t:lnk_file r_file_perms; 27 | allow tcsd_t lib_t:file { rx_file_perms execmod }; 28 | allow tcsd_t lib_t:lnk_file r_file_perms; 29 | allow tcsd_t var_lib_t:dir r_dir_perms; 30 | allow tcsd_t var_lib_t:file { rx_file_perms execmod }; 31 | allow tcsd_t var_lib_t:lnk_file r_file_perms; 32 | allow tcsd_t port_type:tcp_socket { send_msg recv_msg name_bind }; 33 | allow tcsd_t self:capability { chown net_bind_service dac_override fowner fsetid }; 34 | -------------------------------------------------------------------------------- /src/include/daa/anonymity_revocation.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | #ifndef ANONYMITY_REVOCATION_H_ 12 | #define ANONYMITY_REVOCATION_H_ 13 | 14 | #include "bi.h" 15 | #include "daa_structs.h" 16 | 17 | /** 18 | * Cramer Shoup public key (CSPublicKey.java) 19 | */ 20 | typedef struct tdCS_PUBLIC_KEY { 21 | bi_ptr eta; 22 | bi_ptr lambda1; 23 | bi_ptr lambda2; 24 | bi_ptr lambda3; 25 | } CS_PUBLIC_KEY; 26 | 27 | typedef struct tdCS_ENCRYPTION_RESULT { 28 | bi_ptr c1; 29 | bi_ptr c2; 30 | bi_ptr c3; 31 | bi_ptr c4; 32 | } CS_ENCRYPTION_RESULT; 33 | 34 | CS_ENCRYPTION_RESULT *create_CS_ENCRYPTION_RESULT( bi_ptr c1, bi_ptr c2, bi_ptr c3, bi_ptr c4); 35 | 36 | /* 37 | * Cramer-Shoup Encryption Result including randomness. 38 | * 39 | * from com.ibm.zurich.tcg.daa.anonymityrevocationCSEncryptionResultRandomness 40 | */ 41 | typedef struct tdCS_ENCRYPTION_RESULT_RANDOMNESS { 42 | bi_ptr randomness; 43 | CS_ENCRYPTION_RESULT *result; 44 | } CS_ENCRYPTION_RESULT_RANDOMNESS; 45 | 46 | /* 47 | * Cramer-Shoup EncryptionProof 48 | * from com.ibm.zurich.tcg.daa.anonymityrevocation.CSEncryptionProof 49 | */ 50 | CS_ENCRYPTION_RESULT_RANDOMNESS *compute_ecryption_proof( 51 | const bi_ptr msg, 52 | const bi_ptr delta1, 53 | const bi_ptr delta2, 54 | const bi_ptr delta3, 55 | const bi_ptr randomness, 56 | const CS_PUBLIC_KEY *key, 57 | const struct tdTSS_DAA_PK_internal *daa_key, 58 | const BYTE *condition, 59 | const int conditionLength, 60 | const EVP_MD *messageDigest); 61 | 62 | #endif /*ANONYMITY_REVOCATION_H_*/ 63 | -------------------------------------------------------------------------------- /src/include/tsplog.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #ifndef _TSPLOG_H_ 13 | #define _TSPLOG_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | /* Debug logging */ 20 | #ifdef TSS_DEBUG 21 | /* log to stdout */ 22 | #define LogMessage(dest, priority, layer, fmt, ...) \ 23 | do { \ 24 | if (getenv("TSS_DEBUG_OFF") == NULL) { \ 25 | fprintf(dest, "%s %s %s:%d " fmt "\n", priority, layer, __FILE__, __LINE__, ## __VA_ARGS__); \ 26 | } \ 27 | } while (0) 28 | 29 | #define LogDebug(fmt, ...) LogMessage(stdout, "LOG_DEBUG", APPID, fmt, ##__VA_ARGS__) 30 | #define LogDebugFn(fmt, ...) LogMessage(stdout, "LOG_DEBUG", APPID, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__) 31 | #define LogDebugData(sz,blb) LogBlobData(APPID, sz, blb) 32 | 33 | /* Error logging */ 34 | #define LogError(fmt, ...) LogMessage(stderr, "LOG_ERR", APPID, "ERROR: " fmt, ##__VA_ARGS__) 35 | /* Warn logging */ 36 | #define LogWarn(fmt, ...) LogMessage(stdout, "LOG_WARNING", APPID, "WARNING: " fmt, ##__VA_ARGS__) 37 | /* Info Logging */ 38 | #define LogInfo(fmt, ...) LogMessage(stdout, "LOG_INFO", APPID, fmt, ##__VA_ARGS__) 39 | /* Return Value logging */ 40 | extern TSS_RESULT LogTSPERR(TSS_RESULT, char *, int); 41 | #else 42 | #define LogDebug(fmt, ...) 43 | #define LogDebugFn(fmt, ...) 44 | #define LogDebugData(sz,blb) 45 | #define LogError(fmt, ...) 46 | #define LogWarn(fmt, ...) 47 | #define LogInfo(fmt, ...) 48 | #endif 49 | 50 | void LogBlobData(char *appid, unsigned long sizeOfBlob, unsigned char *blob); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/include/authsess.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #ifndef _AUTHSESS_H_ 12 | #define _AUTHSESS_H_ 13 | 14 | struct authsess { 15 | TPM_AUTH *pAuth; 16 | TPM_AUTH auth; 17 | 18 | /* XOR masks created before each use of an OSAP session */ 19 | TPM_ENCAUTH encAuthUse; 20 | TPM_ENCAUTH encAuthMig; 21 | 22 | TSS_HCONTEXT tspContext; 23 | TPM_COMMAND_CODE command; 24 | 25 | TSS_HOBJECT obj_parent; 26 | TSS_HPOLICY hUsageParent; 27 | UINT32 parentMode; 28 | TPM_SECRET parentSecret; 29 | TSS_CALLBACK cb_xor, cb_hmac, cb_sealx; 30 | 31 | TPM_ENTITY_TYPE entity_type; 32 | UINT32 entityValueSize; 33 | BYTE *entityValue; 34 | 35 | TSS_HOBJECT obj_child; 36 | TSS_HPOLICY hUsageChild, hMigChild; 37 | UINT32 uMode, mMode; 38 | 39 | /* Created during OSAP or DSAP protocol initiation */ 40 | TPM_NONCE nonceOddxSAP; 41 | TPM_NONCE nonceEvenxSAP; 42 | TPM_HMAC sharedSecret; 43 | 44 | //MUTEX_DECLARE(lock); 45 | //struct authsess *next; 46 | }; 47 | 48 | TSS_RESULT authsess_oiap_get(TSS_HOBJECT, TPM_COMMAND_CODE, TPM_DIGEST *, TPM_AUTH *); 49 | TSS_RESULT authsess_oiap_put(TPM_AUTH *, TPM_DIGEST *); 50 | 51 | TSS_RESULT authsess_xsap_init(TSS_HCONTEXT, TSS_HOBJECT, TSS_HOBJECT, TSS_BOOL, TPM_COMMAND_CODE, TPM_ENTITY_TYPE, struct authsess **); 52 | TSS_RESULT authsess_xsap_hmac(struct authsess *, TPM_DIGEST *); 53 | TSS_RESULT authsess_xsap_verify(struct authsess *, TPM_DIGEST *); 54 | void authsess_free(struct authsess *); 55 | 56 | #define TSS_AUTH_POLICY_REQUIRED TRUE 57 | #define TSS_AUTH_POLICY_NOT_REQUIRED FALSE 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/include/threads.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | #ifndef __THREADS_H__ 12 | #define __THREADS_H__ 13 | 14 | #ifdef HAVE_PTHREAD_H 15 | 16 | #include 17 | 18 | /* mutex abstractions */ 19 | #define MUTEX_INIT(m) pthread_mutex_init(&m, NULL) 20 | #define MUTEX_LOCK(m) pthread_mutex_lock(&m) 21 | #define MUTEX_UNLOCK(m) pthread_mutex_unlock(&m) 22 | #define MUTEX_DECLARE(m) pthread_mutex_t m 23 | #define MUTEX_DECLARE_INIT(m) pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER 24 | #define MUTEX_DECLARE_EXTERN(m) extern pthread_mutex_t m 25 | 26 | /* condition variable abstractions */ 27 | #define COND_DECLARE(c) pthread_cond_t c 28 | #define COND_INIT(c) pthread_cond_init(&c, NULL) 29 | #define COND_VAR pthread_cond_t 30 | #define COND_WAIT(c,m) pthread_cond_wait(c,m) 31 | #define COND_SIGNAL(c) pthread_cond_signal(c) 32 | 33 | /* thread abstractions */ 34 | #define THREAD_ID ((THREAD_TYPE)pthread_self()) 35 | #define THREAD_TYPE pthread_t 36 | #define THREAD_JOIN pthread_join 37 | #define THREAD_DETACH pthread_detach 38 | #define THREAD_ATTR_DECLARE(a) pthread_attr_t a 39 | #define THREAD_ATTR_INIT(a) pthread_attr_init(&a) 40 | #define THREAD_ATTR_SETJOINABLE(a) pthread_attr_setdetachstate(&a, PTHREAD_CREATE_JOINABLE) 41 | #define THREAD_EXIT pthread_exit 42 | #define THREAD_CREATE(a,b,c,d) pthread_create(a,b,c,d) 43 | #define THREAD_SET_SIGNAL_MASK pthread_sigmask 44 | #define THREAD_NULL (THREAD_TYPE *)0 45 | 46 | #else 47 | 48 | #error No threading library defined! (Cannot find pthread.h) 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/include/obj_daacred.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_DAACRED_H_ 12 | #define _OBJ_DAACRED_H_ 13 | 14 | #ifdef TSS_BUILD_DAA 15 | 16 | /* structures */ 17 | struct tr_daacred_obj { 18 | UINT32 session_handle; // set by [join|sign] stage 0. 19 | TPM_HANDLE tpm_handle; 20 | }; 21 | 22 | /* prototypes */ 23 | void daacred_free(void *data); 24 | TSS_RESULT obj_daacred_add(TSS_HCONTEXT tspContext, TSS_HOBJECT *phObject); 25 | TSS_RESULT obj_daacred_remove(TSS_HDAA_CREDENTIAL, TSS_HCONTEXT); 26 | TSS_BOOL obj_is_daacred(TSS_HDAA_CREDENTIAL); 27 | TSS_RESULT obj_daacred_get_tsp_context(TSS_HDAA_CREDENTIAL, TSS_HCONTEXT *); 28 | TSS_RESULT obj_daacred_get_handle_tpm(TSS_HDAA_CREDENTIAL, TPM_HANDLE *); 29 | TSS_RESULT obj_daacred_set_handle_tpm(TSS_HDAA_CREDENTIAL, TPM_HANDLE); 30 | TSS_RESULT obj_daacred_get_session_handle(TSS_HDAA_CREDENTIAL, UINT32 *); 31 | TSS_RESULT obj_daacred_set_session_handle(TSS_HDAA_CREDENTIAL, UINT32); 32 | 33 | #define DAACRED_LIST_DECLARE struct obj_list daacred_list 34 | #define DAACRED_LIST_DECLARE_EXTERN extern struct obj_list daacred_list 35 | #define DAACRED_LIST_INIT() list_init(&daacred_list) 36 | #define DAACRED_LIST_CONNECT(a,b) obj_connectContext_list(&daacred_list, a, b) 37 | #define DAACRED_LIST_CLOSE(a) obj_list_close(&daacred_list, &daacred_free, a) 38 | 39 | #else 40 | 41 | #define obj_is_daacred(a) FALSE 42 | 43 | #define DAACRED_LIST_DECLARE 44 | #define DAACRED_LIST_DECLARE_EXTERN 45 | #define DAACRED_LIST_INIT() 46 | #define DAACRED_LIST_CONNECT(a,b) 47 | #define DAACRED_LIST_CLOSE(a) 48 | 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/include/tcsem.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #ifndef _TCSEM_H_ 12 | #define _TCSEM_H_ 13 | 14 | struct ext_log_source { 15 | int (*open)(void *, FILE **); 16 | TSS_RESULT (*get_entries_by_pcr)(FILE *, UINT32, UINT32, UINT32 *, TSS_PCR_EVENT **); 17 | TSS_RESULT (*get_entry)(FILE *, UINT32, UINT32 *, TSS_PCR_EVENT **); 18 | int (*close)(FILE *); 19 | }; 20 | 21 | struct event_wrapper { 22 | TSS_PCR_EVENT event; 23 | struct event_wrapper *next; 24 | }; 25 | 26 | struct event_log { 27 | MUTEX_DECLARE(lock); 28 | struct ext_log_source *firmware_source; 29 | struct ext_log_source *kernel_source; 30 | struct event_wrapper **lists; 31 | }; 32 | 33 | /* include the compiled-in log sources and struct references here */ 34 | #include "imaem.h" 35 | #include "biosem.h" 36 | 37 | #ifdef EVLOG_SOURCE_IMA 38 | #define EVLOG_IMA_SOURCE &ima_source 39 | #else 40 | #define EVLOG_IMA_SOURCE NULL 41 | #endif 42 | 43 | #ifdef EVLOG_SOURCE_BIOS 44 | #define EVLOG_BIOS_SOURCE &bios_source 45 | #else 46 | #define EVLOG_BIOS_SOURCE NULL 47 | #endif 48 | 49 | 50 | TSS_RESULT event_log_init(); 51 | TSS_RESULT event_log_final(); 52 | TSS_RESULT copy_pcr_event(TSS_PCR_EVENT *, TSS_PCR_EVENT *); 53 | TSS_RESULT event_log_add(TSS_PCR_EVENT *, UINT32 *); 54 | TSS_PCR_EVENT *get_pcr_event(UINT32, UINT32); 55 | UINT32 get_num_events(UINT32); 56 | TSS_PCR_EVENT *concat_pcr_events(TSS_PCR_EVENT **, UINT32, TSS_PCR_EVENT *, UINT32); 57 | UINT32 get_pcr_event_size(TSS_PCR_EVENT *); 58 | void free_external_events(UINT32, TSS_PCR_EVENT *); 59 | 60 | extern struct event_log *tcs_event_log; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/include/obj_daaarakey.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_DAAARAKEY_H_ 12 | #define _OBJ_DAAARAKEY_H_ 13 | 14 | #ifdef TSS_BUILD_DAA 15 | 16 | /* structures */ 17 | struct tr_daaarakey_obj { 18 | UINT32 session_handle; 19 | TPM_HANDLE tpm_handle; 20 | }; 21 | 22 | /* prototypes */ 23 | void daaarakey_free(void *data); 24 | TSS_RESULT obj_daaarakey_add(TSS_HCONTEXT tspContext, TSS_HOBJECT *phObject); 25 | TSS_RESULT obj_daaarakey_remove(TSS_HDAA_ISSUER_KEY, TSS_HCONTEXT); 26 | TSS_BOOL obj_is_daaarakey(TSS_HDAA_ISSUER_KEY); 27 | TSS_RESULT obj_daaarakey_get_tsp_context(TSS_HDAA_ISSUER_KEY, TSS_HCONTEXT *); 28 | TSS_RESULT obj_daaarakey_get_handle_tpm(TSS_HDAA_ISSUER_KEY, TPM_HANDLE *); 29 | TSS_RESULT obj_daaarakey_set_handle_tpm(TSS_HDAA_ISSUER_KEY, TPM_HANDLE); 30 | TSS_RESULT obj_daaarakey_get_session_handle(TSS_HDAA_ISSUER_KEY, UINT32 *); 31 | TSS_RESULT obj_daaarakey_set_session_handle(TSS_HDAA_ISSUER_KEY, UINT32); 32 | 33 | #define DAAARAKEY_LIST_DECLARE struct obj_list daaarakey_list 34 | #define DAAARAKEY_LIST_DECLARE_EXTERN extern struct obj_list daaarakey_list 35 | #define DAAARAKEY_LIST_INIT() list_init(&daaarakey_list) 36 | #define DAAARAKEY_LIST_CONNECT(a,b) obj_connectContext_list(&daaarakey_list, a, b) 37 | #define DAAARAKEY_LIST_CLOSE(a) obj_list_close(&daaarakey_list, &daaarakey_free, a) 38 | 39 | #else 40 | 41 | #define obj_is_daaarakey(a) FALSE 42 | 43 | #define DAAARAKEY_LIST_DECLARE 44 | #define DAAARAKEY_LIST_DECLARE_EXTERN 45 | #define DAAARAKEY_LIST_INIT() 46 | #define DAAARAKEY_LIST_CONNECT(a,b) 47 | #define DAAARAKEY_LIST_CLOSE(a) 48 | 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/include/tss/tddlapi_error.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | TDDL error return codes for the TPM Device Driver Library Interface (TDDLI) 4 | 5 | --*/ 6 | 7 | #ifndef __TDDLAPI_ERROR_H__ 8 | #define __TDDLAPI_ERROR_H__ 9 | 10 | 11 | // 12 | // error coding scheme for a Microsoft Windows platform - 13 | // refer to the TSS Specification Parts 14 | // 15 | // Values are 32 bit values layed out as follows: 16 | // 17 | // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 18 | // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 19 | // +---+-+-+-----------------------+-------+-----------------------+ 20 | // |Lev|C|R| Facility | Layer | Code | 21 | // +---+-+-+-----------------------+-------+-----------------------+ 22 | // | Platform specific coding | TSS error coding system | 23 | // +---+-+-+-----------------------+-------+-----------------------+ 24 | // 25 | // Lev - is the Level code 26 | // 27 | // 00 - Success 28 | // 01 - Informational 29 | // 10 - Warning 30 | // 11 - Error 31 | // 32 | // C - is the Customer code flag (must actually be set) 33 | // 34 | // R - is a reserved bit (unused) 35 | // 36 | // Facility - is the facility code: TCPA: proposal 0x028 37 | // 38 | // Code - is the facility's status code 39 | // 40 | 41 | 42 | // no macros are used below intentionally 43 | // for a better error code recognition by the reader 44 | 45 | // note that the values of TPM_E_BASE and TSS_E_BASE, TSS_W_BASE and TSS_I_BASE 46 | // have to be adjusted for a platform other than Windows 47 | 48 | // 49 | // TPM specific error codes (layer nibble set to TPM layer TSS_LAYER_TPM) 50 | // 51 | 52 | 53 | #endif // __TDDLAPI_ERROR_H__ 54 | 55 | -------------------------------------------------------------------------------- /src/tspi/daa/utils/list.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "tsplog.h" 16 | 17 | list_ptr list_new( void) { 18 | list_ptr list = (list_ptr)malloc( sizeof( list_struct)); 19 | 20 | if( list == NULL) return NULL; 21 | list->head = NULL; 22 | return list; 23 | } 24 | 25 | void list_add(list_ptr list, void *obj) { 26 | list->current = (node_t *) malloc (sizeof(struct _list_t)); 27 | if (list->current == NULL) { 28 | LogError("[list_add] malloc of %d bytes failed", sizeof(struct _list_t)); 29 | return; 30 | } 31 | if( list->head == NULL) { 32 | list->head = list->current; 33 | } else 34 | list->previous->next = list->current; 35 | list->current->obj = obj; 36 | list->current->next = NULL; 37 | list->previous = list->current; 38 | } 39 | 40 | void list_dump(list_ptr list) { 41 | node_t *current; 42 | 43 | if( list->head == NULL) // if head has not been altered 44 | puts("no data"); // list is empty 45 | else { 46 | current = list->head; // go to first node 47 | do { 48 | printf("%d\n", (int)current->obj); // print value at current node 49 | current = current->next; // traverse through the list 50 | } while(current != NULL); // until current node is NULL 51 | } 52 | } 53 | 54 | void list_freeall(list_ptr list) { 55 | node_t *current = list->head; // go to first node 56 | node_t *next; 57 | 58 | if( list->head != NULL) { 59 | current = list->head; // go to first node 60 | do { 61 | next = current->next; 62 | free(current); 63 | current = next; 64 | } while(current != NULL); // until current node is NULL 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/tcs/tcs_req_mgr.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "trousers/tss.h" 21 | #include "tcs_tsp.h" 22 | #include "tcs_utils.h" 23 | #include "tddl.h" 24 | #include "req_mgr.h" 25 | #include "tcslog.h" 26 | 27 | static struct tpm_req_mgr *trm; 28 | 29 | #ifdef TSS_DEBUG 30 | #define TSS_TPM_DEBUG 31 | #endif 32 | 33 | TSS_RESULT 34 | req_mgr_submit_req(BYTE *blob) 35 | { 36 | TSS_RESULT result; 37 | BYTE loc_buf[TSS_TPM_TXBLOB_SIZE]; 38 | UINT32 size = TSS_TPM_TXBLOB_SIZE; 39 | UINT32 retry = TSS_REQ_MGR_MAX_RETRIES; 40 | 41 | MUTEX_LOCK(trm->queue_lock); 42 | 43 | #ifdef TSS_TPM_DEBUG 44 | LogBlobData("To TPM:", Decode_UINT32(&blob[2]), blob); 45 | #endif 46 | 47 | do { 48 | result = Tddli_TransmitData(blob, Decode_UINT32(&blob[2]), loc_buf, &size); 49 | } while (!result && (Decode_UINT32(&loc_buf[6]) == TCPA_E_RETRY) && --retry); 50 | 51 | if (!result) 52 | memcpy(blob, loc_buf, Decode_UINT32(&loc_buf[2])); 53 | 54 | #ifdef TSS_TPM_DEBUG 55 | LogBlobData("From TPM:", size, loc_buf); 56 | #endif 57 | 58 | MUTEX_UNLOCK(trm->queue_lock); 59 | 60 | return result; 61 | } 62 | 63 | TSS_RESULT 64 | req_mgr_init() 65 | { 66 | if ((trm = calloc(1, sizeof(struct tpm_req_mgr))) == NULL) { 67 | LogError("malloc of %zd bytes failed.", sizeof(struct tpm_req_mgr)); 68 | return TSS_E_OUTOFMEMORY; 69 | } 70 | 71 | MUTEX_INIT(trm->queue_lock); 72 | 73 | return Tddli_Open(); 74 | } 75 | 76 | TSS_RESULT 77 | req_mgr_final() 78 | { 79 | free(trm); 80 | 81 | return Tddli_Close(); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/include/obj_daaissuerkey.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_DAAISSUERKEY_H_ 12 | #define _OBJ_DAAISSUERKEY_H_ 13 | 14 | #ifdef TSS_BUILD_DAA 15 | 16 | /* structures */ 17 | struct tr_daaissuerkey_obj { 18 | UINT32 session_handle; 19 | TPM_HANDLE tpm_handle; 20 | }; 21 | 22 | /* prototypes */ 23 | void daaissuerkey_free(void *data); 24 | TSS_RESULT obj_daaissuerkey_add(TSS_HCONTEXT tspContext, TSS_HOBJECT *phObject); 25 | TSS_RESULT obj_daaissuerkey_remove(TSS_HDAA_ISSUER_KEY, TSS_HCONTEXT); 26 | TSS_BOOL obj_is_daaissuerkey(TSS_HDAA_ISSUER_KEY); 27 | TSS_RESULT obj_daaissuerkey_get_tsp_context(TSS_HDAA_ISSUER_KEY, TSS_HCONTEXT *); 28 | TSS_RESULT obj_daaissuerkey_get_handle_tpm(TSS_HDAA_ISSUER_KEY, TPM_HANDLE *); 29 | TSS_RESULT obj_daaissuerkey_set_handle_tpm(TSS_HDAA_ISSUER_KEY, TPM_HANDLE); 30 | TSS_RESULT obj_daaissuerkey_get_session_handle(TSS_HDAA_ISSUER_KEY, UINT32 *); 31 | TSS_RESULT obj_daaissuerkey_set_session_handle(TSS_HDAA_ISSUER_KEY, UINT32); 32 | 33 | #define DAAISSUERKEY_LIST_DECLARE struct obj_list daaissuerkey_list 34 | #define DAAISSUERKEY_LIST_DECLARE_EXTERN extern struct obj_list daaissuerkey_list 35 | #define DAAISSUERKEY_LIST_INIT() list_init(&daaissuerkey_list) 36 | #define DAAISSUERKEY_LIST_CONNECT(a,b) obj_connectContext_list(&daaissuerkey_list, a, b) 37 | #define DAAISSUERKEY_LIST_CLOSE(a) obj_list_close(&daaissuerkey_list, \ 38 | &daaissuerkey_free, a) 39 | 40 | #else 41 | 42 | #define obj_is_daaissuerkey(a) FALSE 43 | 44 | #define DAAISSUERKEY_LIST_DECLARE 45 | #define DAAISSUERKEY_LIST_DECLARE_EXTERN 46 | #define DAAISSUERKEY_LIST_INIT() 47 | #define DAAISSUERKEY_LIST_CONNECT(a,b) 48 | #define DAAISSUERKEY_LIST_CLOSE(a) 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/tspi/daa/daa_debug.h: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************************************** 3 | * KEY PAIR WITH PROOF 4 | ********************************************************************************************/ 5 | 6 | typedef struct tdKEY_PAIR_WITH_PROOF_internal { 7 | TSS_DAA_PK_internal *pk; 8 | DAA_PRIVATE_KEY_internal *private_key; 9 | TSS_DAA_PK_PROOF_internal *proof; 10 | } KEY_PAIR_WITH_PROOF_internal; 11 | 12 | int save_KEY_PAIR_WITH_PROOF( 13 | FILE *file, 14 | KEY_PAIR_WITH_PROOF_internal *key_pair_with_proof 15 | ); 16 | 17 | KEY_PAIR_WITH_PROOF_internal *load_KEY_PAIR_WITH_PROOF( 18 | FILE *file 19 | ); 20 | 21 | TSS_DAA_KEY_PAIR *get_TSS_DAA_KEY_PAIR( 22 | KEY_PAIR_WITH_PROOF_internal *key_pair_with_proof, 23 | void * (*daa_alloc)(size_t size, TSS_HOBJECT object), 24 | TSS_HOBJECT param_alloc 25 | ); 26 | 27 | 28 | int save_DAA_PK_internal( 29 | FILE *file, 30 | const TSS_DAA_PK_internal *pk_internal 31 | ); 32 | 33 | TSS_DAA_PK_internal *load_DAA_PK_internal( 34 | FILE *file 35 | ); 36 | 37 | int save_DAA_PRIVATE_KEY( 38 | FILE *file, 39 | const DAA_PRIVATE_KEY_internal *private_key 40 | ); 41 | 42 | DAA_PRIVATE_KEY_internal *load_DAA_PRIVATE_KEY( 43 | FILE *file 44 | ); 45 | 46 | int save_DAA_PK_PROOF_internal( 47 | FILE *file, 48 | TSS_DAA_PK_PROOF_internal *pk_internal 49 | ); 50 | 51 | TSS_DAA_PK_PROOF_internal *load_DAA_PK_PROOF_internal( 52 | FILE *file 53 | ); 54 | 55 | TSS_DAA_CRED_ISSUER *load_TSS_DAA_CRED_ISSUER( FILE *file); 56 | 57 | int save_TSS_DAA_CRED_ISSUER( FILE *file, TSS_DAA_CRED_ISSUER *credential); 58 | 59 | TSS_DAA_CREDENTIAL *load_TSS_DAA_CREDENTIAL( FILE *file); 60 | 61 | int save_TSS_DAA_CREDENTIAL( 62 | FILE *file, 63 | TSS_DAA_CREDENTIAL *credential 64 | ); 65 | 66 | 67 | -------------------------------------------------------------------------------- /man/man3/Tspi_Context_Create.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2005 International Business Machines Corporation 2 | .\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Context_Create" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_Context_Create \- create a TSP context handle. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_Context_Create(TSS_HCONTEXT* " phContext ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTspi_Context_Create\fR creates a handle to a new context object. The context is then used by other API functions to track resources related to it. 45 | .SH "PARAMETERS" 46 | .PP 47 | .SS phContext 48 | Receives the handle to the created context object. 49 | 50 | .SH "RETURN CODES" 51 | .PP 52 | \fBTspi_Context_Create\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 53 | .TP 54 | .SM TSS_E_INTERNAL_ERROR - An internal error occurred in the TSS. 55 | 56 | .SH "CONFORMING TO" 57 | 58 | .PP 59 | \fBTspi_Context_Create\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 60 | .SH "SEE ALSO" 61 | 62 | .PP 63 | \fBTspi_Context_Close\fR(3), \fBTspi_Context_Connect\fR(3). 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/include/tss/tss_error_basics.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Basic defines for TSS error return codes 4 | 5 | --*/ 6 | 7 | #ifndef __TSS_ERROR_BASICS_H__ 8 | #define __TSS_ERROR_BASICS_H__ 9 | 10 | 11 | // 12 | // definitions for the various TSS-SW layers 13 | // 14 | #ifndef TSS_LAYER_TPM 15 | #define TSS_LAYER_TPM 0x0000L // definition for TPM layer 16 | #endif // TSS_LAYER_TPM 17 | 18 | #define TSS_LAYER_TDDL 0x1000L // definition for TDDL layer 19 | #define TSS_LAYER_TCS 0x2000L // definition for TCS layer 20 | 21 | #ifndef TSS_LAYER_TSP 22 | #define TSS_LAYER_TSP 0x3000L // definition for TSP layer 23 | #endif // TSS_LAYER_TSP 24 | 25 | 26 | // 27 | // definitions for the start points of layer specific error codes 28 | // 29 | #ifndef TSS_COMMON_OFFSET 30 | #define TSS_COMMON_OFFSET 0x000L 31 | #endif // TSS_COMMON_OFFSET 32 | 33 | #define TSS_TDDL_OFFSET 0x080L 34 | #define TSS_TCSI_OFFSET 0x0C0L 35 | 36 | #ifndef TSS_TSPI_OFFSET 37 | #define TSS_TSPI_OFFSET 0x100L 38 | #endif // TSS_TSPI_OFFSET 39 | 40 | #ifndef TSS_VENDOR_OFFSET 41 | #define TSS_VENDOR_OFFSET 0x800L 42 | #endif // TSS_VENDOR_OFFSET 43 | 44 | // do not exceed TSS_MAX_ERROR for vendor specific code values: 45 | #ifndef TSS_MAX_ERROR 46 | #define TSS_MAX_ERROR 0xFFFL 47 | #endif // TSS_MAX_ERROR 48 | 49 | 50 | /* Macros for the construction and interpretation of error codes */ 51 | #define TPM_ERROR(code) (code) 52 | #define TDDL_ERROR(code) ((code) ? (TSS_LAYER_TDDL | (code)) : (code)) 53 | #define TCS_ERROR(code) ((code) ? (TSS_LAYER_TCS | (code)) : (code)) 54 | #define TSP_ERROR(code) ((code) ? (TSS_LAYER_TSP | (code)) : (code)) 55 | #define ERROR_LAYER(error) ((error) & 0xf000) 56 | #define ERROR_CODE(error) ((error) & 0x0fff) 57 | 58 | #endif // __TSS_ERROR_BASICS_H__ 59 | 60 | -------------------------------------------------------------------------------- /man/man3/Tspi_Context_Close.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Context_Close" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_Context_Close \- destroy a TSP context handle. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_Context_Close(TSS_HCONTEXT " hLocalContext ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTspi_Context_Close\fR destroys a context by passing in the handle to that context. 45 | .SH "PARAMETERS" 46 | .PP 47 | .SS hLocalContext 48 | The handle to the context to be closed. 49 | 50 | .SH "RETURN CODES" 51 | .PP 52 | \fBTspi_Context_Close\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 53 | .TP 54 | .SM TSS_E_INVALID_HANDLE - \fIhLocalContext\fR is an invalid handle. 55 | .TP 56 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 57 | 58 | .SH "CONFORMING TO" 59 | 60 | .PP 61 | \fBTspi_Context_Close\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 62 | .SH "SEE ALSO" 63 | 64 | .PP 65 | \fBTspi_Context_Create\fR(3), \fBTspi_Context_Connect\fR(3). 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/tspi/tspi_random.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "spi_utils.h" 20 | #include "capabilities.h" 21 | #include "tsplog.h" 22 | #include "obj.h" 23 | 24 | 25 | TSS_RESULT 26 | Tspi_TPM_GetRandom(TSS_HTPM hTPM, /* in */ 27 | UINT32 ulRandomDataLength, /* in */ 28 | BYTE ** prgbRandomData) /* out */ 29 | { 30 | TSS_HCONTEXT tspContext; 31 | TSS_RESULT result; 32 | 33 | if (prgbRandomData == NULL || ulRandomDataLength > 4096) 34 | return TSPERR(TSS_E_BAD_PARAMETER); 35 | 36 | if ((result = obj_tpm_get_tsp_context(hTPM, &tspContext))) 37 | return result; 38 | 39 | if (ulRandomDataLength == 0) 40 | return TSS_SUCCESS; 41 | 42 | if ((result = TCS_API(tspContext)->GetRandom(tspContext, ulRandomDataLength, 43 | prgbRandomData))) 44 | return result; 45 | 46 | if ((result = __tspi_add_mem_entry(tspContext, *prgbRandomData))) { 47 | free(*prgbRandomData); 48 | *prgbRandomData = NULL; 49 | return result; 50 | } 51 | 52 | return TSS_SUCCESS; 53 | } 54 | 55 | TSS_RESULT 56 | Tspi_TPM_StirRandom(TSS_HTPM hTPM, /* in */ 57 | UINT32 ulEntropyDataLength, /* in */ 58 | BYTE * rgbEntropyData) /* in */ 59 | { 60 | TSS_RESULT result; 61 | TSS_HCONTEXT tspContext; 62 | 63 | if (ulEntropyDataLength > 0 && rgbEntropyData == NULL) 64 | return TSPERR(TSS_E_BAD_PARAMETER); 65 | 66 | if ((result = obj_tpm_get_tsp_context(hTPM, &tspContext))) 67 | return result; 68 | 69 | if ((result = TCS_API(tspContext)->StirRandom(tspContext, ulEntropyDataLength, 70 | rgbEntropyData))) 71 | return result; 72 | 73 | return TSS_SUCCESS; 74 | } 75 | -------------------------------------------------------------------------------- /man/man3/Tspi_Policy_FlushSecret.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Policy_FlushSecret" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developers Reference 25 | .SH NAME 26 | Tspi_Policy_FlushSecret \- flush a cached secret 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_Policy_FlushSecret(TSS_HPOLICY " hPolicy ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_Policy_FlushSecret\fR 48 | tells the TSS to flush a secret that it had cached for a user. 49 | 50 | .SH "PARAMETERS" 51 | .PP 52 | .SS hPolicy 53 | The \fIhPolicy\fR parameter is the handle of the policy object to be flushed. 54 | 55 | .SH "RETURN CODES" 56 | .PP 57 | \fBTspi_Policy_FlushSecret\fR returns TSS_SUCCESS on success, otherwise 58 | one of the following values is returned: 59 | .TP 60 | .SM TSS_E_INVALID_HANDLE 61 | \fIhPolicy\fR is not a valid handle. 62 | 63 | .TP 64 | .SM TSS_E_INTERNAL_ERROR 65 | An internal SW error has been detected. 66 | 67 | .SH "CONFORMING TO" 68 | 69 | .PP 70 | \fBTspi_Policy_FlushSecret\fR conforms to the Trusted Computing Group 71 | Software Specification version 1.1 Golden 72 | 73 | .SH "SEE ALSO" 74 | 75 | .PP 76 | \fBTspi_Policy_SetSecret\fR(3), \fBTspi_Policy_AssignToObject\fR(3). 77 | 78 | -------------------------------------------------------------------------------- /src/tspi/tspi_pcr_comp12.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "trousers/trousers.h" 17 | #include "trousers_types.h" 18 | #include "spi_utils.h" 19 | #include "capabilities.h" 20 | #include "tsplog.h" 21 | #include "obj.h" 22 | 23 | 24 | TSS_RESULT 25 | Tspi_PcrComposite_SetPcrLocality(TSS_HPCRS hPcrComposite, /* in */ 26 | UINT32 LocalityValue) /* in */ 27 | { 28 | /* LocalityValue must be some combination of TPM_LOC_* values logically or'd together */ 29 | if (!LocalityValue || (LocalityValue & (~TSS_LOCALITY_ALL))) 30 | return TSPERR(TSS_E_BAD_PARAMETER); 31 | 32 | return obj_pcrs_set_locality(hPcrComposite, LocalityValue); 33 | } 34 | 35 | TSS_RESULT 36 | Tspi_PcrComposite_GetPcrLocality(TSS_HPCRS hPcrComposite, /* in */ 37 | UINT32* pLocalityValue) /* out */ 38 | { 39 | if (pLocalityValue == NULL) 40 | return TSPERR(TSS_E_BAD_PARAMETER); 41 | 42 | return obj_pcrs_get_locality(hPcrComposite, pLocalityValue); 43 | 44 | } 45 | 46 | TSS_RESULT 47 | Tspi_PcrComposite_GetCompositeHash(TSS_HPCRS hPcrComposite, /* in */ 48 | UINT32* pLen, /* out */ 49 | BYTE** ppbHashData) /* out */ 50 | { 51 | if (pLen == NULL || ppbHashData == NULL) 52 | return TSPERR(TSS_E_BAD_PARAMETER); 53 | 54 | return obj_pcrs_get_digest_at_release(hPcrComposite, pLen, ppbHashData); 55 | 56 | } 57 | 58 | TSS_RESULT 59 | Tspi_PcrComposite_SelectPcrIndexEx(TSS_HPCRS hPcrComposite, /* in */ 60 | UINT32 ulPcrIndex, /* in */ 61 | UINT32 Direction) /* in */ 62 | { 63 | if (Direction != TSS_PCRS_DIRECTION_CREATION && Direction != TSS_PCRS_DIRECTION_RELEASE) 64 | return TSPERR(TSS_E_BAD_PARAMETER); 65 | 66 | return obj_pcrs_select_index_ex(hPcrComposite, Direction, ulPcrIndex); 67 | } 68 | -------------------------------------------------------------------------------- /src/include/daa/issuer.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006-2007 8 | * 9 | */ 10 | #ifndef __ISSUER_H__ 11 | #define __ISSUER_H__ 12 | 13 | #include "daa/daa_structs.h" 14 | #include "daa/daa_parameter.h" 15 | #include "tsplog.h" 16 | 17 | 18 | TSS_RESULT 19 | generate_key_pair(int num_attributes_issuer, 20 | int num_attributes_receiver, 21 | int base_nameLength, 22 | BYTE *base_name, 23 | KEY_PAIR_WITH_PROOF_internal **key_pair_with_proof 24 | ); 25 | 26 | TSS_DAA_PK_PROOF_internal *generate_proof( 27 | const bi_ptr product_PQ_prime, 28 | const TSS_DAA_PK_internal *public_key, 29 | const bi_ptr xz, 30 | const bi_ptr x0, 31 | const bi_ptr x1, 32 | bi_array_ptr x); 33 | 34 | #if 0 35 | TSPICALL 36 | Tspi_DAA_IssueInit_internal( 37 | TSS_HDAA hDAA, // in 38 | TSS_HKEY issuerAuthPK, // in 39 | TSS_HKEY issuerKeyPair, // in 40 | TSS_DAA_IDENTITY_PROOF identityProof, // in 41 | UINT32 capitalUprimeLength, // in 42 | BYTE* capitalUprime, // in 43 | UINT32 daaCounter, // in 44 | UINT32* nonceIssuerLength, // out 45 | BYTE** nonceIssuer, // out 46 | UINT32* authenticationChallengeLength, // out 47 | BYTE** authenticationChallenge, // out 48 | TSS_DAA_JOIN_ISSUER_SESSION* joinSession // out 49 | ); 50 | 51 | TSPICALL 52 | Tspi_DAA_IssueCredential_internal( 53 | TSS_HDAA hDAA, // in 54 | UINT32 attributesIssuerLength, // in 55 | BYTE** attributesIssuer, // in 56 | TSS_DAA_CREDENTIAL_REQUEST credentialRequest, // in 57 | TSS_DAA_JOIN_ISSUER_SESSION joinSession, // in 58 | TSS_DAA_CRED_ISSUER* credIssuer // out 59 | ); 60 | #endif 61 | TSS_RESULT 62 | compute_join_challenge_issuer( TSS_DAA_PK_internal *pk_intern, 63 | bi_ptr v_prime_prime, 64 | bi_ptr capitalA, 65 | bi_ptr capital_Atilde, 66 | UINT32 nonceReceiverLength, 67 | BYTE *nonceReceiver, 68 | UINT32 *c_primeLength, 69 | BYTE **c_prime); // out allocation 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/include/tss/tss_typedef.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Global typedefs for TSS 4 | 5 | */ 6 | 7 | #ifndef __TSS_TYPEDEF_H__ 8 | #define __TSS_TYPEDEF_H__ 9 | 10 | #include 11 | 12 | //-------------------------------------------------------------------- 13 | // definitions for TSS Service Provider (TSP) 14 | // 15 | typedef UINT32 TSS_HANDLE; 16 | 17 | typedef UINT32 TSS_FLAG; // object attributes 18 | typedef UINT32 TSS_RESULT; // the return code from a TSS function 19 | 20 | typedef UINT32 TSS_HOBJECT; // basic object handle 21 | typedef TSS_HOBJECT TSS_HCONTEXT; // context object handle 22 | typedef TSS_HOBJECT TSS_HPOLICY; // policy object handle 23 | typedef TSS_HOBJECT TSS_HTPM; // TPM object handle 24 | typedef TSS_HOBJECT TSS_HKEY; // key object handle 25 | typedef TSS_HOBJECT TSS_HENCDATA; // encrypted data object handle 26 | typedef TSS_HOBJECT TSS_HPCRS; // PCR composite object handle 27 | typedef TSS_HOBJECT TSS_HHASH; // hash object handle 28 | typedef TSS_HOBJECT TSS_HNVSTORE; // NV storage object handle 29 | typedef TSS_HOBJECT TSS_HMIGDATA; // migration data utility obj handle 30 | typedef TSS_HOBJECT TSS_HDELFAMILY; // delegation family object handle 31 | typedef TSS_HOBJECT TSS_HDAA_CREDENTIAL; // daa credential 32 | typedef TSS_HOBJECT TSS_HDAA_ISSUER_KEY; // daa credential issuer keypair 33 | typedef TSS_HOBJECT TSS_HDAA_ARA_KEY; // daa anonymity revocation 34 | // authority keypair 35 | 36 | typedef UINT32 TSS_EVENTTYPE; 37 | typedef UINT16 TSS_MIGRATE_SCHEME; 38 | typedef UINT32 TSS_ALGORITHM_ID; 39 | typedef UINT32 TSS_KEY_USAGE_ID; 40 | typedef UINT16 TSS_KEY_ENC_SCHEME; 41 | typedef UINT16 TSS_KEY_SIG_SCHEME; 42 | typedef BYTE TSS_KEY_AUTH_DATA_USAGE; 43 | typedef UINT32 TSS_CMK_DELEGATE; 44 | typedef UINT32 TSS_NV_INDEX; 45 | typedef UINT32 TSS_COUNTER_ID; 46 | 47 | #endif // __TSS_TYPEDEF_H__ 48 | 49 | -------------------------------------------------------------------------------- /src/tcs/tcsi_sign.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcsps.h" 21 | #include "tcs_utils.h" 22 | #include "tcs_int_literals.h" 23 | #include "capabilities.h" 24 | #include "tcslog.h" 25 | #include "req_mgr.h" 26 | #include "tcsd_wrap.h" 27 | #include "tcsd.h" 28 | 29 | 30 | TSS_RESULT 31 | TCSP_Sign_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 32 | TCS_KEY_HANDLE keyHandle, /* in */ 33 | UINT32 areaToSignSize, /* in */ 34 | BYTE * areaToSign, /* in */ 35 | TPM_AUTH * privAuth, /* in, out */ 36 | UINT32 * sigSize, /* out */ 37 | BYTE ** sig /* out */ 38 | ) 39 | { 40 | UINT64 offset = 0; 41 | UINT32 paramSize; 42 | TSS_RESULT result; 43 | TCPA_KEY_HANDLE keySlot; 44 | BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 45 | 46 | LogDebug("Entering Sign"); 47 | if ((result = ctx_verify_context(hContext))) 48 | return result; 49 | 50 | if (privAuth != NULL) { 51 | LogDebug("Auth Used"); 52 | if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle))) 53 | goto done; 54 | } else { 55 | LogDebug("No Auth"); 56 | } 57 | 58 | if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot))) 59 | goto done; 60 | 61 | if ((result = tpm_rqu_build(TPM_ORD_Sign, &offset, txBlob, keySlot, areaToSignSize, 62 | areaToSign, privAuth))) 63 | return result; 64 | 65 | if ((result = req_mgr_submit_req(txBlob))) 66 | goto done; 67 | 68 | result = UnloadBlob_Header(txBlob, ¶mSize); 69 | if (!result) { 70 | result = tpm_rsp_parse(TPM_ORD_Sign, txBlob, paramSize, sigSize, sig, privAuth, 71 | NULL); 72 | } 73 | LogResult("sign", result); 74 | done: 75 | auth_mgr_release_auth(privAuth, NULL, hContext); 76 | return result; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /README.selinux: -------------------------------------------------------------------------------- 1 | 2 | How to get TrouSerS up and running with an SELinux policy. 3 | Kent Yoder 4 | 5 | This howto assumes a Fedora Core 4 install. 6 | 7 | 1. Install and load the device driver 8 | # wget http://download.fedora.redhat.com/pub/fedora/linux/core/4/SRPMS/kernel-2.6.11-1.1369_FC4.src.rpm 9 | # rpm -ivh kernel-2.6.11-1.1369_FC4.src.rpm 10 | # cd /usr/src/redhat/SPECS 11 | # rpmbuild -bp ./kernel-2.6.spec 12 | # cd /usr/src/redhat/BUILD/kernel-2.6.11/linux-2.6.11 13 | # make menuconfig 14 | - Goto Device Drivers > Character Devices > TPM Devices 15 | - enable the drivers 16 | # make 17 | # make modules_install 18 | # make install 19 | # reboot 20 | # modprobe tpm_atmel (or others...) 21 | 22 | 2. Build and install trousers in the system location. The SELinux policy assumes 23 | that trousers is installed in the system location. To change these, edit 24 | the trousers.fc file. 25 | 26 | # tar zxvf trousers-0.2.1.tar.gz 27 | # cd trousers-0.2.1 28 | # ./configure --prefix=/usr 29 | # make 30 | # make install 31 | 32 | 3. Install the SELinux policy sources 33 | 34 | # yum install selinux-policy-targeted-sources.noarch 35 | 36 | 4. Install the trousers te and fc files and load the policy 37 | 38 | # cp ./dist/fedora/trousers.te /etc/selinux/targeted/src/policy/domains/program 39 | # cp ./dist/fedora/trousers.fc /etc/selinux/targeted/src/policy/file_contexts/program 40 | # cd /etc/selinux/targeted/src/policy 41 | # make clean 42 | # make reload 43 | # make install 44 | # make relabel 45 | 46 | At this point, there should be a trousers-specific type for /dev/tpm0: 47 | 48 | # ls -Z /dev/tpm* 49 | crw-rw---- root root system_u:object_r:tcsd_device_t /dev/tpm0 50 | 51 | Also, checking the security context of the running tcsd should show it running 52 | with the tcsd_t type: 53 | 54 | # ps -Zef |grep tcsd 55 | root:system_r:tcsd_t root 16362 1 0 15:10 ? 00:00:00 /usr/sbin/tcsd 56 | 57 | 5. That should be it! Send bugs and questions to trousers-users@lists.sf.net. 58 | 59 | -------------------------------------------------------------------------------- /src/tspi/rpc/tcstp/rpc_context.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "spi_utils.h" 20 | #include "tsplog.h" 21 | #include "hosttable.h" 22 | #include "tcsd_wrap.h" 23 | #include "rpc_tcstp_tsp.h" 24 | 25 | 26 | TSS_RESULT 27 | RPC_OpenContext_TP(struct host_table_entry* hte, 28 | UINT32* tpm_version, 29 | TCS_CONTEXT_HANDLE* tcsContext) 30 | { 31 | TSS_RESULT result; 32 | 33 | initData(&hte->comm, 0); 34 | hte->comm.hdr.u.ordinal = TCSD_ORD_OPENCONTEXT; 35 | result = sendTCSDPacket(hte); 36 | 37 | if (result == TSS_SUCCESS) 38 | result = hte->comm.hdr.u.result; 39 | 40 | if (result == TSS_SUCCESS) { 41 | if (getData(TCSD_PACKET_TYPE_UINT32, 0, tcsContext, 0, &hte->comm)) 42 | return TSPERR(TSS_E_INTERNAL_ERROR); 43 | 44 | LogDebugFn("Received TCS Context: 0x%x", *tcsContext); 45 | 46 | if (getData(TCSD_PACKET_TYPE_UINT32, 1, tpm_version, 0, &hte->comm)) 47 | return TSPERR(TSS_E_INTERNAL_ERROR); 48 | } 49 | 50 | return result; 51 | } 52 | 53 | TSS_RESULT 54 | RPC_CloseContext_TP(struct host_table_entry *hte) 55 | { 56 | TSS_RESULT result; 57 | 58 | initData(&hte->comm, 1); 59 | hte->comm.hdr.u.ordinal = TCSD_ORD_CLOSECONTEXT; 60 | LogDebugFn("TCS Context: 0x%x", hte->tcsContext); 61 | 62 | if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm)) 63 | return TSPERR(TSS_E_INTERNAL_ERROR); 64 | 65 | result = sendTCSDPacket(hte); 66 | 67 | if (result == TSS_SUCCESS) 68 | result = hte->comm.hdr.u.result; 69 | 70 | return result; 71 | } 72 | 73 | TSS_RESULT 74 | RPC_FreeMemory_TP(struct host_table_entry *hte, 75 | BYTE * pMemory) /* in */ 76 | { 77 | free(pMemory); 78 | 79 | return TSS_SUCCESS; 80 | } 81 | -------------------------------------------------------------------------------- /man/man3/Tspi_Key_UnloadKey.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Key_UnloadKey" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_Key_UnloadKey \- unload a key from the TPM 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_Key_UnloadKey(TSS_HKEY " hKey ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_Key_UnloadKey\fR unloads the key referenced 48 | by the given key object from the TPM. This call will result in a 49 | TPM_EvictKey operation for the specified key. 50 | 51 | 52 | .SH "PARAMETERS" 53 | .PP 54 | .SS hKey 55 | The \fIhKey\fR parameter is the handle of the key object to unload. 56 | 57 | .SH "RETURN CODES" 58 | .PP 59 | \fBTspi_Key_UnloadKey\fR returns TSS_SUCCESS on success, otherwise 60 | one of the following values is returned: 61 | .TP 62 | .SM TSS_E_INVALID_HANDLE 63 | \fIhKey\fR is not a valid handle. 64 | 65 | .TP 66 | .SM TSS_E_INTERNAL_ERROR 67 | An internal SW error has been detected. 68 | 69 | .TP 70 | .SM TSS_E_BAD_PARAMETER 71 | One or more parameters is bad. 72 | 73 | .SH "CONFORMING TO" 74 | 75 | .PP 76 | \fBTspi_Key_UnloadKey\fR conforms to the Trusted Computing Group Software 77 | Specification version 1.1 Golden 78 | 79 | .SH "SEE ALSO" 80 | 81 | .PP 82 | \fBTspi_Key_LoadKey\fR(3), \fBTspi_Key_GetPubKey\fR(3). 83 | 84 | -------------------------------------------------------------------------------- /src/tcs/tcs_quote2.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "trousers/tss.h" 23 | #include "trousers_types.h" 24 | #include "trousers_types.h" 25 | #include "tcs_tsp.h" 26 | #include "tcs_utils.h" 27 | #include "tcs_int_literals.h" 28 | #include "capabilities.h" 29 | #include "tcsps.h" 30 | #include "tcslog.h" 31 | #include "tddl.h" 32 | #include "req_mgr.h" 33 | #include "tcsd_wrap.h" 34 | #include "tcsd.h" 35 | 36 | TSS_RESULT 37 | UnloadBlob_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_SHORT *pcrInfoOut) 38 | { 39 | TSS_RESULT result; 40 | BYTE locAtRelease; 41 | TPM_DIGEST digest; 42 | 43 | LogDebugFn("UnloadBlob_PCR_INFO_SHORT."); 44 | /* Only adjust the offset until the end of this data type */ 45 | if (!pcrInfoOut) { 46 | if ((result = UnloadBlob_PCR_SELECTION(offset, blob, NULL))) 47 | return result; 48 | /* What should go to &pcrInfoOut->localityAtRelease */ 49 | UnloadBlob_BYTE(offset, NULL, blob); 50 | /* What should go to &pcrInfoOut->digestAtRelease */ 51 | UnloadBlob_DIGEST(offset, blob, NULL); 52 | return TSS_SUCCESS; 53 | } 54 | 55 | /* Normal retrieve or TPM_PCR_INFO_SHORT (not used yet, kept for 56 | * integrity purposes. 57 | * TPM_PCR_SELECTION pcrSelection 58 | * TPM_LOCALITY_SELECTION localityAtRelease 59 | * TPM_COMPOSITE_HASH digestAtRelease 60 | * */ 61 | if ((result = UnloadBlob_PCR_SELECTION(offset, blob, &pcrInfoOut->pcrSelection))) 62 | return result; 63 | 64 | UnloadBlob_BYTE(offset, &locAtRelease, blob); 65 | pcrInfoOut->localityAtRelease = locAtRelease; 66 | UnloadBlob_DIGEST(offset, blob, &digest); 67 | pcrInfoOut->digestAtRelease = digest; 68 | 69 | return TSS_SUCCESS; 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/tcs/tcsi_bind.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcsps.h" 21 | #include "tcs_utils.h" 22 | #include "tcs_int_literals.h" 23 | #include "capabilities.h" 24 | #include "tcslog.h" 25 | #include "req_mgr.h" 26 | #include "tcsd_wrap.h" 27 | #include "tcsd.h" 28 | 29 | 30 | TSS_RESULT 31 | TCSP_UnBind_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 32 | TCS_KEY_HANDLE keyHandle, /* in */ 33 | UINT32 inDataSize, /* in */ 34 | BYTE * inData, /* in */ 35 | TPM_AUTH * privAuth, /* in, out */ 36 | UINT32 * outDataSize, /* out */ 37 | BYTE ** outData) /* out */ 38 | { 39 | UINT32 paramSize; 40 | TSS_RESULT result; 41 | UINT64 offset = 0; 42 | TCPA_KEY_HANDLE keySlot; 43 | BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 44 | 45 | LogDebug("Entering TCSI_UnBind"); 46 | if ((result = ctx_verify_context(hContext))) 47 | goto done; 48 | 49 | if (privAuth != NULL) { 50 | LogDebug("Auth Used"); 51 | if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle))) 52 | goto done; 53 | } else { 54 | LogDebug("No Auth"); 55 | } 56 | 57 | LogDebugFn("calling ensureKeyIsLoaded for TCS handle 0x%x", keyHandle); 58 | if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot))) 59 | goto done; 60 | 61 | if ((result = tpm_rqu_build(TPM_ORD_UnBind, &offset, txBlob, keySlot, inDataSize, inData, 62 | privAuth, NULL))) 63 | return result; 64 | 65 | if ((result = req_mgr_submit_req(txBlob))) 66 | goto done; 67 | 68 | result = UnloadBlob_Header(txBlob, ¶mSize); 69 | if (!result) { 70 | result = tpm_rsp_parse(TPM_ORD_UnBind, txBlob, paramSize, outDataSize, outData, 71 | privAuth, NULL); 72 | } 73 | 74 | done: 75 | auth_mgr_release_auth(privAuth, NULL, hContext); 76 | return result; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/tspi/tsp_get_flags.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "trousers/tss.h" 21 | #include "trousers/trousers.h" 22 | #include "trousers_types.h" 23 | #include "trousers_types.h" 24 | #include "spi_utils.h" 25 | #include "capabilities.h" 26 | #include "tsplog.h" 27 | #include "obj.h" 28 | 29 | 30 | TSS_RESULT 31 | get_tpm_flags(TSS_HCONTEXT tspContext, TSS_HTPM hTPM, UINT32 *volFlags, UINT32 *nonVolFlags) 32 | { 33 | TCPA_DIGEST digest; 34 | TPM_AUTH auth; 35 | TCPA_VERSION version; 36 | TSS_RESULT result; 37 | TSS_HPOLICY hPolicy; 38 | Trspi_HashCtx hashCtx; 39 | 40 | if ((result = obj_tpm_get_policy(hTPM, TSS_POLICY_USAGE, &hPolicy))) 41 | return result; 42 | 43 | /* do an owner authorized get capability call */ 44 | result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1); 45 | result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_GetCapabilityOwner); 46 | if ((result |= Trspi_HashFinal(&hashCtx, digest.digest))) 47 | return result; 48 | 49 | if ((result = secret_PerformAuth_OIAP(hTPM, TPM_ORD_GetCapabilityOwner, hPolicy, FALSE, 50 | &digest, &auth))) 51 | return result; 52 | 53 | if ((result = TCS_API(tspContext)->GetCapabilityOwner(tspContext, &auth, &version, 54 | nonVolFlags, volFlags))) 55 | return result; 56 | 57 | result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1); 58 | result |= Trspi_Hash_UINT32(&hashCtx, result); 59 | result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_GetCapabilityOwner); 60 | result |= Trspi_Hash_VERSION(&hashCtx, (TSS_VERSION *)&version); 61 | result |= Trspi_Hash_UINT32(&hashCtx, *nonVolFlags); 62 | result |= Trspi_Hash_UINT32(&hashCtx, *volFlags); 63 | if ((result |= Trspi_HashFinal(&hashCtx, digest.digest))) 64 | return result; 65 | 66 | return obj_policy_validate_auth_oiap(hPolicy, &digest, &auth); 67 | } 68 | -------------------------------------------------------------------------------- /man/man3/Tspi_Context_CloseObject.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Context_CloseObject" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_Context_CloseObject \- destroy resources associated with an object handle. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI " TSS_RESULT Tspi_Context_CloseObject(TSS_HCONTEXT " hContext ", TSS_HOBJECT " hObject ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTSS_Context_CloseObject\fR destroys the object associated with the object handle. All allocated resources associated within the object are also released. 45 | .SH "PARAMETERS" 46 | .PP 47 | .SS hContext 48 | The handle of the context object. 49 | .PP 50 | .SS hObject 51 | The handle of the object to be destroyed. 52 | .SH "RETURN CODES" 53 | .PP 54 | \fBTspi_Context_CloseObject\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 55 | .TP 56 | .SM TSS_E_INVALID_HANDLE - Either \fIhContext\fR or \fIhObject\fR are invalid handles. 57 | .TP 58 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 59 | .SH "CONFORMING TO" 60 | 61 | .PP 62 | \fBTspi_Context_CloseObject\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 63 | .SH "SEE ALSO" 64 | 65 | .PP 66 | \fBTspi_Context_CreateObject\fR(3). 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /man/man3/Tspi_Key_LoadKey.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2005 International Business Machines Corporation 2 | .\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Key_LoadKey" 3 "2005-02-01" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_Key_LoadKey \- load a key into the TPM 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_Key_LoadKey(TSS_HKEY " hKey ", TSS_HKEY " hUnwrappingKey ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_Key_LoadKey\fR loads the key referenced 48 | by \fIhKey\fR into the TPM. 49 | 50 | .SH "PARAMETERS" 51 | .PP 52 | .SS hKey 53 | The \fIhKey\fR parameter is the handle of the key object to load. 54 | .SS hUnwrappingKey 55 | The \fIhUnwrappingKey\fR parameter is the handle of the key which should be used to unwrap the key addressed by \fIhKey\fR. 56 | 57 | .SH "RETURN CODES" 58 | .PP 59 | \fBTspi_Key_LoadKey\fR returns TSS_SUCCESS on success, otherwise 60 | one of the following values is returned: 61 | .TP 62 | .SM TSS_E_INVALID_HANDLE 63 | Either \fIhKey\fR or \fIhUnwrappingKey\fR is not a valid handle. 64 | 65 | .TP 66 | .SM TSS_E_INTERNAL_ERROR 67 | An internal SW error has been detected. 68 | 69 | .TP 70 | .SM TSS_E_BAD_PARAMETER 71 | One or more parameters is bad. 72 | 73 | .SH "CONFORMING TO" 74 | 75 | .PP 76 | \fBTspi_Key_LoadKey\fR conforms to the Trusted Computing Group Software 77 | Specification version 1.1 Golden 78 | 79 | .SH "SEE ALSO" 80 | 81 | .PP 82 | \fBTspi_Key_UnloadKey\fR(3), \fBTspi_Key_GetPubKey\fR(3). 83 | 84 | -------------------------------------------------------------------------------- /src/tcs/tcs_seal.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "trousers/tss.h" 23 | #include "trousers_types.h" 24 | #include "tcs_tsp.h" 25 | #include "tcs_utils.h" 26 | #include "tcslog.h" 27 | 28 | 29 | TSS_RESULT 30 | UnloadBlob_STORED_DATA(UINT64 *offset, BYTE *blob, TCPA_STORED_DATA *data) 31 | { 32 | if (!data) { 33 | UINT32 size; 34 | 35 | UnloadBlob_VERSION(offset, blob, NULL); 36 | 37 | UnloadBlob_UINT32(offset, &size, blob); 38 | 39 | if (size > 0) 40 | UnloadBlob(offset, size, blob, NULL); 41 | 42 | UnloadBlob_UINT32(offset, &size, blob); 43 | 44 | if (size > 0) 45 | UnloadBlob(offset, size, blob, NULL); 46 | 47 | return TSS_SUCCESS; 48 | } 49 | 50 | UnloadBlob_VERSION(offset, blob, (TPM_VERSION *)&data->ver); 51 | 52 | UnloadBlob_UINT32(offset, &data->sealInfoSize, blob); 53 | 54 | if (data->sealInfoSize > 0) { 55 | data->sealInfo = (BYTE *)calloc(1, data->sealInfoSize); 56 | if (data->sealInfo == NULL) { 57 | LogError("malloc of %u bytes failed.", data->sealInfoSize); 58 | data->sealInfoSize = 0; 59 | return TCSERR(TSS_E_OUTOFMEMORY); 60 | } 61 | UnloadBlob(offset, data->sealInfoSize, blob, data->sealInfo); 62 | } else { 63 | data->sealInfo = NULL; 64 | } 65 | 66 | UnloadBlob_UINT32(offset, &data->encDataSize, blob); 67 | 68 | if (data->encDataSize > 0) { 69 | data->encData = (BYTE *)calloc(1, data->encDataSize); 70 | if (data->encData == NULL) { 71 | LogError("malloc of %u bytes failed.", data->encDataSize); 72 | data->encDataSize = 0; 73 | free(data->sealInfo); 74 | data->sealInfo = NULL; 75 | data->sealInfoSize = 0; 76 | return TCSERR(TSS_E_OUTOFMEMORY); 77 | } 78 | UnloadBlob(offset, data->encDataSize, blob, data->encData); 79 | } else { 80 | data->encData = NULL; 81 | } 82 | 83 | return TSS_SUCCESS; 84 | } 85 | -------------------------------------------------------------------------------- /src/tcs/tcsi_quote.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcsps.h" 21 | #include "tcs_utils.h" 22 | #include "tcs_int_literals.h" 23 | #include "capabilities.h" 24 | #include "tcslog.h" 25 | #include "req_mgr.h" 26 | #include "tcsd_wrap.h" 27 | #include "tcsd.h" 28 | 29 | 30 | TSS_RESULT 31 | TCSP_Quote_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 32 | TCS_KEY_HANDLE keyHandle, /* in */ 33 | TCPA_NONCE antiReplay, /* in */ 34 | UINT32 pcrDataSizeIn, /* in */ 35 | BYTE * pcrDataIn, /* in */ 36 | TPM_AUTH * privAuth, /* in, out */ 37 | UINT32 * pcrDataSizeOut, /* out */ 38 | BYTE ** pcrDataOut, /* out */ 39 | UINT32 * sigSize, /* out */ 40 | BYTE ** sig) /* out */ 41 | { 42 | 43 | UINT64 offset = 0; 44 | UINT32 paramSize; 45 | TSS_RESULT result; 46 | UINT32 keySlot; 47 | BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 48 | 49 | LogDebug("Entering quote"); 50 | 51 | if ((result = ctx_verify_context(hContext))) 52 | goto done; 53 | 54 | if (privAuth != NULL) { 55 | LogDebug("Auth Used"); 56 | if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle))) 57 | goto done; 58 | } else { 59 | LogDebug("No Auth"); 60 | } 61 | if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot))) 62 | goto done; 63 | 64 | if ((result = tpm_rqu_build(TPM_ORD_Quote, &offset, txBlob, keySlot, antiReplay.nonce, 65 | pcrDataSizeIn, pcrDataIn, privAuth))) 66 | goto done; 67 | 68 | if ((result = req_mgr_submit_req(txBlob))) 69 | goto done; 70 | 71 | result = UnloadBlob_Header(txBlob, ¶mSize); 72 | if (!result) { 73 | result = tpm_rsp_parse(TPM_ORD_Quote, txBlob, paramSize, pcrDataSizeOut, pcrDataOut, 74 | sigSize, sig, privAuth); 75 | } 76 | LogResult("Quote", result); 77 | done: 78 | auth_mgr_release_auth(privAuth, NULL, hContext); 79 | return result; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /man/man3/Tspi_Context_Connect.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Context_Connect" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME. 24 | Tspi_Context_Connect\- connect a TSP to a Core Services daemon 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_Context_Connect(TSS_HCONTEXT " hLocalContext ", UNICODE* " wszDestination ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTspi_Context_Connect\fR creates a connetion between the application and the local or remote TSS System. 45 | .SH "PARAMETERS" 46 | .PP 47 | .SS hLocalContext 48 | The handle to the context to be connected. 49 | .PP 50 | .SS wszDestination 51 | A null terminated unicode string which specifies the local or remote system to which one will be connected. If \fIwszDestination\fR is NULL, the connection will be to a local TCS. 52 | 53 | .SH "RETURN CODES" 54 | .PP 55 | \fBTspi_Context_Connect\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 56 | .TP 57 | .SM TSS_E_INVALID_HANDLE - \fIhLocalContext\fR is an invalid handle. 58 | .TP 59 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 60 | .SH "CONFORMING TO" 61 | 62 | .PP 63 | \fBTspi_Context_Connect\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 64 | .SH "SEE ALSO" 65 | 66 | .PP 67 | \fBTspi_Context_Create\fR(3), \fBTspi_Context_Close\fR(3). 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/include/capabilities.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _CAPABILITIES_H_ 12 | #define _CAPABILITIES_H_ 13 | 14 | /* This header has all of the software capabilities that are returned either via 15 | * Tspi_Context_GetCapability or TCS_GetCapability. 16 | */ 17 | 18 | /* TSP */ 19 | /* BOOL */ 20 | #define INTERNAL_CAP_TSP_ALG_RSA TRUE 21 | #define INTERNAL_CAP_TSP_ALG_SHA TRUE 22 | #define INTERNAL_CAP_TSP_ALG_3DES FALSE 23 | #define INTERNAL_CAP_TSP_ALG_DES FALSE 24 | #define INTERNAL_CAP_TSP_ALG_HMAC TRUE 25 | #define INTERNAL_CAP_TSP_ALG_AES TRUE 26 | #define INTERNAL_CAP_TSP_PERSSTORAGE TRUE 27 | 28 | /* UINT32 */ 29 | #define INTERNAL_CAP_TSP_ALG_DEFAULT TSS_ALG_RSA 30 | #define INTERNAL_CAP_TSP_ALG_DEFAULT_SIZE TSS_KEY_SIZEVAL_2048BIT 31 | 32 | /* 1 indicates byte-stream return values, 0 indicates ASN.1 encoded return values */ 33 | #define INTERNAL_CAP_TSP_RETURNVALUE_INFO 1 34 | 35 | /* 0 is unknown platform version/type. Currently the spec is too vague on possible values for this 36 | * information to define anything here. */ 37 | #define INTERNAL_CAP_TSP_PLATFORM_VERSION 0 38 | #define INTERNAL_CAP_TSP_PLATFORM_TYPE 0 39 | 40 | /* TCS */ 41 | /* BOOL */ 42 | #define INTERNAL_CAP_TCS_ALG_RSA FALSE 43 | #define INTERNAL_CAP_TCS_ALG_AES FALSE 44 | #define INTERNAL_CAP_TCS_ALG_3DES FALSE 45 | #define INTERNAL_CAP_TCS_ALG_DES FALSE 46 | #define INTERNAL_CAP_TCS_ALG_SHA TRUE 47 | #define INTERNAL_CAP_TCS_ALG_HMAC FALSE 48 | #define INTERNAL_CAP_TCS_PERSSTORAGE TRUE 49 | #define INTERNAL_CAP_TCS_CACHING_KEYCACHE FALSE 50 | #define INTERNAL_CAP_TCS_CACHING_AUTHCACHE TRUE 51 | 52 | /* UINT32 */ 53 | #define INTERNAL_CAP_TCS_ALG_DEFAULT TSS_ALG_RSA 54 | #define INTERNAL_CAP_TCS_ALG_DEFAULT_SIZE TSS_KEY_SIZEVAL_2048BIT 55 | 56 | /* Common between both TSP and TCS */ 57 | #define INTERNAL_CAP_VERSION { 1, 2, TSS_VER_MAJOR, TSS_VER_MINOR } 58 | 59 | #define INTERNAL_CAP_MANUFACTURER_ID 0x49424D00 60 | #define INTERNAL_CAP_MANUFACTURER_STR { 'I', 0, 'B', 0, 'M', 0, 0, 0 } 61 | #define INTERNAL_CAP_MANUFACTURER_STR_LEN 8 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/include/tss/tcs_error.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | TSS Core Service error return codes 4 | 5 | --*/ 6 | 7 | #ifndef __TCS_ERROR_H__ 8 | #define __TCS_ERROR_H__ 9 | 10 | 11 | #ifndef TSS_E_BASE 12 | #define TSS_E_BASE 0x00000000L 13 | #endif // TSS_E_BASE 14 | 15 | // The context handle supplied is invalid. 16 | #define TCS_E_INVALID_CONTEXTHANDLE (UINT32)(TSS_E_BASE + 0x0C1L) 17 | 18 | // The key handle supplied is invalid. 19 | #define TCS_E_INVALID_KEYHANDLE (UINT32)(TSS_E_BASE + 0x0C2L) 20 | 21 | // The authorization session handle supplied is invalid. 22 | #define TCS_E_INVALID_AUTHHANDLE (UINT32)(TSS_E_BASE + 0x0C3L) 23 | 24 | // the auth session has been closed by the TPM 25 | #define TCS_E_INVALID_AUTHSESSION (UINT32)(TSS_E_BASE + 0x0C4L) 26 | 27 | // the key has been unloaded 28 | #define TCS_E_INVALID_KEY (UINT32)(TSS_E_BASE + 0x0C5L) 29 | 30 | // Key addressed by the application key handle does not match the key addressed 31 | // by the given UUID. 32 | #define TCS_E_KEY_MISMATCH (UINT32)(TSS_E_BASE + 0x0C8L) 33 | 34 | // Key adressed by Key's UUID cannot be loaded because one of the required 35 | // parent keys needs authorization. 36 | #define TCS_E_KM_LOADFAILED (UINT32)(TSS_E_BASE + 0x0CAL) 37 | 38 | // The Key Cache Manager could not reload the key into the TPM. 39 | #define TCS_E_KEY_CONTEXT_RELOAD (UINT32)(TSS_E_BASE + 0x0CCL) 40 | 41 | // Bad memory index 42 | #define TCS_E_BAD_INDEX (UINT32)(TSS_E_BASE + 0x0CDL) 43 | 44 | 45 | // These TCS_E_ macros are defined by name in the TSS spec, however 46 | // they are defined to have the same values as the TSS_E_ equivalents. 47 | #define TCS_SUCCESS TSS_SUCCESS 48 | #define TCS_E_KEY_ALREADY_REGISTERED TSS_E_KEY_ALREADY_REGISTERED 49 | #define TCS_E_KEY_NOT_REGISTERED TSS_E_KEY_NOT_REGISTERED 50 | #define TCS_E_BAD_PARAMETER TSS_E_BAD_PARAMETER 51 | #define TCS_E_OUTOFMEMORY TSS_E_OUTOFMEMORY 52 | #define TCS_E_SIZE TSS_E_SIZE 53 | #define TCS_E_NOTIMPL TSS_E_NOTIMPL 54 | #define TCS_E_INTERNAL_ERROR TSS_E_INTERNAL_ERROR 55 | 56 | #endif // __TCS_ERROR_H__ 57 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_KillMaintenanceFeature.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_KillMaintenanceFeature" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_KillMaintenanceFeature \- Disables the ability to create a maintenance archive 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_KillMaintenanceFeature(TSS_HTPM " hTPM ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_TPM_KillMaintenanceFeature\fR disables the 48 | functionality of creating a maintenance archive. \fBThis feature is 49 | not yet implemented\fR. 50 | 51 | .SH "PARAMETERS" 52 | .PP 53 | .SS hTPM 54 | The \fIhTPM\fR parameter is used to specify the handle of the TPM object. 55 | 56 | .SH "RETURN CODES" 57 | .PP 58 | \fBTspi_TPM_KillMaintenanceFeature\fR returns TSS_SUCCESS on success, 59 | otherwise one of the following values is returned: 60 | .TP 61 | .SM TSS_E_INVALID_HANDLE 62 | \fIhTPM\fR is not a valid handle. 63 | 64 | .TP 65 | .SM TSS_E_INTERNAL_ERROR 66 | An internal SW error has been detected. 67 | 68 | .TP 69 | .SM TSS_E_NOTIMPL 70 | The function is not implemented. 71 | 72 | 73 | .SH "CONFORMING TO" 74 | 75 | .PP 76 | \fBTspi_TPM_KillMaintenanceFeature\fR conforms to the Trusted Computing 77 | Group Software Specification version 1.1 Golden 78 | 79 | .SH "SEE ALSO" 80 | 81 | .PP 82 | \fBTspi_TPM_CreateMaintenanceArchive\fR(3), 83 | \fBTspi_TPM_LoadMaintenancePubKey\fR(3), 84 | \fBTspi_TPM_CheckMaintenancePubKey\fR(3). 85 | 86 | -------------------------------------------------------------------------------- /man/man3/Tspi_Context_FreeMemory.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Context_FreeMemory" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developers Reference 25 | .SH NAME 26 | Tspi_Context_FreeMemory \- Free allocated memory for a given context. 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .br 39 | .HP 40 | .BI "TSS_RESULT Tspi_Context_FreeMemory(TSS_HCONTEXT " hContext ", BYTE* " rgbMemory ");" 41 | .fi 42 | .sp 43 | .ad 44 | .hy 45 | 46 | .SH "DESCRIPTION" 47 | .PP 48 | \fBTspi_Context_FreeMemory\fR frees memory allocated by the TSS Service Provider on a per-context basis. 49 | This should be used before Tspi_Context_Close is called, to avoid memory leaks. 50 | 51 | .SH "PARAMETERS" 52 | .PP 53 | .SS hContext 54 | The \fIhContext\fR parameter is the handle to the local context. 55 | .SS rgbMemory 56 | The \fIrgbMemory\fR parameter is a pointer to the memory block to 57 | be freed. If this is NULL, all memory blocks bound to the context are freed. 58 | 59 | .SH "RETURN CODES" 60 | .PP 61 | \fBTspi_Context_FreeMemory\fR returns TSS_SUCCESS on success, otherwise 62 | one of the following values is returned: 63 | .TP 64 | .SM TSS_E_INVALID_HANDLE 65 | \fIhContext\fR is not a valid handle. 66 | 67 | .TP 68 | .SM TSS_E_INTERNAL_ERROR 69 | An internal SW error has been detected. 70 | 71 | .SH "CONFORMING TO" 72 | 73 | .PP 74 | \fBTspi_Context_FreeMemory\fR conforms to the Trusted Computing Group Software 75 | Specification version 1.1 Golden 76 | 77 | .SH "SEE ALSO" 78 | 79 | .PP 80 | \fBTspi_Context_Create\fR(3), \fBTspi_Context_Close\fR(3). 81 | 82 | -------------------------------------------------------------------------------- /man/man3/Tspi_Context_GetDefaultPolicy.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Context_GetDefaultPolicy" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developers Reference 25 | .SH NAME 26 | Tspi_Context_GetDefaultPolicy \- Get a handle to the default policy object 27 | of a given context. 28 | .SH "SYNOPSIS" 29 | .ad l 30 | .hy 0 31 | .nf 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .B #include 39 | .HP 40 | .BI "TSS_RESULT Tspi_Context_GetDefaultPolicy(TSS_HCONTEXT " hContext ", TSS_HPOLICY " *phPolicy "); " 41 | .fi 42 | .sp 43 | .ad 44 | .hy 45 | 46 | .SH "DESCRIPTION" 47 | .PP 48 | \fBTspi_Context_GetDefaultPolicy\fR 49 | determines what policy is used by all of the keys in a given context. 50 | 51 | .SH "PARAMETERS" 52 | .PP 53 | .SS hContext 54 | The \fIhContext\fR parameter is the handle of the context object. 55 | .SS phPolicy 56 | The \fIphPolicy\fR parameter receives the handle of the default 57 | policy object bound to the context. 58 | 59 | .SH "RETURN CODES" 60 | .PP 61 | \fBTspi_Context_GetDefaultPolicy\fR returns TSS_SUCCESS on success, 62 | otherwise one of the following values is returned: 63 | .TP 64 | .SM TSS_E_INVALID_HANDLE 65 | \fIhContext\fR is not a valid handle. 66 | 67 | .TP 68 | .SM TSS_E_INTERNAL_ERROR 69 | An internal SW error has been detected. 70 | 71 | .SH "CONFORMING TO" 72 | 73 | .PP 74 | \fBTspi_Context_GetDefaultPolicy\fR conforms to the Trusted Computing 75 | Group Software Specification version 1.1 Golden 76 | 77 | .SH "SEE ALSO" 78 | 79 | .PP 80 | \fBTspi_Context_Create\fR(3), \fBTspi_Context_Connect\fR(3), 81 | \fBTspi_Context_FreeMemory\fR(3), \fBTspi_Context_Close\fR(3). 82 | 83 | -------------------------------------------------------------------------------- /src/tcs/log.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "tcslog.h" 18 | 19 | #ifdef TSS_DEBUG 20 | 21 | /* 22 | * LogBlobData() 23 | * 24 | * Log a blob's data to the debugging stream 25 | * 26 | * szDescriptor - The APPID tag found in the caller's environment at build time 27 | * sizeOfBlob - The size of the data to log 28 | * blob - the data to log 29 | * 30 | */ 31 | 32 | void 33 | LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob) 34 | { 35 | char temp[64]; 36 | unsigned int i; 37 | 38 | 39 | if (getenv("TCSD_FOREGROUND") == NULL) 40 | openlog(szDescriptor, LOG_NDELAY|LOG_PID, TSS_SYSLOG_LVL); 41 | memset(temp, 0, sizeof(temp)); 42 | 43 | for (i = 0; (unsigned long)i < sizeOfBlob; i++) { 44 | if ((i > 0) && ((i % 16) == 0)) { 45 | if (getenv("TCSD_FOREGROUND") != NULL) 46 | fprintf(stdout, "%s %s\n", szDescriptor, temp); 47 | else 48 | syslog(LOG_DEBUG, "%s", temp); 49 | memset(temp, 0, sizeof(temp)); 50 | } 51 | snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]); 52 | } 53 | 54 | if (i == sizeOfBlob) { 55 | if (getenv("TCSD_FOREGROUND") != NULL) 56 | fprintf(stdout, "%s %s\n", szDescriptor, temp); 57 | else 58 | syslog(LOG_DEBUG, "%s", temp); 59 | } 60 | } 61 | 62 | void 63 | LogTPMERR(TSS_RESULT result, char *file, int line) 64 | { 65 | if (getenv("TSS_DEBUG_OFF") == NULL) 66 | fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", "TPM", file, line, result); 67 | } 68 | 69 | TSS_RESULT 70 | LogTDDLERR(TSS_RESULT result, char *file, int line) 71 | { 72 | if (getenv("TSS_DEBUG_OFF") == NULL) 73 | fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result); 74 | 75 | return (result | TSS_LAYER_TDDL); 76 | } 77 | 78 | TSS_RESULT 79 | LogTCSERR(TSS_RESULT result, char *file, int line) 80 | { 81 | if (getenv("TSS_DEBUG_OFF") == NULL) 82 | fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result); 83 | 84 | return (result | TSS_LAYER_TCS); 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_GetEvent.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_GetEvent" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_TPM_GetEvent\- get a PCR event for a given PCR index and event number. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_TPM_GetEvent(TSS_HTPM " hTPM ", UINT32 " ulPcrIndex "," 38 | .BI " UINT32 " ulEventNumber ", TSS_PCR_EVENT* " pPcrEvent ");" 39 | .fi 40 | .sp 41 | .ad 42 | .hy 43 | 44 | .SH "DESCRIPTION" 45 | .PP 46 | \fBTspi_TPM_GetEvent\fR provides a PCR event for a given PCR index and event number. 47 | .SH "PARAMETERS" 48 | .PP 49 | .SS hTPM 50 | Handle of the TPM object. 51 | .PP 52 | .SS ulPcrIndex 53 | Index of the PCR to request. 54 | .PP 55 | .SS ulEventNumber 56 | Index of the event to request. 57 | .PP 58 | .SS pPcrEvent 59 | Receives the PCR event data. 60 | .SH "RETURN CODES" 61 | .PP 62 | \fBTspi_TPM_GetEvent\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 63 | .TP 64 | .SM TSS_E_INVALID_HANDLE 65 | \fBhTPM\fR is not a valid handle to the TPM object. 66 | .TP 67 | .SM TSS_E_INTERNAL_ERROR 68 | An error occurred internal to the TSS. 69 | 70 | .SH "CONFORMING TO" 71 | 72 | .PP 73 | \fBTspi_TPM_GetEvent\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 74 | .SH "SEE ALSO" 75 | 76 | .PP 77 | \fBTspi_TPM_GetEvents\fR(3) \fBTspi_TPM_GetEventLog\fR(3). 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/tspi/tsp_dir.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "trousers/tss.h" 16 | #include "trousers/trousers.h" 17 | #include "trousers_types.h" 18 | #include "spi_utils.h" 19 | #include "capabilities.h" 20 | #include "tsplog.h" 21 | #include "obj.h" 22 | 23 | 24 | #ifdef TSS_BUILD_TRANSPORT 25 | TSS_RESULT 26 | Transport_DirWriteAuth(TSS_HCONTEXT tspContext, /* in */ 27 | TCPA_DIRINDEX dirIndex, /* in */ 28 | TCPA_DIRVALUE *newContents, /* in */ 29 | TPM_AUTH * ownerAuth) /* in, out */ 30 | { 31 | TSS_RESULT result; 32 | UINT32 handlesLen = 0; 33 | UINT64 offset; 34 | BYTE data[sizeof(TCPA_DIRINDEX) + sizeof(TCPA_DIRVALUE)]; 35 | 36 | 37 | if ((result = obj_context_transport_init(tspContext))) 38 | return result; 39 | 40 | LogDebugFn("Executing in a transport session"); 41 | 42 | offset = 0; 43 | Trspi_LoadBlob_UINT32(&offset, dirIndex, data); 44 | Trspi_LoadBlob_DIGEST(&offset, data, (TPM_DIGEST *)newContents); 45 | 46 | result = obj_context_transport_execute(tspContext, TPM_ORD_DirWriteAuth, sizeof(data), data, 47 | NULL, &handlesLen, NULL, ownerAuth, NULL, NULL, 48 | NULL); 49 | 50 | return result; 51 | } 52 | 53 | TSS_RESULT 54 | Transport_DirRead(TSS_HCONTEXT tspContext, /* in */ 55 | TCPA_DIRINDEX dirIndex, /* in */ 56 | TCPA_DIRVALUE * dirValue) /* out */ 57 | { 58 | TSS_RESULT result; 59 | UINT32 handlesLen = 0, decLen; 60 | UINT64 offset; 61 | BYTE data[sizeof(TCPA_DIRINDEX)], *dec; 62 | 63 | 64 | if ((result = obj_context_transport_init(tspContext))) 65 | return result; 66 | 67 | LogDebugFn("Executing in a transport session"); 68 | 69 | offset = 0; 70 | Trspi_LoadBlob_UINT32(&offset, dirIndex, data); 71 | 72 | if ((result = obj_context_transport_execute(tspContext, TPM_ORD_DirRead, sizeof(data), data, 73 | NULL, &handlesLen, NULL, NULL, NULL, &decLen, 74 | &dec))) 75 | return result; 76 | 77 | offset = 0; 78 | Trspi_UnloadBlob_DIGEST(&offset, dec, dirValue); 79 | 80 | return result; 81 | } 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_GetTestResult.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_GetTestResult" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_TPM_GetTestResult\- get manufacturer specific information regarding the results of a self test. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_TPM_GetTestResult(TSS_HTPM " hTPM ", UINT32* " pulTestResultLength ", BYTE** " prgbTestResult ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | 43 | .SH "DESCRIPTION" 44 | .PP 45 | \fBTspi_TPM_GetTestResult\fR is provided by a manufacturer of a TPM to provide manufacturer specific self test results. 46 | .SH "PARAMETERS" 47 | .PP 48 | .SS hTPM 49 | Handle of the TPM object 50 | .PP 51 | .SS pulTestREsultLength 52 | Receives the length (in bytes) of the prgbTestResult parameter 53 | .PP 54 | .SS prgbTestResult 55 | Pointer to the memory block containing the TPM manufacturer specific information. 56 | .SH "RETURN CODES" 57 | .PP 58 | \fBTspi_TPM_GetTestResult\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 59 | .TP 60 | .SM TSS_E_INVALID_HANDLE 61 | \fBhTPM\fR is not a valid handle to the TPM object. 62 | .TP 63 | .SM TSS_E_INTERNAL_ERROR 64 | An error occurred internal to the TSS. 65 | 66 | .SH "CONFORMING TO" 67 | 68 | .PP 69 | \fBTspi_TPM_GetTestResult\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 70 | .SH "SEE ALSO" 71 | 72 | .PP 73 | \fBTspi_TPM_SelfTestFull\fR(3). 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_SelfTestFull.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_SelfTestFull" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_SelfTestFull \- perform a self-test of each internal TPM function 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_SelfTestFull(TSS_HTPM " hTPM ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_TPM_SelfTestFull\fR 48 | assures that the TPM is functioning as designed. For FIPS certification, 49 | crypto modules are required to test themselves before they are used, and 50 | this command is used to fulfill that requirement. This command can also be 51 | used to check the TPM whenever such a check is desired. \fBThis command is not 52 | currently implemented\fR. 53 | 54 | .SH "PARAMETERS" 55 | .PP 56 | .SS hTPM 57 | The \fIhTPM\fR parameter is used to specify the handle of the TPM object on 58 | which the self-tests will be run. 59 | 60 | .SH "RETURN CODES" 61 | .PP 62 | \fBTspi_TPM_GetStatus\fR returns TSS_SUCCESS on success, otherwise one of 63 | the following values is returned: 64 | .TP 65 | .SM TSS_E_INVALID_HANDLE 66 | \fIhTPM\fR is not a valid handle. 67 | 68 | .TP 69 | .SM TSS_E_INTERNAL_ERROR 70 | An internal SW error has been detected. 71 | 72 | .SH "CONFORMING TO" 73 | 74 | .PP 75 | \fBTspi_TPM_SelfTestFull\fR conforms to the Trusted Computing Group 76 | Software Specification version 1.1 Golden 77 | 78 | .SH "SEE ALSO" 79 | 80 | .PP 81 | \fBTspi_TPM_CertifySelfTest\fR(3), \fBTspi_TPM_GetTestResults\fR(3). 82 | 83 | -------------------------------------------------------------------------------- /src/tspi/rpc/tcstp/rpc_caps.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "spi_utils.h" 20 | #include "capabilities.h" 21 | #include "tsplog.h" 22 | #include "hosttable.h" 23 | #include "tcsd_wrap.h" 24 | #include "obj.h" 25 | #include "rpc_tcstp_tsp.h" 26 | 27 | 28 | TSS_RESULT 29 | RPC_GetCapability_TP(struct host_table_entry *hte, 30 | TCPA_CAPABILITY_AREA capArea, /* in */ 31 | UINT32 subCapSize, /* in */ 32 | BYTE * subCap, /* in */ 33 | UINT32 * respSize, /* out */ 34 | BYTE ** resp) /* out */ 35 | { 36 | TSS_RESULT result; 37 | 38 | initData(&hte->comm, 4); 39 | hte->comm.hdr.u.ordinal = TCSD_ORD_TCSGETCAPABILITY; 40 | LogDebugFn("TCS Context: 0x%x", hte->tcsContext); 41 | 42 | if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm)) 43 | return TSPERR(TSS_E_INTERNAL_ERROR); 44 | if (setData(TCSD_PACKET_TYPE_UINT32, 1, &capArea, 0, &hte->comm)) 45 | return TSPERR(TSS_E_INTERNAL_ERROR); 46 | if (setData(TCSD_PACKET_TYPE_UINT32, 2, &subCapSize, 0, &hte->comm)) 47 | return TSPERR(TSS_E_INTERNAL_ERROR); 48 | if (setData(TCSD_PACKET_TYPE_PBYTE, 3, subCap, subCapSize, &hte->comm)) 49 | return TSPERR(TSS_E_INTERNAL_ERROR); 50 | 51 | result = sendTCSDPacket(hte); 52 | 53 | if (result == TSS_SUCCESS) 54 | result = hte->comm.hdr.u.result; 55 | 56 | if (result == TSS_SUCCESS) { 57 | if (getData(TCSD_PACKET_TYPE_UINT32, 0, respSize, 0, &hte->comm)) { 58 | result = TSPERR(TSS_E_INTERNAL_ERROR); 59 | goto done; 60 | } 61 | 62 | *resp = (BYTE *) calloc_tspi(hte->tspContext, *respSize); 63 | if (*resp == NULL) { 64 | LogError("malloc of %u bytes failed.", *respSize); 65 | result = TSPERR(TSS_E_OUTOFMEMORY); 66 | goto done; 67 | } 68 | if (getData(TCSD_PACKET_TYPE_PBYTE, 1, *resp, *respSize, &hte->comm)) { 69 | free_tspi(hte->tspContext, *resp); 70 | result = TSPERR(TSS_E_INTERNAL_ERROR); 71 | } 72 | } 73 | 74 | done: 75 | return result; 76 | } 77 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_GetStatus.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_GetStatus" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_GetStatus \- query the TPM's status 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_GetStatus(TSS_HTPM " hTPM ", TSS_FLAG " statusFlag ", BOOL* " pfTpmState ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_TPM_GetStatus\fR queries the status of the 48 | TPM, returning a specific status based on the flags specified. 49 | \fBThis command is not currently implemented\fR. 50 | 51 | .SH "PARAMETERS" 52 | .PP 53 | .SS hTPM 54 | The \fIhTPM\fR parameter is used to specify the handle of the TPM object. 55 | .SS statusFlag 56 | The \fIstatusFlag\fR parameter is the status to be retrieved. 57 | .SS fTpmState 58 | The \fIpfTpmState\fR parameter is a pointer to the value of the status queried. 59 | 60 | .SH "RETURN CODES" 61 | .PP 62 | \fBTspi_TPM_GetStatus\fR returns TSS_SUCCESS on success, otherwise one 63 | of the following values is returned: 64 | .TP 65 | .SM TSS_E_INVALID_HANDLE 66 | \fIhTPM\fR is not a valid handle. 67 | 68 | .TP 69 | .SM TSS_E_INTERNAL_ERROR 70 | An internal SW error has been detected. 71 | 72 | .TP 73 | .SM TSS_E_BAD_PARAMETER 74 | One or more parameters is bad. 75 | 76 | .SH "CONFORMING TO" 77 | 78 | .PP 79 | \fBTspi_TPM_GetStatus\fR conforms to the Trusted Computing Group 80 | Software Specification version 1.1 Golden 81 | 82 | .SH "SEE ALSO" 83 | 84 | .PP 85 | \fBTspi_TPM_SetStatus\fR(3), \fBTspi_TPM_GetCapability\fR(3). 86 | 87 | -------------------------------------------------------------------------------- /src/tcs/rpc/tcstp/rpc_context.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcs_utils.h" 21 | #include "tcs_int_literals.h" 22 | #include "capabilities.h" 23 | #include "tcslog.h" 24 | #include "tcsd_wrap.h" 25 | #include "tcsd.h" 26 | #include "tcs_utils.h" 27 | #include "rpc_tcstp_tcs.h" 28 | 29 | 30 | TSS_RESULT 31 | tcs_wrap_OpenContext(struct tcsd_thread_data *data) 32 | { 33 | TCS_CONTEXT_HANDLE hContext; 34 | TSS_RESULT result; 35 | UINT32 tpm_version = tpm_metrics.version.minor; 36 | 37 | LogDebugFn("thread %ld", THREAD_ID); 38 | 39 | result = TCS_OpenContext_Internal(&hContext); 40 | if (result == TSS_SUCCESS) { 41 | initData(&data->comm, 2); 42 | if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) 43 | return TCSERR(TSS_E_INTERNAL_ERROR); 44 | 45 | if (setData(TCSD_PACKET_TYPE_UINT32, 1, &tpm_version, 0, &data->comm)) 46 | return TCSERR(TSS_E_INTERNAL_ERROR); 47 | 48 | /* Set the context in the thread's object. Later, if something goes wrong 49 | * and the connection can't be closed cleanly, we'll still have a reference 50 | * to what resources need to be freed. */ 51 | data->context = hContext; 52 | } else 53 | initData(&data->comm, 0); 54 | 55 | data->comm.hdr.u.result = result; 56 | 57 | return TSS_SUCCESS; 58 | } 59 | 60 | TSS_RESULT 61 | tcs_wrap_CloseContext(struct tcsd_thread_data *data) 62 | { 63 | TCS_CONTEXT_HANDLE hContext; 64 | TSS_RESULT result; 65 | 66 | if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) 67 | return TCSERR(TSS_E_INTERNAL_ERROR); 68 | 69 | LogDebugFn("thread %ld context %x", THREAD_ID, hContext); 70 | 71 | result = TCS_CloseContext_Internal(hContext); 72 | 73 | /* This will signal the thread that the connection has been closed cleanly */ 74 | if (result == TSS_SUCCESS) 75 | data->context = NULL_TCS_HANDLE; 76 | 77 | initData(&data->comm, 0); 78 | data->comm.hdr.u.result = result; 79 | 80 | return TSS_SUCCESS; 81 | } 82 | -------------------------------------------------------------------------------- /src/tcs/rpc/tcstp/rpc_caps.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2006 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcs_utils.h" 21 | #include "tcs_int_literals.h" 22 | #include "capabilities.h" 23 | #include "tcslog.h" 24 | #include "tcsd_wrap.h" 25 | #include "tcsd.h" 26 | #include "tcs_utils.h" 27 | #include "rpc_tcstp_tcs.h" 28 | 29 | 30 | TSS_RESULT 31 | tcs_wrap_TCSGetCapability(struct tcsd_thread_data *data) 32 | { 33 | TCS_CONTEXT_HANDLE hContext; 34 | TCPA_CAPABILITY_AREA capArea; 35 | UINT32 subCapSize; 36 | BYTE *subCap; 37 | UINT32 respSize; 38 | BYTE *resp; 39 | TSS_RESULT result; 40 | 41 | if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) 42 | return TCSERR(TSS_E_INTERNAL_ERROR); 43 | 44 | LogDebugFn("thread %ld context %x", THREAD_ID, hContext); 45 | 46 | if (getData(TCSD_PACKET_TYPE_UINT32, 1, &capArea, 0, &data->comm)) 47 | return TCSERR(TSS_E_INTERNAL_ERROR); 48 | if (getData(TCSD_PACKET_TYPE_UINT32, 2, &subCapSize, 0, &data->comm)) 49 | return TCSERR(TSS_E_INTERNAL_ERROR); 50 | 51 | subCap = calloc(1, subCapSize); 52 | if (subCap == NULL) { 53 | LogError("malloc of %u bytes failed.", subCapSize); 54 | return TCSERR(TSS_E_OUTOFMEMORY); 55 | } 56 | if (getData(TCSD_PACKET_TYPE_PBYTE, 3, subCap, subCapSize, &data->comm)) { 57 | free(subCap); 58 | return TCSERR(TSS_E_INTERNAL_ERROR); 59 | } 60 | 61 | result = TCS_GetCapability_Internal(hContext, capArea, subCapSize, subCap, 62 | &respSize, &resp); 63 | free(subCap); 64 | 65 | if (result == TSS_SUCCESS) { 66 | initData(&data->comm, 2); 67 | if (setData(TCSD_PACKET_TYPE_UINT32, 0, &respSize, 0, &data->comm)) { 68 | free(resp); 69 | return TCSERR(TSS_E_INTERNAL_ERROR); 70 | } 71 | if (setData(TCSD_PACKET_TYPE_PBYTE, 1, resp, respSize, &data->comm)) { 72 | free(resp); 73 | return TCSERR(TSS_E_INTERNAL_ERROR); 74 | } 75 | free(resp); 76 | } else 77 | initData(&data->comm, 0); 78 | 79 | data->comm.hdr.u.result = result; 80 | return TSS_SUCCESS; 81 | } 82 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_GetEventLog.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_GetEventLog" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_TPM_GetEventLog\- get the entire PCR event log. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_TPM_GetEventLog(TSS_HTPM " hTPM ", UINT32* " pulEventNumber "," 38 | .BI " TSS_PCR_EVENT** " prgPcrEvents ");" 39 | .fi 40 | .sp 41 | .ad 42 | .hy 43 | 44 | .SH "DESCRIPTION" 45 | .PP 46 | \fBTspi_TPM_GetEventLog\fR provides the whole event log that was used to create all of the PCRs. 47 | .SH "PARAMETERS" 48 | .PP 49 | .SS hTPM 50 | Handle of the TPM object. 51 | .PP 52 | .SS pulEventNumber 53 | Receives number of returned event data structures in prgPcrEvents parameter. 54 | .PP 55 | .SS prgPcrEvents 56 | Receives a pointer to an array of PCR event data. 57 | If NULL, only the numberof elements is returned in pulEventNumber parameter. 58 | .SH "RETURN CODES" 59 | .PP 60 | \fBTspi_TPM_GetEventLog\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 61 | .TP 62 | .SM TSS_E_INVALID_HANDLE 63 | \fBhTPM\fR is not a valid handle to the TPM object. 64 | .TP 65 | .SM TSS_E_INTERNAL_ERROR 66 | An error occurred internal to the TSS. 67 | 68 | .SH "CONFORMING TO" 69 | 70 | .PP 71 | \fBTspi_TPM_GetEventLog\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 72 | .SH "SEE ALSO" 73 | 74 | .PP 75 | \fBTspi_TPM_GetEvent\fR(3) \fBTspi_TPM_GetEvents\fR(3). 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/include/obj_delfamily.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_DELFAMILY_H_ 12 | #define _OBJ_DELFAMILY_H_ 13 | 14 | #ifdef TSS_BUILD_DELEGATION 15 | 16 | #define TSS_DELFAMILY_FLAGS_STATE_ENABLED (((UINT32)1)<<0) 17 | #define TSS_DELFAMILY_FLAGS_STATE_LOCKED (((UINT32)1)<<1) 18 | 19 | /* structures */ 20 | struct tr_delfamily_obj { 21 | UINT32 stateFlags; 22 | UINT32 verCount; 23 | UINT32 familyID; 24 | BYTE label; 25 | }; 26 | 27 | /* obj_delfamily.c */ 28 | void delfamily_free(void *data); 29 | TSS_BOOL obj_is_delfamily(TSS_HOBJECT); 30 | TSS_RESULT obj_delfamily_add(TSS_HCONTEXT, TSS_HOBJECT *); 31 | TSS_RESULT obj_delfamily_remove(TSS_HDELFAMILY, TSS_HOBJECT); 32 | void obj_delfamily_find_by_familyid(TSS_HOBJECT, UINT32, TSS_HDELFAMILY *); 33 | TSS_RESULT obj_delfamily_get_tsp_context(TSS_HDELFAMILY, TSS_HCONTEXT *); 34 | TSS_RESULT obj_delfamily_set_locked(TSS_HDELFAMILY, TSS_BOOL, TSS_BOOL); 35 | TSS_RESULT obj_delfamily_get_locked(TSS_HDELFAMILY, TSS_BOOL *); 36 | TSS_RESULT obj_delfamily_set_enabled(TSS_HDELFAMILY, TSS_BOOL, TSS_BOOL); 37 | TSS_RESULT obj_delfamily_get_enabled(TSS_HDELFAMILY, TSS_BOOL *); 38 | TSS_RESULT obj_delfamily_set_vercount(TSS_HDELFAMILY, UINT32); 39 | TSS_RESULT obj_delfamily_get_vercount(TSS_HDELFAMILY, UINT32 *); 40 | TSS_RESULT obj_delfamily_set_familyid(TSS_HDELFAMILY, UINT32); 41 | TSS_RESULT obj_delfamily_get_familyid(TSS_HDELFAMILY, UINT32 *); 42 | TSS_RESULT obj_delfamily_set_label(TSS_HDELFAMILY, BYTE); 43 | TSS_RESULT obj_delfamily_get_label(TSS_HDELFAMILY, BYTE *); 44 | 45 | 46 | #define DELFAMILY_LIST_DECLARE struct obj_list delfamily_list 47 | #define DELFAMILY_LIST_DECLARE_EXTERN extern struct obj_list delfamily_list 48 | #define DELFAMILY_LIST_INIT() list_init(&delfamily_list) 49 | #define DELFAMILY_LIST_CONNECT(a,b) obj_connectContext_list(&delfamily_list, a, b) 50 | #define DELFAMILY_LIST_CLOSE(a) obj_list_close(&delfamily_list, &delfamily_free, a) 51 | 52 | #else 53 | 54 | #define obj_is_delfamily(a) FALSE 55 | 56 | #define DELFAMILY_LIST_DECLARE 57 | #define DELFAMILY_LIST_DECLARE_EXTERN 58 | #define DELFAMILY_LIST_INIT() 59 | #define DELFAMILY_LIST_CONNECT(a,b) 60 | #define DELFAMILY_LIST_CLOSE(a) 61 | 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /man/man3/Tspi_Key_GetPubKey.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Key_GetPubKey" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_Key_GetPubKey \- get the public key of an object 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_Key_GetPubKey(TSS_HKEY " hKey ", UINT32* " pulPubKeyLength ", BYTE** " prgbPubKey ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_Key_GetPubKey\fR gets the public portion of a 48 | given key object. 49 | 50 | .SH "PARAMETERS" 51 | .PP 52 | .SS hKey 53 | The \fIhKey\fR parameter is the handle of the key object to unload. 54 | .SS pulPubKeyLength 55 | The \fIpulPubKeyLength\fR parameter receives the length in bytes of the 56 | \fIprgbPubKey\fR parameter. 57 | .SS prgbPubKey 58 | The \fIprgbPubKey\fR parameter receives a pointer to the memory block 59 | containing the public key blob retrieved for the key object referenced 60 | by \fIhKey\fR. 61 | 62 | .SH "RETURN CODES" 63 | .PP 64 | \fBTspi_Key_GetPubKey\fR returns TSS_SUCCESS on success, otherwise one of 65 | the following values is returned: 66 | .TP 67 | .SM TSS_E_INVALID_HANDLE 68 | \fIhKey\fR is not a valid handle. 69 | 70 | .TP 71 | .SM TSS_E_INTERNAL_ERROR 72 | An internal SW error has been detected. 73 | 74 | .TP 75 | .SM TSS_E_BAD_PARAMETER 76 | One or more parameters is bad. 77 | 78 | .SH "CONFORMING TO" 79 | 80 | .PP 81 | \fBTspi_Key_GetPubKey\fR conforms to the Trusted Computing Group Software 82 | Specification version 1.1 Golden 83 | 84 | .SH "SEE ALSO" 85 | 86 | .PP 87 | \fBTspi_Key_LoadKey\fR(3), \fBTspi_Key_UnloadKey\fR(3), 88 | \fBTspi_Key_CertifyKey\fR(3). 89 | 90 | -------------------------------------------------------------------------------- /man/man3/Tspi_ChangeAuth.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Change_Auth" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_ChangeAuth \- change the authorization data of an entity. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_ChangeAuth(TSS_HOBJECT " hObjectToChange ", TSS_HOBJECT " hParentObject "," 38 | .BI " TSS_HPOLICY " hNewPolicy " );" 39 | .fi 40 | .sp 41 | .ad 42 | .hy 43 | 44 | .SH "DESCRIPTION" 45 | .PP 46 | \fBTspi_ChangeAuth \fR changes the authorization data (secret) of an entity (object) and assigns the object to the policy object. All classes using secrets provide this method for changing their authorization data. 47 | .SH "PARAMETERS" 48 | .PP 49 | .SS hObjectToChange 50 | Handle of the object to change authorization for. 51 | .PP 52 | .SS hParentObject 53 | Handle of the parent object wrapping the object addressed by hObjectToChange. 54 | .PP 55 | .SS hNewPolicy 56 | Handle of the policy object providing the new authorization data. 57 | .SH "RETURN CODES" 58 | .PP 59 | \fBTspi_ChangeAuth\fR returns TSS_SUCCESS on success,otherwise one of the following values are returned: 60 | .TP 61 | .SM TSS_E_INVALID_HANDLE - Either \fIhObjectToChange\fR, or \fIhParentObject\fR are not a valid handle. 62 | .TP 63 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 64 | 65 | .SH "CONFORMING TO" 66 | 67 | .PP 68 | \fBTspi_ChangeAuth\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 69 | .SH "SEE ALSO" 70 | 71 | .PP 72 | \fBTspi_ChangeAuthAsym\fR(3). 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /man/man3/Tspi_PcrComposite_SelectPcrIndex.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_PcrComposite_SelectPcrIndex" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_PcrComposite_SelectPcrIndex\- select a PCR index inside a PCR composite object. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_PcrComposite_SelectPcrIndex(TSS_HPCRS " hPcrComposite ", UINT32 " ulPcrIndex ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTspi_PcrComposite_SelectPcrIndex\fR selects a PCR index inside a PCR composite object. The PCR composite object must be created withthe function Tspi_Context_CreateObject(). An exampled for the usage is the selection of PCR registeres before calling Tspi_TPM_Quote(). 45 | .SH "PARAMETERS" 46 | .PP 47 | .SS hPcrComposite 48 | Handle of the PCR composite object instance where the index should be selected. 49 | .PP 50 | .SS ulPcrIndex 51 | This parameter indicates the index of the PCR to select. 52 | .SH "RETURN CODES" 53 | .PP 54 | \fBTspi_PcrComposite_SelectPcrIndex\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 55 | .TP 56 | .SM TSS_E_INVALID_HANDLE - Either \fIhPcrComposite\fR or \fIulPcrIndex\fR is an invalid handle. 57 | .TP 58 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 59 | 60 | .SH "CONFORMING TO" 61 | 62 | .PP 63 | \fBTspi_PcrComposite_SelectPcrIndex\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 64 | .SH "SEE ALSO" 65 | 66 | .PP 67 | \fBTspi_TPM_Quote\fR(3), \fBTspi_PcrComposite_SetPcrValue\fR(3), \fBTspi_PcrComposite_GetPcrValue\fR(3). 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/include/obj_pcrs.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_PCRS_H_ 12 | #define _OBJ_PCRS_H_ 13 | 14 | #ifdef TSS_BUILD_PCRS_LIST 15 | 16 | /* structures */ 17 | struct tr_pcrs_obj { 18 | UINT32 type; 19 | union { 20 | TPM_PCR_INFO info11; 21 | TPM_PCR_INFO_SHORT infoshort; 22 | TPM_PCR_INFO_LONG infolong; 23 | } info; 24 | TPM_PCRVALUE *pcrs; 25 | }; 26 | 27 | /* obj_pcrs.c */ 28 | void pcrs_free(void *data); 29 | TSS_BOOL obj_is_pcrs(TSS_HOBJECT); 30 | TSS_RESULT obj_pcrs_get_tsp_context(TSS_HPCRS, TSS_HCONTEXT *); 31 | TSS_RESULT obj_pcrs_add(TSS_HCONTEXT, UINT32, TSS_HOBJECT *); 32 | TSS_RESULT obj_pcrs_remove(TSS_HOBJECT, TSS_HCONTEXT); 33 | TSS_RESULT obj_pcrs_get_type(TSS_HPCRS, UINT32 *); 34 | TSS_RESULT obj_pcrs_select_index(TSS_HPCRS, UINT32); 35 | TSS_RESULT obj_pcrs_select_index_ex(TSS_HPCRS, UINT32, UINT32); 36 | TSS_RESULT obj_pcrs_get_value(TSS_HPCRS, UINT32, UINT32 *, BYTE **); 37 | TSS_RESULT obj_pcrs_set_value(TSS_HPCRS, UINT32, UINT32, BYTE *); 38 | TSS_RESULT obj_pcrs_set_values(TSS_HPCRS hPcrs, TCPA_PCR_COMPOSITE *); 39 | TSS_RESULT obj_pcrs_get_selection(TSS_HPCRS, UINT32 *, BYTE *); 40 | TSS_RESULT obj_pcrs_get_digest_at_release(TSS_HPCRS, UINT32 *, BYTE **); 41 | TSS_RESULT obj_pcrs_set_digest_at_release(TSS_HPCRS, TPM_COMPOSITE_HASH); 42 | TSS_RESULT obj_pcrs_create_info_type(TSS_HPCRS, UINT32 *, UINT32 *, BYTE **); 43 | TSS_RESULT obj_pcrs_create_info(TSS_HPCRS, UINT32 *, BYTE **); 44 | TSS_RESULT obj_pcrs_create_info_long(TSS_HPCRS, UINT32 *, BYTE **); 45 | TSS_RESULT obj_pcrs_create_info_short(TSS_HPCRS, UINT32 *, BYTE **); 46 | TSS_RESULT obj_pcrs_get_locality(TSS_HPCRS, UINT32 *); 47 | TSS_RESULT obj_pcrs_set_locality(TSS_HPCRS, UINT32); 48 | 49 | #define PCRS_LIST_DECLARE struct obj_list pcrs_list 50 | #define PCRS_LIST_DECLARE_EXTERN extern struct obj_list pcrs_list 51 | #define PCRS_LIST_INIT() list_init(&pcrs_list) 52 | #define PCRS_LIST_CONNECT(a,b) obj_connectContext_list(&pcrs_list, a, b) 53 | #define PCRS_LIST_CLOSE(a) obj_list_close(&pcrs_list, &pcrs_free, a) 54 | 55 | #else 56 | 57 | #define obj_is_pcrs(a) FALSE 58 | 59 | #define PCRS_LIST_DECLARE 60 | #define PCRS_LIST_DECLARE_EXTERN 61 | #define PCRS_LIST_INIT() 62 | #define PCRS_LIST_CONNECT(a,b) 63 | #define PCRS_LIST_CLOSE(a) 64 | 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/tspi/gtk/support.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004 8 | * 9 | */ 10 | 11 | #ifndef _SUPPORT_H_ 12 | #define _SUPPOR_H_ 13 | 14 | /* 15 | * DO NOT EDIT THIS FILE - it is generated by Glade. 16 | */ 17 | 18 | #ifdef HAVE_CONFIG_H 19 | # include 20 | #endif 21 | 22 | #include 23 | 24 | /* 25 | * Standard gettext macros. 26 | */ 27 | #ifdef ENABLE_NLS 28 | # include 29 | # undef _ 30 | # define _(String) dgettext (PACKAGE, String) 31 | # ifdef gettext_noop 32 | # define N_(String) gettext_noop (String) 33 | # else 34 | # define N_(String) (String) 35 | # endif 36 | #else 37 | # define textdomain(String) (String) 38 | # define gettext(String) (String) 39 | # define dgettext(Domain,Message) (Message) 40 | # define dcgettext(Domain,Message,Type) (Message) 41 | # define bindtextdomain(Domain,Directory) (Domain) 42 | # define _(String) (String) 43 | # define N_(String) (String) 44 | #endif 45 | 46 | 47 | /* 48 | * Public Functions. 49 | */ 50 | 51 | /* 52 | * This function returns a widget in a component created by Glade. 53 | * Call it with the toplevel widget in the component (i.e. a window/dialog), 54 | * or alternatively any widget in the component, and the name of the widget 55 | * you want returned. 56 | */ 57 | GtkWidget* lookup_widget (GtkWidget *widget, 58 | const gchar *widget_name); 59 | 60 | 61 | /* Use this function to set the directory containing installed pixmaps. */ 62 | void __tspi_add_pixmap_directory (const gchar *directory); 63 | 64 | 65 | /* 66 | * Private Functions. 67 | */ 68 | 69 | /* This is used to create the pixmaps used in the interface. */ 70 | GtkWidget* create_pixmap (GtkWidget *widget, 71 | const gchar *filename); 72 | 73 | /* This is used to create the pixbufs used in the interface. */ 74 | GdkPixbuf* create_pixbuf (const gchar *filename); 75 | 76 | /* This is used to set ATK action descriptions. */ 77 | void glade_set_atk_action_description (AtkAction *action, 78 | const gchar *action_name, 79 | const gchar *description); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_GetRandom.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_GetRandom" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_GetRandom \- generate a random number on the TPM 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_GetRandom(TSS_HTPM " hTPM ", UINT32 " size ", BYTE** " random ");" 40 | .fi 41 | .ad 42 | .hy 43 | 44 | .SH "DESCRIPTION" 45 | .PP 46 | \fBTspi_TPM_GetRandom\fR gets a good random number 47 | for the purpose of generating symmetric keys, nonces, or 48 | seeding a random number generator. 49 | 50 | .SH "PARAMETERS" 51 | .PP 52 | .SS hTPM 53 | The \fIhTPM\fR parameter is used to specify the handle of the TPM 54 | object. The command to get the TPM to test itself will be sent here. 55 | .SS size 56 | The \fIsize\fR parameter is the number of random bytes requested. 57 | .SS random 58 | The \fIrandom\fR parameter is a pointer to memory containing the random 59 | data. This is where the generated number goes. Because this internally 60 | allocates memory, Tspi_Context_FreeMemory should also be used. 61 | 62 | .SH "RETURN CODES" 63 | .PP 64 | \fBTspi_TPM_GetRandom\fR returns TSS_SUCCESS on success, otherwise one 65 | of the following values is returned: 66 | .TP 67 | .SM TSS_E_INVALID_HANDLE 68 | \fIhTPM\fR is not a valid handle. 69 | 70 | .TP 71 | .SM TSS_E_INTERNAL_ERROR 72 | An internal SW error has been detected. 73 | 74 | .TP 75 | .SM TSS_E_BAD_PARAMETER 76 | One or more parameters is bad. 77 | 78 | .SH "CONFORMING TO" 79 | 80 | .PP 81 | \fBTspi_TPM_GetRandom\fR conforms to the Trusted Computing Group 82 | Software Specification version 1.1 Golden 83 | 84 | .SH "SEE ALSO" 85 | 86 | .PP 87 | \fBTspi_Context_FreeMemory\fR(3). 88 | 89 | -------------------------------------------------------------------------------- /src/tcs/tcsi_quote2.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "trousers/tss.h" 18 | #include "trousers_types.h" 19 | #include "tcs_tsp.h" 20 | #include "tcsps.h" 21 | #include "tcs_utils.h" 22 | #include "tcs_int_literals.h" 23 | #include "capabilities.h" 24 | #include "tcslog.h" 25 | #include "req_mgr.h" 26 | #include "tcsd_wrap.h" 27 | #include "tcsd.h" 28 | 29 | 30 | TSS_RESULT 31 | TCSP_Quote2_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 32 | TCS_KEY_HANDLE keyHandle, /* in */ 33 | TCPA_NONCE antiReplay, /* in */ 34 | UINT32 pcrDataSizeIn, /* in */ 35 | BYTE * pcrDataIn, /* in */ 36 | TSS_BOOL addVersion, /* in */ 37 | TPM_AUTH * privAuth, /* in, out */ 38 | UINT32 * pcrDataSizeOut, /* out */ 39 | BYTE ** pcrDataOut, /* out */ 40 | UINT32 * versionInfoSize, /* out */ 41 | BYTE ** versionInfo, /* out */ 42 | UINT32 * sigSize, /* out */ 43 | BYTE ** sig) /* out */ 44 | { 45 | UINT64 offset = 0; 46 | UINT32 paramSize; 47 | TSS_RESULT result; 48 | UINT32 keySlot; 49 | 50 | /* Command packet to be sent to the TPM */ 51 | BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 52 | 53 | LogDebug("Entering quote2"); 54 | 55 | if ((result = ctx_verify_context(hContext))) 56 | goto done; 57 | 58 | if (privAuth != NULL) { 59 | LogDebug("Auth Used"); 60 | if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle))) 61 | goto done; 62 | } else { 63 | LogDebug("No Auth"); 64 | } 65 | if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot))) 66 | goto done; 67 | 68 | if ((result = tpm_rqu_build(TPM_ORD_Quote2, &offset, txBlob, keySlot, antiReplay.nonce, 69 | pcrDataSizeIn, pcrDataIn, &addVersion, privAuth))) 70 | goto done; 71 | 72 | if ((result = req_mgr_submit_req(txBlob))) 73 | goto done; 74 | 75 | result = UnloadBlob_Header(txBlob, ¶mSize); 76 | if (!result) { 77 | result = tpm_rsp_parse(TPM_ORD_Quote2, txBlob, paramSize, pcrDataSizeOut, 78 | pcrDataOut, &addVersion, versionInfoSize, versionInfo, 79 | sigSize, sig, privAuth); 80 | } 81 | LogResult("Quote2", result); 82 | done: 83 | auth_mgr_release_auth(privAuth, NULL, hContext); 84 | return result; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/tspi/ssl_ui.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "trousers/tss.h" 8 | #include "spi_utils.h" 9 | 10 | static TSS_RESULT do_ui(BYTE *string, UINT32 *string_len, BYTE *popup, int verify) 11 | { 12 | char pin_buf[UI_MAX_SECRET_STRING_LENGTH + 1]; 13 | char verify_buf[UI_MAX_SECRET_STRING_LENGTH + 1]; 14 | char *popup_nl; 15 | UI *ui; 16 | BYTE *unicode; 17 | TSS_RESULT ret = TSS_E_FAIL; 18 | 19 | popup_nl = malloc(strlen((char *)popup) + 2); 20 | if (!popup_nl) 21 | return TSS_E_OUTOFMEMORY; 22 | 23 | ui = UI_new(); 24 | if (!ui) 25 | goto no_ui; 26 | 27 | sprintf(popup_nl, "%s\n", (char *)popup); 28 | if (!UI_add_info_string(ui, popup_nl)) { 29 | printf("add info fail\n"); 30 | goto out; 31 | } 32 | 33 | /* UI_add_input_string() doesn't count for the null terminator in its last */ 34 | /* parameter, that's why we statically allocated 1 more byte to pin_buf */ 35 | if (!UI_add_input_string(ui, "Enter PIN:", 0, pin_buf, 1, UI_MAX_SECRET_STRING_LENGTH)) { 36 | printf("add input fail\n"); 37 | goto out; 38 | } 39 | 40 | if (verify && 41 | !UI_add_verify_string(ui, "Verify PIN:", 0, verify_buf, 1, UI_MAX_SECRET_STRING_LENGTH, pin_buf)) { 42 | printf("Add verify fail\n"); 43 | goto out; 44 | } 45 | 46 | if (UI_process(ui)) 47 | goto out; 48 | 49 | ret = TSS_SUCCESS; 50 | 51 | unicode = Trspi_Native_To_UNICODE((BYTE *)pin_buf, string_len); 52 | memset(string, 0, UI_MAX_SECRET_STRING_LENGTH); 53 | memcpy(string, unicode, *string_len); 54 | out: 55 | UI_free(ui); 56 | no_ui: 57 | free(popup_nl); 58 | return ret; 59 | } 60 | 61 | /* 62 | * DisplayPINWindow() 63 | * 64 | * Popup the dialog to collect an existing password. 65 | * 66 | * string - buffer that the password will be passed back to caller in 67 | * popup - UTF-8 string to be displayed in the title bar of the dialog box 68 | * 69 | */ 70 | TSS_RESULT DisplayPINWindow(BYTE *string, UINT32 *string_len, BYTE *popup) 71 | { 72 | return do_ui(string, string_len, popup, 0); 73 | } 74 | /* 75 | * DisplayNewPINWindow() 76 | * 77 | * Popup the dialog to collect a new password. 78 | * 79 | * string - buffer that the password will be passed back to caller in 80 | * popup - UTF-8 string to be displayed in the title bar of the dialog box 81 | * 82 | */ 83 | TSS_RESULT DisplayNewPINWindow(BYTE *string, UINT32 *string_len, BYTE *popup) 84 | { 85 | return do_ui(string, string_len, popup, 1); 86 | } 87 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_OwnerGetSRKPubKey.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2007 International Business Machines Corporation 2 | .\" Written by Loulwa Salem based on the Trusted Computing Group Software Stack Specification Version 1.2 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_OwnerGetSRKPubKey" 3 "2007-07-19" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_OwnerGetSRKPubKey \- get public key of the SRK 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .sp 32 | .B "#include " 33 | .B "" 34 | .BI "TSS_RESULT Tspi_TPM_OwnerGetSRKPubKey(TSS_HTPM " hTPM "," 35 | .BI " UINT32* " pulPubKeyLength "," 36 | .BI " BYTE** " prgbPubKey ");" 37 | .fi 38 | .sp 39 | .ad 40 | .hy 41 | 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTspi_TPM_OwnerGetSRKPubKey\fR 45 | returns the public key of the key object using owner authorization. 46 | This can only be used on 1.2 TPMs, and only to return the public key of the SRK. 47 | 48 | .SH "PARAMETERS" 49 | .PP 50 | .SS hTPM 51 | The \fIhTPM\fR parameter is used to specify the handle of the TPM object. 52 | .SS pulPubKeyLength 53 | The \fIpulPubKeyLength\fR parameter is the length (in bytes) of the prgbPubKey parameter. 54 | .SS prgbPubKey 55 | The \fIprgbPubKey\fR parameter is the pointer to the memory block containing the public key blob retrieved for the key object referenced by hKey. 56 | 57 | .SH "RETURN CODES" 58 | .PP 59 | \fBTspi_TPM_OwnerGetSRKPubKey\fR returns TSS_SUCCESS on success, otherwise 60 | one of the following values is returned: 61 | .TP 62 | .SM TSS_E_INVALID_HANDLE 63 | \fIhTPM\fR is not a valid handle. 64 | 65 | .TP 66 | .SM TSS_E_BAD_PARAMETER 67 | One or more parameters is bad. 68 | 69 | .TP 70 | .SM TSS_E_INTERNAL_ERROR 71 | An internal SW error has been detected. 72 | 73 | .TP 74 | .SM TSS_E_TPM_UNSUPPORTED 75 | The TPM is not version 1.2 or later - (Note: still unimplemented) 76 | 77 | .SH "CONFORMING TO" 78 | 79 | .PP 80 | \fBTspi_TPM_OwnerGetSRKPubKey\fR conforms to the Trusted Computing Group 81 | Software Specification version 1.2 82 | 83 | .SH "SEE ALSO" 84 | 85 | .PP 86 | \fBTspi_Context_FreeMemory\fR(3), \fBTspi_Key_GetPubKey\fR(3). 87 | 88 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_PcrRead.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_PcrRead" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_PcrRead \- read the value in a PCR register 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_PcrRead(TSS_HTPM " hTPM ", UINT32 " ulPcrIndex "," 40 | .BI " UINT32* " pulPcrValueLength ", BYTE** " prgbPcrValue ");" 41 | .fi 42 | .sp 43 | .ad 44 | .hy 45 | 46 | .SH "DESCRIPTION" 47 | .PP 48 | \fBTspi_TPM_PcrRead\fR reads a PCR register to find 49 | the current values. 50 | 51 | .SH "PARAMETERS" 52 | .PP 53 | .SS hTPM 54 | The \fIhTPM\fR parameter is used to specify the handle of the TPM 55 | object. The command to get the TPM to test itself will be sent here. 56 | .SS ulPcrIndex 57 | The \fIulPcrIndex\fR parameter is the index of the PCR to read. 58 | .SS pulPcrValueLength 59 | The \fIpulPcrValueLength\fR parameter receives the length in bytes 60 | of the \fIprgbPcrValue\fR parameter. 61 | .SS prgbPcrValue 62 | The \fIprgbPcrValue\fR parameter receives a pointer to the memory 63 | block containing the PCR data. 64 | 65 | .SH "RETURN CODES" 66 | .PP 67 | \fBTspi_TPM_PcrRead\fR returns TSS_SUCCESS on success, otherwise one 68 | of the following values is returned: 69 | .TP 70 | .SM TSS_E_INVALID_HANDLE 71 | \fIhTPM\fR is not a valid handle. 72 | 73 | .TP 74 | .SM TSS_E_INTERNAL_ERROR 75 | An internal SW error has been detected. 76 | 77 | .TP 78 | .SM TSS_E_BAD_PARAMETER 79 | One or more parameters is bad. 80 | 81 | .SH "CONFORMING TO" 82 | 83 | .PP 84 | \fBTspi_TPM_PcrRead\fR conforms to the Trusted Computing Group Software 85 | Specification version 1.1 Golden 86 | 87 | .SH "SEE ALSO" 88 | 89 | .PP 90 | \fBTspi_TPM_PcrExtend\fR(3). 91 | 92 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_SetStatus.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_SetStatus" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_SetStatus \- modify the TPM's status 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_SetStatus(TSS_HTPM " hTPM ", TSS_FLAG " statusFlag "," 40 | .BI " TSS_BOOL " fTpmState ");" 41 | .fi 42 | .sp 43 | .ad 44 | .hy 45 | 46 | .SH "DESCRIPTION" 47 | .PP 48 | \fBTspi_TPM_SetStatus\fR alters the status of the 49 | TPM. Depending on the chosen \fIstatusFlag\fR, \fIfTpmState\fR may 50 | or may not be ignored. This command requires that the TPM be on and 51 | the handle to the TPM available. \fBThis command is not currently 52 | implemented\fR. 53 | 54 | .SH "PARAMETERS" 55 | .PP 56 | .SS hTPM 57 | The \fIhTPM\fR parameter is used to specify the handle of the TPM object. 58 | .SS statusFlag 59 | The \fIstatusFlag\fR parameter is what the TPM status should be set to. 60 | .SS fTpmState 61 | The \fIfTpmState\fR parameter is the status value to set. For some states, 62 | this flag is ignored. 63 | 64 | .SH "RETURN CODES" 65 | .PP 66 | \fBTspi_TPM_SetStatus\fR returns TSS_SUCCESS on success, otherwise 67 | one of the following values is returned: 68 | .TP 69 | .SM TSS_E_INVALID_HANDLE 70 | \fIhTPM\fR is not a valid handle. 71 | 72 | .TP 73 | .SM TSS_E_INTERNAL_ERROR 74 | An internal SW error has been detected. 75 | 76 | .TP 77 | .SM TSS_E_BAD_PARAMETER 78 | One or more parameters is bad. 79 | 80 | .SH "CONFORMING TO" 81 | 82 | .PP 83 | \fBTspi_TPM_SetStatus\fR conforms to the Trusted Computing Group 84 | Software Specification version 1.1 Golden 85 | 86 | .SH "SEE ALSO" 87 | 88 | .PP 89 | \fBTspi_TPM_GetStatus\fR(3), \fBTspi_TPM_GetCapability\fR(3). 90 | 91 | -------------------------------------------------------------------------------- /src/include/daa/daa_parameter.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2006 8 | * 9 | */ 10 | 11 | #ifndef DAA_PARAMETER_H_ 12 | #define DAA_PARAMETER_H_ 13 | 14 | // for message digest 15 | //#include 16 | #include "trousers/tss.h" 17 | //#include "spi_internal_types.h" 18 | #include "spi_utils.h" 19 | 20 | #define DAA_PARAM_TSS_VERSION_LENGTH (4) 21 | static const BYTE DAA_PARAM_TSS_VERSION[] = { 1, 2, 0, 0 }; 22 | 23 | #define DAA_PARAM_DEFAULT_CRYPTO_PROVIDER_NAME "BC" 24 | 25 | // Name of default hash function 26 | #define DAA_PARAM_MESSAGE_DIGEST_ALGORITHM "SHA1" 27 | 28 | // Name of hash function used independently in TSS 29 | #define DAA_PARAM_MESSAGE_DIGEST_ALGORITHM_TSS "SHA1" 30 | 31 | // l_n (bits) 32 | #define DAA_PARAM_SIZE_RSA_MODULUS (2048) 33 | 34 | // l_f (bits) 35 | #define DAA_PARAM_SIZE_F_I (104) 36 | 37 | // l_q (2 * SIZE_F_I) 38 | #define DAA_PARAM_SIZE_RHO (208) 39 | 40 | // l_e 41 | #define DAA_PARAM_SIZE_EXPONENT_CERTIFICATE (368) 42 | 43 | // lPrime_e 44 | #define DAA_PARAM_SIZE_INTERVAL_EXPONENT_CERTIFICATE (120) 45 | 46 | // l_zero 47 | #define DAA_PARAM_SAFETY_MARGIN (80) 48 | 49 | // Byte length of TPM message digest (sha-1) 50 | #define DAA_PARAM_LENGTH_MESSAGE_DIGEST (20) 51 | 52 | // Byte length of TSS message digest (sha-256) 53 | #define DAA_PARAM_LENGTH_MESSAGE_DIGEST_TSS (32) 54 | 55 | // l_H depends on the message digest algo 56 | #define DAA_PARAM_SIZE_MESSAGE_DIGEST (160) 57 | // 8 * LENGTH_MESSAGE_DIGEST; 58 | 59 | // l_GAMMA 60 | #define DAA_PARAM_SIZE_MODULUS_GAMMA (1632) 61 | 62 | #define DAA_PARAM_SIZE_SPLIT_EXPONENT (1024) 63 | 64 | // TPM asym key size (bits) 65 | #define DAA_PARAM_KEY_SIZE (2048) 66 | 67 | // Default RSA public key exponent (Fermat 4) 68 | #define DAA_PARAM_LENGTH_MFG1_ANONYMITY_REVOCATION (25) 69 | // (SIZE_RHO-1)/8; 70 | 71 | #define DAA_PARAM_LENGTH_MFG1_GAMMA (214) 72 | // (SIZE_MODULUS_GAMMA + SIZE_SAFETY_MARGIN)/8; 73 | 74 | #define DAA_PARAM_SIZE_RND_VALUE_CERTIFICATE (2536) 75 | 76 | // (bits) 77 | #define DAA_PARAM_SIZE_RANDOMIZED_ATTRIBUTES (DAA_PARAM_SIZE_F_I+DAA_PARAM_SAFETY_MARGIN+DAA_PARAM_SIZE_MESSAGE_DIGEST) 78 | 79 | #define TSS_FLAG_DAA_SIGN_IDENTITY_KEY 0 80 | #define TSS_FLAG_DAA_SIGN_MESSAGE_HASH 1 81 | 82 | 83 | extern EVP_MD *DAA_PARAM_get_message_digest(void); 84 | 85 | extern char *err_string(TSS_RESULT r); 86 | 87 | #endif /*DAA_PARAMETER_H_*/ 88 | -------------------------------------------------------------------------------- /man/man3/Tspi_Key_CertifyKey.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Key_CertifyKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_Key_CertifyKey \- sign a public key. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_Key_CertifyKey(TSS_HKEY " hKey ", TSS_HKEY " hCertifyingKey "," 38 | .BI " TSS_VALIDATION* " pValidationData ");" 39 | .fi 40 | .sp 41 | .ad 42 | .hy 43 | .SH "DESCRIPTION" 44 | .PP 45 | \fBTspi_Key_CertifyKey\fR signs a public key. 46 | .SH "PARAMETERS" 47 | .PP 48 | .SS hKey 49 | Handle of the key object to be loaded. 50 | .PP 51 | .SS hCertifyingKey 52 | Handle to the certifying key used to sign the addressed by hKey. 53 | .PP 54 | .SS pValidationData 55 | Pointer to a structure of the type TSS_VALIDATION. After successful completion of the call the member rgbValidationData of this structure contains the signature data of the command. The member prgbData of the structure points to a buffer containing a TCPA_CERTIFY_INFO data stream as specified within the TCPA 1.1b Main Specification. 56 | .SH "RETURN CODES" 57 | .PP 58 | \fBTspi_Key_CertifyKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 59 | .TP 60 | .SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR or \fIhCertifyingKey\fR are invalid handles. 61 | .TP 62 | .SM TSS_E_BAD_PARAMETER 63 | .TP 64 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 65 | 66 | .SH "CONFORMING TO" 67 | 68 | .PP 69 | \fBTspi_Key_CertifyKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 70 | .SH "SEE ALSO" 71 | 72 | .PP 73 | \fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_WrapKey\fR(3). 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_CertifySelfTest.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_CertifySelfTest" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_TPM_CertifySelfTest\- have the TPM sign its self test data 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_TPM_CertifySelfTest(TSS_HTPM " hTPM ", TSS_HKEY " hKey "," 38 | .BI " TSS_VALIDATION* " pValidationData " );" 39 | .fi 40 | .sp 41 | .ad 42 | .hy 43 | 44 | .SH "DESCRIPTION" 45 | .PP 46 | \fBTspi_TPM_CertifySelfTest\fR performs a self-test of each internal TPM function and returns an authenticated value (signature) if the test has passed. 47 | .SH "PARAMETERS" 48 | .PP 49 | .SS hTPM 50 | Handle of the TPM object 51 | .PP 52 | .SS hKey 53 | Handle of the signature key object 54 | .PP 55 | .SS 56 | pValidationData 57 | Validation data structure. 58 | [IN] Provide externalData information required to compute the signature. 59 | [OUT] On successful completion of the ocmmand, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed from. 60 | .SH "RETURN CODES" 61 | .PP 62 | \fBTspi_TPM_CertifySelfTest\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 63 | .TP 64 | .SM TSS_E_INVALID_HANDLE 65 | \fBhTPM\fR is not a valid handle to a TPM object. 66 | .TP 67 | .SM TSS_E_INTERNAL_ERROR 68 | An error occurred internal to the TSS. 69 | 70 | .SH "CONFORMING TO" 71 | 72 | .PP 73 | \fBTspi_TPM_CertifySelfTest\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 74 | .SH "SEE ALSO" 75 | 76 | .PP 77 | \fBTspi_TPM_SelfTestFull\fR(3). 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_StirRandom.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_StirRandom" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_StirRandom \- add entropy to the TPM random number generator 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_StirRandom(TSS_HTPM " hTPM ", UINT32 " ulEntropyDataLength ", BYTE* " rgbEntropyData ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_TPM_StirRandom\fR adds entropy to the TPM 48 | random number generator for the purpose of generating better random 49 | numbers. The \fIentropy\fR variable should assigned an appropriately 50 | seeded random number before this function is called. 51 | 52 | .SH "PARAMETERS" 53 | .PP 54 | .SS hTPM 55 | The \fIhTPM\fR parameter is used to specify the handle of the TPM 56 | object. The command to get the TPM to test itself will be sent here. 57 | .SS ulEntropyDataLength 58 | The \fIulEntropyDataLength\fR parameter is the length in bytes of 59 | the \fIrgbEntropyData\fR parameter. 60 | .SS rgbEntropyData 61 | The \fIrgbEntropyData\fR parameter is a pointer to the entropy data. 62 | 63 | .SH "RETURN CODES" 64 | .PP 65 | \fBTspi_TPM_StirRandom\fR returns TSS_SUCCESS on success, otherwise 66 | one of the following values is returned: 67 | .TP 68 | .SM TSS_E_INVALID_HANDLE 69 | \fIhTPM\fR is not a valid handle. 70 | 71 | .TP 72 | .SM TSS_E_INTERNAL_ERROR 73 | An internal SW error has been detected. 74 | 75 | .TP 76 | .SM TSS_E_BAD_PARAMETER 77 | One or more parameters is bad. 78 | 79 | .SH "CONFORMING TO" 80 | 81 | .PP 82 | \fBTspi_TPM_StirRandom\fR conforms to the Trusted Computing Group 83 | Software Specification version 1.1 Golden 84 | 85 | .SH "SEE ALSO" 86 | 87 | .PP 88 | \fBTspi_TPM_GetRandom\fR(3). 89 | 90 | -------------------------------------------------------------------------------- /src/include/obj_encdata.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004-2007 8 | * 9 | */ 10 | 11 | #ifndef _OBJ_ENCDATA_H_ 12 | #define _OBJ_ENCDATA_H_ 13 | 14 | #ifdef TSS_BUILD_ENCDATA_LIST 15 | 16 | /* structures */ 17 | struct tr_encdata_obj { 18 | TSS_HPOLICY usagePolicy; 19 | UINT32 encryptedDataLength; 20 | BYTE *encryptedData; 21 | union { 22 | TPM_PCR_INFO info11; 23 | TPM_PCR_INFO_LONG infolong; 24 | } pcrInfo; 25 | UINT32 pcrInfoType; 26 | UINT32 type; 27 | #ifdef TSS_BUILD_SEALX 28 | UINT32 protectMode; 29 | #endif 30 | }; 31 | 32 | /* obj_encdata.c */ 33 | void encdata_free(void *data); 34 | TSS_BOOL obj_is_encdata(TSS_HOBJECT); 35 | TSS_RESULT obj_encdata_set_policy(TSS_HKEY, TSS_HPOLICY); 36 | TSS_RESULT obj_encdata_set_data(TSS_HENCDATA, UINT32, BYTE *); 37 | TSS_RESULT obj_encdata_remove(TSS_HOBJECT, TSS_HCONTEXT); 38 | TSS_RESULT obj_encdata_get_tsp_context(TSS_HENCDATA, TSS_HCONTEXT *); 39 | TSS_RESULT obj_encdata_add(TSS_HCONTEXT, UINT32, TSS_HOBJECT *); 40 | TSS_RESULT obj_encdata_get_data(TSS_HENCDATA, UINT32 *, BYTE **); 41 | TSS_RESULT obj_encdata_get_pcr_selection(TSS_HENCDATA, TSS_FLAG, TSS_FLAG, UINT32 *, BYTE **); 42 | TSS_RESULT obj_encdata_get_pcr_locality(TSS_HENCDATA, TSS_FLAG, UINT32 *); 43 | TSS_RESULT obj_encdata_get_pcr_digest(TSS_HENCDATA, TSS_FLAG, TSS_FLAG, UINT32 *, BYTE **); 44 | TSS_RESULT obj_encdata_set_pcr_info(TSS_HENCDATA, UINT32, BYTE *); 45 | TSS_RESULT obj_encdata_get_policy(TSS_HENCDATA, UINT32, TSS_HPOLICY *); 46 | void obj_encdata_remove_policy_refs(TSS_HPOLICY, TSS_HCONTEXT); 47 | #ifdef TSS_BUILD_SEALX 48 | TSS_RESULT obj_encdata_set_seal_protect_mode(TSS_HENCDATA, UINT32); 49 | TSS_RESULT obj_encdata_get_seal_protect_mode(TSS_HENCDATA, UINT32 *); 50 | #endif 51 | 52 | 53 | #define ENCDATA_LIST_DECLARE struct obj_list encdata_list 54 | #define ENCDATA_LIST_DECLARE_EXTERN extern struct obj_list encdata_list 55 | #define ENCDATA_LIST_INIT() list_init(&encdata_list) 56 | #define ENCDATA_LIST_CONNECT(a,b) obj_connectContext_list(&encdata_list, a, b) 57 | #define ENCDATA_LIST_CLOSE(a) obj_list_close(&encdata_list, &encdata_free, a) 58 | 59 | #else 60 | 61 | #define obj_is_encdata(a) FALSE 62 | 63 | #define ENCDATA_LIST_DECLARE 64 | #define ENCDATA_LIST_DECLARE_EXTERN 65 | #define ENCDATA_LIST_INIT() 66 | #define ENCDATA_LIST_CONNECT(a,b) 67 | #define ENCDATA_LIST_CLOSE(a) 68 | 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/tspi/tsp_random.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Licensed Materials - Property of IBM 4 | * 5 | * trousers - An open source TCG Software Stack 6 | * 7 | * (C) Copyright International Business Machines Corp. 2004, 2007 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "trousers/tss.h" 17 | #include "trousers/trousers.h" 18 | #include "trousers_types.h" 19 | #include "spi_utils.h" 20 | #include "tsplog.h" 21 | #include "obj.h" 22 | 23 | 24 | #ifdef TSS_BUILD_TRANSPORT 25 | TSS_RESULT 26 | Transport_GetRandom(TSS_HCONTEXT tspContext, /* in */ 27 | UINT32 bytesRequested, /* in */ 28 | BYTE ** randomBytes) /* out */ 29 | { 30 | TSS_RESULT result; 31 | UINT32 decLen = 0; 32 | BYTE *dec = NULL; 33 | UINT64 offset; 34 | TCS_HANDLE handlesLen = 0; 35 | BYTE data[sizeof(UINT32)]; 36 | 37 | if ((result = obj_context_transport_init(tspContext))) 38 | return result; 39 | 40 | LogDebugFn("Executing in a transport session"); 41 | 42 | offset = 0; 43 | Trspi_LoadBlob_UINT32(&offset, bytesRequested, data); 44 | 45 | if ((result = obj_context_transport_execute(tspContext, TPM_ORD_GetRandom, sizeof(data), 46 | data, NULL, &handlesLen, NULL, NULL, NULL, 47 | &decLen, &dec))) 48 | return result; 49 | 50 | *randomBytes = dec; 51 | 52 | return result; 53 | 54 | } 55 | 56 | TSS_RESULT 57 | Transport_StirRandom(TSS_HCONTEXT tspContext, /* in */ 58 | UINT32 inDataSize, /* in */ 59 | BYTE * inData) /* in */ 60 | { 61 | TSS_RESULT result; 62 | UINT64 offset; 63 | UINT32 dataLen; 64 | TCS_HANDLE handlesLen = 0; 65 | BYTE *data; 66 | 67 | if ((result = obj_context_transport_init(tspContext))) 68 | return result; 69 | 70 | LogDebugFn("Executing in a transport session"); 71 | 72 | dataLen = sizeof(UINT32) + inDataSize; 73 | if ((data = malloc(dataLen)) == NULL) { 74 | LogError("malloc of %u bytes failed", dataLen); 75 | return TSPERR(TSS_E_OUTOFMEMORY); 76 | } 77 | 78 | offset = 0; 79 | Trspi_LoadBlob_UINT32(&offset, inDataSize, data); 80 | Trspi_LoadBlob(&offset, inDataSize, data, inData); 81 | 82 | result = obj_context_transport_execute(tspContext, TPM_ORD_StirRandom, dataLen, data, NULL, 83 | &handlesLen, NULL, NULL, NULL, NULL, NULL); 84 | free(data); 85 | 86 | return result; 87 | } 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /man/man3/Tspi_Key_CreateKey.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Key_CreateKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_Key_CreateKey \- create a key pair within the TPM, wrapping it with the key addressed by hWrappingKey. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_Key_CreateKey(TSS_HKEY " hKey ", TSS_HKEY " hWrappingKey ", TSS_HPCRS " hPcrComposite ");" 38 | .fi 39 | .sp 40 | .ad 41 | .hy 42 | .SH "DESCRIPTION" 43 | .PP 44 | \fBTSS_Key_CreateKey\fR 45 | calls the TPM command TPM_CreateWrapKey. If hPcrComposite is not set to NULL, the created key blob is bound to this PCR values. The key object addressed by hKey must contain the key information needed for the creation. 46 | .SH "PARAMETERS" 47 | .PP 48 | .SS hKey 49 | The handle of the key object to create. 50 | .PP 51 | .SS hWrappingKey 52 | The handle to the key used to wrap the newly created key. 53 | .PP 54 | .SS hPcrComposite 55 | The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object. 56 | 57 | .SH "RETURN CODES" 58 | .PP 59 | \fBTspi_Key_CreateKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 60 | .TP 61 | .SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR, \fIhWrappingKey\fR or \fIhPcrComposite\fR are invalid parameters. 62 | .TP 63 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 64 | .SH "CONFORMING TO" 65 | 66 | .PP 67 | \fBTspi_Key_CreateKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 68 | .SH "SEE ALSO" 69 | 70 | .PP 71 | \fBTspi_Key_WrapKey\fR(3), \fBTspi_Key_CertifyKey\fR(3), \fBTspi_Key_RegisterKey\fR(3). 72 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_ClearOwner.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_ClearOwner" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developer's Reference 25 | .SH NAME 26 | Tspi_TPM_ClearOwner \- clear TPM ownership 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_TPM_ClearOwner(TSS_HTPM " hTPM ", TSS_BOOL " fForcedClear ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_TPM_ClearOwner\fR 48 | wipes the TPM of everything but its endorsement key. It will wipe the SRK, so 49 | anything locked to the SRK will also disappear when this command is executed. 50 | This is the only way to be certain that keys are gone, as it is the only way 51 | to guarantee that nothing can keep a copy of the key. You must assert either 52 | physical presence or owner authorization in order to use this command. 53 | 54 | .SH "PARAMETERS" 55 | .PP 56 | .SS hTPM 57 | The \fIhTPM\fR parameter is used to specify the handle of the TPM object. 58 | .SS fForcedClear 59 | The \fIfForcedClear\fR parameter is used to tell whether this command is being 60 | executed with owner authorization or with physical presence. If FALSE, then 61 | TPM owner authorization is used. If TRUE, then physical presence is required 62 | to clear the TPM. 63 | 64 | .SH "RETURN CODES" 65 | .PP 66 | \fBTspi_TPM_ClearOwner\fR returns TSS_SUCCESS on success, otherwise one of the 67 | following values is returned: 68 | .TP 69 | .SM TSS_E_INVALID_HANDLE 70 | \fIhTPM\fR is not a valid handle. 71 | 72 | .TP 73 | .SM TSS_E_INTERNAL_ERROR 74 | An internal SW error has been detected. 75 | 76 | .SH "CONFORMING TO" 77 | 78 | .PP 79 | \fBTspi_TPM_ClearOwner\fR conforms to the Trusted Computing Group 80 | Software Specification version 1.1 Golden 81 | 82 | .SH "SEE ALSO" 83 | 84 | .PP 85 | \fBTspi_TPM_TakeOwnership\fR(3) 86 | -------------------------------------------------------------------------------- /man/man3/Tspi_TPM_Quote.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Kathy Robertson based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_TPM_Quote" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference" 23 | .SH NAME 24 | Tspi_TPM_Quote \- retreive a signed set of PCR values. 25 | .SH "SYNOPSIS" 26 | .ad l 27 | .hy 0 28 | .nf 29 | .B #include 30 | .B #include 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .sp 37 | .BI "TSS_RESULT Tspi_TPM_Quote(TSS_HTPM " hTPM ", TSS_HKEY " hIdentKey "," 38 | .BI " TSS_HPCRS " hPcrComposite ", TSS_VALIDATION* " pValidationData ");" 39 | .fi 40 | .sp 41 | .ad 42 | .hy 43 | .SH "DESCRIPTION" 44 | .PP 45 | \fBTspi_TPM_Quote\fR destroys a context by passing in the handle to that context. 46 | .SH "PARAMETERS" 47 | .PP 48 | .SS hTPM 49 | Handle of the TPM object. 50 | .PP 51 | .SS hIdentKey 52 | Handle of the signature key object. 53 | .PP 54 | .SS hPcrComposite 55 | Handle of the PCR composite object 56 | .PP 57 | .SS pValidationData 58 | Validation data structure 59 | [IN] Provide externalData information required to compute the signature. 60 | [OUT] On successful completion of the command, the structure provides a buffer containing the validation data and a buffer containing the data the validation data was computed form. 61 | .PP 62 | 63 | .SH "RETURN CODES" 64 | .PP 65 | \fBTspi_TPM_Quote\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned: 66 | .TP 67 | .SM TSS_E_INVALID_HANDLE - \fIhTPM\fR, \fIhIdentKey\fR or \fIhPcrComposite\fR is not a valid handle. 68 | .TP 69 | .SM TSS_E_BAD_PARAMETER 70 | .TP 71 | .SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS. 72 | 73 | .SH "CONFORMING TO" 74 | 75 | .PP 76 | \fBTspi_TPM_Quote\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden 77 | .SH "SEE ALSO" 78 | 79 | .PP 80 | \fB(none)\fR. 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /man/man3/Tspi_Policy_AssignToObject.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2004 International Business Machines Corporation 2 | .\" Written by Megan Schneider based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden 3 | .\" 4 | .de Sh \" Subsection 5 | .br 6 | .if t .Sp 7 | .ne 5 8 | .PP 9 | \fB\\$1\fR 10 | .PP 11 | .. 12 | .de Sp \" Vertical space (when we can't use .PP) 13 | .if t .sp .5v 14 | .if n .sp 15 | .. 16 | .de Ip \" List item 17 | .br 18 | .ie \\n(.$>=3 .ne \\$3 19 | .el .ne 3 20 | .IP "\\$1" \\$2 21 | .. 22 | .TH "Tspi_Policy_AssignToObject" 3 "2004-05-25" "TSS 1.1" 23 | .ce 1 24 | TCG Software Stack Developers Reference 25 | .SH NAME 26 | Tspi_Policy_AssignToObject \- assign a policy to an object 27 | .SH "SYNOPSIS" 28 | .ad l 29 | .hy 0 30 | .nf 31 | .B #include 32 | .B #include 33 | .B #include 34 | .B #include 35 | .B #include 36 | .B #include 37 | .B #include 38 | .sp 39 | .BI "TSS_RESULT Tspi_Policy_AssignToObject(TSS_HPOLICY " hPolicy ", TSS_HOBJECT " hObject ");" 40 | .fi 41 | .sp 42 | .ad 43 | .hy 44 | 45 | .SH "DESCRIPTION" 46 | .PP 47 | \fBTspi_Policy_AssignToObject\fR assigns a given object 48 | to a certain policy. The object then uses its assigned policy to process 49 | an authorized TPM command. When each new object is initialized, it is 50 | assigned to the default policy, which is created when a context object 51 | is created. When an object is assigned to a policy, a reference is added 52 | to the list of assigned objects stored in the policy, and a reference 53 | to the policy is stored in the object by internal object functions. 54 | 55 | .SH "PARAMETERS" 56 | .PP 57 | .SS hPolicy 58 | The \fIhPolicy\fR parameter is the handle of the policy object to be 59 | assigned to. 60 | .SS hObject 61 | The \fIhObject\fR parameter is the object that will be assigned to 62 | \fIhPolicy\fR. 63 | 64 | .SH "RETURN CODES" 65 | .PP 66 | \fBTspi_Policy_AssignToObject\fR returns TSS_SUCCESS on success, otherwise 67 | one of the following values is returned: 68 | .TP 69 | .SM TSS_E_INVALID_HANDLE 70 | \fIhPolicy\fR is not a valid handle. 71 | 72 | .TP 73 | .SM TSS_E_INTERNAL_ERROR 74 | An internal SW error has been detected. 75 | 76 | .SH "CONFORMING TO" 77 | 78 | .PP 79 | \fBTspi_Policy_AssignToObject\fR conforms to the Trusted Computing Group 80 | Software Specification version 1.1 Golden 81 | 82 | .SH "SEE ALSO" 83 | 84 | .PP 85 | \fBTspi_Policy_SetSecret\fR(3), \fBTspi_Policy_FlushSecret\fR(3). 86 | 87 | --------------------------------------------------------------------------------