1 #define _XOPEN_SOURCE 500
12 int main(int argc
, char **argv
) {
13 struct isds_ctx
*ctx
= NULL
;
16 setlocale(LC_ALL
, "");
18 if (argc
!= 2 || !argv
[1] || !*argv
[1]) {
19 printf("Usage: %s CMS_SIGNED_MESSAGE_IN_LOCAL_FILE\n",
26 printf("isds_init() failed: %s\n", isds_strerror(err
));
30 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
32 ctx
= isds_ctx_create();
34 printf("isds_ctx_create() failed");
37 err
= isds_set_timeout(ctx
, 10000);
39 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
42 err
= isds_login(ctx
, url
, username(), password(), NULL
, NULL
);
44 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
45 isds_long_message(ctx
));
47 printf("Logged in :)\n");
52 /* Authenticate message saved in local file */
57 if (mmap_file(argv
[1], &fd
, &buffer
, &length
))
60 printf("Sending message from file `%s' to ISDS for authenticity "
61 "check...\n", argv
[1]);
62 err
= isds_authenticate_message(ctx
, buffer
, length
);
64 printf("ISDS states: message is original\n");
65 else if (err
== IE_NOTEQUAL
)
66 printf("ISDS states: message is unkown or tampered\n");
68 printf("isds_authenticate_message() failed: %s: %s\n",
69 isds_strerror(err
), isds_long_message(ctx
));
71 munmap_file(fd
, buffer
,length
);
75 err
= isds_logout(ctx
);
77 printf("isds_logout() failed: %s\n", isds_strerror(err
));
80 err
= isds_ctx_free(&ctx
);
82 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
87 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));