Visible to Intel only — GUID: GUID-4974E8B2-56AF-4F09-9028-C46CD89A7D5B
Introducing Intel® Integrated Performance Primitives Cryptography
Getting Help and Support
Notational Conventions
Getting Started with Intel® Integrated Performance Primitives Cryptography
Intel® Integrated Performance Primitives Cryptography Theory of Operation
Linking Your Application with Intel® Integrated Performance Primitives Cryptography
Using Custom Library Tool for Intel® Integrated Performance Primitives
Programming with Intel® Integrated Performance Primitives Cryptography in the Microsoft* Visual Studio* IDE
Performance Test Tool (perfsys) Command Line Options
Intel® IPP Cryptography Threading and OpenMP* Support
Intel® Integrated Performance Primitives Cryptography API Reference
Notices and Disclaimers
Related Products
Overview
Symmetric Cryptography Primitive Functions
One-Way Hash Primitives
Data Authentication Primitive Functions
Public Key Cryptography Functions
Finite Field Arithmetic
Mitigation for Frequency Throttling Side-Channel Attack
Multi-buffer Cryptography Functions
Support Functions and Classes
Removed Functions
Bibliography
AESGetSize
AESInit
AESSetKey
AESPack, AESUnpack
AESEncryptECB
AESDecryptECB
AESEncryptCBC
AESDecryptCBC
AESEncryptCBC_CS
AESDecryptCBC_CS
AESEncryptCFB
AES_EncryptCFB16_MB
AESDecryptCFB
AESEncryptOFB
AESDecryptOFB
AESEncryptCTR
AESDecryptCTR
AESEncryptXTS_Direct, AESDecryptXTS_Direct
Example of Using AES Functions
HashGetSize
HashInit
HashPack, HashUnpack
HashDuplicate
HashUpdate
HashFinal
HashGetTag
HashMethod
HashMethodSet
HashStateMethodSet
HashMethodGetSize
SM3GetSize
SM3Init
SM3Pack, SM3Unpack
SM3Duplicate
SM3Update
SM3Final
SM3GetTag
MD5GetSize
MD5Init
MD5Pack, MD5Unpack
MD5Duplicate
MD5Update
MD5Final
MD5GetTag
SHA1GetSize
SHA1Init
SHA1Pack, SHA1Unpack
SHA1Duplicate
SHA1Update
SHA1Final
SHA1GetTag
SHA224GetSize
SHA224Init
SHA224Pack, SHA224Unpack
SHA224Duplicate
SHA224Update
SHA224Final
SHA224GetTag
SHA256GetSize
SHA256Init
SHA256Pack, SHA256Unpack
SHA256Duplicate
SHA256Update
SHA256Final
SHA256GetTag
SHA384GetSize
SHA384Init
SHA384Pack, SHA384Unpack
SHA384Duplicate
SHA384Update
SHA384Final
SHA384GetTag
SHA512GetSize
SHA512Init
SHA512Pack, SHA512Unpack
SHA512Duplicate
SHA512Update
SHA512Final
SHA512GetTag
RSA_GetSizePublicKey, RSA_GetSizePrivateKeyType1, RSA_GetSizePrivateKeyType2
RSA_InitPublicKey, RSA_InitPrivateKeyType1, RSA_InitPrivateKeyType2
RSA_SetPublicKey, RSA_SetPrivateKeyType1, RSA_SetPrivateKeyType2
RSA_GetPublicKey, RSA_GetPrivateKeyType1, RSA_GetPrivateKeyType2
RSA_GetBufferSizePublicKey, RSA_GetBufferSizePrivateKey
RSA_MB_GetBufferSizePublicKey, RSA_MB_GetBufferSizePrivateKey
RSA_GenerateKeys
RSA_ValidateKeys
DLPGetSize
DLPInit
DLPPack, DLPUnpack
DLPSet
DLPGet
DLPSetDP
DLPGetDP
DLPGenKeyPair
DLPPublicKey
DLPValidateKeyPair
DLPSetKeyPair
DLPGenerateDSA
DLPValidateDSA
DLPSignDSA
DLPVerifyDSA
Example of Using Discrete-logarithm Based Primitive Functions
DLPGenerateDH
DLPValidateDH
DLPSharedSecretDH
DLGetResultString
ECCPGetSize
ECCPGetSizeStd
ECCPInit
ECCPInitStd
ECCPBindGxyTblStd
ECCPSet
ECCPSetStd
ECCPGet
ECCPGetOrderBitSize
ECCPValidate
ECCPPointGetSize
ECCPPointInit
ECCPSetPoint
ECCPSetPointAtInfinity
ECCPGetPoint
ECCPCheckPoint
ECCPComparePoint
ECCPNegativePoint
ECCPAddPoint
ECCPMulPointScalar
ECCPGenKeyPair
ECCPPublicKey
ECCPValidateKeyPair
ECCPSetKeyPair
ECCPSharedSecretDH
ECCPSharedSecretDHC
ECCPSignDSA
ECCPVerifyDSA
ECCPSignNR
ECCPVerifyNR
ECCPSignSM2
ECCPVerifySM2
Signing/Verification Using the Elliptic Curve Cryptography Functions over a Prime Finite Field
GFpECESGetSize_SM2
GFpECESInit_SM2
GFpECESSetKey_SM2
GFpECESStart_SM2
GFpECESEncrypt_SM2
GFpECESDecrypt_SM2
GFpECESFinal_SM2
GFpECESGetBufferSize_SM2
GFpECEncryptSM2_Ext_EncMsgSize
GFpECDecryptSM2_Ext_DecMsgSize
GFpECEncryptSM2_Ext
GFpECDecryptSM2_Ext
GFpECMessageRepresentationSM2
GFpECUserIDHashSM2
GFpECKeyExchangeSM2_GetSize
GFpECKeyExchangeSM2_Init
GFpECKeyExchangeSM2_Setup
GFpECKeyExchangeSM2_SharedKey
GFpECKeyExchangeSM2_Confirm
GFpECGetSize
GFpECInit
GFpECSet
GFpECSetSubgroup
GFpECInitStd
GFpECGet
GFpECGetSubgroup
GFpECScratchBufferSize
GFpECVerify
GFpECPointGetSize
GFpECPointInit
GFpECSetPointAtInfinity
GFpECSetPoint, GFpECSetPointREgular
GFpECSetPointOctString
GFpECSetPointRandom
GFpECMakePoint
GFpECSetPointHash, GFpECSetPointHashBackCompatible, GFpECSetPointHash_rmf, GFpECSetPointHashBackCompatible_rmf
GFpECGetPoint , GFpECGetPointRegular
GFpECGetPointOctString
GFpECTstPoint
GFpECTstPointInSubgroup
GFpECCpyPoint
GFpECCmpPoint
GFpECNegPoint
GFpECAddPoint
GFpECMulPoint
GFpECPrivateKey, GFpECPublicKey, GFpECTstKeyPair
GFpECPublicKey
GFpECTstKeyPair
GFpECPSharedSecretDH, GFpECPSharedSecretDHC
GFpECSharedSecretDHC
GFpECPSignDSA, GFpECPSignNR, GFpECPSignSM2
GFpECPVerifyDSA, GFpECPVerifyNR, GFpECPVerifySM2
GFpECSignNR
GFpECVerifyNR
GFpECSignSM2
GFpECVerifySM2
GFpInit
GFpMethod
GFpGetSize
GFpxInitBinomial
GFpxInit
GFpxMethod
GFpxGetSize
GFpScratchBufferSize
GFpElementGetSize
GFpElementInit
GFpSetElement
GFpSetElementOctString
GFpSetElementRandom
GFpSetElementHash
GFpCpyElement
GFpGetElement
GFpGetElementOctString
GFpCmpElement
GFpIsZeroElement
GFpIsUnityElement
GFpConj
GFpNeg
GFpInv
GFpSqrt
GFpAdd
GFpSub
GFpMul
GFpSqr
GFpExp
GFpMultiExp
GFpAdd_PE
GFpSub_PE
GFpMul_PE
RSA Algorithm Functions (MBX)
NIST Recommended Elliptic Curve Functions
Montgomery Curve25519 Elliptic Curve Functions
Edwards Curve25519 Elliptic Curve Functions
SM2 Elliptic Curve Functions
SM3 Hash Functions
SM4 Algorithm Functions
SM4 XTS Algorithm Functions
SM4 CCM Algorithm Functions
SM4 GCM Algorithm Functions
Modular Exponentiation
Visible to Intel only — GUID: GUID-4974E8B2-56AF-4F09-9028-C46CD89A7D5B
Signing/Verification Using the Elliptic Curve Cryptography Functions over a Prime Finite Field
Use of ECCPSignDSA, ECCPVerifyDSA
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#include "ippcp.h"
static IppsECCPState* newStd_256_ECP(void)
{
int ctxSize;
ippsECCPGetSize(256, &ctxSize);
IppsECCPState* pCtx = (IppsECCPState*)( new Ipp8u [ctxSize] );
ippsECCPInit(256, pCtx);
ippsECCPSetStd(IppECCPStd256r1, pCtx);
return pCtx;
}
static IppsECCPPointState* newECP_256_Point(void)
{
int ctxSize;
ippsECCPPointGetSize(256, &ctxSize);
IppsECCPPointState* pPoint = (IppsECCPPointState*)( new Ipp8u [ctxSize] );
ippsECCPPointInit(256, pPoint);
return pPoint;
}
static IppsBigNumState* newBN(int len, const Ipp32u* pData)
{
int ctxSize;
ippsBigNumGetSize(len, &ctxSize);
IppsBigNumState* pBN = (IppsBigNumState*)( new Ipp8u [ctxSize] );
ippsBigNumInit(len, pBN);
if(pData)
ippsSet_BN(IppsBigNumPOS, len, pData, pBN);
return pBN;
}
IppsPRNGState* newPRNG(void)
{
int ctxSize;
ippsPRNGGetSize(&ctxSize);
IppsPRNGState* pCtx = (IppsPRNGState*)( new Ipp8u [ctxSize] );
ippsPRNGInit(160, pCtx);
return pCtx;
}
int main(void)
{
// define standard 256-bit EC
IppsECCPState* pECP = newStd_256_ECP();
// extract or use any other way to get order(ECP)
const Ipp32u secp256r1_r[] = {0xFC632551, 0xF3B9CAC2, 0xA7179E84, 0xBCE6FAAD
0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF};
const int ordSize = sizeof(secp256r1_r)/sizeof(Ipp32u);
IppsBigNumState* pECPorder = newBN(ordSize, secp256r1_r);
// define a message to be signed; let it be random, for example
IppsPRNGState* pRandGen = newPRNG(); // 'external' PRNG
Ipp32u tmpData[ordSize];
ippsPRNGen(tmpData, 256, pRandGen);
IppsBigNumState* pRandMsg = newBN(ordSize, tmpData); // random 256-bit message
IppsBigNumState* pMsg = newBN(ordSize, 0); // msg to be signed
ippsMod_BN(pRandMsg, pECPorder, pMsg);
// declare Signer's regular and ephemeral key pair
IppsBigNumState* regPrivate = newBN(ordSize, 0);
IppsBigNumState* ephPrivate = newBN(ordSize, 0);
// define Signer's ephemeral key pair
IppsECCPPointState* regPublic = newECP_256_Point();
IppsECCPPointState* ephPublic = newECP_256_Point();
// generate regular & ephemeral key pairs, should be different each other
ippsECCPGenKeyPair(regPrivate, regPublic, pECP, ippsPRNGen, pRandGen);
ippsECCPGenKeyPair(ephPrivate, ephPublic, pECP, ippsPRNGen, pRandGen);
//
// signature
//
// set ephemeral key pair
ippsECCPSetKeyPair(ephPrivate, ephPublic, ippFalse, pECP);
// compure signature
IppsBigNumState* signX = newBN(ordSize, 0);
IppsBigNumState* signY = newBN(ordSize, 0);
ippsECCPSignDSA(pMsg, regPrivate, signX, signY, pECP);
//
// verification
//
ippsECCPSetKeyPair(NULL, regPublic, ippTrue, pECP);
IppECResult eccResult;
ippsECCPVerifyDSA(pMsg, signX,signY, &eccResult, pECP);
if(ippECValid == eccResult)
cout << "signature verificatioin passed" <<endl;
else
cout << "signature verificatioin failed" <<endl;
delete [] (Ipp8u*)signX;
delete [] (Ipp8u*)signY;
delete [] (Ipp8u*)ephPublic;
delete [] (Ipp8u*)regPublic;
delete [] (Ipp8u*)ephPrivate;
delete [] (Ipp8u*)regPrivate;
delete [] (Ipp8u*)pRandMsg;
delete [] (Ipp8u*)pMsg;
delete [] (Ipp8u*)pRandGen;
delete [] (Ipp8u*)pECPorder;
delete [] (Ipp8u*)pECP;
return 0;
}