10 #define RECORD_HEADER_SIZE 17
14 enum class SignerCommand : uint16_t {
17 SET_SIGNATURE_TYPE = 0x10,
21 ADD_PROOF_LINE = 0x40,
27 GET_STATUS_REPORT = 0xD0
30 enum class SignerResult : uint16_t {
41 uint16_t command_count;
44 uint16_t payloadLength;
47 command( 0 ), flags( 0 ), sessid( 0 ), command_count( 0 ), totalLength( 0 ), offset( 0 ), payloadLength( 0 ) {
51 void append( std::string& str, T val ) {
52 str.append( ( char* ) &val, sizeof( T ) );
56 void read( std::string::iterator& it, T& val ) {
57 char* data = ( char* ) &val;
59 for( size_t i = 0; i < sizeof( T ); i++ ) {
65 std::string packToString() {
67 res.reserve( RECORD_HEADER_SIZE );
68 append( res, command );
70 append( res, sessid );
71 append( res, command_count );
72 append( res, totalLength );
73 append( res, offset );
74 append( res, payloadLength );
78 void unpackFromString( std::string str ) {
79 if( str.size() != RECORD_HEADER_SIZE ) {
80 throw "Invalid string length";
83 auto it = str.begin();
87 read( it, command_count );
88 read( it, totalLength );
90 read( it, payloadLength );
95 std::string parseCommand( RecordHeader& head, const std::string input, std::shared_ptr<std::ostream> log );
97 void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio, std::shared_ptr<std::ostream> log );