10 #define RECORD_HEADER_SIZE 17
14 enum class SignerCommand : uint16_t {
17 SET_SIGNATURE_TYPE = 0x10,
21 ADD_PROOF_LINE = 0x40,
25 GET_STATUS_REPORT = 0xD0
28 enum class SignerResult : uint16_t {
37 uint16_t command_count;
40 uint16_t payloadLength;
43 command( 0 ), flags( 0 ), sessid( 0 ), command_count( 0 ), totalLength( 0 ), offset( 0 ), payloadLength( 0 ) {
47 void append( std::string& str, T val ) {
48 str.append( ( char* ) &val, sizeof( T ) );
52 void read( std::string::iterator& it, T& val ) {
53 char* data = ( char* ) &val;
55 for( int i = 0; i < sizeof( T ); i++ ) {
61 std::string packToString() {
63 res.reserve( RECORD_HEADER_SIZE );
64 append( res, command );
66 append( res, sessid );
67 append( res, command_count );
68 append( res, totalLength );
69 append( res, offset );
70 append( res, payloadLength );
74 void unpackFromString( std::string str ) {
75 if( str.size() != RECORD_HEADER_SIZE ) {
76 throw "Invalid string length";
79 auto it = str.begin();
83 read( it, command_count );
84 read( it, totalLength );
86 read( it, payloadLength );
91 std::string parseCommand( RecordHeader& head, const std::string& input );
93 void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio );