TrustCore SDK NanoCrypto API reference  version 7.0
ecc_edwards.h File Reference

Header for curve25519 and curve448 operations. More...

Go to the source code of this file.

Functions

MOC_EXTERN void CURVE25519_addPoints (projPoint25519 *pResult, const projPoint25519 *pP, const projPoint25519 *pQ, sbyte4 *pTemps)
 Adds two projective form points on curve25519. More...
 
MOC_EXTERN MSTATUS CURVE25519_convertEncodedToProjective (projPoint25519 *pResult, const ubyte *pEncodedInput)
 Converts an encoded point on curve25519 to a projective form. More...
 
MOC_EXTERN MSTATUS CURVE25519_convertProjectiveToEncoded (ubyte *pBuffer, const projPoint25519 *pInput)
 Converts a projective form point on curve25519 to an encoded form point. More...
 
MOC_EXTERN MSTATUS CURVE25519_createCombMutex (void)
 Creates a mutex for thread safety for curve25519 comb generation. More...
 
MOC_EXTERN MSTATUS CURVE25519_deleteCombAndMutex (void)
 Zeroes and frees the persisted comb and mutex for curve25519. More...
 
MOC_EXTERN MSTATUS CURVE25519_multiplyPoint (MOC_ECC(hwAccelDescr hwAccelCtx) projPoint25519 *pResult, const ubyte *pScalar, const projPoint25519 *pP)
 Performs a scalar point multiplication on curve25519. More...
 
MOC_EXTERN MSTATUS CURVE25519_X25519 (MOC_ECC(hwAccelDescr hwAccelCtx) ubyte *pResult, ubyte *pScalar, ubyte *pU)
 Scalar point multiplication for EDDH on curve25519. More...
 
MOC_EXTERN void CURVE448_addPoints (projPoint448 *pResult, const projPoint448 *pP, const projPoint448 *pQ, pf_unit *pTemps)
 Adds two projective form points on curve448. More...
 
MOC_EXTERN MSTATUS CURVE448_convertEncodedToProjective (projPoint448 *pResult, const ubyte *pEncodedInput)
 Converts an encoded point on curve448 to a projective form. More...
 
MOC_EXTERN MSTATUS CURVE448_convertProjectiveToEncoded (ubyte *pBuffer, const projPoint448 *pInput)
 Converts a projective form point on curve448 to an encoded form point. More...
 
MOC_EXTERN MSTATUS CURVE448_createCombMutex (void)
 Creates a mutex for thread safety for curve448 comb generation. More...
 
MOC_EXTERN MSTATUS CURVE448_deleteCombAndMutex (void)
 Zeroes and frees the persisted comb and mutex for curve448. More...
 
MOC_EXTERN MSTATUS CURVE448_multiplyPoint (MOC_ECC(hwAccelDescr hwAccelCtx) projPoint448 *pResult, const ubyte *pScalar, const projPoint448 *pP)
 Performs a scalar point multiplication on curve448. More...
 
MOC_EXTERN MSTATUS CURVE448_X448 (MOC_ECC(hwAccelDescr hwAccelCtx) ubyte *pResult, ubyte *pScalar, ubyte *pU)
 Scalar point multiplication for EDDH on curve448. More...
 

Detailed Description

Documentation file for curve25519 and curve448 operations.

To enable the methods in this file one must define

  • __ENABLE_MOCANA_ECC__ and at least one or more of the following flags
  • __ENABLE_MOCANA_ECC_EDDH_25519__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__
  • __ENABLE_MOCANA_ECC_EDDH_448__
  • __ENABLE_MOCANA_ECC_EDDSA_448__

ecc_edwards.h

Function Documentation

◆ CURVE25519_addPoints()

MOC_EXTERN void CURVE25519_addPoints ( projPoint25519 *  pResult,
const projPoint25519 *  pP,
const projPoint25519 *  pQ,
sbyte4 *  pTemps 
)

Adds two projective form points on curve25519.

Parameters
pResultThe resulting sum. This must be a distinct pointer from pP or pQ.
pPThe first point to be added.
pQThe second point to be added.
pTempsScratch memory space. This must have space for four finite field elements.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__

◆ CURVE25519_convertEncodedToProjective()

MOC_EXTERN MSTATUS CURVE25519_convertEncodedToProjective ( projPoint25519 *  pResult,
const ubyte *  pEncodedInput 
)

Converts an encoded point on curve25519 to a projective form. See the description of CURVE25519_convertProjectiveToEncoded for a description of an encoded point.

Parameters
pResultPointer to the projective form point that will be set.
pEncodedInputBuffer holding The exising encoded point. This must be 32 bytes in length.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE25519_convertProjectiveToEncoded()

MOC_EXTERN MSTATUS CURVE25519_convertProjectiveToEncoded ( ubyte *  pBuffer,
const projPoint25519 *  pInput 
)

Converts a projective form point to an encoded form point. The encoded form consists of the 255 bit affine Y coordinate in a 32 byte (256 bit) buffer in Little Endian (bytewise) form, and with the last bit of the 256 bit buffer set to the least significant bit of the affine X coordinate.

Parameters
pBufferBuffer to hold the resulting encoded form point. This must be 32 bytes in space.
pInputPointer to the input projective form point.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE25519_createCombMutex()

