首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yubikey 5 NFC:获取“打包”的认证声明

Yubikey 5 NFC:获取“打包”的认证声明
EN

Stack Overflow用户
提问于 2019-01-07 02:49:29
回答 3查看 355关注 0票数 0

使用以下javascript请求:

代码语言: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 5NFC系统地返回一条"fido-u2f"证明语句:

代码语言:javascript
复制
%{
  "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"认证声明?

EN

回答 3

Stack Overflow用户

发布于 2019-01-08 04:23:40

根据当前的规范/标准,我不认为您(作为依赖方)可以“选择”您从验证方(即“设备”)收到的证明声明格式。这是验证者做出的决定。

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

票数 0
EN

Stack Overflow用户

发布于 2019-04-02 19:26:16

没有办法使用这样简单的键选择证明。为了测试这两个证明的实现,我简单地购买了两个不同的密钥,一个来自Yibico,另一个来自Nitrokey。Yubico发送fido-u2f,而Nitrokey发送打包的证明。

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

代码语言:javascript
复制
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
}
票数 0
EN

Stack Overflow用户

发布于 2021-12-06 08:15:42

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54064774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档