我正在尝试对 pkcs7 封装的内容信息进行编码:
Sequence:
OID
[0] Context-specific
OCTET STRING
我的第一个问题是编码特定于上下文的:
[0] Context-specific
所以我尝试使用“八位组字符串”创建一个“SET Context-specific”,但没有成功:
// Create ASN1_OCTET
ASN1_OCTET_STRING *obj = ASN1_OCTET_STRING_new();
const BYTE* ptr = dataToSign.getData();
ASN1_OCTET_STRING_set(obj, ptr, dataToSign.getSize());
// Create ASN1_TYPE using ASN1_OCTET
ASN1_TYPE *asn1Type = ASN1_TYPE_new();
asn1Type->type = V_ASN1_OCTET_STRING;
asn1Type->value.octet_string = obj;
// Using i2d_ASN1_SET_OF_ASN1_TYPE
stack_st_ASN1_TYPE* sk = sk_ASN1_TYPE_new_null();
sk_ASN1_TYPE_push(sk,asn1Type);
int tamanho = i2d_ASN1_SET_OF_ASN1_TYPE(sk,(unsigned char **) NULL, i2d_ASN1_TYPE,V_ASN1_SET, V_ASN1_CONTEXT_SPECIFIC, IS_SET);
unsigned char* data = new BYTE[tamanho];
tamanho = i2d_ASN1_SET_OF_ASN1_TYPE(sk,(unsigned char **) &data, i2d_ASN1_TYPE,V_ASN1_SET, V_ASN1_CONTEXT_SPECIFIC, IS_SET);
我没有在openssl的网站上找到文档。这个地方更好umich - Openssl 文档
我在正确的轨道上吗?