@@ -799,7 +799,7 @@ \subsection{Background}
799799$ P$ under the key $ k$ as $ E_k(P)$ . In some modes there exists an initialization vector denoted as $ C_{-1}$ .
800800
801801\subsubsection {ECB Mode }
802- \index {ECB mode }
802+ \index {ECB Mode }
803803ECB or Electronic Codebook Mode is the simplest method to use. It is given as:
804804\begin {equation }
805805C_i = E_k(P_i)
@@ -808,7 +808,7 @@ \subsubsection{ECB Mode}
808808than once.
809809
810810\subsubsection {CBC Mode }
811- \index {CBC mode }
811+ \index {CBC Mode }
812812CBC or Cipher Block Chaining mode is a simple mode designed to prevent trivial forms of replay and swap attacks on ciphers.
813813It is given as:
814814\begin {equation }
@@ -817,7 +817,7 @@ \subsubsection{CBC Mode}
817817It is important that the initialization vector be unique and preferably random for each message encrypted under the same key.
818818
819819\subsubsection {CTR Mode }
820- \index {CTR mode }
820+ \index {CTR Mode }
821821CTR or Counter Mode is a mode which only uses the encryption function of the cipher. Given a initialization vector which is
822822treated as a large binary counter the CTR mode is given as:
823823\begin {eqnarray }
@@ -829,24 +829,24 @@ \subsubsection{CTR Mode}
829829as the block cipher is under a chosen plaintext attack (provided the initialization vector is unique).
830830
831831\subsubsection {CFB Mode }
832- \index {CFB mode }
832+ \index {CFB Mode }
833833CFB or Ciphertext Feedback Mode is a mode akin to CBC. It is given as:
834834\begin {eqnarray }
835835C_i = P_i \oplus C_{-1} \nonumber \\
836836C_{-1} = E_k(C_i)
837837\end {eqnarray }
838- Note that in this library the output feedback width is equal to the size of the block cipher. That is this mode is used
839- to encrypt whole blocks at a time . However, the library will buffer data allowing the user to encrypt or decrypt partial
838+ The library supports all output feedback widths as specified in NIST SP 800-38A: CFB1, CFB8, and CFB64 resp. CFB128, i.e. equal
839+ to the size of the block cipher . The library will buffer data allowing the user to encrypt or decrypt partial
840840blocks without a delay. When this mode is first setup it will initially encrypt the initialization vector as required.
841841
842842\subsubsection {OFB Mode }
843- \index {OFB mode }
843+ \index {OFB Mode }
844844OFB or Output Feedback Mode is a mode akin to CBC as well. It is given as:
845845\begin {eqnarray }
846846C_{-1} = E_k(C_{-1}) \nonumber \\
847847C_i = P_i \oplus C_{-1}
848848\end {eqnarray }
849- Like the CFB mode the output width in CFB mode is the same as the width of the block cipher. OFB mode will also
849+ The output width in OFB mode is the same as the width of the block cipher. OFB mode will also
850850buffer the output which will allow you to encrypt or decrypt partial blocks without delay.
851851
852852\subsection {Choice of Mode }
@@ -874,8 +874,8 @@ \subsection{Ciphertext Stealing}
874874The more sane way to deal with partial blocks is to pad them with zeroes, and then use CBC normally.
875875
876876\subsection {Initialization }
877- \index {CBC Mode } \index {CTR Mode }
878- \index {OFB Mode } \index {CFB Mode }
877+ \index {CBC Initialization } \index {CTR Initialization }
878+ \index {OFB Initialization } \index {CFB Initialization }
879879The library provides simple support routines for handling CBC, CTR, CFB, OFB and ECB encoded messages. Assuming the mode
880880you want is XXX there is a structure called \textit {symmetric\_ XXX } that will contain the information required to
881881use that mode. They have identical setup routines (except CTR and ECB mode):
@@ -913,6 +913,7 @@ \subsection{Initialization}
913913The routines return {\bf CRYPT\_ OK} if the cipher initialized correctly, otherwise, they return an error code.
914914
915915\subsubsection {CTR Mode }
916+ \index {CTR Initialization - specific}
916917In the case of CTR mode there is an additional parameter \textit {ctr\_ mode } which specifies the mode that the counter is to be used in.
917918If \textbf {CTR\_ COUNTER\_ LITTLE\_ ENDIAN } was specified then the counter will be treated as a little endian value. Otherwise, if
918919\textbf {CTR\_ COUNTER\_ BIG\_ ENDIAN } was specified the counter will be treated as a big endian value. As of v1.15 the RFC 3686 style of
@@ -942,6 +943,37 @@ \subsubsection{CTR Mode}
942943Changing the counter size has little (really no) effect on the performance of the CTR chaining mode. It is provided for compatibility
943944with other software (and hardware) which have smaller fixed sized counters.
944945
946+ \subsubsection {CFB Mode }
947+ \index {CFB Initialization - specific}
948+
949+ In the case of the CFB mode there are multiple segment sizes possible. The most common one, where each processed segment equals the
950+ block size of the underlying cipher, and two speciality modes. 1-bit CFB mode and 8-bit CFB mode, where each processed segment is
951+ either 1 or 8 bits wide. Each segment denotes here one block cipher operation.
952+ To produce 16 bytes AES-CFB output, a single AES operation is required.
953+ To produce 16 bytes AES-CFB8 output, 16 AES operations are required.
954+ To produce 16 bytes AES-CFB1 output, 128 AES operations are required.
955+
956+ The extended setup API looks as follows and accepts the values \textit {0, 1, 8 and 64 or 128 }. Whether \textit {64 } or \textit {128 } is
957+ accepted depends on the block size of the underlying cipher, \textit {0 } will automatically select the block size as width.
958+
959+ \begin {small }
960+ \begin {verbatim }
961+ /**
962+ Extended initialization of a CFB context
963+ @param cipher The index of the cipher desired
964+ @param IV The initialization vector
965+ @param key The secret key
966+ @param keylen The length of the secret key (octets)
967+ @param num_rounds Number of rounds in the cipher desired (0 for default)
968+ @param width The width of the mode (0 for default)
969+ @param cfb The CFB state to initialize
970+ @return CRYPT_OK if successful
971+ */
972+ int cfb_start_ex(int cipher, const unsigned char *IV, const unsigned char *key,
973+ int keylen, int num_rounds, int width, symmetric_CFB *cfb);
974+ \end {verbatim }
975+ \end {small }
976+
945977\subsection {Encryption and Decryption }
946978To actually encrypt or decrypt the following routines are provided:
947979\index {ecb\_ encrypt()} \index {ecb\_ decrypt()} \index {cfb\_ encrypt()} \index {cfb\_ decrypt()}
0 commit comments