Hi Roberto,

Essentially, the Trspi functions shouldn't be exported directly, but through 
the Tspi layer instead. There will be a TSSWG conference call tomorrow, I'll 
propose to place such functions' mappings in the Tspi layer.

The previous patches (1 to 5) look good, applying them in a few.

Thanks,
---
Rajiv Andrade
Security Development
IBM Linux Technology Center



On Sep 7, 2010, at 3:05 PM, Roberto Sassu wrote:

> From: Giovanni Cabiddu <[email protected]>
> 
> This patch permits to export the Trsp functions Trspi_Error_String,
> Trspi_Error_Layer and TSS_RESULT Trspi_Error_Code when TrouSerS is 
> cross-compiled for the windows architecture.
> 
> 
> Signed-off-by: Roberto Sassu <[email protected]>
> ---
> src/include/trousers/trousers.h |   19 ++++++++++++++++---
> src/trspi/Makefile.am           |    2 +-
> src/trspi/trousers.c            |    6 +++---
> 3 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/src/include/trousers/trousers.h b/src/include/trousers/trousers.h
> index 39d8787..c73b83f 100644
> --- a/src/include/trousers/trousers.h
> +++ b/src/include/trousers/trousers.h
> @@ -11,6 +11,19 @@
> #ifndef _TROUSERS_H_
> #define _TROUSERS_H_
> 
> +#if !defined( TRSPICALL )
> +     #if !defined(WIN32) || defined (TRSP_STATIC)
> +     // Linux, or a Win32 static library
> +             #define TRSPICALL extern
> +     #elif defined (TRSPDLL_EXPORTS)
> +     // Win32 DLL build
> +             #define TRSPICALL extern __declspec(dllexport)
> +     #else
> +     // Win32 DLL import
> +             #define TRSPICALL extern __declspec(dllimport) 
> +     #endif
> +#endif /* TSPICALL */
> +
> #ifdef __cplusplus
> extern "C" {
> #endif
> @@ -251,13 +264,13 @@ BYTE *Trspi_UNICODE_To_Native(BYTE *string, unsigned 
> *len);
> /* Error Functions */
> 
> /* return a human readable string based on the result */
> -char *Trspi_Error_String(TSS_RESULT);
> +TRSPICALL char *Trspi_Error_String(TSS_RESULT);
> 
> /* return a human readable error layer ( "tpm", "tddl", etc...) */
> -char *Trspi_Error_Layer(TSS_RESULT);
> +TRSPICALL char *Trspi_Error_Layer(TSS_RESULT);
> 
> /* return just the error code bits of the result */
> -TSS_RESULT Trspi_Error_Code(TSS_RESULT);
> +TRSPICALL TSS_RESULT Trspi_Error_Code(TSS_RESULT);
> 
> #ifdef __cplusplus
> }
> diff --git a/src/trspi/Makefile.am b/src/trspi/Makefile.am
> index 300e492..dac2ed8 100644
> --- a/src/trspi/Makefile.am
> +++ b/src/trspi/Makefile.am
> @@ -1,7 +1,7 @@
> noinst_LTLIBRARIES=libtrousers.la
> 
> libtrousers_la_SOURCES=trousers.c crypto/@CRYPTO_PACKAGE@/hash.c
> -libtrousers_la_CFLAGS=-DAPPID=\"TSPI\" -I${top_srcdir}/src/include
> +libtrousers_la_CFLAGS=-DAPPID=\"TSPI\" -I${top_srcdir}/src/include 
> -DTRSPDLL_EXPORTS
> 
> if TSS_BUILD_ASYM_CRYPTO
> libtrousers_la_SOURCES+=crypto/@CRYPTO_PACKAGE@/rsa.c
> diff --git a/src/trspi/trousers.c b/src/trspi/trousers.c
> index e4007a8..79450b4 100644
> --- a/src/trspi/trousers.c
> +++ b/src/trspi/trousers.c
> @@ -1231,7 +1231,7 @@ Trspi_LoadBlob_BOUND_DATA(UINT64 *offset, 
> TCPA_BOUND_DATA bd, UINT32 payloadLeng
> }
> 
> /* function to mimic strerror with TSS error codes */
> -char *
> +TRSPICALL char *
> Trspi_Error_String(TSS_RESULT r)
> {
>       /* Check the return code to see if it is common to all layers.
> @@ -1450,7 +1450,7 @@ Trspi_Error_String(TSS_RESULT r)
>       }
> }
> 
> -char *
> +TRSPICALL char *
> Trspi_Error_Layer(TSS_RESULT r)
> {
>       switch (TSS_ERROR_LAYER(r)) {
> @@ -1462,7 +1462,7 @@ Trspi_Error_Layer(TSS_RESULT r)
>       }
> }
> 
> -TSS_RESULT
> +TRSPICALL TSS_RESULT
> Trspi_Error_Code(TSS_RESULT r)
> {
>       return TSS_ERROR_CODE(r);
> -- 
> 1.7.2.2
> 
> 
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
> 
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> TrouSerS-tech mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/trousers-tech


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to