Packages
fast_tls
1.1.21
1.1.26
1.1.25
1.1.24
1.1.22
1.1.21
1.1.20
1.1.19
1.1.18
1.1.16
1.1.15
1.1.14
1.1.13
1.1.12
1.1.11
1.1.10
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.26
1.0.25
1.0.23
1.0.22
1.0.21
1.0.20
1.0.19
1.0.18
1.0.16
1.0.15
1.0.13
1.0.12
1.0.11
1.0.10
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-beta1
TLS / SSL OpenSSL-based native driver for Erlang / Elixir
Current section
Files
Jump to
Current section
Files
c_src/p1_sha.c
/*
* Copyright (C) 2002-2024 ProcessOne, SARL. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <erl_nif.h>
#include <stdio.h>
static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
{
return 0;
}
static int upgrade(ErlNifEnv* caller_env, void** priv_data,
void** old_priv_data, ERL_NIF_TERM load_info)
{
return 0;
}
static ERL_NIF_TERM to_hexlist(ErlNifEnv* env, int argc,
const ERL_NIF_TERM argv[])
{
ErlNifBinary in;
ErlNifBinary out;
int res, i;
if (argc == 1) {
if (enif_inspect_iolist_as_binary(env, argv[0], &in)) {
res = enif_alloc_binary(2*in.size, &out);
if (res) {
for (i = 0; i<in.size; i++) {
sprintf((char *) (out.data + 2*i), "%02x", in.data[i]);
}
return enif_make_binary(env, &out);
}
}
}
return enif_make_badarg(env);
}
static ErlNifFunc nif_funcs[] =
{
{"to_hexlist", 1, to_hexlist}
};
ERL_NIF_INIT(p1_sha, nif_funcs, load, NULL, upgrade, NULL)