{
  "classes": [
    {
      "constants": [],
      "types": [],
      "name": "@eryx/crypto/pem",
      "tags": [],
      "functions": [
        {
          "source": {
            "path": "",
            "line": 50
          },
          "is_method": false,
          "signature": "pem.encode(\n    label: string,  -- The PEM label (the text that appears between the dashes).\n    data: buffer  -- Raw DER bytes to encode.\n) → (\n    string  -- PEM-formatted string. \n)",
          "owner": "pem",
          "desc": "Wraps raw DER bytes in a PEM block with the given label.\n\nThe output follows RFC 7468: base64-encoded content is line-wrapped at\n64 characters, with `-----BEGIN <label>-----` and `-----END <label>-----`\nheader/footer lines.\n\nCommon labels: `\"RSA PRIVATE KEY\"`, `\"PUBLIC KEY\"`, `\"CERTIFICATE\"`,\n`\"CERTIFICATE REQUEST\"`.\n\n```luau\nlocal pemS = pem.encode(\"PUBLIC KEY\", derBytes)\n-- \"-----BEGIN PUBLIC KEY-----\\nMIIB...\\n-----END PUBLIC KEY-----\\n\"\n```\n",
          "tags": [],
          "name": "encode",
          "return_str": "string",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "string",
              "desc": "PEM-formatted string. "
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "label",
              "desc": "The PEM label (the text that appears between the dashes)."
            },
            {
              "lua_type": "buffer",
              "name": "data",
              "desc": "Raw DER bytes to encode."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 75
          },
          "is_method": false,
          "signature": "pem.decode(\n    pemStr: string  -- A string containing at least one PEM block.\n) → (\n    string,  -- The label from the BEGIN line.\n    buffer  -- Raw DER bytes. \n)",
          "owner": "pem",
          "desc": "Decodes the **first** PEM block found in `pemStr` and returns its\nlabel and raw DER bytes.\n\nWhitespace inside the base64 body (including CRLF line endings) is\nignored. Raises an error if no valid PEM block is found.\n\n```luau\nlocal label, der = pem.decode(pemStr)\nprint(label)  -- e.g. \"RSA PRIVATE KEY\"\n```\n",
          "tags": [],
          "name": "decode",
          "return_str": "(string, buffer)",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The label from the BEGIN line."
            },
            {
              "lua_type": "buffer",
              "desc": "Raw DER bytes. "
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "pemStr",
              "desc": "A string containing at least one PEM block."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 100
          },
          "is_method": false,
          "signature": "pem.decodeAll(\n    pemStr: string  -- A string containing one or more PEM blocks.\n) → (\n    {{label: string, data: buffer}}  -- Array of decoded PEM blocks. \n)",
          "owner": "pem",
          "desc": "Decodes **all** PEM blocks found in `pemStr` and returns them as an\narray.\n\nUseful when a single file contains multiple certificates or keys (e.g.\na CA bundle or a certificate chain).\n\n```luau\nlocal blocks = pem.decodeAll(chain_pem)\nfor _, block in blocks do\n    print(block.label, buffer.len(block.data))\nend\n```\n",
          "tags": [],
          "name": "decodeAll",
          "return_str": "{ { label: string, data: buffer } }",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "{ { label: string, data: buffer } }",
              "desc": "Array of decoded PEM blocks. "
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "pemStr",
              "desc": "A string containing one or more PEM blocks."
            }
          ]
        }
      ],
      "properties": [],
      "source": {
        "path": "",
        "line": 0
      },
      "desc": "PEM (Privacy-Enhanced Mail) encoding and decoding.\n\nPEM is the standard text format for cryptographic objects such as\nkeys and certificates. A PEM file wraps a base64-encoded DER blob\nbetween `-----BEGIN <label>-----` and `-----END <label>-----` markers.\n\nThis module handles the text-level encoding only - it converts between\nPEM strings and raw DER `buffer` values. It does not parse the ASN.1\nstructure inside the DER. To work with RSA keys specifically, see\n`@eryx/crypto/rsa` which provides [[rsa.private_to_der]], etc.\n\n```luau\nlocal pem = require(\"@eryx/crypto/pem\")\nlocal rsa = require(\"@eryx/crypto/rsa\")\n\nlocal priv = rsa.generate_key()\n\n-- Convert PEM -> DER -> PEM (round-trip)\nlocal der   = rsa.private_to_der(priv)\nlocal pemS = pem.encode(\"RSA PRIVATE KEY\", der)\nlocal label, der2 = pem.decode(pemS)\nassert(label == \"RSA PRIVATE KEY\")\n```\n"
    }
  ]
}