Reputation: 469
I'm trying to digitally sign a pdf document using OpenSSL library. Now I want to get a digest from the pdf document content. I only found method which create the digest from ASN1_ITEM
. But what I have is ASN1_OCTET_STRING
object which I can convert to ASN1_TYPE
if needed. I suppose that there should be some way to convert ASN1_TYPE
or ASN1_OCTET_STRING
into ASN1_ITEM
. But I don't understand how ASN1_TYPE
and ASN1_TYPE
are related.
P.S. Would be grateful if someone share some kind of proper documentation of OpenSSL. What I could find are mostly source files without proper explanation.
Upvotes: 1
Views: 539
Reputation: 17383
Since you write "what I have is ASN1_OCTET_STRING
object", the following snippet, found under the NOTES section in the documentation of the ASN1_STRING
utilities, seems useful:
Almost all ASN1 types in OpenSSL are represented as an
ASN1_STRING
structure. Other types such asASN1_OCTET_STRING
are simply typedef'ed toASN1_STRING
and the functions call theASN1_STRING
equivalents.
(You can verify that this happens in ossl_typ.h
, it is actually not a typedef
but a #define
)
That same documentation page gives a function ASN1_STRING_to_UTF8()
that you can use to get a representation of the data as an unsigned char *
as well as its length. Once you have that, you can calculate a digest to your liking.
This is not an answer to your question "how ASN1_TYPE
and ASN1_ITEM
are related" but it seems to cover the problem that you describe. If that is not the case, please clarify.
Upvotes: 2