security/nss/lib/freebl/rijndael.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/rijndael.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef _RIJNDAEL_H_
     1.9 +#define _RIJNDAEL_H_ 1
    1.10 +
    1.11 +#include "blapii.h"
    1.12 +
    1.13 +#define RIJNDAEL_MIN_BLOCKSIZE 16 /* bytes */
    1.14 +#define RIJNDAEL_MAX_BLOCKSIZE 32 /* bytes */
    1.15 +
    1.16 +typedef SECStatus AESBlockFunc(AESContext *cx, 
    1.17 +                               unsigned char *output,
    1.18 +                               const unsigned char *input);
    1.19 +
    1.20 +/* RIJNDAEL_NUM_ROUNDS
    1.21 + *
    1.22 + * Number of rounds per execution
    1.23 + * Nk - number of key bytes
    1.24 + * Nb - blocksize (in bytes)
    1.25 + */
    1.26 +#define RIJNDAEL_NUM_ROUNDS(Nk, Nb) \
    1.27 +    (PR_MAX(Nk, Nb) + 6)
    1.28 +
    1.29 +/* RIJNDAEL_MAX_STATE_SIZE 
    1.30 + *
    1.31 + * Maximum number of bytes in the state (spec includes up to 256-bit block
    1.32 + * size)
    1.33 + */
    1.34 +#define RIJNDAEL_MAX_STATE_SIZE 32
    1.35 +
    1.36 +/*
    1.37 + * This magic number is (Nb_max * (Nr_max + 1))
    1.38 + * where Nb_max is the maximum block size in 32-bit words,
    1.39 + *       Nr_max is the maximum number of rounds, which is Nb_max + 6
    1.40 + */
    1.41 +#define RIJNDAEL_MAX_EXP_KEY_SIZE (8 * 15)
    1.42 +
    1.43 +/* AESContextStr
    1.44 + *
    1.45 + * Values which maintain the state for Rijndael encryption/decryption.
    1.46 + *
    1.47 + * iv          - initialization vector for CBC mode
    1.48 + * Nb          - the number of bytes in a block, specified by user
    1.49 + * Nr          - the number of rounds, specified by a table
    1.50 + * expandedKey - the round keys in 4-byte words, the length is Nr * Nb
    1.51 + * worker      - the encryption/decryption function to use with worker_cx
    1.52 + * destroy     - if not NULL, the destroy function to use with worker_cx
    1.53 + * worker_cx   - the context for worker and destroy
    1.54 + * isBlock     - is the mode of operation a block cipher or a stream cipher?
    1.55 + */
    1.56 +struct AESContextStr
    1.57 +{
    1.58 +    unsigned int   Nb;
    1.59 +    unsigned int   Nr;
    1.60 +    freeblCipherFunc worker;
    1.61 +    /* NOTE: The offsets of iv and expandedKey are hardcoded in intel-aes.s.
    1.62 +     * Don't add new members before them without updating intel-aes.s. */
    1.63 +    unsigned char iv[RIJNDAEL_MAX_BLOCKSIZE];
    1.64 +    PRUint32      expandedKey[RIJNDAEL_MAX_EXP_KEY_SIZE];
    1.65 +    freeblDestroyFunc destroy;
    1.66 +    void	      *worker_cx;
    1.67 +    PRBool	      isBlock;
    1.68 +};
    1.69 +
    1.70 +#endif /* _RIJNDAEL_H_ */

mercurial