{"size": 3286, "ext": "scrbl", "max_stars_repo_path": "doc/utils/rfc/pem.scrbl", "max_stars_repo_name": "christoff-buerger/sagittarius-scheme", "max_stars_repo_stars_event_min_datetime": "2015-11-07T07:13:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T03:35:14.000Z", "max_issues_repo_path": "doc/utils/rfc/pem.scrbl", "max_issues_repo_name": "christoff-buerger/sagittarius-scheme", "max_issues_repo_issues_event_min_datetime": "2016-04-28T21:59:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T08:42:21.000Z", "max_forks_repo_path": "doc/utils/rfc/pem.scrbl", "max_forks_repo_name": "christoff-buerger/sagittarius-scheme", "max_forks_repo_forks_event_min_datetime": "2016-12-28T12:41:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-26T20:52:02.000Z"}
{"max_stars_count": 39, "max_issues_count": 3, "max_forks_count": 4, "avg_line_length": 32.86, "max_line_length": 80, "alphanum_fraction": 0.7133292757}
@; -*- coding: utf-8 -*-
@subsection[:tag "rfc.pem"]{(rfc pem) - PEM format  library}

@define[Library]{@name{(rfc pem)}}
@desc{This library provides PEM format file parser.

Currently only supports RFC 1421 format.
}

@subsubsection{Conditions}

This library defines these conditions.

@define["Condition Type"]{@name{&pem-error}}
@desc{Super condition of all PEM file process related conditions.}

@define["Condition Type"]{@name{&invalid-pem-format}}
@desc{This condition indicates, given PEM file contains invalid format.}
@define[Function]{@name{invalid-pem-format?} @args{obj}}
@desc{Returns #t, if the given @var{obj} is @code{&invalid-pem-format},
otherwise #f.}

@define["Condition Type"]{@name{&pre-eb-as-boundary}}
@desc{This condition indicates, given PEM file contains Pre-Encapsulation 
Boundary as the end of Encapsulated Message without specifying 
@code{:multiple}.}
@define[Function]{@name{pre-eb-as-boundary?} @args{obj}}
@desc{Returns #t, if the given @var{obj} is @code{&pre-eb-as-boundary},
otherwise #f.}

@subsubsection{Operations}

@define[Function]{@name{parse-pem}
 @args{in :key (multiple #f) (builder #f) (asn1 #f) decoder}}
@desc{@var{in} must be textual input port.

Parses given input port @var{in} and returns 2 values, parameter alist and
decoded bytevector.

Keyword arguments
@dl-list{
  @dl-item[@code{multiple}]{
    When this keyword argument is #t, then the procedure returns a list which
    contains alist of parameter and content.

    This parameter is useful for the PEM files which contains multiple contents.
  }
  @dl-item[@code{builder}]{
    This keyword argument must take a procedure which accept one argument or
    #f. If @var{builder} is specified then the given procedure will be called
    to build then contents of the PEM.

    This argument is not correspond with @var{asn1} keyword argument and has
    higher priority. So if both arguments are specified, then @var{builder}
    will be used.
  }
  @dl-item[@code{asn1}]{
    When this keyword argument is #t, then the procedure converts BASE64
    bytevector to ASN.1 object defined in @code{(asn.1)} library.
  }
  @dl-item[@code{decorder}]{
    When this keyword argument is specified, it must be a procedure which
    accepts one argument, then the @code{parse-pem} uses the specified
    procedure to convert body of the PEM content.

    If it's not specified, the procedure uses BASE64 decoding.
  }
}

The procedure may raise following conditions:
@dl-list{
  @dl-item[@code{&invalid-pem-format}]{
    When given @var{in} contains invalid PEM format.
  }
  @dl-item[@code{&pre-eb-as-boundary}]{
    When given @var{in} contains Pre-Encapsulation Boundary as the end of
    Encapsulated Message and @code{:multiple} is #f.

    For example:
    @codeblock{
-----BEGIN FOO-----
... foo value ...
-----BEGIN BAR-----
... bar value...
-----END BAR-----
    }
    parsing PEM like above must specify @code{:multiple} with true value.
    Otherwise, @code{&pre-eb-as-boundary} is signaled.
  }
}
}

@define[Function]{@name{parse-pem-file} @args{file :rest options}}
@define[Function]{@name{parse-pem-string} @args{pem-string :rest options}}
@desc{Convenient procedures.

Parse given file and PEM string, respectively.

@var{option} will be passed to the @code{parse-pem}.
}