xilpki
Vitis Drivers API Documentation
XilPKI Library APIs

Data Structures

struct  XPki_Request_Info
 PKI Request info struct. More...
 

Macros

#define XPKI_INVALID_PARAM   0x2U
 Error codes. More...
 
#define XPKI_ERROR_UNALIGN_ADDR   0x3U
 For unaligned address. More...
 
#define XPKI_INVALID_QUEUE_ID   0x4U
 Invalid Queue ID. More...
 
#define XPKI_UNSUPPORTED_OPS   0x5U
 Unsupported operation. More...
 
#define XPKI_QUEUE_FULL   0x6U
 Queue full. More...
 
#define XPKI_SLOT_SIZE_ERR   0x7U
 For incompatiable slot size. More...
 
#define XPKI_INVALID_REQ_ID   0x8U
 Invalid request ID. More...
 
#define XPKI_SIGN_COPY_ERR   0x9U
 Failed to copy the signature into the user pointed buffer. More...
 
#define XPKI_PRIV_KEY_COPY_ERR   0xAU
 Failed to copy the private-key into the user pointed buffer. More...
 
#define XPKI_PUB_KEY_COPY_ERR   0xBU
 Failed to copy the public-key into the user pointed buffer. More...
 
#define NIST_P192_LEN_BYTES   24U
 Bytes. More...
 
#define NIST_P384_LEN_BYTES   48U
 Bytes. More...
 
#define NIST_P256_LEN_BYTES   32U
 Bytes. More...
 
#define NIST_P521_LEN_BYTES   66U
 Bytes. More...
 

Enumerations

enum  Xpki_OpsType {
  PKI_ECC_NIST_P192_SIGN = 1, PKI_ECC_NIST_P256_SIGN, PKI_ECC_NIST_P384_SIGN, PKI_ECC_NIST_P521_SIGN,
  PKI_ECC_NIST_P192_SIGN_VERIFY, PKI_ECC_NIST_P256_SIGN_VERIFY, PKI_ECC_NIST_P384_SIGN_VERIFY, PKI_ECC_NIST_P521_SIGN_VERIFY,
  PKI_ECC_NIST_P192_KEY_PRIV_GEN, PKI_ECC_NIST_P256_KEY_PRIV_GEN, PKI_ECC_NIST_P384_KEY_PRIV_GEN, PKI_ECC_NIST_P521_KEY_PRIV_GEN,
  PKI_ECC_NIST_P192_KEY_PUB_GEN, PKI_ECC_NIST_P256_KEY_PUB_GEN, PKI_ECC_NIST_P384_KEY_PUB_GEN, PKI_ECC_NIST_P521_KEY_PUB_GEN,
  PKI_MAX_OPS
}
 PKI ECC supported operation. More...
 
enum  XPki_EcdsaCrvType { ECC_NIST_P192 = 1, ECC_NIST_P256, ECC_NIST_P384, ECC_NIST_P521 }
 
enum  XPki_EcdsaCrv { ECC_BINARY = 1, ECC_PRIME }
 

Functions

void XPki_Reset (void)
 This function reset the PKI module. More...
 
void XPki_SoftReset (void)
 This function performs the PKI module soft reset. More...
 
int XPki_Initialize (XPki_Instance *InstancePtr)
 This function performs the PKI module initialization. More...
 
int XPki_EcdsaGenerateKeyPair (XPki_Instance *InstancePtr, XPki_EcdsaCrvType CrvType, XPki_EcdsaKey *PubKey, u8 *PrivKey)
 This function Generate key pairs for the ECC curves NIST-P192, P256, P384, and P521. More...
 
int XPki_EcdsaVerifySignKat (XPki_Instance *InstancePtr, XPki_EcdsaCrvInfo *CrvInfo)
 This function performs ECC sign verify known answer test(KAT) More...
 
int XPki_EcdsaSignGenerateKat (XPki_Instance *InstancePtr, XPki_EcdsaCrvInfo *CrvInfo)
 This function performs ECC sign generate known answer test(KAT) More...
 
int XPki_EcdsaPwct (XPki_Instance *InstancePtr, XPki_EcdsaCrvInfo *CrvInfo, XPki_EcdsaKey *PubKey, u8 *PrivKey)
 This function performs ECC pairwise consistency test on ECC Curves. More...
 
int XPki_TrngGenerateRandomNum (u8 GenSize, u8 *RandBuf)
 This function is used to generate the Random number for the give size. More...
 
