-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathstubs-sha2.c
34 lines (31 loc) · 970 Bytes
/
stubs-sha2.c
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
#include "sha2.h"
#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/memory.h>
CAMLprim value camlpdf_caml_sha256(value message)
{
CAMLparam1(message);
value digest = caml_alloc_string(32);
camlpdf_sha256((const unsigned char *) (String_val(message)),
caml_string_length(message),
((unsigned char *) String_val(digest)));
CAMLreturn(digest);
}
CAMLprim value camlpdf_caml_sha384(value message)
{
CAMLparam1(message);
value digest = caml_alloc_string(48);
camlpdf_sha384((const unsigned char *) (String_val(message)),
caml_string_length(message),
((unsigned char *) String_val(digest)));
CAMLreturn(digest);
}
CAMLprim value camlpdf_caml_sha512(value message)
{
CAMLparam1(message);
value digest = caml_alloc_string(64);
camlpdf_sha512((const unsigned char *) (String_val(message)),
caml_string_length(message),
((unsigned char *) String_val(digest)));
CAMLreturn(digest);
}