IMPLEMENT_ASN1_FUNCTIONS tutorial or help
Matt Caswell
matt at openssl.org
Tue Aug 17 14:38:54 UTC 2021
On 16/08/2021 21:56, Ken Goldman wrote:
> I am trying to parse some ASN.1 DER so I can add it to an X.509
> certificate.
>
> For the input side, a poster showed me
>
> ASN1_SEQUENCE, ASN1_SEQUENCE_END, and then
> DECLARE_ASN1_FUNCTIONS, IMPLEMENT_ASN1_FUNCTIONS
>
> which created the i2d() function.
It should also give you the d2i() function too!
>
> Now I would like to do the other end, where I have der and I
> want to parse back to the structure, using d2i()
>
> 1 - Is there a tutorial on this?
Seems like you don't need one. If you got i2d working you should have
d2i already!
Matt
>
> 2 - Can someone show me this structure?
>
> The DER is a version, serial number, signature algorithm,
> public key algorithm, and public key.
>
> The dump looks like this:
>
> 0 337: SEQUENCE {
> 4 3: . [0] {
> 6 1: . . INTEGER 2
> : . . }
> 9 21: . INTEGER 00 87 12 50 78 0A C9 8B 60 DD AC FA 75 18 05 EC DC
> 30 51 53 23
> 32 13: . SEQUENCE {
> 34 9: . . OBJECT IDENTIFIER sha256WithRSAEncryption (1 2 840 113549
> 1 1 11)
> : . . . (PKCS #1)
> 45 0: . . NULL
> : . . }
> 47 290: . SEQUENCE {
> 51 13: . . SEQUENCE {
> 53 9: . . . OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1)
> : . . . . (PKCS #1)
> 64 0: . . . NULL
> : . . . }
> 66 271: . . BIT STRING, encapsulates {
> 71 266: . . . SEQUENCE {
> 75 257: . . . . INTEGER
> : . . . . . 00 B0 83 4A E9 41 78 E0 6A C3 0F D6 E4 B9 7D 96
> : . . . . . 70 74 05 00 C9 E2 2C 6C 4C 6E 16 02 40 5C 35 29
> : . . . . . F6 EF 9F 55 3A BD 4B 74 1D 6A 21 38 20 69 C8 88
> : . . . . . A3 6B 56 62 2A 91 02 41 58 92 97 87 19 1C AD 19
> : . . . . . 53 56 FB 7E 9D 86 B8 4E 8D 82 6A 87 A7 93 55 8F
> : . . . . . AB E8 89 D7 63 0B C9 02 99 D8 37 F8 FB 6B 32 98
> : . . . . . 6A 05 3F 9E 22 B6 D3 6F BB BE 2D AC 6C 74 17 5D
> : . . . . . 15 EE 84 E5 A4 8F 9C C3 83 CD 83 81 63 EC B5 85
> : . . . . . 6B 1A B8 57 80 2C ED E3 A7 F2 8C F7 3F 13 D9 27
> : . . . . . 2E 64 37 49 E6 47 8E 0A 11 64 46 72 DD F9 EB 4F
> : . . . . . B8 13 58 0B 47 F7 72 AB 29 D6 A5 05 44 30 E7 8D
> : . . . . . FE 86 8A E8 5F 10 91 13 04 57 47 96 A7 97 28 3C
> : . . . . . 39 BD 23 3F C6 41 5E 45 3F A5 41 F5 BF 7D C2 7C
> : . . . . . CC F9 97 20 3F 20 82 AF 64 8C BC 0D 99 F4 BA 10
> : . . . . . 53 58 C5 EC 86 DE 26 ED D9 D6 F2 60 49 C9 E7 9B
> : . . . . . 6A 64 D2 BC C5 0E B0 1D EB 45 43 89 A6 4E 64 B4
> : . . . . . A1
> 336 3: . . . . INTEGER 65537
> : . . . . }
> : . . . }
> : . . }
> : . }
>
>
More information about the openssl-users
mailing list