int XilPki_EnQueue (XPki_Instance *InstancePtr, XPki_Request_Info *Request_InfoPtr, u32 *RequestID)
 This function is used to submit the crypto operation to the PKI Queue. More...
 
int XilPki_DeQueue (XPki_Instance *InstancePtr, XPki_Request_Info *Request_InfoPtr, u32 RequestID)
 This function is used to get the crypto operation results from the PKI Queue. More...
 
void XPki_Close (void)
 This function is used to disable access to the PKI Hardware. More...
 

Variables

void * XPki_Request_Info::PtrInputData
 Pointer to the input data. More...
 
void * XPki_Request_Info::PtrOutputData
 Pointer to the outout data. More...
 
Xpki_OpsType XPki_Request_Info::OpsType
 ECC operation type. More...
 
void(* XPki_Request_Info::XPki_CompletionCallBack )(u32 RequestID, u32 Status)
 Request completion callback function pointer. More...
 

Macro Definition Documentation

#define NIST_P192_LEN_BYTES   24U

Bytes.

#define NIST_P256_LEN_BYTES   32U

Bytes.

#define NIST_P384_LEN_BYTES   48U

Bytes.

#define NIST_P521_LEN_BYTES   66U

Bytes.

#define XPKI_ERROR_UNALIGN_ADDR   0x3U

For unaligned address.

#define XPKI_INVALID_PARAM   0x2U

Error codes.

Invalid parameters

Referenced by XilPki_DeQueue(), XilPki_EnQueue(), and XPki_Initialize().

#define XPKI_INVALID_QUEUE_ID   0x4U

Invalid Queue ID.

#define XPKI_INVALID_REQ_ID   0x8U

Invalid request ID.

#define XPKI_PRIV_KEY_COPY_ERR   0xAU

Failed to copy the private-key into the user pointed buffer.

#define XPKI_PUB_KEY_COPY_ERR   0xBU

Failed to copy the public-key into the user pointed buffer.

#define XPKI_QUEUE_FULL   0x6U

Queue full.

Referenced by XilPki_EnQueue().

#define XPKI_SIGN_COPY_ERR   0x9U

Failed to copy the signature into the user pointed buffer.

#define XPKI_SLOT_SIZE_ERR   0x7U

For incompatiable slot size.

#define XPKI_UNSUPPORTED_OPS   0x5U

Unsupported operation.

Referenced by XilPki_EnQueue().

Enumeration Type Documentation

Enumerator
ECC_BINARY 

ECC Binary curve.

ECC_PRIME 

ECC Prime curve.

Enumerator
ECC_NIST_P192 

NIST P-192 curve.

ECC_NIST_P256 

NIST P-256 curve.

ECC_NIST_P384 

NIST P-384 curve.

ECC_NIST_P521 

NIST P-251 curve.

PKI ECC supported operation.

Enumerator
PKI_ECC_NIST_P192_SIGN 

ECC NIST P-192 signature generation.

PKI_ECC_NIST_P256_SIGN 

ECC NIST P-256 signature generation.

PKI_ECC_NIST_P384_SIGN 

ECC NIST P-384 signature generation.

PKI_ECC_NIST_P521_SIGN 

ECC NIST P-521 signature generation.

PKI_ECC_NIST_P192_SIGN_VERIFY 

ECC NIST P-192 signature verification.

PKI_ECC_NIST_P256_SIGN_VERIFY 

ECC NIST P-256 signature verification.

PKI_ECC_NIST_P384_SIGN_VERIFY 

ECC NIST P-384 signature verification.

PKI_ECC_NIST_P521_SIGN_VERIFY 

ECC NIST P-521 signature verification.

PKI_ECC_NIST_P192_KEY_PRIV_GEN 

ECC NIST P-192 private-key generation.

PKI_ECC_NIST_P256_KEY_PRIV_GEN 

ECC NIST P-256 private-key generation.

PKI_ECC_NIST_P384_KEY_PRIV_GEN 

ECC NIST P-384 private-key generation.

PKI_ECC_NIST_P521_KEY_PRIV_GEN 

ECC NIST P-521 private-key generation.

PKI_ECC_NIST_P192_KEY_PUB_GEN 

ECC NIST P-192 public-key generation.

PKI_ECC_NIST_P256_KEY_PUB_GEN 

ECC NIST P-256 public-key generation.

