ver
[libexssl.git] / test / test02.c
blob6c30cf7407820c0ebac3a274244a820925da329e
1 #include <libex/file.h>
2 #include "ssl.h"
4 int main (int argc, const char *argv[]) {
5 ssl_key_t *sk, *pk;
6 str_t *str;
7 unsigned char *sig = NULL;
8 size_t siglen = 0;
9 if (2 != argc) return 1;
10 ssl_init();
11 sk = ssl_key_init();
12 pk = ssl_key_init();
13 if (0 == ssl_load_priv_fl("./private.pem", "password", sk) && 0 == ssl_load_pub_fl("./public.pem", pk)) {
14 str = load_all_file(argv[1], 32, 4096);
15 if (0 == ssl_sign((const unsigned char*)str->ptr, str->len, &sig, &siglen, 0, sk)) {
16 if (0 == ssl_verify((const unsigned char*)str->ptr, str->len, sig, siglen, 0, pk))
17 printf("Ok");
18 else
19 printf("Fail");
21 free(str);
23 if (sig)
24 OPENSSL_free(sig);
25 ssl_free_key(pk);
26 ssl_free_key(sk);
27 ssl_done();