security/nss/lib/freebl/rijndael.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef _RIJNDAEL_H_
     6 #define _RIJNDAEL_H_ 1
     8 #include "blapii.h"
    10 #define RIJNDAEL_MIN_BLOCKSIZE 16 /* bytes */
    11 #define RIJNDAEL_MAX_BLOCKSIZE 32 /* bytes */
    13 typedef SECStatus AESBlockFunc(AESContext *cx, 
    14                                unsigned char *output,
    15                                const unsigned char *input);
    17 /* RIJNDAEL_NUM_ROUNDS
    18  *
    19  * Number of rounds per execution
    20  * Nk - number of key bytes
    21  * Nb - blocksize (in bytes)
    22  */
    23 #define RIJNDAEL_NUM_ROUNDS(Nk, Nb) \
    24     (PR_MAX(Nk, Nb) + 6)
    26 /* RIJNDAEL_MAX_STATE_SIZE 
    27  *
    28  * Maximum number of bytes in the state (spec includes up to 256-bit block
    29  * size)
    30  */
    31 #define RIJNDAEL_MAX_STATE_SIZE 32
    33 /*
    34  * This magic number is (Nb_max * (Nr_max + 1))
    35  * where Nb_max is the maximum block size in 32-bit words,
    36  *       Nr_max is the maximum number of rounds, which is Nb_max + 6
    37  */
    38 #define RIJNDAEL_MAX_EXP_KEY_SIZE (8 * 15)
    40 /* AESContextStr
    41  *
    42  * Values which maintain the state for Rijndael encryption/decryption.
    43  *
    44  * iv          - initialization vector for CBC mode
    45  * Nb          - the number of bytes in a block, specified by user
    46  * Nr          - the number of rounds, specified by a table
    47  * expandedKey - the round keys in 4-byte words, the length is Nr * Nb
    48  * worker      - the encryption/decryption function to use with worker_cx
    49  * destroy     - if not NULL, the destroy function to use with worker_cx
    50  * worker_cx   - the context for worker and destroy
    51  * isBlock     - is the mode of operation a block cipher or a stream cipher?
    52  */
    53 struct AESContextStr
    54 {
    55     unsigned int   Nb;
    56     unsigned int   Nr;
    57     freeblCipherFunc worker;
    58     /* NOTE: The offsets of iv and expandedKey are hardcoded in intel-aes.s.
    59      * Don't add new members before them without updating intel-aes.s. */
    60     unsigned char iv[RIJNDAEL_MAX_BLOCKSIZE];
    61     PRUint32      expandedKey[RIJNDAEL_MAX_EXP_KEY_SIZE];
    62     freeblDestroyFunc destroy;
    63     void	      *worker_cx;
    64     PRBool	      isBlock;
    65 };
    67 #endif /* _RIJNDAEL_H_ */

mercurial