1

有使用 cose-js 经验的人知道如何将 cbor 标签添加到 cose 签名中吗?更具体地说,标签“18”表示它是 cos-sign1。

我正在为我的计算机科学课程学习 COSE,我需要使用 cose-sign1 程序使用 CBOR 和 COSE 对秘方进行编码。

const payload = Buffer.from('mysecretfoodrecipe', 'base64') 
const headers = {
  'p': {'alg': 'ES256', 'kid': 'chefsid'},
  'u': []
};
const signer = {
  'key': {
    'd': Buffer.from('mysecretrecipesignature', 'hex')
  }
};

cose.sign.create(
  headers,
  payload,
  signer)
.then((buf) => {
  console.log('Signed message: ' + buf.toString('hex'));
  console.log(headers, payload, signer)
  return buf.toString('hex')
}).catch((error) => {
  console.log(error);
});

目前你得到这个 --> {[[protected header, unprotected header], [payload], [signature]]}。

但我需要这个 --> {Number: 18 Content: [[protected header, unprotected header], [payload], [signature]]}

有任何想法吗?

谢谢

4

0 回答 0