10 #define RECORD_HEADER_SIZE 17
14 enum class SignerCommand : uint16_t {
17 SET_SIGNATURE_TYPE = 0x10,
21 ADD_PROOF_LINE = 0x40,
28 GET_STATUS_REPORT = 0xD0
31 enum class SignerResult : uint16_t {
43 uint16_t command_count;
46 uint16_t payloadLength;
49 command( 0 ), flags( 0 ), sessid( 0 ), command_count( 0 ), totalLength( 0 ), offset( 0 ), payloadLength( 0 ) {
53 void append( std::string& str, T val ) {
54 str.append( ( char* ) &val, sizeof( T ) );
58 void read( std::string::iterator& it, T& val ) {
59 char* data = ( char* ) &val;
61 for( size_t i = 0; i < sizeof( T ); i++ ) {
67 std::string packToString() {
69 res.reserve( RECORD_HEADER_SIZE );
70 append( res, command );
72 append( res, sessid );
73 append( res, command_count );
74 append( res, totalLength );
75 append( res, offset );
76 append( res, payloadLength );
80 void unpackFromString( std::string str ) {
81 if( str.size() != RECORD_HEADER_SIZE ) {
82 throw "Invalid string length";
85 auto it = str.begin();
89 read( it, command_count );
90 read( it, totalLength );
92 read( it, payloadLength );
97 std::string parseCommand( RecordHeader& head, const std::string input, std::shared_ptr<std::ostream> log );
99 void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio, std::shared_ptr<std::ostream> log );