Hannes Rantzsch

Results 26 comments of Hannes Rantzsch

You could use Botan with Boost Beast. Here's a small example: https://github.com/hrantzsch/beast-botan-https-client

You'll need both Botan and Boost Beast compiled for Android I guess, but I have never used this on Android and I don't know what you have to do for...

You can use [BER_Decoder](https://botan.randombit.net/doxygen/classBotan_1_1BER__Decoder.html) for decoding and you can see multiple examples of how it's used to [decode X.509 objects here](https://github.com/randombit/botan/blob/a19627a2b76e7f1b9b7e19fbaf2ef464ac220ce6/src/lib/x509/x509_obj.cpp). On that note, what you want to decode there...

You can use the decoder analogously to the encoder. For your example above: ```c++ // ... std::vector randomNumberDEREncoded = Botan::unlock(signedData); Botan::OID oid; std::vector rand; Botan::BER_Decoder(randomNumberDEREncoded) .start_cons(Botan::ASN1_Tag::SEQUENCE) .decode(oid) .start_cons(Botan::ASN1_Tag::SET) .decode(rand, Botan::ASN1_Tag::OCTET_STRING)...

> you please share the sample example link as well which you mentioned above I'm not sure which link you are referring to. I linked https://github.com/randombit/botan/blob/a19627a2b76e7f1b9b7e19fbaf2ef464ac220ce6/src/lib/x509/x509_obj.cpp above. > example to...

Hi, which of the instructions above throws the exception? I assume it's one of the `decode`s? Maybe you can look up under which circumstances `decode` throws the exception you get.

Ah, the problem seems to be that you need to decode the printable string into a `Botan::ASN1_String`, rather than a plain vector.

```cpp Botan::ASN1_String contextString; // ... .decode(contextString, Botan::ASN1_Tag::PRINTABLE_STRING) ``` ~~should work :)~~ Edit: sorry, I think I misread your question. You can find example usages of `CONTEXT_SPECIFIC` decoding in `src/lib/x509/ocsp.cpp`. Can...

```c++ decode(ContextString1, Botan::OCTET_STRING, Botan::UNIVERSAL, Botan::CONTEXT_SPECIFIC); ``` Does this work for you?

Unfortunately not, as far as I know.