%%
%% This is file `cyber.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cyber.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (c) 2015 Jared Jennings <jjennings@fastmail.fm>
%% 
%% Permission is hereby granted, free of charge, to any person obtaining
%% a copy of this software and associated documentation files (the
%% "Software"), to deal in the Software without restriction, including
%% without limitation the rights to use, copy, modify, merge, publish,
%% distribute, sublicense, and/or sell copies of the Software, and to
%% permit persons to whom the Software is furnished to do so, subject to
%% the following conditions:
%% 
%% The above copyright notice and this permission notice shall be
%% included in all copies or substantial portions of the Software.
%% 
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
%% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
%% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
%% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%% 
%% 
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cyber}
   [2018/01/24 v2.2 Add some semicolons in accordance with DTIC guidance]
\makeatletter
\RequirePackage{longtable}
\RequirePackage{color}
\RequirePackage{index}
\RequirePackage{fancyhdr}
\RequirePackage{graphicx}

\newindex{cybercompliance}{cybercompliance.idx}{cybercompliance.ind}{Compliance}
\AtBeginDocument{
\newwrite\complianceaux
\immediate\openout\complianceaux=cyber_compliance.aux
\newwrite\explanationsaux
\immediate\openout\explanationsaux=cyber_explanations.aux
}

\AtEndDocument{
\immediate\closeout\complianceaux
\immediate\closeout\explanationsaux
}

\def\foreach#1#2#3#4{%
  \@test@foreach{#1}{#2}{#3}#4,\@end@token%
}

\def\@swallow#1{}

\def\@test@foreach#1#2#3{%
  \@ifnextchar\@end@token%
    {\@swallow}%
    {\@foreach{#1}{#2}{#3}}%
}

\def\@foreach#1#2#3#4,#5\@end@token{%
  #1{#2}{#3}{#4}%
  \@test@foreach{#1}{#2}{#3}#5\@end@token%
}

\newcommand{\requirementsdocument}[3]{%
    % Say how to name requirements that come from this document.
    \expandafter\providecommand\csname #1\endcsname[1]{%
        \namedrequirement{#1}{#3}{##1}}
    \expandafter\newcommand\csname indexhead#1\endcsname{#2}
}

\newcommand{\requirement}[2]{%
    \expandafter\csname requirement@#1\endcsname{#2}}

\newcommand{\namedrequirement}[3]{%
    \index[cybercompliance]{\csname indexhead#1\endcsname @\iaindexheadstyle{\csname indexhead#1\endcsname}!{#3}!}%
    {\small #2\mbox{#3}}%
}
\def\addtosectionname#1{}
\newif\ifCyberindexingenabled
\Cyberindexingenabledtrue
\newcommand{\iaindexheadstyle}[1]{%
    \vspace{1em}{\large \textbf{#1}}\vspace{1em}}
\newcommand{\indexhelper}[3]{%
\ifCyberindexingenabled\index[cybercompliance]{\csname indexhead#1\endcsname @\iaindexheadstyle{\csname indexhead#1\endcsname}!{#3}!{#2}}\fi}
\newcommand{\marginhelper}[3]{#2~\mbox{#3}\\ }
\newcommand{\compliancehelper}[3]{%
\write\complianceaux{#1:#3:#2}}
\newcommand{\explanationshelper}[3]{%
\write\explanationsaux{#1:#3:}%
\write\explanationsaux{#2}%
\write\explanationsaux{:}%
}

\newcommand{\sectionnamehelper}[3]{%
    \def\@numberone{#1}%
    \def\@iacontrol{iacontrol}%
    \ifx\@numberone\@iacontrol\addtosectionname{#3}\fi}
\def\iamarginsize{\footnotesize}
\newcommand{\implements}[2]{%
    \@bsphack
    \hspace{0pt}% this makes sure the marginpar doesn't go with the previous
                % paragraph
    \foreach{\indexhelper}{#1}{implemented}{#2}%
    \marginpar{\iamarginsize \raggedright%
        \foreach{\marginhelper}{#1}{auto:}{#2}%
    }%
    \foreach{\compliancehelper}{#1}{compliant}{#2}%
    \foreach{\sectionnamehelper}{#1}{}{#2}%
    \@esphack}
\newcommand{\unimplemented}[3]{%
    \@bsphack
    \hspace{0pt}% this makes sure the marginpar doesn't go with the previous
                % paragraph
    \foreach{\indexhelper}{#1}{\textcolor{red}{unimplemented}}{#2}%
    \marginpar{\iamarginsize \color{red} \raggedright%
        \foreach{\marginhelper}{#1}{}{#2}%
    }%
    \foreach{\compliancehelper}{#1}{non-compliant}{#2}%
    \foreach{\explanationshelper}{#1}{#3}{#2}%
    \foreach{\sectionnamehelper}{#1}{}{#2}%
    {#3}%
    \@esphack}
\newcommand{\bydefault}[3]{%
    \@bsphack
    \hspace{0pt}% this makes sure the marginpar doesn't go with the previous
                % paragraph
    \foreach{\indexhelper}{#2}{default for {#1}}{#3}%
    \marginpar{\iamarginsize \raggedright%
        \foreach{\marginhelper}{#2}{#1: }{#3}%
    }%
    \foreach{\compliancehelper}{#2}{compliant}{#3}%
    \foreach{\sectionnamehelper}{#1}{}{#2}%
    \@esphack}
\newcommand{\notapplicable}[2]{%
    \@bsphack
    \hspace{0pt}% this makes sure the marginpar doesn't go with the previous
                % paragraph
    \foreach{\indexhelper}{#1}{N/A}{#2}%
    \marginpar{\iamarginsize \raggedright%
        \foreach{\marginhelper}{#1}{N/A: }{#2}%
    }%
    \foreach{\compliancehelper}{#1}{N/A}{#2}%
    \@esphack}

\newcommand{\doneby}[3]{%
    \@bsphack
    \hspace{0pt}% this makes sure the marginpar doesn't go with the previous
                % paragraph
    \foreach{\indexhelper}{#2}{prescribed}{#3}%
    \marginpar{\iamarginsize \raggedright%
        \foreach{\marginhelper}{#2}{#1 do }{#3}%
    }%
    \foreach{\compliancehelper}{#2}{compliant}{#3}%
    \foreach{\sectionnamehelper}{#1}{}{#2}%
    \@esphack}

\newcommand{\prescribed}[2]{\doneby{admins}{#1}{#2}}

\newcommand{\documented}[2]{%
    \@bsphack
    \hspace{0pt}% this makes sure the marginpar doesn't go with the previous
                % paragraph
    \foreach{\indexhelper}{#1}{documented}{#2}%
    \marginpar{\iamarginsize \raggedright%
        \foreach{\marginhelper}{#1}{}{#2}%
    }%
    \foreach{\compliancehelper}{#1}{compliant}{#2}%
    \foreach{\sectionnamehelper}{#1}{}{#2}%
    \@esphack}

\newcommand{\documents}[2]{\documented{#1}{#2}}

\newcommand{\articlesecuritylabel}[1]{%
    \pagestyle{fancy}%
    \renewcommand{\headrulewidth}{0pt}%
    \fancyhf{}%
    \chead{#1}%
    \cfoot{\thepage}%
    \fancypagestyle{plain}{%
        \fancyhf{}%
        \fancyhead[C]{#1}%
    }%
}
\newcommand{\booksecuritylabel}[1]{%
    \pagestyle{fancy}%
    \renewcommand{\headrulewidth}{0.1pt}%
    \fancyhf{}%
    \fancyhead[CE,CO]{#1\vspace{2\baselineskip}}%
    \fancyhead[LE,RO]{\thepage}%
    \fancyhead[RE]{\nouppercase{\leftmark}}%
    \fancyhead[LO]{\nouppercase{\rightmark}}%
    %
    \fancypagestyle{empty}{%
        \renewcommand{\headrulewidth}{0pt}%
        \fancyhf{}%
        \fancyhead[C]{#1\vspace{2\baselineskip}}%
    }%
    \fancypagestyle{plain}{%
        \renewcommand{\headrulewidth}{0pt}%
        \fancyhf{}%
        \fancyhead[C]{#1\vspace{2\baselineskip}}%
    \fancyfoot[C]{\thepage}%
    }%
}
\def\@distribution{\@latex@warning@no@line{No distribution statement given}}
\def\@destruction{%
    \textbf{DESTRUCTION NOTICE}: Destroy by any method that will prevent disclosure or reconstruction of the document.}
\def\distributionA#1{%
    \gdef\@distribution{%
        \textbf{DISTRIBUTION STATEMENT A}: Approved for public release. #1}}
\def\distributionB#1#2{%
    \gdef\@distribution{%
        \textbf{DISTRIBUTION STATEMENT B}: Distribution authorized to U.S. Government agencies only; #1; \@date. Other requests for this document shall be referred to #2.}}
\def\distributionC#1#2{%
    \gdef\@distribution{%
        \textbf{DISTRIBUTION STATEMENT C}: Distribution authorized to U.S. Government agencies and their contractors; #1; \@date. Other requests for this document shall be referred to #2.}}
\def\distributionD#1#2{%
    \gdef\@distribution{%
        \textbf{DISTRIBUTION STATEMENT D}: Distribution authorized to the Department of Defense and U.S. DoD contractors only; #1; \@date. Other requests shall be referred to #2.}}
\def\distributionE#1#2{%
    \gdef\@distribution{%
        \textbf{DISTRIBUTION STATEMENT E}: Distribution authorized to DoD Components only; #1; \@date. Other requests shall be referred to #2.}}
\def\distributionF#1{%
    \gdef\@distribution{%
        \textbf{DISTRIBUTION STATEMENT F}: Further dissemination only as directed by #1 \@date\ or higher DoD authority.}}

\def\@version{}

\def\version#1{\gdef\@version{#1}}

\def\today{\number\day\space\ifcase\month\or Jan\or Feb\or Mar\or Apr\or
  May\or Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi
  \space\number\year}

\newcommand{\narrowermargins}{%
    \addtolength{\hoffset}{-0.5in}%
    \addtolength{\textwidth}{1in}%
    \addtolength{\marginparwidth}{-0.5in}%
    \addtolength{\voffset}{-0.5in}%
    \addtolength{\textheight}{1in}%
    % bring up bottom of text to match whitespace at top caused by security
    % label
    \addtolength{\textheight}{-2\baselineskip}%
}
\newcommand{\makedodtitle}[0]{%
    \begin{titlepage}%
    \begin{center}%
    ~\vskip 1.5in%
    {\LARGE \@title \par}%
    \vskip 3em%
    {\large \lineskip .75em \begin{tabular}[t]{c}%
      \@author%
     \end{tabular}\par}%
    {\large \@date \par \large \@version}\vskip 0.5in%
    \includegraphics[width=0.4\textwidth]{org_logo}
    \end{center}\par%
    \@thanks\vskip 0.5in\par%
    \@distribution\par%
    \@destruction%
    \vfil\null
    \end{titlepage}}
\newcommand{\change}[3]{%
    {#1} & {#2} & {#3}\\
}
\newenvironment{changelog}{
    \phantomsection
    \chapter*{Changelog}
    \addcontentsline{toc}{chapter}{Changelog}
    \begin{longtable}{@{\extracolsep{\fill}} l l p{4in}}
    \hline
    {\bf Date} & {\bf Person} & {\bf Change Description}\\
    \hline\hline
    \endhead
}{\end{longtable}}
\newcommand{\executivesummaryiacontrol}[2]{%
    {#1} & {#2}\\
}
\newenvironment{executivesummary}{
    \phantomsection
    \chapter*{Executive Summary}
    \addcontentsline{toc}{chapter}{Executive Summary}
    The following table lists the NIST SP 800-53 Security Controls that are satisfied
    through this artifact.

    \begin{longtable}{@{\extracolsep{\fill}} l p{4in}}
    \hline
    {\bf IA Control Number} & {\bf IA Control Name}\\
    \hline\hline
    \endhead
}{\end{longtable}}
\makeatother
\endinput
%%
%% End of file `cyber.sty'.
