feature add message

This commit is contained in:
tqcq 2023-12-02 15:48:13 +08:00
parent 7003f08f3a
commit 73846e885a
3 changed files with 45 additions and 8 deletions

View File

@ -20,8 +20,10 @@ OPEN_BRACE: '{';
CLOSE_BRACE: '}'; CLOSE_BRACE: '}';
OPEN_PAREN: '('; OPEN_PAREN: '(';
CLOSE_PAREN: ')'; CLOSE_PAREN: ')';
SLASH: '/';
NUMBER: [0-9]+; NUMBER: [0-9]+;
ID: [a-zA-Z_][a-zA-Z_0-9]*; ID: [a-zA-Z_][a-zA-Z_0-9]*;
NEWLINE: '\r'? '\n' -> skip;
WHITESPACE: [ \t\r\n]+ -> skip; WHITESPACE: [ \t\r\n]+ -> skip;

View File

@ -4,6 +4,7 @@ options{ tokenVocab='gen/ProtoLexer'; language=Cpp; }
program: syntaxStatement baseStatement* EOF; program: syntaxStatement baseStatement* EOF;
commentStatement : SLASH SLASH .*? NEWLINE;
syntaxStatement: SYNTAX_TYPE '=' '"' (VERSION2 | VERSION3) '"' ';'; syntaxStatement: SYNTAX_TYPE '=' '"' (VERSION2 | VERSION3) '"' ';';
baseStatement: messageStatement | serviceStatement | ';'; baseStatement: messageStatement | serviceStatement | ';';
messageStatement: MESSAGE_TYPE ID '{' (itemStatement | ';')* '}'; messageStatement: MESSAGE_TYPE ID '{' (itemStatement | ';')* '}';

View File

@ -3,6 +3,7 @@ syntax = "proto3";
message Empty { message Empty {
} }
message StatusResponse { message StatusResponse {
int32 code = 1; int32 code = 1;
string msg = 2; string msg = 2;
@ -17,26 +18,55 @@ message ApplicationPINRequest {
string pin = 6; string pin = 6;
} }
message SingleDataResponse{
int32 code = 1;
string msg = 2;
string data = 4;
}
message GenerateRandomRequest { message GenerateRandomRequest {
int32 length = 1; int32 length = 1;
} }
message GenerateHashRequest { message GenerateHashRequest {
int32 length = 1;
string data = 2;
}
message BaseResponse{
int32 code = 1; int32 code = 1;
string msg = 2; string msg = 2;
int32 length = 3; string source_data = 3;
string data = 4; string ecc_public_key = 4;
int32 hash_type = 5;
} }
message GenerateSignatureByInternalPrivateKeyRequest {
int32 code = 1;
string msg = 2;
string source_data = 3;
}
message GenerateSignatureByExternalPrivateKeyRequest {
int32 code = 1;
string msg = 2;
string source_data = 3;
string ecc_private_key = 4;
}
message VerifySignatureRequest {
int32 code = 1;
string msg = 2;
string source_data = 3;
string ecc_public_key = 4;
string ecc_signature = 5;
}
service DeviceService { service DeviceService {
rpc Init(Empty) returns (StatusResponse) {} rpc Init(Empty) returns (StatusResponse) {}
rpc Status(Empty) returns (StatusResponse) {} rpc Status(Empty) returns (StatusResponse) {}
rpc GetHWCode(Empty) returns (SingleDataResponse) {}
rpc Close(Empty) returns (StatusResponse) {} rpc Close(Empty) returns (StatusResponse) {}
rpc ClearApp(Empty) returns (Empty) {} rpc ClearApp(Empty) returns (Empty) {}
@ -44,5 +74,9 @@ service DeviceService {
rpc ChangeApplicationPIN(ApplicationPINRequest) returns (StatusResponse) {} rpc ChangeApplicationPIN(ApplicationPINRequest) returns (StatusResponse) {}
rpc VerifyApplicationPIN(ApplicationPINRequest) returns (StatusResponse) {} rpc VerifyApplicationPIN(ApplicationPINRequest) returns (StatusResponse) {}
rpc GenerateRandom(GenerateRandomRequest) returns (BaseResponse) {} rpc GenerateRandom(GenerateRandomRequest) returns (SingleDataResponse) {}
rpc GenerateHash(GenerateHashRequest) returns (SingleDataResponse) {}
rpc GenerateSignatureByInternalPrivateKey(GenerateSignatureByInternalPrivateKeyRequest) returns (SingleDataResponse) {}
rpc GenerateSignatureByExternalPrivateKey(GenerateSignatureByExternalPrivateKeyRequest) returns (SingleDataResponse) {}
} }