Imports #
"bytes"
"encoding/base64"
"errors"
"io"
"slices"
"strings"
"bytes"
"encoding/base64"
"errors"
"io"
"slices"
"strings"
var colon = *ast.CallExpr
var nl = []byte{...}
var pemEnd = *ast.CallExpr
var pemEndOfLine = *ast.CallExpr
const pemLineLength = 64
var pemStart = *ast.CallExpr
A Block represents a PEM encoded structure. The encoded form is: -----BEGIN Type----- Headers base64-encoded Bytes -----END Type----- where [Block.Headers] is a possibly empty sequence of Key: Value lines.
type Block struct {
Type string
Headers map[string]string
Bytes []byte
}
type lineBreaker struct {
line [pemLineLength]byte
used int
out io.Writer
}
func (l *lineBreaker) Close() (err error)
Decode will find the next PEM formatted block (certificate, private key etc) in the input. It returns that block and the remainder of the input. If no PEM data is found, p is nil and the whole of the input is returned in rest.
func Decode(data []byte) (p *Block, rest []byte)
Encode writes the PEM encoding of b to out.
func Encode(out io.Writer, b *Block) error
EncodeToMemory returns the PEM encoding of b. If b has invalid headers and cannot be encoded, EncodeToMemory returns nil. If it is important to report details about this error case, use [Encode] instead.
func EncodeToMemory(b *Block) []byte
func (l *lineBreaker) Write(b []byte) (n int, err error)
getLine results the first \r\n or \n delineated line from the given byte array. The line does not include trailing whitespace or the trailing new line bytes. The remainder of the byte array (also not including the new line bytes) is also returned and this will always be smaller than the original argument.
func getLine(data []byte) (line []byte, rest []byte)
removeSpacesAndTabs returns a copy of its input with all spaces and tabs removed, if there were any. Otherwise, the input is returned unchanged. The base64 decoder already skips newline characters, so we don't need to filter them out here.
func removeSpacesAndTabs(data []byte) []byte
func writeHeader(out io.Writer, k string, v string) error
Generated with Arrow