-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht_openssl.c
More file actions
86 lines (54 loc) · 1.44 KB
/
t_openssl.c
File metadata and controls
86 lines (54 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <openssl/sha.h>
#include "types.h"
void
test_openssl_3(char * buf, size_t size)
{
#define template_NAME "OpenSSL SHA1_* funcs"
#define template_CONTEXT SHA_CTX
#define template_INIT(c) SHA1_Init(c)
#define template_UPDATE(c,b,l) SHA1_Update(c,b,l)
#define template_FINAL(c,o) SHA1_Final(o,c)
#include "template_3funcs.c"
}
void
test_openssl_1(char * buf, size_t size)
{
unsigned char o[SHA_DIGEST_LENGTH];
timestamp_t t0 = timestamp();
SHA1(buf, size, o);
timestamp_t t1 = timestamp();
report("OpenSSL SHA1()", o, t1-t0);
}
#include <openssl/bio.h>
#include <openssl/evp.h>
void
test_openssl_biomem(char * buf, size_t size)
{
unsigned char o[EVP_MAX_MD_SIZE];
BIO * mdbio;
BIO * membio;
timestamp_t t0 = timestamp();
mdbio = BIO_new(BIO_f_md());
BIO_set_md(mdbio, EVP_sha1());
membio = BIO_new_mem_buf(buf, size);
BIO_push(mdbio, membio);
BIO_gets(mdbio, o, sizeof(o));
timestamp_t t1 = timestamp();
report("OpenSSL BIO memory", o, t1-t0);
}
void
test_openssl_biofile(char * fname)
{
unsigned char o[EVP_MAX_MD_SIZE];
BIO * mdbio;
BIO * filebio;
timestamp_t t0 = timestamp();
mdbio = BIO_new(BIO_f_md());
BIO_set_md(mdbio, EVP_sha1());
filebio = BIO_new_file(fname, "r");
// BIO_read(filebio,
BIO_push(mdbio, filebio);
BIO_gets(mdbio, o, sizeof(o));
timestamp_t t1 = timestamp();
report("OpenSSL BIO file", o, t1-t0);
}