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

Header for Edward's curve Digital Signature (EDDSA) related methods. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS edDSA_finalSign (MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *pEdDSA_ctx, ubyte *pSignature, ubyte4 bufferSize, ubyte4 *pSignatureLen, void *pExtCtx)
 Finalizes an edDSA_CTX and outputs the signature. More...
 
MOC_EXTERN MSTATUS edDSA_finalVerify (MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *pEdDSA_ctx, ubyte4 *pVerifyStatus, void *pExtCtx)
 Finalizes an edDSA_CTX context and writes the verify status. More...
 
MOC_EXTERN MSTATUS edDSA_initSignPreHash (MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *pEdDSA_ctx, edECCKey *pKey, BulkHashAlgo *pShaSuite, ubyte *pCtx, ubyte4 ctxLen, void *pExtCtx)
 Initializes an edDSA_CTX for use in the EdDSA sign algorithm. More...
 
MOC_EXTERN MSTATUS edDSA_initVerify (MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *pEdDSA_ctx, edECCKey *pKey, ubyte *pSignature, ubyte4 signatureLen, BulkHashAlgo *pShaSuite, byteBoolean preHash, ubyte *pCtx, ubyte4 ctxLen, void *pExtCtx)
 Initializes an edDSA_CTX for use in the EdDSA verify algorithm. More...
 
MOC_EXTERN MSTATUS edDSA_Sign (MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte *pMessage, ubyte4 messageLen, ubyte *pSignature, ubyte4 bufferSize, ubyte4 *pSignatureLen, BulkHashAlgo *pShaSuite, byteBoolean preHash, ubyte *pCtx, ubyte4 ctxLen, void *pExtCtx)
 Signs a message via the EdDSA algorithm. More...
 
MOC_EXTERN MSTATUS edDSA_update (MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *pEdDSA_ctx, ubyte *pMessage, ubyte4 messageLen, void *pExtCtx)
 Updates an edDSA_CTX with data. More...
 
MOC_EXTERN MSTATUS edDSA_VerifySignature (MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte *pMessage, ubyte4 messageLen, ubyte *pSignature, ubyte4 signatureLen, ubyte4 *pVerifyStatus, BulkHashAlgo *pShaSuite, byteBoolean preHash, ubyte *pCtx, ubyte4 ctxLen, void *pExtCtx)
 A one shot verify of a message via the EdDSA algorithm. More...
 

Detailed Description

Documentation file for Edward's curve Digital Signature (EDDSA) related methods.

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_EDDSA_25519__
  • __ENABLE_MOCANA_ECC_EDDSA_448__

ecc_edwards_dsa.h

Function Documentation

◆ edDSA_finalSign()

MOC_EXTERN MSTATUS edDSA_finalSign ( MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *  pEdDSA_ctx,
ubyte *  pSignature,
ubyte4  bufferSize,
ubyte4 *  pSignatureLen,
void *  pExtCtx 
)

Finalizes an edDSA_CTX and outputs the signature.

Parameters
pEdDSA_ctxPointer to a previous initialized context.
pSignatureBuffer that will hold the resulting signature.
bufferSizeThe length of the buffer pSignature in bytes.
pSignatureLenContents will be set to the number of bytes actually written to the pSignature buffer.
pExtCtxAn extended context reserved for future use.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ edDSA_finalVerify()

MOC_EXTERN MSTATUS edDSA_finalVerify ( MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *  pEdDSA_ctx,
ubyte4 *  pVerifyStatus,
void *  pExtCtx 
)

Finalizes an edDSA_CTX context and writes the verify status.

Parameters
pEdDSA_ctxPointer to a previous initialized and updated context.
pVerifyStatusContents will be set to 0 for a valid signature and a nonzero value for an invalid signature.
pExtCtxAn extended context reserved for future use.
Warning
Be sure to check for both a return status of OK and a verify status of 0 before accepting that a signature is valid.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ edDSA_initSignPreHash()

MOC_EXTERN MSTATUS edDSA_initSignPreHash ( MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *  pEdDSA_ctx,
edECCKey *  pKey,
BulkHashAlgo pShaSuite,
ubyte *  pCtx,
ubyte4  ctxLen,
void *  pExtCtx 
)

Initializes an edDSA_CTX for use in the EdDSA sign algorithm. The appropriate SHA Suite must be passed in. This is SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.

Parameters
pEdDSA_ctxPointer to the context to be initialized.
pKeyPointer to the public key.
pSignatureBuffer holding the signature to be verified.
signatureLenThe length of the signature in bytes.
pShaSuiteThe SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.
pCtxOptional. For curve25519 set to non-null for Ed25519ctx mode. For curve448 the context is optional for pre-hash mode.
ctxLenThe length of the context in bytes. This cannot be more than 255.
pExtCtxAn extended context reserved for future use.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ edDSA_initVerify()

MOC_EXTERN MSTATUS edDSA_initVerify ( MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *  pEdDSA_ctx,
edECCKey *  pKey,
ubyte *  pSignature,
ubyte4  signatureLen,
BulkHashAlgo pShaSuite,
byteBoolean  preHash,
ubyte *  pCtx,
ubyte4  ctxLen,
void *  pExtCtx 
)

Initializes an edDSA_CTX for use in the EdDSA verify algorithm. The appropriate SHA Suite must be passed in. This is SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.

Parameters
pEdDSA_ctxPointer to the context to be initialized.
pKeyPointer to the public key.
pSignatureBuffer holding the signature to be verified.
signatureLenThe length of the signature in bytes.
pShaSuiteThe SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.
preHashSet to TRUE (1) for EdDSAph "pre-hash" mode.
pCtxOptional. For curve25519 set to non-null for Ed25519ctx mode. For curve448 the context is optional for pure Ed448 or pre-hash mode.
ctxLenThe length of the context in bytes. This cannot be more than 255.
pExtCtxAn extended context reserved for future use.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ edDSA_Sign()

MOC_EXTERN MSTATUS edDSA_Sign ( MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *  pKey,
ubyte *  pMessage,
ubyte4  messageLen,
ubyte *  pSignature,
ubyte4  bufferSize,
ubyte4 *  pSignatureLen,
BulkHashAlgo pShaSuite,
byteBoolean  preHash,
ubyte *  pCtx,
ubyte4  ctxLen,
void *  pExtCtx 
)

Signs a message via the EdDSA algorithm. The appropriate SHA Suite must be passed in. This is SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.

Parameters
pKeyPointer to the private signing key.
pMessageBuffer holding the message to be signed.
messageLenThe length of the message in bytes.
pSignatureBuffer that will hold the resulting signature.
bufferSizeThe length of the buffer pSignature in bytes.
pSignatureLenContents will be set to the number of bytes actually written to the pSignature buffer.
pShaSuiteThe SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.
preHashSet to TRUE (1) for EdDSAph "pre-hash" mode.
pCtxOptional. For curve25519 set to non-null for Ed25519ctx mode. For curve448 the context is optional for pure Ed448 or pre-hash mode.
ctxLenThe length of the context in bytes. This cannot be more than 255.
pExtCtxAn extended context reserved for future use.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ edDSA_update()

MOC_EXTERN MSTATUS edDSA_update ( MOC_ECC(hwAccelDescr hwAccelCtx) edDSA_CTX *  pEdDSA_ctx,
ubyte *  pMessage,
ubyte4  messageLen,
void *  pExtCtx 
)

Updates an edDSA_CTX with some portion of the data to be signed or verified. You may call this API as many times as is appropriate.

Parameters
pEdDSA_ctxPointer to a previous initialized context.
pMessageBuffer holding the message or portion of the message to be signed or verified.
messageLenThe length of the message or portion of the message in bytes.
pExtCtxAn extended context reserved for future use.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ edDSA_VerifySignature()

MOC_EXTERN MSTATUS edDSA_VerifySignature ( MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *  pKey,
ubyte *  pMessage,
ubyte4  messageLen,
ubyte *  pSignature,
ubyte4  signatureLen,
ubyte4 *  pVerifyStatus,
BulkHashAlgo pShaSuite,
byteBoolean  preHash,
ubyte *  pCtx,
ubyte4  ctxLen,
void *  pExtCtx 
)

A one shot verify of a message via the EdDSA algorithm. The appropriate SHA Suite must be passed in. This is SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.

Parameters
pKeyPointer to the public key.
pMessageBuffer holding the message to be verified.
messageLenThe length of the message in bytes.
pSignatureBuffer holding the signature to be verified.
signatureLenThe length of the signature in bytes.
pVerifyStatusContents will be set to 0 for a valid signature and a nonzero value for an invalid signature.
pShaSuiteThe SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448.
preHashSet to TRUE (1) for EdDSAph "pre-hash" mode.
pCtxOptional. For curve25519 set to non-null for Ed25519ctx mode. For curve448 the context is optional for pure Ed448 or pre-hash mode.
ctxLenThe length of the context in bytes. This cannot be more than 255.
pExtCtxAn extended context reserved for future use.
Warning
Be sure to check for both a return status of OK and a verify status of 0 before accepting that a signature is valid.
Returns
OK (0) if successful execution of the method, otherwise a negative number error code from merrors.h