将属性添加到PKCS#7 envelpe [英] Adding attributes to PKCS#7 envelpe

查看:133
本文介绍了将属性添加到PKCS#7 envelpe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,目前我正在尝试向pcks#7信封添加属性,但我找不到任何有关如何添加属性的信息。

Hello, currently I'm trying to add attributes to pcks#7 envelope but I cannot find any info how to add attributes.

以下是MS的示例。

http: //msdn.microsoft.com/en-us/library/windows/desktop/aa382367(v=vs.85).aspx

我想添加3个属性到SignPara.rgAuthAttr。

I am trying to add 3 attributes into SignPara.rgAuthAttr.

首先初始化CRYPT_ATTRIBUTE结构。

First initialize CRYPT_ATTRIBUTE structure.

SignPara.cAuthAttr = 3;

SignPara.cAuthAttr = 3;

CRYPT_ATTRIBUTE * pkimsg_attrs =(CRYPT_ATTRIBUTE *)malloc( SignPara.cAuthAttr * sizeof(CRYPT_ATTRIBUTE));

CRYPT_ATTRIBUTE* pkimsg_attrs = (CRYPT_ATTRIBUTE*)malloc(SignPara.cAuthAttr * sizeof(CRYPT_ATTRIBUTE));

然后添加BLOB对象并将其添加到  pkimsg_attrs。

Then add BLOB object and add it into pkimsg_attrs .

然后将其指定为

SignPara.rgAuthAttr = pkimsg_attrs;

SignPara.rgAuthAttr = pkimsg_attrs;

但是当我解密信封时,属性都是无效的。

But when I decrypt the envelope, the attributes are all invalid.

以下是我添加新属性的方法到pkimsg_attrs;

Below is how I add new attribute into pkimsg_attrs;

推荐答案

pkimsg_attrs-> pszObjId = new char [strlen(nid_messageType)];


strcpy(pkimsg_attrs-> pszObjId,nid_messageType);
pkimsg_attrs->pszObjId = new char[strlen(nid_messageType)];
strcpy(pkimsg_attrs->pszObjId,nid_messageType);

这里有一个缓冲区溢出:你没有为终止NUL分配空间。

You have a buffer overrun here: you don't allocate space for the terminating NUL.

您已经展示了如何设置第一个属性。如何设置其他两个?

You've shown how you set up the first attribute. How do you set up the other two?

如何确定属性无效?问题可能在于您解密和检索属性的代码。

How do you determine the attributes are invalid? Perhaps the problem lies in the code where you decrypt and retrieve attributes.


这篇关于将属性添加到PKCS#7 envelpe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