> For the complete documentation index, see [llms.txt](https://www.x509.wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.x509.wiki/important-data-formats/asn.1-and-pem.md).

# ASN.1 and PEM

The Abstract Syntax Notation One (ASN.1) is a language used to describe data structures. There are some pre-defined base data types like integers or sequences and an author of a protocol or file format can then define custom data types using the basic ones.

### DER Encoding

The [ITU-T standard X.680](https://www.itu.int/rec/T-REC-X.680/) defines different encodings for data specified as ASN.1. For X.509-related data, the most important encoding is DER, because there is only one way to encode a type; therefore, a hash of the binary DER representation of the type will always have the same value, which is important for example when signing ASN.1-encoded data.

### PEM Encoding

For many, but not all X.509-related file types, you can either store the file binary in DER-encoding or apply an additional [PEM-encoding](https://datatracker.ietf.org/doc/html/rfc7468) on top of the DER encoding. PEM uses only ASCII characters and can therefore be copy and pasted easily in a clipboard or, some decades ago when this was still relevant, send via email.

### Tools

If you have an ASN.1-encoded file and either you do not know which type it is or you have no application  handling this specific type, you can still decode the raw ASN.1 structure and see what it shows. On Windows, the built-in tool certutil can do this with the command `certutil -decode`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.x509.wiki/important-data-formats/asn.1-and-pem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
