ASN1_item_d2i function

  1. @RecordUse.new()
  2. @Native<Pointer<ASN1_VALUE> Function(Pointer<Pointer<ASN1_VALUE>>, Pointer<Pointer<UnsignedChar>>, Long, Pointer<ASN1_ITEM>)>(ffi.Pointer<ffi.Pointer<ASN1_VALUE>>, ffi.Pointer<ffi.Pointer<ffi.UnsignedChar>>, ffi.Long, ffi.Pointer<ASN1_ITEM>)>(symbol: 'bssl_dart_ASN1_item_d2i')
Pointer<ASN1_VALUE> ASN1_item_d2i(
  1. Pointer<Pointer<ASN1_VALUE>> out,
  2. Pointer<Pointer<UnsignedChar>> inp,
  3. int len,
  4. Pointer<ASN1_ITEM> it,
)

ASN1_item_d2i parses the ASN.1 type |it| from up to |len| bytes at |*inp|. It behaves like |d2i_SAMPLE|, except that |out| and the return value are cast to |ASN1_VALUE| pointers.

TODO(https://crbug.com/boringssl/444): C strict aliasing forbids type-punning |T*| and |ASN1_VALUE*| the way this function signature does. When that bug is resolved, we will need to pick which type |out| is (probably |T|). Do not use a non-NULL |out| to avoid ending up on the wrong side of this question.

This function may not be used with |ASN1_ITEM|s whose C type is |ASN1_BOOLEAN|.

WARNING: Casting the result of this function to the wrong type, or passing a pointer of the wrong type into this function, are potentially exploitable memory errors. Callers must ensure |out| is consistent with |it|. Prefer using type-specific functions such as |d2i_ASN1_OCTET_STRING|.

Implementation

@meta.RecordUse()
@ffi.Native<
  ffi.Pointer<ASN1_VALUE> Function(
    ffi.Pointer<ffi.Pointer<ASN1_VALUE>>,
    ffi.Pointer<ffi.Pointer<ffi.UnsignedChar>>,
    ffi.Long,
    ffi.Pointer<ASN1_ITEM>,
  )
>(symbol: 'bssl_dart_ASN1_item_d2i')
external ffi.Pointer<ASN1_VALUE> ASN1_item_d2i(
  ffi.Pointer<ffi.Pointer<ASN1_VALUE>> out,
  ffi.Pointer<ffi.Pointer<ffi.UnsignedChar>> inp,
  int len,
  ffi.Pointer<ASN1_ITEM> it,
);