29CertificateInfo
ReadData(
const std::string& file_name) {
30 int fd = open(file_name.c_str(), O_RDONLY, 0666);
32 printf(
"open file %s fail %s\n", file_name.c_str(), strerror(errno));
40 read_len = read(fd, tmp,
sizeof(tmp));
44 res.append(tmp, read_len);
48 assert(info.ParseFromString(res));
52KeyInfo
ReadKey(
const std::string& file_name) {
53 int fd = open(file_name.c_str(), O_RDONLY, 0666);
55 printf(
"open file %s fail %s\n", file_name.c_str(), strerror(errno));
63 read_len = read(fd, tmp,
sizeof(tmp));
67 res.append(tmp, read_len);
71 assert(key.ParseFromString(res));
75int main(
int argc,
char** argv) {
76 std::string cert_path, private_key_path;
78 printf(
"<private key path> <cert path>\n");
81 private_key_path = argv[1];
85 KeyInfo private_key =
ReadKey(private_key_path);
88 CertificateInfo info =
ReadData(cert_path);
92 auto resp_info = verifier.
VerifyKey(info.public_key().public_key_info(),
93 info.public_key().certificate());