tree: 78ef2b38081cef2132a698f346e9b630012ccf25 [path history] [tgz]
  1. client/
  2. dbus_bindings/
  3. fuzzers/
  4. init/
  5. pkcs11/
  6. tmpfiles.d/
  7. attributes.cc
  8. attributes.h
  9. attributes_fuzzer.cc
  10. BUILD.gn
  11. chaps.cc
  12. chaps.h
  13. chaps_adaptor.cc
  14. chaps_adaptor.h
  15. chaps_client.cc
  16. chaps_factory.h
  17. chaps_factory_impl.cc
  18. chaps_factory_impl.h
  19. chaps_factory_mock.cc
  20. chaps_factory_mock.h
  21. chaps_interface.h
  22. chaps_metrics.cc
  23. chaps_metrics.h
  24. chaps_metrics_test.cc
  25. chaps_proxy.cc
  26. chaps_proxy.h
  27. chaps_proxy_mock.h
  28. chaps_service.cc
  29. chaps_service.h
  30. chaps_service_test.cc
  31. chaps_test.cc
  32. chaps_utility.cc
  33. chaps_utility.h
  34. chaps_utility_fuzzer.cc
  35. chapsd.cc
  36. chapsd_test.cc
  37. CPPLINT.cfg
  38. DIR_METADATA
  39. handle_generator.h
  40. handle_generator_mock.h
  41. isolate.h
  42. isolate_chromeos.cc
  43. isolate_mock.h
  44. object.h
  45. object_impl.cc
  46. object_impl.h
  47. object_mock.cc
  48. object_mock.h
  49. object_policy.h
  50. object_policy_cert.cc
  51. object_policy_cert.h
  52. object_policy_common.cc
  53. object_policy_common.h
  54. object_policy_data.cc
  55. object_policy_data.h
  56. object_policy_key.cc
  57. object_policy_key.h
  58. object_policy_mock.cc
  59. object_policy_mock.h
  60. object_policy_private_key.cc
  61. object_policy_private_key.h
  62. object_policy_public_key.cc
  63. object_policy_public_key.h
  64. object_policy_secret_key.cc
  65. object_policy_secret_key.h
  66. object_policy_test.cc
  67. object_pool.h
  68. object_pool_impl.cc
  69. object_pool_impl.h
  70. object_pool_mock.cc
  71. object_pool_mock.h
  72. object_pool_test.cc
  73. object_store.h
  74. object_store_fake.h
  75. object_store_fuzzer.cc
  76. object_store_impl.cc
  77. object_store_impl.h
  78. object_store_mock.cc
  79. object_store_mock.h
  80. object_store_test.cc
  81. object_test.cc
  82. org.chromium.Chaps.conf
  83. org.chromium.Chaps.service
  84. OWNERS
  85. p11_replay.cc
  86. platform_globals.h
  87. platform_globals_chromeos.cc
  88. proto_conversion.cc
  89. proto_conversion.h
  90. README.md
  91. session.h
  92. session_impl.cc
  93. session_impl.h
  94. session_mock.cc
  95. session_mock.h
  96. session_test.cc
  97. slot_manager.h
  98. slot_manager_impl.cc
  99. slot_manager_impl.h
  100. slot_manager_mock.cc
  101. slot_manager_mock.h
  102. slot_manager_test.cc
  103. slot_policy.h
  104. slot_policy_default.cc
  105. slot_policy_default.h
  106. slot_policy_default_test.cc
  107. slot_policy_mock.cc
  108. slot_policy_mock.h
  109. slot_policy_shared_slot.cc
  110. slot_policy_shared_slot.h
  111. slot_policy_shared_slot_test.cc
  112. system_shutdown_blocker.cc
  113. system_shutdown_blocker.h
  114. threading_mode.h
  115. token_manager_client.cc
  116. token_manager_client.h
  117. token_manager_client_mock.h
  118. token_manager_interface.h
chaps/README.md

Chaps

Chaps is a PKCS #11 implementation for Chromium OS. This document clarifies how the PKCS #11 standard is supported for HWSec-backed tokens and what a calling application can expect from Chaps.

Token Initialization

Token initialization is performed on demand and does not need to be initiated by any application. If files associated with a token are corrupt that token will be reinitialized automatically.

Roles and Authentication

Chaps does not manage roles or authentication. Rather, it integrates with other parts of the Chromium OS system which manages the authentication of users. A user does not log in or log out of an inserted token; instead an inserted token implies that a user has logged in and now their token is available. Since users are managed outside of Chaps, there is no need for a Security Officer (SO) role and so Chaps has no notion of a SO.

This approach has the following implications for PKCS #11 applications:

  • C_GetTokenInfo reports the flag CKF_PROTECTED_AUTHENTICATION_PATH.
  • C_InitToken always returns CKR_PIN_INCORRECT.
  • C_InitPIN always returns CKR_USER_NOT_LOGGED_IN.
  • C_SetPIN always returns CKR_PIN_INVALID.
  • C_Login will return success if the protected authentication path is used (i.e. the PIN argument is NULL). It will also return success if the legacy PIN ‘111111’ is used. Otherwise, it will return CKR_PIN_INCORRECT. In any case the call has no effect and the token remains logged in. When the user actually logs out of the system, that user's token will be removed.
  • C_Logout always returns success but has no effect.

Operation State

Operation state cannot be saved and restored. Operation state information is never provided to calling applications.

  • C_GetOperationState will return CKR_STATE_UNSAVEABLE.
  • C_SetOperationState will return CKR_SAVED_STATE_INVALID.

Chaps-specific WrapKey/UnWrapKey mechanism

We implemented a new chaps-specific mechanism, “kChapsKeyWrapMechanism”, which is specifically designed to securely move keys from one token to another. The mechanism is designed based on the CKM_AES_KEY_WRAP_KWP mechanism, which is using the same AES key to wrap/unwrap the target key. However, instead of retrieving the wrapping/unwrapping key from the handle, kChapsKeyWrapMechanism uses chaps' internal random seed (which is shared between chaps tokens) to derive the temporary AES key. As a result, no external wrapping/unwrapping key is needed for this mechanism, therefore avoid leaking the key outside of Chaps.

Wrap key in source slot for transfer example:

CK_SESSION_HANDLE hSession;
CK_OBJECT_HANDLE hWrappingKey, hKey;
CK_MECHANISM mechanism = {
  kChapsKeyWrapMechanism, NULL_PTR, 0
};
CK_BYTE wrappedKey[4096];
CK_ULONG ulWrappedKeyLen;
CK_RV rv;
.
.
ulWrappedKeyLen = sizeof(wrappedKey);

rv = C_WrapKey(
  hSession, &mechanism,
  hWrappingKey, hKey,
  wrappedKey, &ulWrappedKeyLen);

if (rv == CKR_OK) {
  .
  .
}

Unwrap key in destination slot for transfer example:

CK_SESSION_HANDLE hSession;
CK_OBJECT_HANDLE hUnwrappingKey, hKey;
CK_MECHANISM mechanism = {
  kChapsKeyWrapMechanism, NULL_PTR, 0
};
CK_BYTE wrappedKey[4096] = {...};
CK_OBJECT_CLASS keyClass = CKO_SECRET_KEY;
CK_KEY_TYPE keyType = CKK_DES;
CK_BBOOL true = CK_TRUE;
CK_ATTRIBUTE template[] = {
  {CKA_CLASS, &keyClass, sizeof(keyClass)},
  {CKA_KEY_TYPE, &keyType, sizeof(keyType)},
  {CKA_ENCRYPT, &true, sizeof(true)},
  {CKA_DECRYPT, &true, sizeof(true)}
};
CK_RV rv;

.
.
rv = C_UnwrapKey(
  hSession, &mechanism, hUnwrappingKey,
  wrappedKey, sizeof(wrappedKey), template, 4, &hKey);

if (rv == CKR_OK) {
  .
  .
}

Checkout the implementation in chaps/session_impl.cc for more details.

Unsupported Functions

The following functions are not supported and will always return CKR_FUNCTION_NOT_SUPPORTED:

  • C_DigestKey
  • C_SignRecoverInit
  • C_SignRecover
  • C_VerifyRecoverInit
  • C_VerifyRecover
  • C_DigestEncryptUpdate
  • C_DecryptDigestUpdate
  • C_SignEncryptUpdate
  • C_DecryptVerifyUpdate