10 #define RECORD_HEADER_SIZE 17
14 enum class SignerCommand : uint16_t {
17 SET_SIGNATURE_TYPE = 0x10,
23 ADD_PROOF_LINE = 0x40,
30 GET_STATUS_REPORT = 0xD0
33 enum class SignerResult : uint16_t {
45 uint16_t command_count;
48 uint16_t payloadLength;
51 command( 0 ), flags( 0 ), sessid( 0 ), command_count( 0 ), totalLength( 0 ), offset( 0 ), payloadLength( 0 ) {
55 static void append( std::string& str, T val ) {
56 str.append( ( char* ) &val, sizeof( T ) );
60 static void read( std::string::iterator& it, T& val ) {
61 char* data = ( char* ) &val;
63 for( size_t i = 0; i < sizeof( T ); i++ ) {
69 std::string packToString() {
71 res.reserve( RECORD_HEADER_SIZE );
72 append( res, command );
74 append( res, sessid );
75 append( res, command_count );
76 append( res, totalLength );
77 append( res, offset );
78 append( res, payloadLength );
82 void unpackFromString( std::string str ) {
83 if( str.size() != RECORD_HEADER_SIZE ) {
84 throw "Invalid string length";
87 auto it = str.begin();
91 read( it, command_count );
92 read( it, totalLength );
94 read( it, payloadLength );
99 std::string parseCommand( RecordHeader& head, const std::string& input, std::shared_ptr<std::ostream> log );
101 void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio, std::shared_ptr<std::ostream> log );