10 #define RECORD_HEADER_SIZE 17
14 enum class SignerCommand : uint16_t {
17 SET_SIGNATURE_TYPE = 0x10,
21 ADD_PROOF_LINE = 0x40,
26 GET_STATUS_REPORT = 0xD0
29 enum class SignerResult : uint16_t {
39 uint16_t command_count;
42 uint16_t payloadLength;
45 command( 0 ), flags( 0 ), sessid( 0 ), command_count( 0 ), totalLength( 0 ), offset( 0 ), payloadLength( 0 ) {
49 void append( std::string& str, T val ) {
50 str.append( ( char* ) &val, sizeof( T ) );
54 void read( std::string::iterator& it, T& val ) {
55 char* data = ( char* ) &val;
57 for( size_t i = 0; i < sizeof( T ); i++ ) {
63 std::string packToString() {
65 res.reserve( RECORD_HEADER_SIZE );
66 append( res, command );
68 append( res, sessid );
69 append( res, command_count );
70 append( res, totalLength );
71 append( res, offset );
72 append( res, payloadLength );
76 void unpackFromString( std::string str ) {
77 if( str.size() != RECORD_HEADER_SIZE ) {
78 throw "Invalid string length";
81 auto it = str.begin();
85 read( it, command_count );
86 read( it, totalLength );
88 read( it, payloadLength );
93 std::string parseCommand( RecordHeader& head, const std::string input, std::shared_ptr<std::ostream> log );
95 void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr<OpensslBIO> bio, std::shared_ptr<std::ostream> log );