SignedAndEnvelopedData 使用和构造

SignedAndEnvelopedData

Pkcs7的一种结构,用来包装加密的私钥。结构如下:

Purpose:数字信封

SignedAndEnvelopedData ::= SEQUENCE {
  version         INTEGER {seVer1(1), seVer2(2)} (seVer1 | seVer2),
  recipientInfos  RecipientInfos,
  digestAlgorithms
                  DigestAlgorithmIdentifiers,
  encryptedContentInfo
                  EncryptedContentInfo,
  certificates CHOICE {
    certSet       [0] IMPLICIT ExtendedCertificatesAndCertificates,
    certSequence  [2] IMPLICIT Certificates
  } OPTIONAL,
  crls CHOICE {
    crlSet        [1] IMPLICIT CertificateRevocationLists,
    crlSequence   [3] IMPLICIT CRLSequence
  } OPTIONAL,
  signerInfos     SignerInfos
} (WITH COMPONENTS { ..., version (seVer1),
    recipientInfos   (WITH COMPONENTS { ..., riSet PRESENT }),
    digestAlgorithms (WITH COMPONENTS { ..., daSet PRESENT }),
    certificates     (WITH COMPONENTS { ..., certSequence ABSENT }),
    crls             (WITH COMPONENTS { ..., crlSequence ABSENT }),
    signerInfos      (WITH COMPONENTS { ..., siSet PRESENT })
} |
  WITH COMPONENTS { ..., version (seVer2),
    recipientInfos   (WITH COMPONENTS { ..., riSequence PRESENT }),
    digestAlgorithms (WITH COMPONENTS { ..., daSequence PRESENT }),
    certificates     (WITH COMPONENTS { ..., certSet ABSENT }),
    crls             (WITH COMPONENTS { ..., crlSet ABSENT }),
    signerInfos      (WITH COMPONENTS { ..., siSequence PRESENT })
})

解密数字信封:

首先获取recipientInfo中的EncryptedKey的value值,用私钥解密出来对称秘钥symmKey,在用对称秘钥去解EncryptedContentInfo中的EncryptedContent的value值,解密后获得enprivateKey。

验证数字信封签名:

验证签名首先判断signerInfo中的AuthenticatedAttributes是否有值,有值获取该属性的attributesValue值,用symmKey解密该attributesValue后的到的结果,作为明文data与EncryptedDigest验签。

如果AuthenticatedAttributes没有值,则获取

signedAndEnvelopedData.getEncryptedContentInfo().getEncryptedContent()

用symmKey解密的结果作为明文data与EncryptedDigest验签。

故验证数字信封签名需要先解密获取到对称秘钥KEY才能验签。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值