Project

General

Profile

Actions

Task #2948

closed

Define new abstraction of Tpm

Added by Yingdi Yu almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Security
Target version:
Start date:
06/24/2015
Due date:
% Done:

100%

Estimated time:

Description

One of the overhead of the current SecTpm is the key lookup, which is similar to the old implementation of Pib (SecPib). For example, to perform a signing operation, the current implementation must do a lookup operation in Tpm. In SecTpmOsx, the lookup involves inter-process operation; in SecTpmFile, the lookup involves file system operation, and even worse it has to load the key from file every time. It would be better to optimize the Tpm with the similar abstraction as the one of new Pib implementation (Pib). That is, we have a front end abstraction (whose public interface is read-only) and have a back end abstraction provides the handler of key.

A key handler is the abstract interface to manipulate a private key in TPM. For example, in the TPM based on OS X keychain, the handler is a Keychain Item Reference. Every private key related crypto function in OS X keychain service requires such a item reference. In previous implementation, we will lookup the reference in every crypto function. With the KeyHandler abstraction that retain the reference, we can avoid the lookup and directly invoke OS X keychain service functions.

In Memory-based TPM, the handler could simply carry the private key.

With the new abstraction, the front end can maintain in memory a list of key handlers that have been used before.
This new abstraction also makes the style of the implementation of TPM and PIB consistent.


Related issues 4 (0 open4 closed)

Blocks ndn-cxx - Task #2926: Refactor KeyChainClosedYingdi Yu

Actions
Blocked by ndn-cxx - Task #2949: Adding libcrypto-based crypto supportClosedYingdi Yu07/02/2015

Actions
Blocks ndn-cxx - Task #2418: Improve ValidatorConfig test suiteClosed

Actions
Blocks ndn-cxx - Task #2923: Reduce number lookups during KeyChain::sign operationClosedYingdi Yu

Actions
Actions #1

Updated by Yingdi Yu almost 9 years ago

Actions #2

Updated by Yingdi Yu almost 9 years ago

  • Blocked by Task #2949: Adding libcrypto-based crypto support added
Actions #3

Updated by Yingdi Yu over 8 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 70
Actions #4

Updated by Junxiao Shi over 8 years ago

  • Blocks Task #2418: Improve ValidatorConfig test suite added
Actions #5

Updated by Yingdi Yu over 8 years ago

  • Description updated (diff)
Actions #6

Updated by Junxiao Shi over 8 years ago

The term key handler is inaccurate.

Merriam-Webster dictionary defines handler as: one that handles something.
handle as a verb is defined as: to act on or perform a required function with regard to.

This means key handler is an active subject that acts on a key.

However, statements "the handler is a Keychain Item Reference" and "the handler could simply carry the private key" indicate that the key handler is an passive object that represents or references a key.

I recommend the term key handle, where dictionary meaning for handle is: a part that is designed especially to be grasped by the hand.

The usage of handle is also consistent with its meaning in Win32 API: An object is a data structure that represents a system resource, such as a file, thread, or graphic image. An application cannot directly access object data or the system resource that an object represents. Instead, an application must obtain an object handle, which it can use to examine or modify the system resource.

Under this definition, a key (either OSX Keychain Item Reference or the private key in a file-based TPM back end) is an object, and a key handle is used to examine that object.

Actions #7

Updated by Yingdi Yu over 8 years ago

I am ok to change this class name to KeyHandle

Actions #8

Updated by Junxiao Shi over 8 years ago

Reply to note-7:

Description of this issue should be updated to reflect this decision.

Actions #9

Updated by Yingdi Yu over 8 years ago

  • Related to Task #2923: Reduce number lookups during KeyChain::sign operation added
Actions #10

Updated by Yingdi Yu over 8 years ago

  • Related to deleted (Task #2923: Reduce number lookups during KeyChain::sign operation)
Actions #11

Updated by Yingdi Yu over 8 years ago

  • Blocks Task #2923: Reduce number lookups during KeyChain::sign operation added
Actions #12

Updated by Yingdi Yu over 8 years ago

We recently ran into a decision problem about the default way to create a key ID. Here is the problem:

An identity may have more than one keys, in order to distinguish different keys under the same identity, we add a KeyId component as a part of key name, after the portion of Identity, so the purpose is to make sure there is no two keys for the same identity have the same key name.

In our earlier implementation, the default way to create a key ID is to use the timestamp. However, timestamp does not provide a strong uniqueness. Here are several possible scenarios:

  • In ndn-cxx test cases, we use a pseudo clock in some test cases, such a clock always start from a fixed time point, and does not move forward unless there is an explicit advance call. So that it is highly possible that test cases will try to create keys with the same key ID. This is usually fine if the clean up phase of test cases works well. However, once there is some error, or configuration of test case environment goes wrong, keys may not be cleaned up in the TPM, so that when we tried to create a key with the same name, the library will throw an Error saying that key already exists.

  • In distributed signing scenario, for example, Alice wants to create her keys for the same app on both her laptop and smart phone. It cannot guaranteed that the two timestamps would be different.

Moreover, the default mechanism should be used when people do not care about the key ID, therefore using key hash as the default mechanism can always guarantee the uniqueness of the key name unless the hash algorithm is broken. On the other side, if we use timestamp as the default mechanism, it requires every system must have synchronized clock, and it is difficult to control the library to use the appropriate timestamp as the key id.

So the problem is: should we take key hash or timestamp as the default way to create key ID?

Actions #13

Updated by Alex Afanasyev over 8 years ago

I'm strongly opposing the use of a key hash name component provide "uniqueness" (as a default). Name hierarchy provides the context and most of the uniqueness properties, with timestamp having relatively good uniqueness properties (minus a few corner cases you mentioned), plus having

  • short and concise representation, it is easy to read and distinguish different keys
  • increasingly monotonic, so it is easy to see which one created later
Actions #14

Updated by Yingdi Yu over 8 years ago

Alex and I had a discussion about this problem. We clarified our desires.

What I want is "a default KeyId generating method which is independent of any system", such as clock.

What Alex wants is "not using hash as the KeyId", because it may discourage people to use naming hierarchy to assure uniqueness of name.

We agreed to use 8-byte random number as the default KeyID generating method. Hopefully, this compromise can resolve this issue.

Actions #15

Updated by Yingdi Yu over 8 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 70 to 100
Actions #16

Updated by Yingdi Yu over 8 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF