Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sha1_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef SSIZE_T ssize_t;
#else
#include <unistd.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <string.h>
#include "sha1.h"
Expand Down Expand Up @@ -87,12 +88,15 @@ CAMLprim value stub_sha1_update(value ctx, value data, value ofs, value len)
CAMLprim value stub_sha1_update_bigarray(value ctx, value buf)
{
CAMLparam2(ctx, buf);
struct sha1_ctx ctx_dup;
unsigned char *data = Data_bigarray_val(buf);
size_t len = Bigarray_val(buf)->dim[0];

ctx_dup = *GET_CTX_STRUCT(ctx);
caml_release_runtime_system();
sha1_update(GET_CTX_STRUCT(ctx), data, len);
sha1_update(&ctx_dup, data, len);
caml_acquire_runtime_system();
*GET_CTX_STRUCT(ctx) = ctx_dup;

CAMLreturn(Val_unit);
}
Expand Down
6 changes: 5 additions & 1 deletion sha256_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef SSIZE_T ssize_t;
#else
#include <unistd.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <string.h>
#include "sha256.h"
Expand Down Expand Up @@ -86,12 +87,15 @@ CAMLprim value stub_sha256_update(value ctx, value data, value ofs, value len)
CAMLprim value stub_sha256_update_bigarray(value ctx, value buf)
{
CAMLparam2(ctx, buf);
struct sha256_ctx ctx_dup;
unsigned char *data = Data_bigarray_val(buf);
size_t len = Bigarray_val(buf)->dim[0];

ctx_dup = *GET_CTX_STRUCT(ctx);
caml_release_runtime_system();
sha256_update(GET_CTX_STRUCT(ctx), data, len);
sha256_update(&ctx_dup, data, len);
caml_acquire_runtime_system();
*GET_CTX_STRUCT(ctx) = ctx_dup;

CAMLreturn(Val_unit);
}
Expand Down
6 changes: 5 additions & 1 deletion sha512_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef SSIZE_T ssize_t;
#else
#include <unistd.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <string.h>
#include "sha512.h"
Expand Down Expand Up @@ -86,12 +87,15 @@ CAMLprim value stub_sha512_update(value ctx, value data, value ofs, value len)
CAMLprim value stub_sha512_update_bigarray(value ctx, value buf)
{
CAMLparam2(ctx, buf);
struct sha512_ctx ctx_dup;
unsigned char *data = Data_bigarray_val(buf);
size_t len = Bigarray_val(buf)->dim[0];

ctx_dup = *GET_CTX_STRUCT(ctx);
caml_release_runtime_system();
sha512_update(GET_CTX_STRUCT(ctx), data, len);
sha512_update(&ctx_dup, data, len);
caml_acquire_runtime_system();
*GET_CTX_STRUCT(ctx) = ctx_dup;

CAMLreturn(Val_unit);
}
Expand Down