【问题标题】:Yubikey 5 NFC: get a "packed" attestation statementYubikey 5 NFC:获得“打包”证明声明
【发布时间】:2019-06-01 13:12:35
【问题描述】:

使用以下 javascript 请求:

navigator.credentials.create({
  publicKey: {
    // random, cryptographically secure, at least 16 bytes
    challenge: new Uint8Array(16),
    // relying party
    rp: {
      id: 'localhost',
      name: 'My website'
    },
    user: {
      id: new Uint8Array(16),
      name: 'Tang',
      displayName: 'Tang'
    },
    pubKeyCredParams: [
      {
        type: "public-key", alg: -7
      }
    ],
    attestation: "direct"
  }
})

兼容 FIDO2 的 Yubikey 5 NFC 系统地返回 "fido-u2f" 证明声明:

%{
  "attStmt" => %{
    "sig" => <<48, 69, 2, 33, 0, 132, 31, 225, 91, 58, 61, 190, 47, 66, 168, 8,
      177, 18, 136, 106, 100, 219, 54, 52, 255, 103, 106, 156, 230, 141, 240,
      82, 130, 167, 204, 128, 100, 2, 32, 61, 159, 126, 9, 244, 55, 100, 123,
      169, ...>>,
    "x5c" => [
      <<48, 130, 2, 188, 48, 130, 1, 164, 160, 3, 2, 1, 2, 2, 4, 3, 173, 240,
        18, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 46, 49,
        44, 48, 42, 6, 3, 85, 4, 3, 19, ...>>
    ]
  },
  "authData" => <<73, 150, 13, 229, 136, 14, 140, 104, 116, 52, 23, 15, 100,
    118, 96, 91, 143, 228, 174, 185, 162, 134, 50, 199, 153, 92, 243, 186, 131,
    29, 151, 99, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>,
  "fmt" => "fido-u2f"
}

如何改为接收 FIDO2 "packed" 证明声明?

【问题讨论】:

    标签: yubico webauthn


    【解决方案1】:

    根据当前的规范/标准,我认为您(作为信赖方)无法“选择”您从身份验证器(即“设备”)收到的证明声明格式。这是 Authenticator 做出的决定。

    我认为通过 Chrome 桌面的 MacBook Pro TouchID 平台身份验证器正在发送“打包”的证明声明,如果这有帮助的话。

    【讨论】:

      【解决方案2】:

      无法使用如此简单的键选择证明。为了测试我对这两种证明的实现,我只是从 Yibico 和 Nitrokey 购买了两个不同的密钥。 Yubico 发送 fido-u2f,而 Nitrokey 发送打包证明。

      如果有人想知道,我就是这样实现的:

      let verifyAuthenticatorAttestationResponse = (webAuthnResponse) => {
      
          let attestationBuffer = 
            base64url.toBuffer(webAuthnResponse.response.attestationObject);
          let ctapMakeCredResp  = cbor.decodeAllSync(attestationBuffer)[0];
          let authrDataStruct   = parseMakeCredAuthData(ctapMakeCredResp.authData);
          let response          = {'verified': false };
      
          if(ctapMakeCredResp.fmt === 'fido-u2f' || ctapMakeCredResp.fmt === 'packed') {
      
              if(!(authrDataStruct.flags & U2F_USER_PRESENTED))
                  throw new Error('User was NOT presented durring authentication!');
      
              let clientDataHash  = 
                 hash(base64url.toBuffer(webAuthnResponse.response.clientDataJSON))
              let publicKey       = COSEECDHAtoPKCS(authrDataStruct.COSEPublicKey)
              let PEMCertificate  = ASN1toPEM(ctapMakeCredResp.attStmt.x5c[0]);
              let signature       = ctapMakeCredResp.attStmt.sig;
              let signatureBase;
      
              if(ctapMakeCredResp.fmt === 'fido-u2f') {
                  signatureBase   = Buffer.concat([Buffer.from([0x00]), authrDataStruct.rpIdHash, clientDataHash, authrDataStruct.credID, publicKey]);
              } else {
                  signatureBase   = Buffer.concat([ctapMakeCredResp.authData, clientDataHash]);
              }
      
              response.verified = verifySignature(signature, signatureBase, PEMCertificate)
      
              if(response.verified) {
                  response.authrInfo = {
                      fmt:       `${ctapMakeCredResp.fmt}`,
                      publicKey: base64url.encode(publicKey),
                      counter:   authrDataStruct.counter,
                      credID:    base64url.encode(authrDataStruct.credID)
                  }
              }
          }
      
          return response
      }
      

      【讨论】:

        【解决方案3】:

        默认情况下,浏览器可能会选择 U2F。尝试通过将其设置为“必需”来强制 UV。这将强制浏览器使用 FIDO2,因为 U2F 不支持 UV。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-08-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-06-09
          • 2014-02-20
          • 1970-01-01
          • 2016-06-18
          相关资源
          最近更新 更多