PKI_ECC_NIST_P384_KEY_PUB_GEN 

ECC NIST P-384 public-key generation.

PKI_ECC_NIST_P521_KEY_PUB_GEN 

ECC NIST P-521 public-key generation.

PKI_MAX_OPS 

Maximum supported ops count.

Function Documentation

int XilPki_DeQueue ( XPki_Instance *  InstancePtr,
XPki_Request_Info Request_InfoPtr,
u32  RequestID 
)

This function is used to get the crypto operation results from the PKI Queue.

Parameters
InstancePtrPointer to the XPki instance
Request_InfoPtrPointer to the queue info structure
RequestIDUnique request ID Filled by the XilPki_EnQueue() API.
Returns
  • XST_SUCCESS - On success
  • XPKI_INVALID_PARAM - On invalid argument
  • XPKI_UNSUPPORTED_OPS - If the requested operation is not supported.
  • XST_FAILURE - On failure

References XPKI_INVALID_PARAM.

Referenced by XPki_EcdsaGenerateKeyPair(), XPki_EcdsaPwct(), and XPki_EcdsaSignGenerateKat().

int XilPki_EnQueue ( XPki_Instance *  InstancePtr,
XPki_Request_Info Request_InfoPtr,
u32 *  RequestID 
)

This function is used to submit the crypto operation to the PKI Queue.

Parameters
InstancePtrPointer to the XPki instance
Request_InfoPtrPointer to the queue info structure
RequestIDPointer to the RequestID. if the request is successfully submitted it filled with unique id
Returns
  • XST_SUCCESS - On success
  • XPKI_INVALID_PARAM - On invalid argument
  • XPKI_UNSUPPORTED_OPS - If the requested operation is not supported.
  • XST_FAILURE - On failure

References XPki_Request_Info::OpsType, PKI_MAX_OPS, XPKI_INVALID_PARAM, XPKI_QUEUE_FULL, and XPKI_UNSUPPORTED_OPS.

Referenced by XPki_EcdsaGenerateKeyPair(), XPki_EcdsaPwct(), XPki_EcdsaSignGenerateKat(), and XPki_EcdsaVerifySignKat().

void XPki_Close ( void  )

This function is used to disable access to the PKI Hardware.

int XPki_EcdsaGenerateKeyPair ( XPki_Instance *  InstancePtr,
XPki_EcdsaCrvType  CrvType,
XPki_EcdsaKey *  PubKey,
u8 *  PrivKey 
)

This function Generate key pairs for the ECC curves NIST-P192, P256, P384, and P521.

Parameters
InstancePtrPointer to the XPki instance
CrvTypeType of ECC curve(NIST-P192,P256,P384, and P521)
PubKeyPointer to the pulic-key buffer
PrivKeyPointer to the private-key buffer
Returns
  • XST_SUCCESS - when passes
  • Errorcode - when fails

References ECC_NIST_P192, ECC_NIST_P256, ECC_NIST_P384, XPki_Request_Info::OpsType, PKI_ECC_NIST_P192_KEY_PRIV_GEN, PKI_ECC_NIST_P192_KEY_PUB_GEN, PKI_ECC_NIST_P256_KEY_PRIV_GEN, PKI_ECC_NIST_P256_KEY_PUB_GEN, PKI_ECC_NIST_P384_KEY_PRIV_GEN, PKI_ECC_NIST_P384_KEY_PUB_GEN, PKI_ECC_NIST_P521_KEY_PRIV_GEN, PKI_ECC_NIST_P521_KEY_PUB_GEN, XPki_Request_Info::PtrInputData, XPki_Request_Info::PtrOutputData, XilPki_DeQueue(), XilPki_EnQueue(), and XPki_Request_Info::XPki_CompletionCallBack.

int XPki_EcdsaPwct ( XPki_Instance *  InstancePtr,
XPki_EcdsaCrvInfo *  CrvInfo,
XPki_EcdsaKey *  PubKey,
u8 *  PrivKey 
)

This function performs ECC pairwise consistency test on ECC Curves.

Parameters
InstancePtrPointer to the XPki instance
CrvInfoType of ECC curve class either prime or binary class and curve type(NIST-P192,P256,P384, and P521)
PubKeyECC public key
PrivKeyECC private key
Returns
  • XST_SUCCESS - when KAT passes
  • Errorcode - when KAT fails