MOC_EXTERN MSTATUS CURVE25519_createCombMutex ( void  )

Creates a mutex to be used for thread safety when creating a scalar point multiplication comb for the generator of the large cyclic group on curve25519.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE25519_deleteCombAndMutex()

MOC_EXTERN MSTATUS CURVE25519_deleteCombAndMutex ( void  )

Zeroes and frees the persisted comb made for the generator of the large cyclic group on curve25519. Also deletes the mutex made for thread safety.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE25519_multiplyPoint()

MOC_EXTERN MSTATUS CURVE25519_multiplyPoint ( MOC_ECC(hwAccelDescr hwAccelCtx) projPoint25519 *  pResult,
const ubyte *  pScalar,
const projPoint25519 *  pP 
)

Performs a scalar point multiplication on curve25519.

Parameters
pResultThe result of the scalar point multiply. This must be a distinct pointer from pP.
pScalarThe scalar in Little endian byte array form. This must be 32 bytes in length.
pPThe point to be scaled. If this is NULL then the curve's large cyclic group generator will be scaled by the scalar.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_25519__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE25519_X25519()

MOC_EXTERN MSTATUS CURVE25519_X25519 ( MOC_ECC(hwAccelDescr hwAccelCtx) ubyte *  pResult,
ubyte *  pScalar,
ubyte *  pU 
)

The scalar point multiply "X25519" method as described in RFC 7748 Section 5. The pU and pResult are actually Montgomery form X-coordinates in Little Endian byte array form with the 256th bit of the buffer cleared. All 3 inputs to this method must be buffers of 32 bytes in length.

Parameters
pResultBuffer to hold the result of the scalar point multiply. It is ok for pResult to be the same buffer as pU.
pScalarBuffer holding the input scalar in Little Endian byte array form.
pUBuffer holding the input point.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDH_25519__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE448_addPoints()

MOC_EXTERN void CURVE448_addPoints ( projPoint448 *  pResult,
const projPoint448 *  pP,
const projPoint448 *  pQ,
pf_unit *  pTemps 
)

Adds two projective form points on curve448.

Parameters
pResultThe resulting sum. This must be a distinct pointer from pP or pQ.
pPThe first point to be added.
pQThe second point to be added.
pTempsScratch memory space. This must have space for seven finite field elements.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_448__

◆ CURVE448_convertEncodedToProjective()

MOC_EXTERN MSTATUS CURVE448_convertEncodedToProjective ( projPoint448 *  pResult,
const ubyte *  pEncodedInput 
)

Converts an encoded point on curve448 to a projective form. See the description of CURVE448_convertProjectiveToEncoded for a description of an encoded point.

Parameters
pResultPointer to the projective form point that will be set.
pEncodedInputBuffer holding The exising encoded point. This must be 57 bytes in length.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_448__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE448_convertProjectiveToEncoded()

MOC_EXTERN MSTATUS CURVE448_convertProjectiveToEncoded ( ubyte *  pBuffer,
const projPoint448 *  pInput 
)

Converts a projective form point to an encoded form point. The encoded form consists of the 448 bit affine Y coordinate in the first 56 bytes of a 57 byte buffer in Little Endian (bytewise) form, and with the most significant bit of the 57th byte being the least significant bit of the affine X coordinate.

Parameters
pBufferBuffer to hold the resulting encoded form point. This must be 57 bytes in space.
pInputPointer to the input projective form point.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_448__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE448_createCombMutex()

MOC_EXTERN MSTATUS CURVE448_createCombMutex ( void  )

Creates a mutex to be used for thread safety when creating a scalar point multiplication comb for the generator of the large cyclic group on curve448.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_448__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE448_deleteCombAndMutex()

MOC_EXTERN MSTATUS CURVE448_deleteCombAndMutex ( void  )

Zeroes and frees the persisted comb made for the generator of the large cyclic group on curve448. Also deletes the mutex made for thread safety.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_448__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE448_multiplyPoint()

MOC_EXTERN MSTATUS CURVE448_multiplyPoint ( MOC_ECC(hwAccelDescr hwAccelCtx) projPoint448 *  pResult,
const ubyte *  pScalar,
const projPoint448 *  pP 
)

Performs a scalar point multiplication on curve448.

Parameters
pResultThe result of the scalar point multiply. This must be a distinct pointer from pP.
pScalarThe scalar in Little endian byte array form. This must be 57 bytes in length.
pPThe point to be scaled. If this is NULL then the curve's large cyclic group generator will be scaled by the scalar.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDSA_448__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ CURVE448_X448()

MOC_EXTERN MSTATUS CURVE448_X448 ( MOC_ECC(hwAccelDescr hwAccelCtx) ubyte *  pResult,
ubyte *  pScalar,
ubyte *  pU 
)

The scalar point multiply "X448" method as described in RFC 7748 Section 5. The pU and pResult are actually Montgomery form X-coordinates in Little Endian byte array form. All 3 inputs to this method must be buffers of 56 bytes in length.

Parameters
pResultBuffer to hold the result of the scalar point multiply. It is ok for pResult to be the same buffer as pU.
pScalarBuffer holding the input scalar in Little Endian byte array form.
pUBuffer holding the input point.

To enable this method one must define both flags

  • __ENABLE_MOCANA_ECC__
  • __ENABLE_MOCANA_ECC_EDDH_448__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h