我想給PKCS7編碼封裝的內容信息進行編碼上下文特定的ASN.1:如何使用OpenSSL
Sequence:
OID
[0] Context-specific
OCTET STRING
我的第一個問題是編碼上下文具體:
[0] 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 documentation
我在正確的軌道上嗎?