Skip to content

Commit

Permalink
Merge pull request #219 from v0-e/asn1-copy-oer
Browse files Browse the repository at this point in the history
asn1: OER-based copy for asn1c wrapper
  • Loading branch information
riebl authored Jan 30, 2024
2 parents b2e1409 + f51cabc commit f0a136a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vanetza/asn1/asn1c_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ void* copy(asn_TYPE_descriptor_t& td, const void* original)
ByteBuffer buffer;

asn_enc_rval_t ec;
ec = der_encode(&td, const_cast<void*>(original), write_buffer, &buffer);
ec = oer_encode(&td, const_cast<void*>(original), write_buffer, &buffer);
if (ec.encoded == -1) {
throw std::runtime_error("DER encoding failed");
throw std::runtime_error("OER encoding failed");
}

asn_dec_rval_t dc;
dc = ber_decode(0, &td, &copy, buffer.data(), buffer.size());
dc = oer_decode(0, &td, &copy, buffer.data(), buffer.size());
if (dc.code != RC_OK) {
free(td, copy);
throw std::runtime_error("BER decoding failed");
throw std::runtime_error("OER decoding failed");
}

return copy;
Expand Down

0 comments on commit f0a136a

Please sign in to comment.