Protocol++® (Protocolpp®)  v5.6.2
ProtocolPP::jdsa Class Reference
Inheritance diagram for ProtocolPP::jdsa:
Collaboration diagram for ProtocolPP::jdsa:

Public Member Functions

 jdsa (int bitsize, std::shared_ptr< InterfacePP::jlogger > &logger)
 
 jdsa (int bitsize, CryptoPP::Integer p, CryptoPP::Integer q, CryptoPP::Integer g, std::shared_ptr< InterfacePP::jlogger > &logger)
 
 jdsa (int bitsize, CryptoPP::DSA::PrivateKey &PRVKey, CryptoPP::DSA::PublicKey &PUBKey, std::shared_ptr< InterfacePP::jlogger > &logger)
 
 jdsa (int bitsize, std::pair< CryptoPP::DSA::PrivateKey, CryptoPP::DSA::PublicKey > &keypair, std::shared_ptr< InterfacePP::jlogger > &logger)
 
 jdsa (std::shared_ptr< jdsasa > &security)
 
virtual ~jdsa ()=default
 Standard deconstructor.
 
template<typename T >
void set_field (field_t field, T fieldval)
 
template<typename T >
get_field (field_t field)
 
void gen_keypair ()
 
void sign (std::shared_ptr< jarray< uint8_t >> &data, std::shared_ptr< jarray< uint8_t >> &signature)
 
void verify (std::shared_ptr< jarray< uint8_t >> &data)
 
void get_security (std::shared_ptr< jdsasa > &sec)
 
void to_xml (tinyxml2::XMLPrinter &myxml, direction_t direction)
 
void to_json (std::ofstream &myjson, direction_t direction, std::string &indent)
 
void set_hdr (jarray< uint8_t > &hdr)
 
void set_field (field_t field, uint64_t value)
 
jarray< uint8_t > get_hdr ()
 
uint64_t get_field (field_t field, jarray< uint8_t > &hdr)
 
void encap_packet (std::shared_ptr< jarray< uint8_t >> &input, std::shared_ptr< jarray< uint8_t >> &output)
 
void decap_packet (std::shared_ptr< jarray< uint8_t >> &input, std::shared_ptr< jarray< uint8_t >> &output)
 
 jdsa (jdsa &jdsa)=delete
 
 jdsa (const jdsa &jdsa)=delete
 
- Public Member Functions inherited from ProtocolPP::jprotocol
 jprotocol (direction_t dir)
 
 jprotocol (direction_t dir, std::string &file)
 
 jprotocol (direction_t dir, std::shared_ptr< jrand > &rand)
 
 jprotocol (direction_t dir, std::shared_ptr< jrand > &rand, std::string &file)
 
virtual ~jprotocol ()
 Standard deconstructor.
 
virtual void encap_packet (std::shared_ptr< jarray< uint8_t >> &output)
 
virtual void decap_packet (std::shared_ptr< jarray< uint8_t >> &input)
 
bool hasfile ()
 
uint32_t get_status ()
 
jarray< uint8_t > checksum (iana_t prot, direction_t dir, jarray< uint8_t > &check, uint32_t offset=0)
 
jarray< uint8_t > pad (pad_t padtype, uint32_t len)
 
 jprotocol (jprotocol &jprotocol)=delete
 
 jprotocol (const jprotocol &jprotocol)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from ProtocolPP::jprotocol
const static std::string currentDateTime ()
 
static std::string str_status (uint32_t status)
 
static jarray< uint8_t > to_array (uint8_t input)
 
static jarray< uint8_t > to_array (uint16_t input)
 
static jarray< uint8_t > to_array (uint32_t input)
 
static jarray< uint8_t > to_array (uint64_t input)
 
static uint8_t to_u8 (jarray< uint8_t > src_array)
 
static uint16_t to_u16 (jarray< uint8_t > src_array)
 
static uint32_t to_u32 (jarray< uint8_t > src_array)
 
static uint64_t to_u64 (jarray< uint8_t > src_array)
 
static uint32_t fnv_hash (std::shared_ptr< jarray< uint8_t >> &header, jarray< uint8_t > &mask, uint32_t hdrlen)
 
- Protected Member Functions inherited from ProtocolPP::jprotocol
template<typename T , typename TE >
std::shared_ptr< jreplay< T, TE > > update_replay (protocol_t prot, T &seqnum, TE &extseq, bool usext, uint32_t size)
 
template<typename T , typename TE >
std::shared_ptr< jreplay< T, TE > > update_replay (protocol_t prot, T &seqnum, TE &extseq, bool usext, uint32_t size, jarray< uint8_t > &window)
 
void update_status (uint32_t stat)
 
void get_data (std::shared_ptr< jarray< uint8_t >> &data)
 
void put_data (std::shared_ptr< jarray< uint8_t >> &wdata)
 
void encryptdat (std::shared_ptr< jarray< uint8_t >> &red, std::shared_ptr< jarray< uint8_t >> &black)
 
void decryptdat (std::shared_ptr< jarray< uint8_t >> &black, std::shared_ptr< jarray< uint8_t >> &red)
 
uint32_t roundup (uint32_t value, uint32_t mult)
 
- Protected Attributes inherited from ProtocolPP::jprotocol
direction_t m_dir
 direction of processing
 
uint32_t m_status
 
std::shared_ptr< jrandm_rand
 random data generator passed into constructor
 
std::string m_filename
 file input string for this protocol
 
std::fstream m_file
 input file stream object for this protocol
 
endian_t m_endian
 endianess string for this protocol
 

Constructor & Destructor Documentation

◆ jdsa() [1/5]

ProtocolPP::jdsa::jdsa ( int  bitsize,
std::shared_ptr< InterfacePP::jlogger > &  logger 
)

Digital Signature Constructor from bitsize

Parameters
bitsize- size of the key
logger- logging object

◆ jdsa() [2/5]

ProtocolPP::jdsa::jdsa ( int  bitsize,
CryptoPP::Integer  p,
CryptoPP::Integer  q,
CryptoPP::Integer  g,
std::shared_ptr< InterfacePP::jlogger > &  logger 
)

Digital Signature Constructor from domain parameters

Parameters
bitsize- size of the key
p- Product (Prime) domain parameter
q- Quotient (SubPrime) domain parameter
g- Generator domain parameter
logger- logging object

◆ jdsa() [3/5]

ProtocolPP::jdsa::jdsa ( int  bitsize,
CryptoPP::DSA::PrivateKey &  PRVKey,
CryptoPP::DSA::PublicKey &  PUBKey,
std::shared_ptr< InterfacePP::jlogger > &  logger 
)

Digital Signature Constructor from private and public key

Parameters
bitsize- size of the key
PRVKey- Private key
PUBKey- Public key
logger- logging object

◆ jdsa() [4/5]

ProtocolPP::jdsa::jdsa ( int  bitsize,
std::pair< CryptoPP::DSA::PrivateKey, CryptoPP::DSA::PublicKey > &  keypair,
std::shared_ptr< InterfacePP::jlogger > &  logger 
)

Digital Signature Constructor from private and public key pair

Parameters
bitsize- size of the key
keypair- Private/Public key pair as std::pair()
logger- logging object

◆ jdsa() [5/5]

ProtocolPP::jdsa::jdsa ( std::shared_ptr< jdsasa > &  security)
explicit

Digital Signature Constructor from security association

Parameters
security- security associtiation

Member Function Documentation

◆ decap_packet()

void ProtocolPP::jdsa::decap_packet ( std::shared_ptr< jarray< uint8_t >> &  input,
std::shared_ptr< jarray< uint8_t >> &  output 
)
virtual

Not used in this protocol

Parameters
input- encapsulated data
output- decapsulated packet

Implements ProtocolPP::jprotocol.

◆ encap_packet()

void ProtocolPP::jdsa::encap_packet ( std::shared_ptr< jarray< uint8_t >> &  input,
std::shared_ptr< jarray< uint8_t >> &  output 
)
virtual

Not used in this protocol

Parameters
input- data to encapsulate
output- encapsulated packet

Implements ProtocolPP::jprotocol.

◆ gen_keypair()

void ProtocolPP::jdsa::gen_keypair ( )

Generate a new key pair which modifies this object's key pair retrieve the keypair using the accessor functions

◆ get_field() [1/2]

template<typename T >
T ProtocolPP::jdsa::get_field ( field_t  field)
virtual

Returns the version field of the DSA security association

