为订单资源添加更多类型

https://blueprints.launchpad.net/barbican/+spec/api-orders-add-more-types

Barbican 的订单资源用于代表客户端生成密钥。目前(Icehouse M2 版本时),只能生成特定的对称密钥。此蓝图描述了如何修改订单资源以生成其他有用的密钥类型,例如非对称密钥对。

问题描述

Barbican 当前缺乏对以下密钥类型的生成支持,而这些类型是密钥管理器高度期望的

Barbican 可以通过订单资源生成三种主要类型的密钥信息

    • 对称加密密钥:AES、3DES、Camellia、RC4。

    • 其他类型的密钥:HMAC、字节流

  1. 非对称密钥
    • RSA、DSA、EC。

    • 可以包含公钥和私钥,以及密码短语

  2. 证书
    • 通过 CA 签署的 CSR 生成。

    • 通过 Barbican 及其后端插件使用不同的参数生成。

提议的变更

这是一个多阶段的计划,如下所述

1. 增强 Barbican 加密插件框架以支持生成不同类型的密钥。(已完成)

  1. 对订单数据模型进行适当的更改以保存所需的参数。

  2. 增强订单 REST API 以支持密钥和非对称密钥。

  3. 增强订单 REST API 以支持证书类型密钥,包括
    • 支持 CSR POST 的 API 更改。

    • 支持 POST 或证书参数的 API 更改。

    • Barbican 核心子系统与 CA 集成。

    • Barbican 事件子系统发出证书生命周期事件。

备选方案

无。

数据模型影响

Barbican 订单模型需要增强以支持这些需求。需要在模型中添加以下新字段

  1. 类型(字符串):此字段将表示订单类型。允许的选项是

    key、asymmetric 和 certificates

  2. Meta(文本):此字段将保存 JSON 字符串并存储所有元属性

    用于密钥。

  3. container_id:一个可选字段,具体取决于生成的工件,特定

    类型的密钥可以有多个子密钥。此类密钥需要 Container 对象来分组多个密钥。例如,非对称密钥的私钥、公钥和密码短语。

注意:一旦订单变为 ACTIVE,container_id 或现有的 secret_id 将被填充,具体取决于订单生成的密钥类型。

REST API 影响

订单资源允许通过 Barbican 生成密钥材料。订单对象封装了密钥创建的工作流程和历史记录。由于生成密钥的时间因密钥类型而异,因此此接口实现为异步过程。

资源结构

{
   "type": "--type--",
   "meta": {
      "name": "--name--",
      "algorithm": "--algorithm--",
      "bit_length": --bit_length--,
      "mode": "--mode--",
      "pass_phrase": "--pass_phrase--",
      "expiration": "--expiration--",
      "payload_content_type": "--type--"
   }
}

注意:证书类型的 meta 结构尚未确定。

必需属性

type (string)

密钥的类型,支持的选项是 key、asymmetric 和 certificate

meta (string)

描述有关密钥的附加信息

meta.name (string)

密钥的人类可读名称

meta.algorithm (string)

用于生成密钥的加密算法类型。例如,aes、3des、hmacsha1、hmacsha256、hmacsha384、hmacsha512、rsa 和 dsa

meta.bit_length (int)

密钥的位数。

可选属性

meta.mode (string)

与密钥信息关联的算法的类型/模式

meta.pass_phrase (string)

与密钥关联的密码短语。与类型为 asymmetric 时一起使用

meta.expiration (string)

密钥的 ISO-8601 格式的到期日期。密钥过期后,API 或代理将不再返回该密钥。如果未提供此字段,则密钥没有到期日期

meta.payload_content_type (string)

API

订单

创建订单:POST /{tenant_id}/orders

示例 01 - 对称密钥生成

Request:

    POST /v1/{tenant_id}/orders

    {
       "type": "key",
       "meta": {
          "name": "secretname",
          "algorithm": "aes",
          "bit_length": 256,
          "mode": "cbc",
          "expiration": "2015-02-28T19:14:44.180394",
          "payload_content_type": "application/octet-stream"
       }
    }

Response:

    Status: 201 Created

    {
        "order_ref": "https://:9311/v1/1234/orders/daf3c6de-095f-46a8-94ec-65ec0d98eb68"
    }

示例 02 - 非对称密钥生成

Request:

    POST /v1/{tenant_id}/orders

    {
       "type": "asymmetric",
       "meta": {
          "name": "secretname",
          "algorithm": "RSA",
          "bit_length": 2048,
          "expiration": "2015-02-28T19:14:44.180394",
          "payload_content_type": "application/octet-stream"
       }
    }

Response:

    Status: 201 Created

    {
        "order_ref": "https://:9311/v1/1234/orders//a8957047-16c6-4b05-ac57-8621edd0e9ee"
    }

示例 03 - 证书生成

Request: (TBD)

Response: (TBD)

列出订单:GET /{tenant_id}/orders

列出每个租户的订单

Request:

    GET /v1/{tenant_id}/orders

Response:

    Status: 200 OK

    {
      "orders": [
        {
          "status": "ACTIVE",
          "secret_ref": "https://:9311/v1/12345/secrets/bf2b33d5-5347-4afb-9009-b4597f415b7f",
          "updated": "2013-06-28T18:29:37.058718",
          "created": "2013-06-28T18:29:36.001750",
            "type": "key",
            "meta": {
              "name": "secretname",
              "algorithm": "AES",
              "bit_length": 256,
              "mode": "cbc",
              "expiration": "2015-02-28T19:14:44.180394",
              "payload_content_type": "application/octet-stream"
          },
          "order_ref": "https://:9311/v1/1234/orders/daf3c6de-095f-46a8-94ec-65ec0d98eb68"
        },
        {
          "status": "ACTIVE",
          "container_ref": "https://:9311/v1/12345/containers/fa71b143-f10e-4f7a-aa82-cc292dc33eb5",
          "updated": "2013-06-28T18:29:37.058718",
          "created": "2013-06-28T18:29:36.001750",
            "type": "asymmetric",
            "meta": {
              "name": "secretname",
              "algorithm": "RSA",
              "bit_length": 2048,
              "expiration": "2015-02-28T19:14:44.180394",
              "payload_content_type": "application/octet-stream"
          },
          "order_ref": "https://:9311/v1/1234/orders//a8957047-16c6-4b05-ac57-8621edd0e9ee"
        }
      ]
    }

注意:现有的“limit”和“offset”筛选器参数没有更改。

获取订单:GET /{tenant_id}/orders/{order_id}

按 order_id 获取订单

Request:

    GET /v1/{tenant_id}/orders/{order_id}

Response:

    Status: 200 OK

   {
            "type": "asymmetric",
            "meta": {
              "name": "secretname",
              "algorithm": "RSA",
              "bit_length": 2048,
              "expiration": "2015-02-28T19:14:44.180394",
              "payload_content_type": "application/octet-stream"
          },
          "status": "ACTIVE",
          "container_ref": "https://:9311/v1/12345/containers/fa71b143-f10e-4f7a-aa82-cc292dc33eb5",
          "updated": "2013-06-28T18:29:37.058718",
          "created": "2013-06-28T18:29:36.001750",
          "order_ref": "https://:9311/v1/1234/orders//a8957047-16c6-4b05-ac57-8621edd0e9ee"
        }

安全影响

通知与审计影响

无。

其他最终用户影响

  • Barbican-python 客户端需要增强以适应 API 更改。

性能影响

其他部署者影响

无。

开发人员影响

无。

实现

负责人

Arvind Tiwari (atiwari) 正在领导此功能增强。

工作项

  • 增强加密插件框架以支持不同类型的密钥生成。(atiwari,已完成)

  • 数据迁移以在订单模型中添加类型、Meta 和 container_id。(atiwari,已完成)

  • 增强订单 REST API 以支持 key 和 asymmetric 订单类型。(atiwari,进行中,https://review.openstack.org/#/c/87405/

  • 增强订单 REST API 以支持证书订单类型。(TBD)

  • 增强 Barbican python 客户端以支持 key 和 asymmetric 订单类型。(TBD)

  • 增强 Barbican python 客户端以支持证书订单类型。(TBD)

依赖项

测试

  • 需要为新的订单类型添加单元测试。

  • 此更改必须向后兼容,允许使用当前的订单契约来生成对称密钥,除了此蓝图概述的新方法之外。

文档影响

参考资料