References ECC_NIST_P192, ECC_NIST_P256, ECC_NIST_P384, XPki_Request_Info::OpsType, PKI_ECC_NIST_P192_SIGN, PKI_ECC_NIST_P192_SIGN_VERIFY, PKI_ECC_NIST_P256_SIGN, PKI_ECC_NIST_P256_SIGN_VERIFY, PKI_ECC_NIST_P384_SIGN, PKI_ECC_NIST_P384_SIGN_VERIFY, PKI_ECC_NIST_P521_SIGN, PKI_ECC_NIST_P521_SIGN_VERIFY, XPki_Request_Info::PtrInputData, XPki_Request_Info::PtrOutputData, XilPki_DeQueue(), XilPki_EnQueue(), and XPki_Request_Info::XPki_CompletionCallBack.

int XPki_EcdsaSignGenerateKat ( XPki_Instance *  InstancePtr,
XPki_EcdsaCrvInfo *  CrvInfo 
)

This function performs ECC sign generate known answer test(KAT)

Parameters
InstancePtrPointer to the XPki instance
CrvInfoType of ECC curve class either prime or binary class and curve type(NIST-P192,P256,P384, and P521)
Returns
  • XST_SUCCESS - when KAT passes
  • Errorcode - when KAT fails

References ECC_NIST_P192, ECC_NIST_P256, ECC_NIST_P384, XPki_Request_Info::OpsType, PKI_ECC_NIST_P192_SIGN, PKI_ECC_NIST_P256_SIGN, PKI_ECC_NIST_P384_SIGN, PKI_ECC_NIST_P521_SIGN, XPki_Request_Info::PtrInputData, XPki_Request_Info::PtrOutputData, XilPki_DeQueue(), XilPki_EnQueue(), and XPki_Request_Info::XPki_CompletionCallBack.

int XPki_EcdsaVerifySignKat ( XPki_Instance *  InstancePtr,
XPki_EcdsaCrvInfo *  CrvInfo 
)

This function performs ECC sign verify known answer test(KAT)

Parameters
InstancePtrPointer to the XPki instance
CrvInfoType of ECC curve class either prime/binary curve and curve type(NIST-P192,P256,P384, and P521)
Returns
  • XST_SUCCESS - when KAT passes
  • Errorcode - when KAT fails

References ECC_NIST_P192, ECC_NIST_P256, ECC_NIST_P384, XPki_Request_Info::OpsType, PKI_ECC_NIST_P192_SIGN_VERIFY, PKI_ECC_NIST_P256_SIGN_VERIFY, PKI_ECC_NIST_P384_SIGN_VERIFY, PKI_ECC_NIST_P521_SIGN_VERIFY, XPki_Request_Info::PtrInputData, XilPki_EnQueue(), and XPki_Request_Info::XPki_CompletionCallBack.

int XPki_Initialize ( XPki_Instance *  InstancePtr)

This function performs the PKI module initialization.

Parameters
InstancePtrPointer to the XPki instance
Returns
  • XST_SUCCESS - On success
  • XPKI_INVALID_PARAM - On invalid argument
  • XPKI_ERROR_UNALIGN_ADDR - On Request/Completion queue Address are not Word aligned.
  • XST_FAILURE - On failure

References XPKI_INVALID_PARAM, XPki_Reset(), and XPki_SoftReset().

void XPki_Reset ( void  )

This function reset the PKI module.

Referenced by XPki_Initialize().

void XPki_SoftReset ( void  )

This function performs the PKI module soft reset.

Referenced by XPki_Initialize().

int XPki_TrngGenerateRandomNum ( u8  GenSize,
u8 *  RandBuf 
)

This function is used to generate the Random number for the give size.

Parameters
GenSizeRequired Random Number length in bytes.
RandBufPointer to store the Random Number.
Returns
  • XST_SUCCESS - On success
  • XST_FAILURE - On failure

Variable Documentation

void* XPki_Request_Info::PtrInputData
void* XPki_Request_Info::PtrOutputData

Pointer to the outout data.

Referenced by XPki_EcdsaGenerateKeyPair(), XPki_EcdsaPwct(), and XPki_EcdsaSignGenerateKat().

void(* XPki_Request_Info::XPki_CompletionCallBack)(u32 RequestID, u32 Status)

Request completion callback function pointer.

Referenced by XPki_EcdsaGenerateKeyPair(), XPki_EcdsaPwct(), XPki_EcdsaSignGenerateKat(), and XPki_EcdsaVerifySignKat().