tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cmac.h (1586B)


      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/. */
      4 
      5 #ifndef _CMAC_H_
      6 #define _CMAC_H_
      7 
      8 typedef struct CMACContextStr CMACContext;
      9 
     10 SEC_BEGIN_PROTOS
     11 
     12 /* Enum for identifying the underlying block cipher we're using internally. */
     13 typedef enum {
     14    CMAC_AES = 0
     15 } CMACCipher;
     16 
     17 /* Initialize an existing CMACContext struct. */
     18 SECStatus CMAC_Init(CMACContext *ctx, CMACCipher type,
     19                    const unsigned char *key, unsigned int key_len);
     20 
     21 /* Allocate and initialize a new CMAC context with the specified cipher and
     22 * key. */
     23 CMACContext *CMAC_Create(CMACCipher type, const unsigned char *key,
     24                         unsigned int key_len);
     25 
     26 /* Called automatically by CMAC_*{Create,Init}(...). Only useful for restarting
     27 * an already-started CMAC instance. */
     28 SECStatus CMAC_Begin(CMACContext *ctx);
     29 
     30 /* Add the specified bytes into the CMAC state. */
     31 SECStatus CMAC_Update(CMACContext *ctx, const unsigned char *data,
     32                      unsigned int data_len);
     33 
     34 /* Finalize the CMAC state and return the result. */
     35 SECStatus CMAC_Finish(CMACContext *ctx, unsigned char *result,
     36                      unsigned int *result_len,
     37                      unsigned int max_result_len);
     38 
     39 /* Note: CMAC_Clone isn't implemented here because AES doesn't expose a
     40 * context-cloning operation. */
     41 
     42 /* Destroy a CMAC context, optionally freeing it. */
     43 void CMAC_Destroy(CMACContext *ctx, PRBool free_it);
     44 
     45 SEC_END_PROTOS
     46 
     47 #endif