Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: import of TPM keys #140

Closed
wants to merge 1 commit into from

Conversation

t-higuchi
Copy link
Contributor

I have merged AndreasFuchsTPM@7f35306 , removed -j option, and fixed testcases so that they works with tpm2-tools 3.2.1-rc0.

I confirmed that existing openssl-generated RSA keys can be imported with tpm2-tools-4.0-rc0 in this way:

tpm2_createprimary -C o -g sha256 -G ecc -a "fixedtpm|fixedparent|sensitivedataorigin|noda|decrypt|restricted|userwithauth" -c primary.ctx
tpm2_import -G rsa -g sha256 -i rsakey.pem -C primary.ctx -u tpmkey.pub -r tpmkey.priv
tpm2tss-genkey -i tpmkey.pub -k tpmkey.priv rsakey.tss

I did not added testcase for this though since it requires migration to tpm2-tools-4.0, which breaks other testcases.
so Issue #39 could be closed after migration to tpm2-tools-4.0.

Signed-off-by: Andreas Fuchs <[email protected]>
@codecov
Copy link

codecov bot commented Aug 28, 2019

Codecov Report

Merging #140 into master will increase coverage by 0.13%.
The diff coverage is 72.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #140      +/-   ##
==========================================
+ Coverage   67.34%   67.47%   +0.13%     
==========================================
  Files           9        9              
  Lines        1228     1276      +48     
==========================================
+ Hits          827      861      +34     
- Misses        401      415      +14     
Impacted Files Coverage Δ
src/tpm2-tss-engine-common.c 77.35% <65.62%> (-1.48%) ⬇️
src/tpm2tss-genkey.c 60.00% <83.33%> (+2.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d04c6ec...32f53d7. Read the comment docs.

Copy link
Member

@AndreasFuchsTPM AndreasFuchsTPM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for picking up that work !!!

Some minor things in comments below...

@@ -199,6 +213,12 @@ parse_opts(int argc, char **argv)
ERR("%s", help);
exit(1);
}

if (opt.importpub && !opt.importtpm) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( ... || (!opt.importpub && opt.importtpm))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (a != b)

* @retval 1 on success
* @retval 0 on failure
*/
//TODO: all the Errors !!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's done ?

* Read a tpm key as marshaled TPM2B_PUBLIC and (encrypted) TPM2B_PRIVATE from
* disk and convert them into a TPM2_DATA representation
* @param filename The filename to read the data from.
* @param tpm2Datap The data after read.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing parameters...

return 0;
}

tpm2data = OPENSSL_malloc(sizeof(TPM2_DATA));

This comment was marked as resolved.

This comment was marked as resolved.

}

tpm2data = OPENSSL_malloc(sizeof(TPM2_DATA));
if (!tpm2data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation issue.

@@ -199,6 +213,12 @@ parse_opts(int argc, char **argv)
ERR("%s", help);
exit(1);
}

if (opt.importpub && !opt.importtpm) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (a != b)

@@ -199,6 +213,12 @@ parse_opts(int argc, char **argv)
ERR("%s", help);
exit(1);
}

if (opt.importpub && !opt.importtpm) {
ERR("--importpub requires --importtpm");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this limitation? Can't we just import a public key only?

gotthardp added a commit to gotthardp/tpm2-tss-engine that referenced this pull request Oct 24, 2020
gotthardp added a commit to gotthardp/tpm2-tss-engine that referenced this pull request Oct 24, 2020
@gotthardp gotthardp mentioned this pull request Oct 24, 2020
gotthardp added a commit to gotthardp/tpm2-tss-engine that referenced this pull request Oct 25, 2020
 - Migrated tests to tpm2-tools 4.x
 - Added missing documentation
 - Fixed indentation

Signed-off-by: Petr Gotthard <[email protected]>
@AndreasFuchsTPM
Copy link
Member

Closing; see #194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants