Discussion:
[TrouSerS-users] Can TPM unbind data encrypted outside TPM?
Shu Zhang
2013-07-17 01:10:10 UTC
Permalink
Hello trousers users,

I'd like to send a secret securely from a server to a client with TPM
and make sure only the client with the TPM can get the secret. I
wonder if something like this would work:

1. generate and register an RSA key pair on the client's TPM, copy its
UUID as well as its public key to the server

2. when the connection between the client and server is established,
the server encrypts the secret using the TPM public key, sends the
encrypted secret and the UUID of the TPM key to the client

3. the client's TPM loads the TPM key using the UUID and unbinds the
encrypted secret

I understand Tspi_Data_Unbind can unbind data encrypted with
Tspi_Data_Bind using the same key, but would it also work with data
encrypted outside TPM? I'm guessing if the same decryption algorithm
is used as the encryption, then it would, but I don't know much about
RSA.

Thank you.

Shu
Bruce Lin
2013-07-17 01:52:27 UTC
Permalink
Post by Shu Zhang
Hello trousers users,
I'd like to send a secret securely from a server to a client with TPM
and make sure only the client with the TPM can get the secret. I
1. generate and register an RSA key pair on the client's TPM, copy its
UUID as well as its public key to the server
hi,shu!
I use the trousers not long too. Last time i do something like what you do.
the server just needs the pubkey to encrypt.Use the RSA_public_encrypt
from openssl,and use RSA_padding_add_PKCS1_OAEP to
set 'TCPA' padding before encrypt. And the client use the Tspi_Data_Unbind
to decrypt.
I hope it may help.
Bruce
Post by Shu Zhang
2. when the connection between the client and server is established,
the server encrypts the secret using the TPM public key, sends the
encrypted secret and the UUID of the TPM key to the client
3. the client's TPM loads the TPM key using the UUID and unbinds the
encrypted secret
I understand Tspi_Data_Unbind can unbind data encrypted with
Tspi_Data_Bind using the same key, but would it also work with data
encrypted outside TPM? I'm guessing if the same decryption algorithm
is used as the encryption, then it would, but I don't know much about
RSA.
Thank you.
Shu
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
Shu Zhang
2013-07-17 02:11:49 UTC
Permalink
Hi Bruce,

Thank you for your reply. Good to know you've got it to work! I'll
also give it a try!

What TPM chip are you using? I'm using a lenovo T530 and I hope mine
will just work with your instructions.

And just curious, it this a part of the TPM spec or it just happened to work.

Thanks!

Shu
Post by Bruce Lin
Post by Shu Zhang
Hello trousers users,
I'd like to send a secret securely from a server to a client with TPM
and make sure only the client with the TPM can get the secret. I
1. generate and register an RSA key pair on the client's TPM, copy its
UUID as well as its public key to the server
hi,shu!
I use the trousers not long too. Last time i do something like what you do.
the server just needs the pubkey to encrypt.Use the RSA_public_encrypt
from openssl,and use RSA_padding_add_PKCS1_OAEP to
set 'TCPA' padding before encrypt. And the client use the Tspi_Data_Unbind
to decrypt.
I hope it may help.
Bruce
Post by Shu Zhang
2. when the connection between the client and server is established,
the server encrypts the secret using the TPM public key, sends the
encrypted secret and the UUID of the TPM key to the client
3. the client's TPM loads the TPM key using the UUID and unbinds the
encrypted secret
I understand Tspi_Data_Unbind can unbind data encrypted with
Tspi_Data_Bind using the same key, but would it also work with data
encrypted outside TPM? I'm guessing if the same decryption algorithm
is used as the encryption, then it would, but I don't know much about
RSA.
Thank you.
Shu
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
Olga Chen
2013-07-17 12:55:27 UTC
Permalink
That should work. The whole point of using a binding key is that the data
can be encrypted outside the TPM, but decrypted inside.

-- per aspera ad astra --
Post by Shu Zhang
Hello trousers users,
I'd like to send a secret securely from a server to a client with TPM
and make sure only the client with the TPM can get the secret. I
1. generate and register an RSA key pair on the client's TPM, copy its
UUID as well as its public key to the server
2. when the connection between the client and server is established,
the server encrypts the secret using the TPM public key, sends the
encrypted secret and the UUID of the TPM key to the client
3. the client's TPM loads the TPM key using the UUID and unbinds the
encrypted secret
I understand Tspi_Data_Unbind can unbind data encrypted with
Tspi_Data_Bind using the same key, but would it also work with data
encrypted outside TPM? I'm guessing if the same decryption algorithm
is used as the encryption, then it would, but I don't know much about
RSA.
Thank you.
Shu
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
Shu Zhang
2013-07-17 21:36:46 UTC
Permalink
Thank you, Olga.

Is there any *working* sample code for binding and unbinding data in
TPM? I've looked for a while but haven't got any luck so far.

Shu
Post by Olga Chen
That should work. The whole point of using a binding key is that the data
can be encrypted outside the TPM, but decrypted inside.
-- per aspera ad astra --
Post by Shu Zhang
Hello trousers users,
I'd like to send a secret securely from a server to a client with TPM
and make sure only the client with the TPM can get the secret. I
1. generate and register an RSA key pair on the client's TPM, copy its
UUID as well as its public key to the server
2. when the connection between the client and server is established,
the server encrypts the secret using the TPM public key, sends the
encrypted secret and the UUID of the TPM key to the client
3. the client's TPM loads the TPM key using the UUID and unbinds the
encrypted secret
I understand Tspi_Data_Unbind can unbind data encrypted with
Tspi_Data_Bind using the same key, but would it also work with data
encrypted outside TPM? I'm guessing if the same decryption algorithm
is used as the encryption, then it would, but I don't know much about
RSA.
Thank you.
Shu
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
Olga Chen
2013-07-25 15:32:09 UTC
Permalink
I thought there were examples in "A Practical Guide to Trusted Computing"
by D. Challener, et. al (ISBN 978-0132398428). Also there is a Programming
with TrouSerS tutorial from Trusted Infrastructure Workshop available
online: www.cylab.cmu.edu/tiw/slides/challener-handout.pdf. It has
bind/unbind examples.

-- per aspera ad astra --
Post by Shu Zhang
Thank you, Olga.
Is there any *working* sample code for binding and unbinding data in
TPM? I've looked for a while but haven't got any luck so far.
Shu
Post by Olga Chen
That should work. The whole point of using a binding key is that the data
can be encrypted outside the TPM, but decrypted inside.
-- per aspera ad astra --
Post by Shu Zhang
Hello trousers users,
I'd like to send a secret securely from a server to a client with TPM
and make sure only the client with the TPM can get the secret. I
1. generate and register an RSA key pair on the client's TPM, copy its
UUID as well as its public key to the server
2. when the connection between the client and server is established,
the server encrypts the secret using the TPM public key, sends the
encrypted secret and the UUID of the TPM key to the client
3. the client's TPM loads the TPM key using the UUID and unbinds the
encrypted secret
I understand Tspi_Data_Unbind can unbind data encrypted with
Tspi_Data_Bind using the same key, but would it also work with data
encrypted outside TPM? I'm guessing if the same decryption algorithm
is used as the encryption, then it would, but I don't know much about
RSA.
Thank you.
Shu
------------------------------------------------------------------------------
Post by Olga Chen
Post by Shu Zhang
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
Post by Olga Chen
Post by Shu Zhang
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
Lucas Magasweran
2015-08-10 21:18:56 UTC
Permalink
Post by Shu Zhang
Is there any *working* sample code for binding and unbinding data in
TPM? I've looked for a while but haven't got any luck so far.
In addition the documentation referenced by Olga, you'll need the following.

// create a TPM Bind Key using the PKCS#1 OAEP SHA-1 encryption scheme

Tspi_SetAttribUint32(hBind_Key, TSS_TSPATTRIB_KEY_INFO,
TSS_TSPATTRIB_KEYINFO_ENCSCHEME, TSS_ES_RSAESOAEP_SHA1_MGF1);

// extract the modulus and exponent to create the RSA PEM public key
// using PEM_write_bio_RSA_PUBKEY() from OpenSSL

Tspi_GetAttribData(hBind_Key, TSS_TSPATTRIB_RSAKEY_INFO,
TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, &m_size, &m);
Tspi_GetAttribData(hBind_Key, TSS_TSPATTRIB_RSAKEY_INFO,
TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT, &e_size, &e);

// when encrypting with the public key using OpenSSL, add the
// TPM_BOUND_DATA header and TPM padding

unsigned char *input_wrapped = malloc(input_wrapped_length);
TPM_BOUND_DATA tpm_bound_data_header = {
{0x01, 0x01, 0x00, 0x00},
TPM_PT_BIND,
0
};
memcpy(input_wrapped, &tpm_bound_data_header, sizeof(TPM_BOUND_DATA));
memcpy(input_wrapped + 5, input, input_length);

unsigned char input_wrapped_padded[256] = {'\0'};
const unsigned char oaep_pad[] = "TCPA";
int rsa_status = RSA_padding_add_PKCS1_OAEP(
input_wrapped_padded, RSA_size(rsa),
input_wrapped, input_wrapped_length,
oaep_pad, strlen((const char *)oaep_pad));

// TODO seed random number generator
RSA_public_encrypt(RSA_size(rsa), input_wrapped_padded, output,
rsa, RSA_NO_PADDING);

Good luck!



------------------------------------------------------------------------------
Olga Chen
2013-07-26 11:37:44 UTC
Permalink
Yes I forgot to mention the TrouSerS test suite. It's available on sourceforge.
Date: July 25, 2013, 20:34:13 EDT
Subject: Re: [TrouSerS-users] Can TPM unbind data encrypted outside TPM?
I should mention that the test code that comes with trousers has working examples of virtually everything.... Kent Yoder wrote most of that I think.
I thought there were examples in "A Practical Guide to Trusted Computing" by D. Challener, et. al (ISBN 978-0132398428). Also there is a Programming with TrouSerS tutorial from Trusted Infrastructure Workshop available online: www.cylab.cmu.edu/tiw/slides/challener-handout.pdf. It has bind/unbind examples.
-- per aspera ad astra --
Post by Shu Zhang
Thank you, Olga.
Is there any *working* sample code for binding and unbinding data in
TPM? I've looked for a while but haven't got any luck so far.
Shu
Loading...