如何使用可通过OpenSSL验证的windows加密API进行签名?

如何使用可通过OpenSSL验证的windows加密API进行签名?,openssl,digital-signature,ecdsa,webcrypto-api,webauthn,Openssl,Digital Signature,Ecdsa,Webcrypto Api,Webauthn,我正在使用crypto API进行签名,并将其发送到使用开放SSL验证签名的Web服务器。签名使用Windows crypto API成功验证,但在服务器端使用open SSL验证时出错 错误: ECDsa签名不是有效的DER序列 签名功能: public async sign(data: Uint8Array): Promise<any> { if (!this.privateKey) { throw new Error('no private key

我正在使用crypto API进行签名,并将其发送到使用开放SSL验证签名的Web服务器。签名使用Windows crypto API成功验证,但在服务器端使用open SSL验证时出错

错误:

ECDsa签名不是有效的DER序列

签名功能:

  public async sign(data: Uint8Array): Promise<any> {
    if (!this.privateKey) {
        throw new Error('no private key available for signing');
    }
    return window.crypto.subtle.sign(
        this.getKeyParams(),
        this.privateKey,
        data,
    );
}

private getKeyParams(): EcdsaParams {
    return { name: 'ECDSA', hash: coseEllipticCurveNames[ECDSA.ellipticCurveKeys[this.algorithm]] };
}

private async toCOSE(key: CryptoKey): Promise<Map<number, any>> {
    const exportedKey = await window.crypto.subtle.exportKey('jwk', key);
    const attData = new Map();
    attData.set(1, 2); // EC2 key type
    attData.set(3, this.algorithm);
    attData.set(-1, ECDSA.ellipticCurveKeys[this.algorithm]);
    attData.set(-2, base64ToByteArray(exportedKey.x, true));
    attData.set(-3, base64ToByteArray(exportedKey.y, true));
    return attData;
}
公共异步符号(数据:Uint8Array):承诺{
如果(!this.privateKey){
抛出新错误(“没有可用于签名的私钥”);
}
返回窗口.crypto.sential.sign(
此参数为.getKeyParams(),
这是私钥,
数据,
);
}
私有getKeyParams():EcdsaParams{
返回{name:'ECDSA',hash:coseElliticCurveNames[ECDSA.ElliticCurveKeys[this.algorithm]};
}
私有异步toCOSE(密钥:加密密钥):承诺{
const exportedKey=wait window.crypto.minute.exportKey('jwk',key);
const attData=新映射();
attData.set(1,2);//EC2键类型
attData.set(3,本算法);
attData.set(-1,ECDSA.ellipticCurveKeys[this.algorithm]);
attData.set(-2,base64ToByteArray(exportedKey.x,true));
attData.set(-3,base64ToByteArray(exportedKey.y,true));
返回数据;
}

WebCrypto和Windows使用P1363格式签名,而OpenSSL外部仅支持“DER”(ASN.1)格式。请参阅我之前在#39554165中列出的Dups,Stack已经在本页右侧自动建议了它。这个问题需要更多细节和更深入的调查。你可以发电子邮件给margus。pala@smartid.ee . 我相信我可以帮助您解决这个问题。请检查此答案是否有助于您满足web身份验证需求…WebCrypto和Windows使用P1363格式签名,而OpenSSL外部仅支持“DER”(ASN.1)格式。请参阅我之前在#39554165中列出的Dups,Stack已经在本页右侧自动建议了它。这个问题需要更多细节和更深入的调查。你可以发电子邮件给margus。pala@smartid.ee . 我相信我可以帮助你解决这个问题。检查这个答案是否有助于你的web身份验证需要。。。