package core:encoding/pem

⌘K
Ctrl+K
or
/

    Overview

    Encodes and decodes PEM formatted data.

    See: https://www.rfc-editor.org/rfc/rfc7468.html

    Types

    Block ¶

    Block :: struct {
    	label: string,
    	data:  [dynamic]u8,
    }
     

    Block is a block of PEM encoded data.

    Related Procedures With Parameters
    Related Procedures With Returns

    Decode_Error ¶

    Decode_Error :: enum int {
    	None, 
    	Bad_Boundary,         // Invalid boundary line.
    	Bad_Label,            // Invalid label in BEGIN/END boundary line.
    	Bad_Data,             // Invalid base64 data.
    	Label_Mismatch,       // Label in END boundary line does not match.
    	Missing_End_Boundary, // End of data without END boundary.
    }

    Error ¶

    Error :: union {
    	runtime.Allocator_Error, 
    	Decode_Error, 
    }
    Related Procedures With Returns

    Constants

    LABEL_ATTRIBUTE_CERTIFICATE ¶

    LABEL_ATTRIBUTE_CERTIFICATE :: "ATTRIBUTE CERTIFICATE"
     

    RFC 5755

    LABEL_CERTIFICATE ¶

    LABEL_CERTIFICATE :: "CERTIFICATE"
     

    RFC 5280

    LABEL_CERTIFICATE_REQUEST ¶

    LABEL_CERTIFICATE_REQUEST :: "CERTIFICATE REQUEST"
     

    RFC 2986

    LABEL_CMS ¶

    LABEL_CMS :: "CMS"
     

    RFC 5652

    LABEL_ENCRYPTED_PRIVATE_KEY ¶

    LABEL_ENCRYPTED_PRIVATE_KEY :: "ENCRYPTED PRIVATE KEY"
     

    RFC 5958

    LABEL_PKCS7 ¶

    LABEL_PKCS7 :: "PKCS7"
     

    RFC 2315

    LABEL_PRIVATE_KEY ¶

    LABEL_PRIVATE_KEY :: "PRIVATE KEY"
     

    RFC 5208/ RFC 5958

    LABEL_PUBLIC_KEY ¶

    LABEL_PUBLIC_KEY :: "PUBLIC KEY"
     

    RFC 5280

    LABEL_X509_CRL ¶

    LABEL_X509_CRL :: "X509_CRL"
     

    RFC 5280

    Variables

    This section is empty.

    Procedures

    block_bytes ¶

    block_bytes :: proc(blk: ^Block) -> []u8 {…}
     

    block_bytes returns a slice to the Block's data.

    block_delete ¶

    block_delete :: proc(blk: ^Block) {…}
     

    block_delete frees a Block returned from decode.

    Note: No allocator is specified as decode uses the same allocator for everything.

    decode ¶

    decode :: proc(data: []u8, allocator := context.allocator) -> (blk: ^Block, remaining: []u8, err: Error) {…}
     

    decode decodes the first encountered PEM block, returning the resulting block, remaining data, and nil iff the process was successful.

    Note: No PEM blocks will result in this procedure returning all nils, and is not considered an error.

    encode ¶

    encode :: proc(label: string, data: []u8, newline: bool = false, allocator := context.allocator) -> (res: []u8, err: runtime.Allocator_Error) #optional_ok {…}
     

    encode encodes the specified label and data into PEM format.

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2026-06 (vendor "odin") Windows_amd64 @ 2026-06-07 21:58:31.804950500 +0000 UTC