Protocol++® (Protocolpp®)
v5.6.2
|
#include "include/jsnow3g.h"
SNOW 3G is a word-oriented stream cipher that generates a sequence of 32-bit words under the control of a 128-bit key and a 128-bit initialisation variable. These words can be used to mask the plaintext. First a key initialisation is performed, i.e. the cipher is clocked without producing output, see 4.1. Then with every clock tick it produces a 32-bit word of output
Functions used in different Components of SNOW 3G
MULx maps 16 bits to 8 bits. Let V and c be 8-bit input values. Then MULx is defined:
If the leftmost (i.e. the most significant) bit of V equals 1, then
MULxPOW maps 16 bits and an positive integer i to 8 bit. Let V and c be 8-bit input values, then MULxPOW(V, i, c) is recursively defined:
If i equals 0, then , else
Linear Feedback Shift Register (LFSR)
The Linear Feedback Shift Register (LFSR) consists of sixteen stages each holding 32 bits
Finite State Machine (FSM)
The Finite State Machine (FSM) has three 32-bit registers R1, R2 and R3. The S-boxes S1 and S2 are used to update the registers R2 and R3
The 32x32-bit S-Box S1
The S-Box maps a 32-bit input to a 32-bit output. Let the 32-bit input with the most and the least significant byte
Let with the most and the least significant byte. We use the 8 to 8 bit Rijndael S-Box defined in 5.1
Then are defined as
The 32x32-bit S-Box S2
The S-Box maps a 32-bit input to a 32-bit output. Let the 32-bit input with the most and the least significant byte. Let with the most and the least significant byte. We use the 8 to 8 bit S-Box defined in 5.2
Then are defined as
Clocking the LFSR
The clocking of the LFSR has two different modes of operation, the Initialisation Mode 3.4.4 and the Keystream Mode 3.4.5. In both modes the functions and are used which are defined in 3.4.2 resp. 3.4.3
The function
The function maps 8 bits to 32 bits. Let c be the 8-bit input, then is defined as
The function
The function maps 8 bits to 32 bits. Let c be the 8-bit input, then is defined as
Initialisation Mode
In the Initialisation Mode the LFSR receives a 32-bit input word F, which is the output of the FSM
Let with being the most and being the least significant byte of .
Let with being the most and being the least significant byte of
Compute the intermediate value v as
Set
Keystream Mode
In the Keystream Mode the LFSR does not receive any input
Let with being the most and being the least significant byte of
Let with being the most and being the least significant byte of
Compute the intermediate value v as
v =
Set
Clocking the FSM
The FSM has two input words and from the LFSR. It produces a 32-bit output word F:
Then the registers are updated. Compute the intermediate value r as
Set
Initialisation
SNOW 3G is initialized with a 128-bit key consisting of four 32-bit words and an 128-bit initialisation variable consisting of four 32-bit words as follows
Let 1 be the all-ones word (0xffffffff)
The FSM is initialised with
Then the cipher runs in a special mode without producing output:
repeat 32-times {
STEP 1: The FSM is clocked (see 3.4.6) producing the 32-bit word F
STEP 2: Then the LFSR is clocked in Initialisation Mode (see 3.4.4) consuming F
}
Generation of Keystream
First the FSM is clocked once, see 3.4.6. The output word of the FSM is discarded. Then the LFSR is clocked once in Keystream Mode, see 3.4.4
After that n 32-bit words of keystream are produced:
for t = 1 to n {
STEP 1: The FSM is clocked (see 3.4.6) and produces a 32-bit output word F
STEP 2: The next keystream word is computed as
STEP 3: Then the LFSR is clocked in Keystream Mode, see 3.4.4
}
The Rijndael S-box
The S-box SR maps 8 bit to 8 bit. Here the input and output is presented in hexadecimal form
Let be hexadecimal digits with , then the cell at the intersection of the row and the column contains the values for in hexadecimal form
For example
The S-box
The S-box maps 8 bit to 8 bit. Here the input is presented in hexadecimal form
Let be hexadecimal digits with , then the cell at the intersection of the row and the column contains the values for in hexadecimal form
For example
For API Documentation:
For Additional Documentation:
The source code contained or described herein and all documents related to the source code (herein called "Material") are owned by John Peter Greninger and Sheila Rocha Greninger. Title to the Material remains with John Peter Greninger and Sheila Rocha Greninger. The Material contains trade secrets and proprietary and confidential information of John Peter Greninger and Sheila Rocha Greninger. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without prior express written consent of John Peter Greninger and Sheila Rocha Greninger (both are required)
No license under any patent, copyright, trade secret, or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel, or otherwise. Any license under such intellectual property rights must be express and approved by John Peter Greninger and Sheila Rocha Greninger in writing
Licensing information can be found at www.protocolpp.com/license with use of the binary forms permitted provided that the following conditions are met:
Use of the source code requires purchase of the source code. Source code can be purchased at www.protocolpp.com/shop
The name of its contributor may not be used to endorse or promote products derived from this software without specific prior written permission and licensing
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE