A template helper class for reading and decoding cryptographic data in different formats (DER/PEM)
More...
#include <CryptoDataReader.h>
|
static std::unique_ptr< CryptoDecoder > | fromDER (uint8_t *derData, size_t derDataLen, bool ownDerData=false) |
|
static std::unique_ptr< CryptoDecoder > | fromDER (const std::string &derData) |
|
static std::unique_ptr< CryptoDecoder > | fromDERFile (const std::string &derFileName) |
|
static std::unique_ptr< CryptoDecoder > | fromPEM (const std::string &pemData) |
|
static std::unique_ptr< CryptoDecoder > | fromPEMFile (const std::string &pemFileName) |
|
template<typename CryptoDecoder>
class pcpp::internal::CryptoDataReader< CryptoDecoder >
A template helper class for reading and decoding cryptographic data in different formats (DER/PEM)
- Template Parameters
-
CryptoDecoder | The decoder type that will be used to process the cryptographic data. Must be a class that can be constructed with a byte array and a length, or a unique pointer to a byte array and a length |
◆ fromDER() [1/2]
template<typename CryptoDecoder >
Creates a decoder from a hex string containing DER-encoded data
- Parameters
-
[in] | derData | Hex string containing DER-encoded data |
- Returns
- A unique pointer to the created decoder
- Exceptions
-
An | exception if the data is not a valid ASN.1 record |
◆ fromDER() [2/2]
template<typename CryptoDecoder >
static std::unique_ptr<CryptoDecoder> pcpp::internal::CryptoDataReader< CryptoDecoder >::fromDER |
( |
uint8_t * |
derData, |
|
|
size_t |
derDataLen, |
|
|
bool |
ownDerData = false |
|
) |
| |
|
inlinestatic |
Creates a decoder from DER-encoded data
- Parameters
-
[in] | derData | Pointer to the DER-encoded data |
[in] | derDataLen | Length of the DER-encoded data |
[in] | ownDerData | If true, the decoder will take ownership of the data and free it when the decoder class is destructed |
- Returns
- A unique pointer to the created decoder
- Exceptions
-
An | exception if the data is not a valid ASN.1 record |
◆ fromDERFile()
template<typename CryptoDecoder >
Creates a decoder from a file containing DER-encoded data
- Parameters
-
[in] | derFileName | Path to the file containing DER-encoded data |
- Returns
- A unique pointer to the created decoder
- Exceptions
-
An | exception if the file doesn't exist, cannot be read or contains invalid data |
◆ fromPEM()
template<typename CryptoDecoder >
Creates a decoder from PEM-encoded data
- Parameters
-
[in] | pemData | PEM-encoded data |
- Returns
- A unique pointer to the created decoder
- Exceptions
-
std::invalid_argument | exception if the data is not a valid PEM-encoded data |
◆ fromPEMFile()
template<typename CryptoDecoder >
Creates a decoder from a file containing PEM-encoded data
- Parameters
-
[in] | pemFileName | Path to the file containing PEM-encoded data |
- Returns
- A unique pointer to the created decoder
- Exceptions
-
std::runtime_error | exception if the file doesn't exist or cannot be read |
std::invalid_argument | exception if the data is not a valid PEM-encoded data |