Portuguese eID Middleware SDK  Version: 3.12.0
eIDMW::PTEID_Card Class Referenceabstract

#include <eidlib.h>

Public Member Functions

virtual PTEIDSDK_API ~PTEID_Card ()=0
 
virtual PTEIDSDK_API PTEID_CardType getType ()
 
virtual PTEIDSDK_API PTEID_ByteArray sendAPDU (const PTEID_ByteArray &cmd)
 
virtual PTEIDSDK_API PTEID_ByteArray Sign (const PTEID_ByteArray &data, bool signatureKey=false) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignSHA256 (const PTEID_ByteArray &data, bool signatureKey=false) override
 
virtual PTEIDSDK_API PTEID_ByteArray Sign (const PTEID_ByteArray &data, PTEID_RSAPaddingType paddingType, bool signatureKey=false)
 
virtual PTEIDSDK_API PTEID_ByteArray SignXades (const char *output_path, const char *const *paths, unsigned int n_paths, PTEID_SignatureLevel level=PTEID_LEVEL_BASIC) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignXadesT (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignXadesA (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API void SignXadesIndividual (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API void SignXadesTIndividual (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API void SignXadesAIndividual (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API int SignPDF (PTEID_PDFSignature &sig_handler, int page, int page_sector, bool is_landscape, const char *location, const char *reason, const char *outfile_path) override
 
virtual PTEIDSDK_API int SignPDF (PTEID_PDFSignature &sig_handler, int page, double coord_x, double coord_y, const char *location, const char *reason, const char *outfile_path) override
 
virtual PTEIDSDK_API PTEID_CertificatesgetCertificates () override
 
virtual PTEIDSDK_API PTEID_CertificategetCert (PTEID_CertifType type) override
 
virtual PTEIDSDK_API PTEID_CertificategetRoot () override
 
virtual PTEIDSDK_API PTEID_CertificategetCA () override
 
virtual PTEIDSDK_API PTEID_CertificategetSignature () override
 
virtual PTEIDSDK_API PTEID_CertificategetAuthentication () override
 
virtual PTEIDSDK_API PTEID_SigningDeviceType getDeviceType () override
 
virtual PTEIDSDK_API PTEID_ByteArray readFile (const char *fileID, unsigned long ulOffset=0, unsigned long ulMaxLength=0)
 
virtual PTEIDSDK_API bool writeFile (const char *fileID, const PTEID_ByteArray &oData, unsigned long ulOffset=0)
 
virtual PTEIDSDK_API void initPaceAuthentication (const char *secret, size_t length, PTEID_CardPaceSecretType secretType)
 
- Public Member Functions inherited from eIDMW::PTEID_Object
virtual PTEIDSDK_API ~PTEID_Object ()=0
 
NOEXPORT_PTEIDSDK void Init (const SDK_Context *context, void *impl)
 
NOEXPORT_PTEIDSDK void Release ()
 

Protected Member Functions

 PTEID_Card (const SDK_Context *context, APL_Card *impl)
 
- Protected Member Functions inherited from eIDMW::PTEID_Object
 PTEID_Object (const SDK_Context *context, void *impl)
 
void addObject (PTEID_Object *impl)
 
void backupObject (unsigned long idx)
 
PTEID_ObjectgetObject (unsigned long idx)
 
PTEID_ObjectgetObject (void *impl)
 
void delObject (unsigned long idx)
 
void delObject (void *impl)
 
void checkContextStillOk () const
 
 PTEID_Object (const PTEID_Object &obj)
 
PTEID_Objectoperator= (const PTEID_Object &obj)
 

Additional Inherited Members

- Protected Attributes inherited from eIDMW::PTEID_Object
bool m_delimpl
 
void * m_impl
 
unsigned long m_ulIndexExtAdd
 
std::map< unsigned long, PTEID_Object * > m_objects
 
SDK_Context * m_context
 

Detailed Description

Abstract base class for all the card type supported. The PTEID_ReaderContext::getCard() method will return such an object.

Constructor & Destructor Documentation

◆ ~PTEID_Card()

virtual PTEIDSDK_API eIDMW::PTEID_Card::~PTEID_Card ( )
pure virtual

Destructor

◆ PTEID_Card()

eIDMW::PTEID_Card::PTEID_Card ( const SDK_Context *  context,
APL_Card *  impl 
)
protected

For internal use : Constructor

Member Function Documentation

◆ getAuthentication()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_Card::getAuthentication ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getCA()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_Card::getCA ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getCert()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_Card::getCert ( PTEID_CertifType  type)
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getCertificates()

virtual PTEIDSDK_API PTEID_Certificates& eIDMW::PTEID_Card::getCertificates ( )
overridevirtual
Returns
an object to access all the certificates on the card.

Implements eIDMW::PTEID_SigningDevice.

◆ getDeviceType()

virtual PTEIDSDK_API PTEID_SigningDeviceType eIDMW::PTEID_Card::getDeviceType ( )
inlineoverridevirtual

Get type of SigningDeviceType.

Implements eIDMW::PTEID_SigningDevice.

753 { return PTEID_SigningDeviceType::CC; }

◆ getRoot()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_Card::getRoot ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getSignature()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_Card::getSignature ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getType()

virtual PTEIDSDK_API PTEID_CardType eIDMW::PTEID_Card::getType ( )
virtual

Return the type of the card

◆ initPaceAuthentication()

virtual PTEIDSDK_API void eIDMW::PTEID_Card::initPaceAuthentication ( const char *  secret,
size_t  length,
PTEID_CardPaceSecretType  secretType 
)
virtual

Init the Pace authentication process

Parameters
secretstring that holds the secret to make the PACE process
lengthsize of the secret string
secretTypetype of the secret used to make the PACE process

◆ readFile()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::readFile ( const char *  fileID,
unsigned long  ulOffset = 0,
unsigned long  ulMaxLength = 0 
)
virtual

Read a File from the card.

Parameters
fileIDis the path of the file
ulOffsetis the offset to begin the reading
ulMaxLengthis the maximum length of bytes to read
Returns
A PTEID_ByteArray with the content of the file

◆ sendAPDU()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::sendAPDU ( const PTEID_ByteArray cmd)
virtual

Send an APDU command to the card and get the result.

Parameters
cmdis the apdu command
Returns
A PTEID_ByteArray containing the result

◆ Sign() [1/2]

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::Sign ( const PTEID_ByteArray data,
bool  signatureKey = false 
)
overridevirtual

Signs a block of data using RSA-PKCS#1.

Parameters
datablock of data to be signed. Has to be hashed using either sha1, sha256, sha384 or sha512. Therefore, size of data array has to be at max 64 bytes.
signatureKeyby default uses the 'Authentication private key' to sign message. Setting this to true makes use of 'Signature private key' instead.
Returns
PTEID_ByteArray containing the signature

Implements eIDMW::PTEID_SigningDevice.

◆ Sign() [2/2]

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::Sign ( const PTEID_ByteArray data,
PTEID_RSAPaddingType  paddingType,
bool  signatureKey = false 
)
virtual

Signs a block of data using either RSA-PKCS#1 or RSA-PSS.

Parameters
datablock of data to be signed. Has to be hashed using either sha1, sha256, sha384 or sha512. Therefore, data has to be at max 64 bytes.
paddingTypeeither RSA-PSS or RSA-PKCS#1
signatureKeyby default uses the 'Authentication private key' to sign message. Setting this to true makes use of 'Signature private key' instead.
Returns
PTEID_ByteArray containing the signature

◆ SignPDF() [1/2]

virtual PTEIDSDK_API int eIDMW::PTEID_Card::SignPDF ( PTEID_PDFSignature sig_handler,
int  page,
int  page_sector,
bool  is_landscape,
const char *  location,
const char *  reason,
const char *  outfile_path 
)
overridevirtual

PDF Signature with location by page sector (the portrait A4 page is split into 18 cells: 6 lines and 3 columns) If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a PAdES-B signature. If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a PAdES-LT or PAdES-LTA depending where the timestamping fails.

Parameters
sig_handlerthis defines the input file and some signature options
pagein case of visible signature it defines the page where the signature will appear
page_sectorposition in the signature grid, between 1 to 18 for Portrait documents and 1 to 20 for Landscape ones
is_landscapeis unused parameter, the SDK now detects document orientation automatically
locationSignature metadata field
reasonSignature metadata field
outfile_pathNative Filesystem path of the ouput file
Deprecated:
use the SignPDF function with location coordinates instead

Implements eIDMW::PTEID_SigningDevice.

◆ SignPDF() [2/2]

virtual PTEIDSDK_API int eIDMW::PTEID_Card::SignPDF ( PTEID_PDFSignature sig_handler,
int  page,
double  coord_x,
double  coord_y,
const char *  location,
const char *  reason,
const char *  outfile_path 
)
overridevirtual

PDF Signature with location by coordinates (expressed in percentage of page height/width). The coordinate system has its origin in the top left corner of the page If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a PAdES-B signature. If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a PAdES-LT or PAdES-LTA depending where the timestamping fails.

Parameters
sig_handlerthis defines the input file and some signature options
pagein case of visible signature it defines the page where the signature will appear
coord_xX coordinate of the signature location (percentage of page width)
coord_yY coordinate of the signature location (percentage of page height)
locationLocation field in the added signature metadata
reasonSignature metadata field
outfile_pathNative Filesystem path of the ouput file

Implements eIDMW::PTEID_SigningDevice.

◆ SignSHA256()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::SignSHA256 ( const PTEID_ByteArray data,
bool  signatureKey = false 
)
overridevirtual

Raw RSA signature with PCKS #1 padding (applied to a SHA256 hash).

Parameters
dataholds the data to be signed, it should be 32 bytes.
signatureKeywhether to use the 'Signature key'. By default, it uses the 'Authentication private key'. To sign with the 'Signature private key' set the parameter signatureKey to true.
Returns
A PTEID_ByteArray containing the signed data.
Deprecated:
This method is now deprecated. Use PTEID_SigningDevice::Sign method instead, which already supports SHA256.
Deprecated:
Use PTEID_Card::Sign instead.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXades()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::SignXades ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths,
PTEID_SignatureLevel  level = PTEID_LEVEL_BASIC 
)
overridevirtual

Produce a XAdES Signature of the files indicated by the parameter paths and stores the results in one ASiC container in a zip format. The location of the resulting ASiC container is indicated by the parameter output_path.

Parameters
pathsis an array of null-terminated strings representing absolute paths in the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA signature
n_pathsis the number of elements in the paths array
output_pathpoints to the resulting container
levelis an enum used to set the XAdES signature level/profile: XAdES-B (PTEID_LEVEL_BASIC), XAdES-T (PTEID_LEVEL_T), XAdES-LTA (PTEID_LEVEL_LTV). Note: Setting parameter level to PTEID_LEVEL_LT will throw PTEID_Exception(EIDMW_ERR_PARAM_BAD), as it is not supported yet.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesA()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::SignXadesA ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual

Produce a XAdES-LTA Signature of the files indicated by the parameter paths and stores the results in one ASiC container in a zip format. The location of the resulting ASiC container is indicated by the parameter output_path. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a XAdES-B signature. If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a XAdES-LT or XAdES-LTA depending where the timestamping fails.

Parameters
pathsis an array of null-terminated strings representing absolute paths in the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA signature
n_pathsis the number of elements in the paths array
output_pathpoints to the resulting container
Deprecated:
use the SignXades function and set signature level with level (PTEID_SignatureLevel) parameter instead

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesAIndividual()

virtual PTEIDSDK_API void eIDMW::PTEID_Card::SignXadesAIndividual ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual

Produce XAdES-A Signatures of the files indicated by the parameter paths and stores each of the results in an individual ASiC container in a zip format. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a XAdES-B signature. If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a XAdES-LT or XAdES-LTA depending where the timestamping fails.

Parameters
pathsis an array of null-terminated strings representing absolute paths in the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA signature
n_pathsis the number of elements in the paths array
output_pathdirectory of the created ASiC containers

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesIndividual()

virtual PTEIDSDK_API void eIDMW::PTEID_Card::SignXadesIndividual ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual

Produce XAdES-B Signatures of the files indicated by the parameter paths and stores each of the results in an individual ASiC container in a zip format.

Parameters
pathsis an array of null-terminated strings representing absolute paths in the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA signature
n_pathsis the number of elements in the paths array
output_pathdirectory of the created ASiC containers

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesT()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_Card::SignXadesT ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual

Produce a XAdES-T Signature of the files indicated by the parameter paths and stores the results in one ASiC container in a zip format. The location of the resulting ASiC container is indicated by the parameter output_path. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a XAdES-B signature.

Parameters
pathsis an array of null-terminated strings representing absolute paths in the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA signature
n_pathsis the number of elements in the paths array
output_pathpoints to the resulting container
Deprecated:
use the SignXades function and set signature level with level (PTEID_SignatureLevel) parameter instead

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesTIndividual()

virtual PTEIDSDK_API void eIDMW::PTEID_Card::SignXadesTIndividual ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual

Produce XAdES-T Signatures of the files indicated by the parameter paths and stores each of the results in an individual ASiC container in a zip format. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a XAdES-B signature.

Parameters
pathsis an array of null-terminated strings representing absolute paths in the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA signature
n_pathsis the number of elements in the paths array
output_pathdirectory of the created ASiC containers

Implements eIDMW::PTEID_SigningDevice.

◆ writeFile()

virtual PTEIDSDK_API bool eIDMW::PTEID_Card::writeFile ( const char *  fileID,
const PTEID_ByteArray oData,
unsigned long  ulOffset = 0 
)
virtual

Write a file to the card.

Parameters
fileIDis the path of the file
oDatacontents the bytes to write
ulOffsetis the offset to begin the writing