---
name: "sc_asn1_encode"
section: "3"
platform: "linux"
package: "libopensc2-dev"
version: "0.11.13-1.1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_asn1_encode"
---

# sc\_asn1\_encode(3)

Encode ASN.1 entries into a stream

## NAME

sc\_asn1\_encode - Encode ASN.1 entries into a stream

## SYNOPSIS

```
#include <opensc.h>
int sc_asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1,
                   unsigned char **newbuf, size_t *size);
```

## DESCRIPTION

This function encodes an array of entries pointed to by *asn1* and terminated by a NULL entry (i.e. where the *name* field of the entry is NULL) into a newly allocated buffer.

The new buffer containing the ASN.1 stream will be stored in *newbuf*, and the size of this buffer is stored in *size*. The application must free this buffer after use.

## RETURN VALUE

Returns 0 if successful, or a negative value in case of error.
