fix
[libexssl.git] / test / sign.c
blob4f0b35f32d685cdc19402bd02e6af67b9c5496de
1 #include <string.h>
2 #include "ssl.h"
4 int main (int argc, const char *argv[]) {
5 if (argc < 3) return 1;
6 const unsigned char *txt = (const unsigned char*)argv[1];
7 const char *pkn = argv[2];
8 unsigned char *sig = NULL;
9 size_t slen = 0,
10 len = strlen(argv[1]);
11 if (-1 == ssl_init())
12 return 1;
13 ssl_key_t *key = ssl_key_init();
14 if (-1 == ssl_load_pub_fl(pkn, key))
15 goto done;
16 if (0 == ssl_sign(txt, len, &sig, &slen, 0, key)) {
17 int rc = ssl_verify(txt, len, sig, slen, 0, key);
18 printf("Signatute: ");
19 for (size_t i = 0; i < slen; ++i)
20 printf("%02X", sig[i]);
21 printf("\nResult: %d\n", rc);
23 done:
24 if (sig)
25 OPENSSL_free(sig);
26 ssl_free_key(key);
27 ssl_done();
28 return 0;