GnuTLS (tpmtools) api for signing data in a TPM












1














Recently I started working with a TPM (version 1.2), and after checking the oficial GnuTLS API, I was wondering which API functions are the correct ones to do all the crypto stuff inside the chip (sign certificates get pk+ keys etc...).



At the moment Im able of getting this data outside of the TPM so I can sign or get a private key in my C code but thats not what I want.



Thank all!










share|improve this question


















  • 1




    You can't get private keys out of the TPM.
    – James K Polk
    Nov 24 '18 at 20:58
















1














Recently I started working with a TPM (version 1.2), and after checking the oficial GnuTLS API, I was wondering which API functions are the correct ones to do all the crypto stuff inside the chip (sign certificates get pk+ keys etc...).



At the moment Im able of getting this data outside of the TPM so I can sign or get a private key in my C code but thats not what I want.



Thank all!










share|improve this question


















  • 1




    You can't get private keys out of the TPM.
    – James K Polk
    Nov 24 '18 at 20:58














1












1








1







Recently I started working with a TPM (version 1.2), and after checking the oficial GnuTLS API, I was wondering which API functions are the correct ones to do all the crypto stuff inside the chip (sign certificates get pk+ keys etc...).



At the moment Im able of getting this data outside of the TPM so I can sign or get a private key in my C code but thats not what I want.



Thank all!










share|improve this question













Recently I started working with a TPM (version 1.2), and after checking the oficial GnuTLS API, I was wondering which API functions are the correct ones to do all the crypto stuff inside the chip (sign certificates get pk+ keys etc...).



At the moment Im able of getting this data outside of the TPM so I can sign or get a private key in my C code but thats not what I want.



Thank all!







security cryptography tpm gnutls






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 16:28









Arraiz

175




175








  • 1




    You can't get private keys out of the TPM.
    – James K Polk
    Nov 24 '18 at 20:58














  • 1




    You can't get private keys out of the TPM.
    – James K Polk
    Nov 24 '18 at 20:58








1




1




You can't get private keys out of the TPM.
– James K Polk
Nov 24 '18 at 20:58




You can't get private keys out of the TPM.
– James K Polk
Nov 24 '18 at 20:58












1 Answer
1






active

oldest

votes


















2














The sequence of events is something like this:




  1. Invoke gnutls_tpm_key_list_get_url to get the list of the TPM keys.

  2. Choose the key you want to sign with from the list and import it with gnutls_privkey_import_tpm_url.

  3. Now you have the gnutls_privkey_t object you can use with the abstract API just like any other key. In your case, you probably want to use gnutls_privkey_sign_data or one of the similar signing functions.


Keep in mind that going with this approach limits you to TPM 1.2. From GnuTLS docs:




Note that we recommend against using TPM with this API because it is
restricted to TPM 1.2. We recommend instead to use PKCS#11 wrappers
for TPM such as CHAPS14 or opencryptoki15. These will allow using the
standard smart card and HSM functionality (see Smart cards and HSMs)
for TPM keys.







share|improve this answer





















  • thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
    – Arraiz
    Nov 24 '18 at 10:41








  • 2




    @Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
    – mnistic
    Nov 24 '18 at 15:52










  • thanks a lot for the help!! saved my life
    – Arraiz
    Nov 27 '18 at 12:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450131%2fgnutls-tpmtools-api-for-signing-data-in-a-tpm%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














The sequence of events is something like this:




  1. Invoke gnutls_tpm_key_list_get_url to get the list of the TPM keys.

  2. Choose the key you want to sign with from the list and import it with gnutls_privkey_import_tpm_url.

  3. Now you have the gnutls_privkey_t object you can use with the abstract API just like any other key. In your case, you probably want to use gnutls_privkey_sign_data or one of the similar signing functions.


Keep in mind that going with this approach limits you to TPM 1.2. From GnuTLS docs:




Note that we recommend against using TPM with this API because it is
restricted to TPM 1.2. We recommend instead to use PKCS#11 wrappers
for TPM such as CHAPS14 or opencryptoki15. These will allow using the
standard smart card and HSM functionality (see Smart cards and HSMs)
for TPM keys.







share|improve this answer





















  • thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
    – Arraiz
    Nov 24 '18 at 10:41








  • 2




    @Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
    – mnistic
    Nov 24 '18 at 15:52










  • thanks a lot for the help!! saved my life
    – Arraiz
    Nov 27 '18 at 12:48
















2














The sequence of events is something like this:




  1. Invoke gnutls_tpm_key_list_get_url to get the list of the TPM keys.

  2. Choose the key you want to sign with from the list and import it with gnutls_privkey_import_tpm_url.

  3. Now you have the gnutls_privkey_t object you can use with the abstract API just like any other key. In your case, you probably want to use gnutls_privkey_sign_data or one of the similar signing functions.


Keep in mind that going with this approach limits you to TPM 1.2. From GnuTLS docs:




Note that we recommend against using TPM with this API because it is
restricted to TPM 1.2. We recommend instead to use PKCS#11 wrappers
for TPM such as CHAPS14 or opencryptoki15. These will allow using the
standard smart card and HSM functionality (see Smart cards and HSMs)
for TPM keys.







share|improve this answer





















  • thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
    – Arraiz
    Nov 24 '18 at 10:41








  • 2




    @Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
    – mnistic
    Nov 24 '18 at 15:52










  • thanks a lot for the help!! saved my life
    – Arraiz
    Nov 27 '18 at 12:48














2












2








2






The sequence of events is something like this:




  1. Invoke gnutls_tpm_key_list_get_url to get the list of the TPM keys.

  2. Choose the key you want to sign with from the list and import it with gnutls_privkey_import_tpm_url.

  3. Now you have the gnutls_privkey_t object you can use with the abstract API just like any other key. In your case, you probably want to use gnutls_privkey_sign_data or one of the similar signing functions.


Keep in mind that going with this approach limits you to TPM 1.2. From GnuTLS docs:




Note that we recommend against using TPM with this API because it is
restricted to TPM 1.2. We recommend instead to use PKCS#11 wrappers
for TPM such as CHAPS14 or opencryptoki15. These will allow using the
standard smart card and HSM functionality (see Smart cards and HSMs)
for TPM keys.







share|improve this answer












The sequence of events is something like this:




  1. Invoke gnutls_tpm_key_list_get_url to get the list of the TPM keys.

  2. Choose the key you want to sign with from the list and import it with gnutls_privkey_import_tpm_url.

  3. Now you have the gnutls_privkey_t object you can use with the abstract API just like any other key. In your case, you probably want to use gnutls_privkey_sign_data or one of the similar signing functions.


Keep in mind that going with this approach limits you to TPM 1.2. From GnuTLS docs:




Note that we recommend against using TPM with this API because it is
restricted to TPM 1.2. We recommend instead to use PKCS#11 wrappers
for TPM such as CHAPS14 or opencryptoki15. These will allow using the
standard smart card and HSM functionality (see Smart cards and HSMs)
for TPM keys.








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 17:59









mnistic

7,0981821




7,0981821












  • thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
    – Arraiz
    Nov 24 '18 at 10:41








  • 2




    @Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
    – mnistic
    Nov 24 '18 at 15:52










  • thanks a lot for the help!! saved my life
    – Arraiz
    Nov 27 '18 at 12:48


















  • thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
    – Arraiz
    Nov 24 '18 at 10:41








  • 2




    @Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
    – mnistic
    Nov 24 '18 at 15:52










  • thanks a lot for the help!! saved my life
    – Arraiz
    Nov 27 '18 at 12:48
















thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
– Arraiz
Nov 24 '18 at 10:41






thanks you very much for answering, but that sequence needs to store the key somewhere in the memory (under gnutls_privkey_t ) and that something I need to avoid, what I was looking for is something like 1º get the data i want to sign/encrypt.... 2º tell the GnuTLS to sign that data with this key referenced by some "uuiid" calling something like gnutls_tpm_crypto_stuff(uuid_of_the_key,&data_i_want_to_sign) thanks for telling about chaps and opencryptoki15 going to check it
– Arraiz
Nov 24 '18 at 10:41






2




2




@Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
– mnistic
Nov 24 '18 at 15:52




@Arraiz I'm not sure what the problem is, but if your'e concerned that sensitive information about the key is somehow stored in gnutls_privkey_t -- there's no reason to be. The private key will never leave the TPM, because it can't. The only thing that's stored in gnutls_privkey_t is the TSS context, that allows the TSS to communicate with the TPM and identify the key (including the UUID).
– mnistic
Nov 24 '18 at 15:52












thanks a lot for the help!! saved my life
– Arraiz
Nov 27 '18 at 12:48




thanks a lot for the help!! saved my life
– Arraiz
Nov 27 '18 at 12:48


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450131%2fgnutls-tpmtools-api-for-signing-data-in-a-tpm%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks