26 #ifndef __DSA_HEADER__ 27 #define __DSA_HEADER__ 29 #include "../cap/capdecl.h" 31 #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE__ 32 #include "../crypto_interface/crypto_interface_dsa_priv.h" 35 #include "../crypto/ffc.h" 43 #define DSA_CONTEXT(X) (X)->p_dsaDescr 44 #define PRIVATE_KEY_BYTE_SIZE (20) 51 #define NUM_DSA_VLONG (5) 52 #define NUM_DSA_MODEXP (2) 56 vlong* dsaVlong[NUM_DSA_VLONG];
58 MocAsymKey pPrivateKey;
59 MocAsymKey pPublicKey;
66 DSA_sha224 = FFC_sha224,
67 DSA_sha256 = FFC_sha256,
68 DSA_sha384 = FFC_sha384,
69 DSA_sha512 = FFC_sha512
79 #define DSA_P(k) ((k)->dsaVlong[0]) 80 #define DSA_Q(k) ((k)->dsaVlong[1]) 81 #define DSA_G(k) ((k)->dsaVlong[2]) 82 #define DSA_Y(k) ((k)->dsaVlong[3]) 83 #define DSA_X(k) ((k)->dsaVlong[4]) 85 typedef struct MDsaKeyTemplate *MDsaKeyTemplatePtr;
169 MOC_EXTERN MSTATUS
DSA_cloneKey(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey** ppNew,
const DSAKey* pSrc);
213 MOC_EXTERN MSTATUS
DSA_freeKey(DSAKey **pp_dsaDescr, vlong **ppVlongQueue);
285 MOC_EXTERN MSTATUS
DSA_generateKey(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, ubyte4 *pRetC, ubyte *pRetSeed, vlong **ppRetH, vlong **ppVlongQueue);
335 MOC_EXTERN MSTATUS
DSA_generateKeyEx(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, ubyte4 qSize, DSAHashType hashType, ubyte4 *pRetC, ubyte *pRetSeed, vlong **ppRetH, vlong **ppVlongQueue);
389 MOC_EXTERN MSTATUS
DSA_computeKeyPair(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, DSAKey *p_dsaDescr, vlong **ppVlongQueue);
429 MOC_EXTERN MSTATUS
DSA_computeKeyPairEx(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 Lin, ubyte4 Nin, vlong **ppVlongQueue);
479 MOC_EXTERN MSTATUS
DSA_computeSignature(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext,
const DSAKey *p_dsaDescr,
480 vlong* m, intBoolean *pVerifySignature, vlong **ppR, vlong **ppS, vlong **ppVlongQueue);
533 RNGFun rngfun,
void* rngArg,
534 const DSAKey *p_dsaDescr, vlong* m,
535 intBoolean *pVerifySignature,
536 vlong **ppR, vlong **ppS, vlong **ppVlongQueue);
586 MOC_EXTERN MSTATUS
DSA_verifySignature(MOC_DSA(hwAccelDescr hwAccelCtx)
const DSAKey *p_dsaDescr,
587 vlong *m, vlong *pR, vlong *pS, intBoolean *isGoodSignature, vlong **ppVlongQueue);
627 MOC_EXTERN MSTATUS
DSA_verifyKeys(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, ubyte *pSeed,
const DSAKey *p_dsaDescr, ubyte4 C, vlong *pH, intBoolean *isGoodKeys, vlong **ppVlongQueue);
682 MOC_EXTERN MSTATUS
DSA_verifyKeysEx(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, ubyte *pSeed, ubyte4 seedSize,
const DSAKey *p_dsaDescr, DSAHashType hashType, DSAKeyType keyType, ubyte4 C, vlong *pH, intBoolean *isGoodKeys, vlong **ppVlongQueue);
716 MOC_EXTERN MSTATUS
DSA_verifyPQ(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx,
717 DSAKey *p_dsaDescr, ubyte4 L, ubyte4 Nin, DSAHashType hashType, DSAKeyType keyType, ubyte4 C,
718 ubyte *pSeed, ubyte4 seedSize, intBoolean *pIsPrimePQ, vlong **ppVlongQueue);
743 MOC_EXTERN MSTATUS
DSA_verifyG(MOC_DSA(hwAccelDescr hwAccelCtx) vlong *pP, vlong *pQ, vlong *pG, intBoolean *isValid, vlong **ppVlongQueue);
792 MOC_EXTERN MSTATUS
DSA_makeKeyBlob(MOC_DSA(hwAccelDescr hwAccelCtx)
const DSAKey *p_dsaDescr, ubyte *pKeyBlob, ubyte4 *pRetKeyBlobLength);
834 MOC_EXTERN MSTATUS
DSA_extractKeyBlob(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey **pp_RetNewDsaDescr,
const ubyte *pKeyBlob, ubyte4 keyBlobLength);
875 MOC_EXTERN MSTATUS
DSA_equalKey(MOC_DSA(hwAccelDescr hwAccelCtx)
const DSAKey *pKey1,
const DSAKey *pKey2, byteBoolean* pResult);
909 MOC_EXTERN MSTATUS
DSA_setAllKeyParameters(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey* pKey,
const ubyte* p, ubyte4 pLen,
910 const ubyte* q, ubyte4 qLen,
911 const ubyte* g, ubyte4 gLen,
912 const ubyte* x, ubyte4 xLen,
913 vlong **ppVlongQueue);
947 const ubyte* q, ubyte4 qLen,
948 const ubyte* g, ubyte4 gLen,
949 const ubyte* y, ubyte4 yLen,
950 vlong **ppVlongQueue);
981 MOC_EXTERN MSTATUS
DSA_setKeyParameters (MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey,
const ubyte* p, ubyte4 pLen,
982 const ubyte* q, ubyte4 qLen,
983 const ubyte* g, ubyte4 gLen,
984 vlong **ppVlongQueue);
1004 MOC_EXTERN MSTATUS
DSA_getCipherTextLength(MOC_DSA(hwAccelDescr hwAccelCtx)
const DSAKey *pKey, sbyte4* cipherTextLen);
1027 MOC_EXTERN MSTATUS
DSA_getSignatureLength (MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, ubyte4 *pSigLen);
1072 MOC_EXTERN MSTATUS
generatePQ(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx,
1073 DSAKey *p_dsaDescr, ubyte4 L,
1074 ubyte4 Nin, DSAHashType hashType,
1075 ubyte4 *pRetC, ubyte *pRetSeed,
1076 vlong **ppVlongQueue);
1108 MOC_EXTERN MSTATUS
generateG(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *p_dsaDescr,
1109 vlong **ppRetH, vlong **ppVlongQueue);
1142 MOC_EXTERN MSTATUS
DSA_generateRandomG (MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *p_dsaDescr,
1143 randomContext *pRandomContext, vlong **ppRetH, vlong **ppVlongQueue);
1176 randomContext *pRandomContext, ubyte **ppH, ubyte4 *pHLen, vlong **ppVlongQueue);
1210 MOC_EXTERN MSTATUS
DSA_generateKeyAux(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, vlong **ppVlongQueue);
1253 MOC_EXTERN MSTATUS
DSA_generateKeyAux2(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext* pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize,
1254 ubyte4 qSize, DSAHashType hashType, vlong **ppVlongQueue);
1291 MOC_EXTERN MSTATUS
DSA_computeSignatureAux(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pRngCtx, DSAKey *pKey, ubyte *pM, ubyte4 mLen, intBoolean *pVerify, ubyte **ppR, ubyte4 *pRLen, ubyte **ppS, ubyte4 *pSLen, vlong **ppVlongQueue);
1328 MOC_EXTERN MSTATUS
DSA_verifySignatureAux(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, ubyte *pM, ubyte4 mLen, ubyte *pR, ubyte4 rLen, ubyte *pS, ubyte4 sLen, intBoolean *pIsGoodSignature, vlong **ppVlongQueue);
1349 MOC_EXTERN MSTATUS
DSA_setKeyParametersAux(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, MDsaKeyTemplatePtr pTemplate);
1373 MOC_EXTERN MSTATUS
DSA_getKeyParametersAlloc(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, MDsaKeyTemplatePtr pTemplate, ubyte keyType);
MOC_EXTERN MSTATUS DSA_generateRandomGAux(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *p_dsaDescr, randomContext *pRandomContext, ubyte **ppH, ubyte4 *pHLen, vlong **ppVlongQueue)
Randomly computes a generator g of the cyclic group of order q.
MOC_EXTERN MSTATUS DSA_verifyKeysEx(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, ubyte *pSeed, ubyte4 seedSize, const DSAKey *p_dsaDescr, DSAHashType hashType, DSAKeyType keyType, ubyte4 C, vlong *pH, intBoolean *isGoodKeys, vlong **ppVlongQueue)
Verify DSA key.
MOC_EXTERN MSTATUS DSA_cloneKey(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey **ppNew, const DSAKey *pSrc)
Clone (copy) a DSA key.
MOC_EXTERN MSTATUS DSA_verifyPQ(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 L, ubyte4 Nin, DSAHashType hashType, DSAKeyType keyType, ubyte4 C, ubyte *pSeed, ubyte4 seedSize, intBoolean *pIsPrimePQ, vlong **ppVlongQueue)
Verifies that the parameters p and q come from seed and initial domain parameters passed in...
MOC_EXTERN MSTATUS DSA_generateRandomG(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *p_dsaDescr, randomContext *pRandomContext, vlong **ppRetH, vlong **ppVlongQueue)
Randomly computes a generator g of the cyclic group of order q.
MOC_EXTERN MSTATUS generatePQ(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 L, ubyte4 Nin, DSAHashType hashType, ubyte4 *pRetC, ubyte *pRetSeed, vlong **ppVlongQueue)
Generates the DSA domain parameters p and q.
MOC_EXTERN MSTATUS DSA_setKeyParametersAux(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, MDsaKeyTemplatePtr pTemplate)
Sets DSA key and domain parameters.
MOC_EXTERN MSTATUS DSA_computeSignature(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const DSAKey *p_dsaDescr, vlong *m, intBoolean *pVerifySignature, vlong **ppR, vlong **ppS, vlong **ppVlongQueue)
Generate DSA signature.
MOC_EXTERN MSTATUS DSA_generateKeyEx(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, ubyte4 qSize, DSAHashType hashType, ubyte4 *pRetC, ubyte *pRetSeed, vlong **ppRetH, vlong **ppVlongQueue)
Generate DSA key pair (private and public keys).
MOC_EXTERN MSTATUS DSA_generateKeyAux2(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, ubyte4 qSize, DSAHashType hashType, vlong **ppVlongQueue)
Generate DSA key pair (private and public keys) and associated parameters with flexibility to set the...
MOC_EXTERN MSTATUS DSA_freeKeyTemplate(DSAKey *pKey, MDsaKeyTemplatePtr pTemplate)
Frees the fields within a key template.
MOC_EXTERN MSTATUS DSA_freeKey(DSAKey **pp_dsaDescr, vlong **ppVlongQueue)
Free (delete) a DSA key.
MOC_EXTERN MSTATUS DSA_makeKeyBlob(MOC_DSA(hwAccelDescr hwAccelCtx) const DSAKey *p_dsaDescr, ubyte *pKeyBlob, ubyte4 *pRetKeyBlobLength)
Get DSA key blob converted from DSA key data structure.
MOC_EXTERN MSTATUS DSA_computeKeyPairEx(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 Lin, ubyte4 Nin, vlong **ppVlongQueue)
Generate DSA key pair (but not their associated parameters).
MOC_EXTERN MSTATUS DSA_setAllKeyParameters(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, const ubyte *p, ubyte4 pLen, const ubyte *q, ubyte4 qLen, const ubyte *g, ubyte4 gLen, const ubyte *x, ubyte4 xLen, vlong **ppVlongQueue)
Sets all the DSA domain and key parameters in a DSA key.
MOC_EXTERN MSTATUS DSA_equalKey(MOC_DSA(hwAccelDescr hwAccelCtx) const DSAKey *pKey1, const DSAKey *pKey2, byteBoolean *pResult)
Determine whether two DSA keys are equal.
MOC_EXTERN MSTATUS DSA_getKeyParametersAlloc(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, MDsaKeyTemplatePtr pTemplate, ubyte keyType)
Gets DSA key and domain parameters.
MOC_EXTERN MSTATUS DSA_verifySignature(MOC_DSA(hwAccelDescr hwAccelCtx) const DSAKey *p_dsaDescr, vlong *m, vlong *pR, vlong *pS, intBoolean *isGoodSignature, vlong **ppVlongQueue)
Verify message's DSA signature.
MOC_EXTERN MSTATUS DSA_extractKeyBlob(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey **pp_RetNewDsaDescr, const ubyte *pKeyBlob, ubyte4 keyBlobLength)
Get DSA key data structure converted from DSA key blob.
MOC_EXTERN MSTATUS DSA_computeKeyPair(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, vlong **ppVlongQueue)
Generate DSA key pair (but not their associated parameters).
MOC_EXTERN MSTATUS DSA_verifySignatureAux(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, ubyte *pM, ubyte4 mLen, ubyte *pR, ubyte4 rLen, ubyte *pS, ubyte4 sLen, intBoolean *pIsGoodSignature, vlong **ppVlongQueue)
Verifies a DSA signature.
MOC_EXTERN MSTATUS DSA_computeSignatureEx(MOC_DSA(hwAccelDescr hwAccelCtx) RNGFun rngfun, void *rngArg, const DSAKey *p_dsaDescr, vlong *m, intBoolean *pVerifySignature, vlong **ppR, vlong **ppS, vlong **ppVlongQueue)
This is the same as DSAComputeSignature, except that it uses an RNGFun and rngArg to generate the ran...
MOC_EXTERN MSTATUS DSA_getCipherTextLength(MOC_DSA(hwAccelDescr hwAccelCtx) const DSAKey *pKey, sbyte4 *cipherTextLen)
Gets the length in bytes of the DSA prime p.
MOC_EXTERN MSTATUS DSA_setPublicKeyParameters(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, const ubyte *p, ubyte4 pLen, const ubyte *q, ubyte4 qLen, const ubyte *g, ubyte4 gLen, const ubyte *y, ubyte4 yLen, vlong **ppVlongQueue)
Sets all the DSA domain and public key parameters in a DSA key.
MOC_EXTERN MSTATUS DSA_verifyG(MOC_DSA(hwAccelDescr hwAccelCtx) vlong *pP, vlong *pQ, vlong *pG, intBoolean *isValid, vlong **ppVlongQueue)
Verifies that g generates a cyclic group of prime order q.
sbyte4(* RNGFun)(void *rngFunArg, ubyte4 length, ubyte *buffer)
Function pointer type for a method that produces (pseudo) random bytes.
Definition: random.h:98
MOC_EXTERN MSTATUS DSA_createKey(DSAKey **pp_dsaDescr)
Create memory storage for a DSA key.
MOC_EXTERN MSTATUS generateG(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *p_dsaDescr, vlong **ppRetH, vlong **ppVlongQueue)
Deterministically computes a generator g of the cyclic group of order q.
MOC_EXTERN MSTATUS DSA_computeSignatureAux(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pRngCtx, DSAKey *pKey, ubyte *pM, ubyte4 mLen, intBoolean *pVerify, ubyte **ppR, ubyte4 *pRLen, ubyte **ppS, ubyte4 *pSLen, vlong **ppVlongQueue)
Computes the DSA signature.
MOC_EXTERN MSTATUS DSA_generateKeyAux(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, vlong **ppVlongQueue)
Generate DSA key pair (private and public keys) and associated parameters.
MOC_EXTERN MSTATUS DSA_generateKey(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, DSAKey *p_dsaDescr, ubyte4 keySize, ubyte4 *pRetC, ubyte *pRetSeed, vlong **ppRetH, vlong **ppVlongQueue)
Generate DSA key pair (private and public keys) and associated parameters.
MOC_EXTERN MSTATUS DSA_verifyKeys(MOC_DSA(hwAccelDescr hwAccelCtx) randomContext *pFipsRngCtx, ubyte *pSeed, const DSAKey *p_dsaDescr, ubyte4 C, vlong *pH, intBoolean *isGoodKeys, vlong **ppVlongQueue)
Verify DSA key.
MOC_EXTERN MSTATUS DSA_setKeyParameters(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, const ubyte *p, ubyte4 pLen, const ubyte *q, ubyte4 qLen, const ubyte *g, ubyte4 gLen, vlong **ppVlongQueue)
Sets the DSA domain parameters in a DSA key.
MOC_EXTERN MSTATUS DSA_getSignatureLength(MOC_DSA(hwAccelDescr hwAccelCtx) DSAKey *pKey, ubyte4 *pSigLen)
Gets the length in bytes of the DSA prime q and therefore the signature components r and s...