#ifndef SECMATH_H
#define SECMATH_H

/**
  @file secmath.h

  @brief This header file defines the interface to all crypto math
         operations.

   The approach to crypto math operations can be broken into two types: provide
   big integer operations and let the caller construct the operations they need
   from such primitives, or make a crypto math library that is tuned for the type
   of operations that the crypto library is performing. This library is performing
   the latter
*/

/*===========================================================================
   Copyright (c) 2011 by Qualcomm Technologies, Incorporated.  All Rights Reserved.
===========================================================================*/

/*===========================================================================

                            EDIT HISTORY FOR FILE

  $Header: //components/rel/ssg.tz/1.0.2/securemsm/secmath/shared/inc/secmath.h#1 $
  $DateTime: 2018/02/06 03:00:17 $
  $Author: pwbldsvc $

when       who      what, where, why
--------   ---      ------------------------------------
05/11/11   vg             Initial Revision

===========================================================================*/

#include "comdef.h"
#include "secmath_err.h"

/**
 * @addtogroup SecMath
 * @{
 */
#ifdef __cplusplus
extern "C"
{
#endif


typedef uint32 BLONG;
#define MAX_KEY_SIZE 4128                          ///< Maximum key size in bits
#define BLONG_SIZE sizeof(BLONG)                   ///< Bytes per digit
#define BLONGS_PER_KEY  (MAX_KEY_SIZE + 8*BLONG_SIZE - 1)/(8*BLONG_SIZE)  ///< Digits per key


typedef struct
{
  BLONG a[BLONGS_PER_KEY];             ///< Make room for multiplication
  int n;                                         ///< Current length of a
} BigInt;

/**
 * @brief
 *  Read an unsigned buffer of bytes into a big integer
 */
SECMATH_ERRNO_ET secmath_BIGINT_read_unsigned_bin(BigInt * a, const uint8 * buf,
                                                  uint32 len);

#ifdef __cplusplus
}
#endif

/// @}

#endif
