1 /* Copyright (c) 2007-2018, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
9 #include "trunnel/ed25519_cert.h"
10 #include "lib/cc/torint.h" /* TOR_PRIdSZ */
11 #include "lib/crypt_ops/crypto_format.h"
12 #include "lib/malloc/malloc.h"
15 main(int argc
, char **argv
)
17 ed25519_cert_t
*cert
= NULL
;
20 fprintf(stderr
, "Usage:\n");
21 fprintf(stderr
, "%s <path to ed25519_signing_cert file>\n", argv
[0]);
25 const char *filepath
= argv
[1];
29 ssize_t cert_body_len
= crypto_read_tagged_contents_from_file(
30 filepath
, "ed25519v1-cert",
31 &got_tag
, certbuf
, sizeof(certbuf
));
33 if (cert_body_len
<= 0) {
34 fprintf(stderr
, "crypto_read_tagged_contents_from_file failed with "
35 "error: %s\n", strerror(errno
));
40 fprintf(stderr
, "Found no tag\n");
44 if (strcmp(got_tag
, "type4") != 0) {
45 fprintf(stderr
, "Wrong tag: %s\n", got_tag
);
51 ssize_t parsed
= ed25519_cert_parse(&cert
, certbuf
, cert_body_len
);
53 fprintf(stderr
, "ed25519_cert_parse failed with return value %" TOR_PRIdSZ
58 time_t expires_at
= (time_t)cert
->exp_field
* 60 * 60;
60 printf("Expires at: %s", ctime(&expires_at
));
62 ed25519_cert_free(cert
);