DSA Get Fields
field typefield nameExample
intBITSIZEint size = get_field<int>(field_t::BITSIZE)
keymode_tMODEkeymode_t mode = get_field<keymode_t>(field_t::MODE)
CryptoPP::Integer GENERATORCryptoPP::Integer generator = get_field<CryptoPP::Integer>(field_t::GENERATOR)
CryptoPP::Integer QUOTIENTCryptoPP::Integer quotient = get_field<CryptoPP::Integer>(field_t::QUOTIENT)
CryptoPP::Integer PRODUCTCryptoPP::Integer product = get_field<CryptoPP::Integer>(field_t::PRODUCT)
CryptoPP::DSA::PublicKey PUBKEYCryptoPP::DSA::PublicKey pubkey = get_field<CryptoPP::DSA::PublicKey>(field_t::PUBKEY)
CryptoPP::DSA::PrivateKey PRVKEYCryptoPP::DSA::PrivateKey prvkey = get_field<CryptoPP::DSA::PrivateKey>(field_t::PRVKEY)
Parameters
field- field to retrieve from the DSA security association
Returns
field of the DSA security association

Reimplemented from ProtocolPP::jprotocol.

◆ get_field() [2/2]

uint64_t ProtocolPP::jdsa::get_field ( field_t  field,
jarray< uint8_t > &  hdr 
)
virtual

Not used in this protocol

Returns
0

Implements ProtocolPP::jprotocol.

◆ get_hdr()

jarray<uint8_t> ProtocolPP::jdsa::get_hdr ( )
virtual

Not used in this protocol

Returns
empty array

Implements ProtocolPP::jprotocol.

◆ get_security()

void ProtocolPP::jdsa::get_security ( std::shared_ptr< jdsasa > &  sec)

get_security

Parameters
sec- Shared pointer to hold the security association

◆ set_field() [1/2]

template<typename T >
void ProtocolPP::jdsa::set_field ( field_t  field,
fieldval 
)

Allows the user to update the field Diffie-Hellman object

DSA Set Fields
field typefield nameExample
int BITSIZEset_field<int>(field_t::BITSIZE, size)
keymode_tMODEset_field<keymode_t>(field_t::MODE, keymode_t::GENKEYPAIR)
CryptoPP::Integer GENERATORset_field<CryptoPP::Integer>(field_t::GENERATOR, g)
CryptoPP::Integer QUOTIENTset_field<CryptoPP::Integer>(field_t::QUOTIENT, q)
CryptoPP::Integer PRODUCTset_field<CryptoPP::Integer>(field_t::PRODUCT, p)
CryptoPP::DSA::PublicKey PUBKEYset_field<CryptoPP::DSA::PublicKey>(field_t::PUBKEY, pubkey)
CryptoPP::DSA::PrivateKey PRVKEYset_field<CryptoPP::DSA::PrivateKey>(field_t::PRVKEY, prvkey)
Parameters
field- field to update the DSA security association
fieldval- value to update the DSA security association

◆ set_field() [2/2]

void ProtocolPP::jdsa::set_field ( field_t  field,
uint64_t  value 
)
virtual

Not used in this protocol

Parameters
field- field to update
value- new value of the field

Implements ProtocolPP::jprotocol.

◆ set_hdr()

void ProtocolPP::jdsa::set_hdr ( jarray< uint8_t > &  hdr)
virtual

Not used in this protocol

Parameters
hdr- header of the packet

Implements ProtocolPP::jprotocol.

◆ sign()

void ProtocolPP::jdsa::sign ( std::shared_ptr< jarray< uint8_t >> &  data,
std::shared_ptr< jarray< uint8_t >> &  signature 
)

Generate a signature

Parameters
data- data to sign
signature- Signature generated from private key and data

◆ to_json()

void ProtocolPP::jdsa::to_json ( std::ofstream &  myjson,
direction_t  direction,
std::string &  indent 
)
virtual

Prints the protocol object in JSON

Parameters
myjson- JSON object to print to
direction- randomzation
indent- indentation for JSON output

Implements ProtocolPP::jprotocol.

◆ to_xml()

void ProtocolPP::jdsa::to_xml ( tinyxml2::XMLPrinter myxml,
direction_t  direction 
)
virtual

Prints the protocol object in XML

Parameters
myxml- XMLPrinter object to print to
direction- randomzation

Implements ProtocolPP::jprotocol.

◆ verify()

void ProtocolPP::jdsa::verify ( std::shared_ptr< jarray< uint8_t >> &  data)

Verify the signature using the received public key

Parameters
data- data and signature concatenated to verify (data || signature) returns result of signature verification in status word

The documentation for this class was generated from the following file: