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 {
42 uint16_t command_count;
45 uint16_t payloadLength;
48 command( 0 ), flags( 0 ), sessid( 0 ), command_count( 0 ), totalLength( 0 ), offset( 0 ), payloadLength( 0 ) {
52 void append( std::string& str, T val ) {
53 str.append( ( char* ) &val, sizeof( T ) );
57 void read( std::string::iterator& it, T& val ) {
58 char* data = ( char* ) &val;
60 for( size_t i = 0; i < sizeof( T ); i++ ) {
66 std::string packToString() {
68 res.reserve( RECORD_HEADER_SIZE );
69 append( res, command );
71 append( res, sessid );
72 append( res, command_count );
73 append( res, totalLength );
74 append( res, offset );
75 append( res, payloadLength );
79 void unpackFromString( std::string str ) {
80 if( str.size() != RECORD_HEADER_SIZE ) {
81 throw "Invalid string length";
84 auto it = str.begin();
88 read( it, command_count );
89 read( it, totalLength );
91 read( it, payloadLength );
96 std::string parseCommand( RecordHeader& head, const std::string input, std::shared_ptr<std::ostream> log );
98 void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio, std::shared_ptr<std::ostream> log );